Greenbone Vulnerability Management Libraries 22.32.0
radiusutils_tests.c
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2019-2025 Greenbone AG
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later
4 */
5
6#include "radiusutils.c"
7
8#include <cgreen/assertions.h>
9#include <cgreen/cgreen.h>
10#include <cgreen/constraint_syntax_helpers.h>
11#include <cgreen/internal/c_assertions.h>
12#include <cgreen/mocks.h>
13
14Describe (radiusutils);
15BeforeEach (radiusutils)
16{
17}
18
19AfterEach (radiusutils)
20{
21}
22
23#define HOST "eghost"
24#define SECRET "the_secret"
25
26#ifdef ENABLE_RADIUS_AUTH
27
28/* radius_init */
29
30Ensure (radiusutils, radius_init)
31{
32 rc_handle *rh;
33
34 rh = radius_init (HOST, SECRET);
35 assert_that (rh, is_not_null);
36 rc_destroy (rh);
37}
38
39#else
40
41/* radius_authenticate */
42
43Ensure (radiusutils, radius_authenticate_returns_minus1)
44{
45 assert_that (radius_authenticate ("h", "s", "u", "p"), is_equal_to (-1));
46}
47
48#endif
49
50/* Test suite. */
51int
52main (int argc, char **argv)
53{
54 int ret;
55 TestSuite *suite;
56
57 suite = create_test_suite ();
58
59#ifdef ENABLE_RADIUS_AUTH
60 add_test_with_context (suite, radiusutils, radius_init);
61#else
62 add_test_with_context (suite, radiusutils,
63 radius_authenticate_returns_minus1);
64#endif
65
66 if (argc > 1)
67 ret = run_single_test (suite, argv[1], create_text_reporter ());
68 else
69 ret = run_test_suite (suite, create_text_reporter ());
70
71 destroy_test_suite (suite);
72
73 return ret;
74}
Implementation of an API for Radius authentication.
int radius_authenticate(const char *hostname, const char *secret, const char *username, const char *password)
Dummy function for manager.
int main(int argc, char **argv)
Describe(radiusutils)
BeforeEach(radiusutils)
Ensure(radiusutils, radius_authenticate_returns_minus1)
AfterEach(radiusutils)
#define SECRET
#define HOST