Greenbone Vulnerability Management Libraries 22.32.0
credentials_tests.c File Reference
#include "credentials.c"
#include "strings.h"
#include <cgreen/cgreen.h>
#include <cgreen/mocks.h>
Include dependency graph for credentials_tests.c:

Go to the source code of this file.

Functions

 Describe (credentials)
 BeforeEach (credentials)
 AfterEach (credentials)
 Ensure (credentials, free_credentials_frees_all_fields)
 Ensure (credentials, append_to_credentials_username_appends_text)
 Ensure (credentials, append_to_credentials_password_appends_text)
int main (int argc, char **argv)

Function Documentation

◆ AfterEach()

AfterEach ( credentials )

Definition at line 16 of file credentials_tests.c.

17{
18}

◆ BeforeEach()

BeforeEach ( credentials )

Definition at line 13 of file credentials_tests.c.

14{
15}

◆ Describe()

Describe ( credentials )

◆ Ensure() [1/3]

Ensure ( credentials ,
append_to_credentials_password_appends_text  )

Definition at line 67 of file credentials_tests.c.

68{
69 credentials_t credentials;
70
71 credentials.password = NULL;
72
73 append_to_credentials_password (&credentials, "secret", 6);
74
75 assert_that (credentials.password, is_equal_to_string ("secret"));
76
77 append_to_credentials_password (&credentials, "123", 3);
78
79 assert_that (credentials.password, is_equal_to_string ("secret123"));
80
81 g_free (credentials.password);
82}
void append_to_credentials_password(credentials_t *credentials, const char *text, gsize length)
Append text to the password of a credential pair.
Definition credentials.c:64
A username password pair.
Definition credentials.h:20
gchar * password
Password of user.
Definition credentials.h:23

References append_to_credentials_password(), and credentials_t::password.

Here is the call graph for this function:

◆ Ensure() [2/3]

Ensure ( credentials ,
append_to_credentials_username_appends_text  )

Definition at line 48 of file credentials_tests.c.

49{
50 credentials_t credentials;
51
52 credentials.username = NULL;
53
54 append_to_credentials_username (&credentials, "test", 4);
55
56 assert_that (credentials.username, is_equal_to_string ("test"));
57
58 append_to_credentials_username (&credentials, "user", 4);
59
60 assert_that (credentials.username, is_equal_to_string ("testuser"));
61
62 g_free (credentials.username);
63}
void append_to_credentials_username(credentials_t *credentials, const char *text, gsize length)
Append text to the username of a credential pair.
Definition credentials.c:50
gchar * username
Login name of user.
Definition credentials.h:21

References append_to_credentials_username(), and credentials_t::username.

Here is the call graph for this function:

◆ Ensure() [3/3]

Ensure ( credentials ,
free_credentials_frees_all_fields  )

Definition at line 22 of file credentials_tests.c.

23{
24 credentials_t credentials;
25
26 credentials.username = g_strdup ("testuser");
27 credentials.password = g_strdup ("testpass");
28 credentials.uuid = g_strdup ("12345");
29 credentials.timezone = g_strdup ("UTC");
30 credentials.default_severity = 5.0;
31 credentials.severity_class = g_strdup ("nist");
32 credentials.dynamic_severity = 1;
33 credentials.role = g_strdup ("admin");
34 credentials.excerpt_size = 100;
35
36 free_credentials (&credentials);
37
38 assert_that (credentials.username, is_null);
39 assert_that (credentials.password, is_null);
40 assert_that (credentials.uuid, is_null);
41 assert_that (credentials.timezone, is_null);
42 assert_that (credentials.role, is_null);
43 assert_that (credentials.severity_class, is_null);
44}
void free_credentials(credentials_t *credentials)
Free credentials.
Definition credentials.c:31
int dynamic_severity
Dynamic Severity setting of user.
Definition credentials.h:33
double default_severity
Default Severity setting of user.
Definition credentials.h:29
gchar * role
Role of user.
Definition credentials.h:35
gchar * timezone
Timezone of user.
Definition credentials.h:27
gchar * uuid
UUID of user.
Definition credentials.h:25
gchar * severity_class
Severity Class setting of user.
Definition credentials.h:31
int excerpt_size
Note/Override Excerpt Size setting of user.
Definition credentials.h:37

References credentials_t::default_severity, credentials_t::dynamic_severity, credentials_t::excerpt_size, free_credentials(), credentials_t::password, credentials_t::role, credentials_t::severity_class, credentials_t::timezone, credentials_t::username, and credentials_t::uuid.

Here is the call graph for this function:

◆ main()

int main ( int argc,
char ** argv )

Definition at line 87 of file credentials_tests.c.

88{
89 int ret;
90 TestSuite *suite;
91
92 suite = create_test_suite ();
93
94 add_test_with_context (suite, credentials, free_credentials_frees_all_fields);
95 add_test_with_context (suite, credentials,
96 append_to_credentials_username_appends_text);
97 add_test_with_context (suite, credentials,
98 append_to_credentials_password_appends_text);
99
100 if (argc > 1)
101 ret = run_single_test (suite, argv[1], create_text_reporter ());
102 else
103 ret = run_test_suite (suite, create_text_reporter ());
104
105 destroy_test_suite (suite);
106
107 return ret;
108}