Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix attack_test. Mock redis_lnk_reset #748

Merged
merged 1 commit into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed
- Use host from the original hosts list when boreas is enabled. [#725](https://github.com/greenbone/openvas/pull/725)
- Initialize the the kb to store results for openvas-nasl [#735](https://github.com/greenbone/openvas/pull/735)
- Fix unittest. Mock kb_lnk_reset. [#748](https://github.com/greenbone/openvas/pull/748)

### Removed

Expand Down
10 changes: 10 additions & 0 deletions src/attack_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ __wrap_redis_push_str (kb_t kb, const char *name, const char *value)
return 0;
}

int
__wrap_redis_lnk_reset (kb_t kb)
{
(void) kb; /* Used. */
mock ();
return 0;
}

Ensure (attack, comm_send_status_returns_neg1_for_null_args)
{
struct kb kb_struct;
Expand Down Expand Up @@ -91,9 +99,11 @@ Ensure (attack, comm_send_status_sends_correct_text)
/* We can't wrap kb_item_push_str because it is inline, so we have to do
* a little hacking. */
kb_ops_struct.kb_push_str = __wrap_redis_push_str;
kb_ops_struct.kb_lnk_reset = __wrap_redis_lnk_reset;
kb->kb_ops = &kb_ops_struct;

expect (__wrap_redis_push_str);
expect (__wrap_redis_lnk_reset);
assert_that (comm_send_status (kb, "127.0.0.1", 11, 67), is_equal_to (0));
assert_that (strcmp (given_name, "internal/status"), is_equal_to (0));
assert_that (strcmp (given_value, "127.0.0.1/11/67"), is_equal_to (0));
Expand Down