File: common_ini_https_timeout.c

package info (click to toggle)
duo-unix 1.11.3-1.2
  • links: PTS
  • area: main
  • in suites: sid, trixie
  • size: 2,892 kB
  • sloc: sh: 12,108; ansic: 9,223; python: 1,639; makefile: 156
file content (51 lines) | stat: -rw-r--r-- 1,437 bytes parent folder | download | duplicates (2)
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
#include "common_ini_test.h"

/* Test setting https_timeout for duo_config */ 
static void test_https_timeout_negitive_one() {
    struct duo_config cfg = {0};
    char *name = "https_timeout";
    char *value = "-1";
    int expected_timeout = -1;

    duo_common_ini_handler(&cfg, SECTION, name, value);
    TEST_ASSERT_EQUAL(expected_timeout, cfg.https_timeout);
}

static void test_https_timeout_zero() {
    struct duo_config cfg = {0};
    char *name = "https_timeout";
    char *value = "0";
    int expected_timeout = -1;

    duo_common_ini_handler(&cfg, SECTION, name, value);
    TEST_ASSERT_EQUAL(expected_timeout, cfg.https_timeout);
}

static void test_https_timeout_one() {
    struct duo_config cfg = {0};
    char *name = "https_timeout";
    char *value = "1";
    int expected_timeout = 1000;

    duo_common_ini_handler(&cfg, SECTION, name, value);
    TEST_ASSERT_EQUAL(expected_timeout, cfg.https_timeout);
}

static void test_https_timeout_four() { 
    struct duo_config cfg = {0};
    char *name = "https_timeout";
    char *value = "4";
    int expected_timeout = 4000;

    duo_common_ini_handler(&cfg, SECTION, name, value);
    TEST_ASSERT_EQUAL(expected_timeout, cfg.https_timeout);
}

int main() {
    UNITY_BEGIN();
    RUN_TEST(test_https_timeout_negitive_one);
    RUN_TEST(test_https_timeout_zero);
    RUN_TEST(test_https_timeout_one);
    RUN_TEST(test_https_timeout_four);
    return UNITY_END();
}