OpenVAS Scanner 23.40.3
table_driven_lsc_tests.c File Reference
#include "table_driven_lsc.c"
#include <cgreen/cgreen.h>
#include <cgreen/constraint_syntax_helpers.h>
#include <cgreen/mocks.h>
#include <sys/cdefs.h>
Include dependency graph for table_driven_lsc_tests.c:

Go to the source code of this file.

Functions

 Describe (lsc)
 BeforeEach (lsc)
 AfterEach (lsc)
 Ensure (lsc, make_pkg_in_json)
 Ensure (lsc, process_resp)
int main (int argc, char **argv)

Variables

static char * resp_str

Function Documentation

◆ AfterEach()

AfterEach ( lsc )

Definition at line 17 of file table_driven_lsc_tests.c.

18{
19}

◆ BeforeEach()

BeforeEach ( lsc )

Definition at line 14 of file table_driven_lsc_tests.c.

15{
16}

◆ Describe()

Describe ( lsc )

◆ Ensure() [1/2]

Ensure ( lsc ,
make_pkg_in_json  )

Definition at line 52 of file table_driven_lsc_tests.c.

53{
54 char *pkglist = "pkg1.2.3\npkg4.5.6\nfoo-24\nbar-35";
55 char *json = "[\"pkg1.2.3\",\"pkg4.5.6\",\"foo-24\",\"bar-35\"]";
56
57 assert_that (strcmp (make_package_list_as_json_str (pkglist), json),
58 is_equal_to (0));
59}
static gchar * make_package_list_as_json_str(const char *packages)
Build a json array from the package list to start a table drive LSC.

References make_package_list_as_json_str().

Here is the call graph for this function:

◆ Ensure() [2/2]

Ensure ( lsc ,
process_resp  )

Definition at line 61 of file table_driven_lsc_tests.c.

62{
64
66 assert_that ((*advisories).count, is_equal_to (2));
67
68 assert_that ((*advisories).advisories[0]->count, is_equal_to (2));
69 assert_that ((*advisories).advisories[0]->pkgs[0]->type,
70 is_equal_to (SINGLE));
71 assert_that (
72 strcmp ((*advisories).advisories[0]->pkgs[0]->pkg_name, "grafana8"),
73 is_equal_to (0));
74 assert_that (
75 strcmp ((*advisories).advisories[0]->pkgs[0]->install_version, "8.5.23"),
76 is_equal_to (0));
77 assert_that (
78 strcmp ((*advisories).advisories[0]->pkgs[1]->pkg_name, "grafana9"),
79 is_equal_to (0));
80 assert_that (
81 strcmp ((*advisories).advisories[0]->pkgs[1]->install_version, "9.4.7"),
82 is_equal_to (0));
83
84 assert_that ((*advisories).advisories[0]->pkgs[1]->type, is_equal_to (RANGE));
85
86 assert_that ((*advisories).advisories[1]->count, is_equal_to (1));
87 assert_that ((*advisories).advisories[0]->pkgs[1]->type, is_equal_to (RANGE));
88
90}
void advisories_free(advisories_t *advisories)
Free()'s an advisories.
advisories_t * lsc_process_response(const gchar *resp, const size_t len)
Process a json object which contains advisories and vulnerable packages.
struct advisories advisories_t
@ SINGLE
@ RANGE
static char * resp_str

References advisories_free(), lsc_process_response(), RANGE, resp_str, and SINGLE.

Here is the call graph for this function:

◆ main()

int main ( int argc,
char ** argv )

Definition at line 93 of file table_driven_lsc_tests.c.

94{
95 int ret;
96 TestSuite *suite;
97
98 suite = create_test_suite ();
99
100 add_test_with_context (suite, lsc, process_resp);
101 add_test_with_context (suite, lsc, make_pkg_in_json);
102 if (argc > 1)
103 ret = run_single_test (suite, argv[1], create_text_reporter ());
104 else
105 ret = run_test_suite (suite, create_text_reporter ());
106
107 destroy_test_suite (suite);
108
109 return ret;
110}

Variable Documentation

◆ resp_str

char* resp_str
static
Initial value:
= "{"
"\"1.3.6.1.4.1.25623.1.1.7.2.2023.0988598199100\": ["
"{"
"\"name\": \"grafana8\","
"\"installed_version\": \"8.5.23\","
"\"fixed_version\": {"
"\"version\": \"8.5.24\","
"\"specifier\": \">=\""
"}"
"},"
"{"
"\"name\": \"grafana9\","
"\"installed_version\": \"9.4.7\","
"\"fixed_version\": {"
"\"start\": \"9.4.0\","
"\"end\": \"9.4.9\""
"}"
"}"
"],"
"\"1.3.6.1.4.1.25623.1.1.7.2.2023.10089729899100\": ["
"{"
"\"name\": \"gitlab-ce\","
"\"installed_version\": \"16.0.1\","
"\"fixed_version\": {"
"\"start\": \"16.0.0\","
"\"end\": \"16.0.7\""
"}"
"}"
"]"
"}"

Definition at line 21 of file table_driven_lsc_tests.c.

Referenced by Ensure().