File: radiusutils_tests.c

package info (click to toggle)
gvm-libs 22.38.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,028 kB
  • sloc: ansic: 40,126; makefile: 26
file content (74 lines) | stat: -rw-r--r-- 1,329 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* SPDX-FileCopyrightText: 2019-2025 Greenbone AG
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#include "radiusutils.c"

#include <cgreen/assertions.h>
#include <cgreen/cgreen.h>
#include <cgreen/constraint_syntax_helpers.h>
#include <cgreen/internal/c_assertions.h>
#include <cgreen/mocks.h>

Describe (radiusutils);
BeforeEach (radiusutils)
{
}

AfterEach (radiusutils)
{
}

#define HOST "eghost"
#define SECRET "the_secret"

#ifdef ENABLE_RADIUS_AUTH

/* radius_init */

Ensure (radiusutils, radius_init)
{
  rc_handle *rh;

  rh = radius_init (HOST, SECRET);
  assert_that (rh, is_not_null);
  rc_destroy (rh);
}

#else

/* radius_authenticate */

Ensure (radiusutils, radius_authenticate_returns_minus1)
{
  assert_that (radius_authenticate ("h", "s", "u", "p"), is_equal_to (-1));
}

#endif

/* Test suite. */
int
main (int argc, char **argv)
{
  int ret;
  TestSuite *suite;

  suite = create_test_suite ();

#ifdef ENABLE_RADIUS_AUTH
  add_test_with_context (suite, radiusutils, radius_init);
#else
  add_test_with_context (suite, radiusutils,
                         radius_authenticate_returns_minus1);
#endif

  if (argc > 1)
    ret = run_single_test (suite, argv[1], create_text_reporter ());
  else
    ret = run_test_suite (suite, create_text_reporter ());

  destroy_test_suite (suite);

  return ret;
}