Greenbone Vulnerability Management Libraries 22.40.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 70 of file credentials_tests.c.

71{
72 credentials_t credentials;
73
74 credentials.password = NULL;
75
76 append_to_credentials_password (&credentials, "secret", 6);
77
78 assert_that (credentials.password, is_equal_to_string ("secret"));
79
80 append_to_credentials_password (&credentials, "123", 3);
81
82 assert_that (credentials.password, is_equal_to_string ("secret123"));
83
84 g_free (credentials.password);
85}
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:65
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 51 of file credentials_tests.c.

52{
53 credentials_t credentials;
54
55 credentials.username = NULL;
56
57 append_to_credentials_username (&credentials, "test", 4);
58
59 assert_that (credentials.username, is_equal_to_string ("test"));
60
61 append_to_credentials_username (&credentials, "user", 4);
62
63 assert_that (credentials.username, is_equal_to_string ("testuser"));
64
65 g_free (credentials.username);
66}
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:51
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 credentials.jwt_requested = 1;
36 credentials.jwt = g_strdup ("test.token.value");
37
38 free_credentials (&credentials);
39
40 assert_that (credentials.username, is_null);
41 assert_that (credentials.password, is_null);
42 assert_that (credentials.uuid, is_null);
43 assert_that (credentials.timezone, is_null);
44 assert_that (credentials.role, is_null);
45 assert_that (credentials.severity_class, is_null);
46 assert_that (credentials.jwt, is_null);
47}
void free_credentials(credentials_t *credentials)
Free credentials.
Definition credentials.c:31
int dynamic_severity
Dynamic Severity setting of user.
Definition credentials.h:33
int jwt_requested
Whether a JSON web token is requested.
Definition credentials.h:39
double default_severity
Default Severity setting of user.
Definition credentials.h:29
gchar * role
Role of user.
Definition credentials.h:35
gchar * jwt
Current JSON web token of user.
Definition credentials.h:41
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::jwt, credentials_t::jwt_requested, 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 90 of file credentials_tests.c.

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