|
| 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 | + |
| 14 | +Describe (radiusutils); |
| 15 | +BeforeEach (radiusutils) |
| 16 | +{ |
| 17 | +} |
| 18 | + |
| 19 | +AfterEach (radiusutils) |
| 20 | +{ |
| 21 | +} |
| 22 | + |
| 23 | +#define HOST "eghost" |
| 24 | +#define SECRET "the_secret" |
| 25 | + |
| 26 | +#ifdef ENABLE_RADIUS_AUTH |
| 27 | + |
| 28 | +/* radius_init */ |
| 29 | + |
| 30 | +Ensure (radiusutils, radius_init) |
| 31 | +{ |
| 32 | + rc_handle *rh; |
| 33 | + |
| 34 | + rh = radius_init (HOST, SECRET); |
| 35 | + assert_that (rh, is_not_null); |
| 36 | +} |
| 37 | + |
| 38 | +#else |
| 39 | + |
| 40 | +/* radius_authenticate */ |
| 41 | + |
| 42 | +Ensure (radiusutils, radius_authenticate_returns_minus1) |
| 43 | +{ |
| 44 | + assert_that (radius_authenticate ("h", "s", "u", "p"), |
| 45 | + is_equal_to (-1)); |
| 46 | +} |
| 47 | + |
| 48 | +#endif |
| 49 | + |
| 50 | +/* Test suite. */ |
| 51 | +int |
| 52 | +main (int argc, char **argv) |
| 53 | +{ |
| 54 | + TestSuite *suite; |
| 55 | + |
| 56 | + suite = create_test_suite (); |
| 57 | + |
| 58 | +#ifdef ENABLE_RADIUS_AUTH |
| 59 | + add_test_with_context (suite, radiusutils, radius_init); |
| 60 | +#else |
| 61 | + add_test_with_context (suite, radiusutils, radius_authenticate_returns_minus1); |
| 62 | +#endif |
| 63 | + |
| 64 | + if (argc > 1) |
| 65 | + return run_single_test (suite, argv[1], create_text_reporter ()); |
| 66 | + |
| 67 | + return run_test_suite (suite, create_text_reporter ()); |
| 68 | +} |
0 commit comments