Skip to content

Commit

Permalink
Fix attack_test. Mock redis_lnk_reset
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnicola committed May 31, 2021
1 parent 106a206 commit d109259
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
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

0 comments on commit d109259

Please sign in to comment.