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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
|
#include "common_ini_test.h"
/* Testing duo_set_boolean_option(val) */
static void test_set_boolean_option_yes() {
char *value = "yes";
TEST_ASSERT_TRUE(duo_set_boolean_option(value));
}
static void test_set_boolean_option_one() {
char *value = "1";
TEST_ASSERT_TRUE(duo_set_boolean_option(value));
}
static void test_set_boolean_option_true() {
char *value = "true";
TEST_ASSERT_TRUE(duo_set_boolean_option(value));
}
static void test_set_boolean_option_on() {
char *value = "on";
TEST_ASSERT_TRUE(duo_set_boolean_option(value));
}
static void test_set_boolean_option_off() {
char *value = "off";
TEST_ASSERT_FALSE(duo_set_boolean_option(value));
}
static void test_set_boolean_option_random() {
char *value = "random";
TEST_ASSERT_FALSE(duo_set_boolean_option(value));
}
static void test_set_boolean_option_empty() {
TEST_ASSERT_FALSE(duo_set_boolean_option(EMPTY_STR));
}
static void test_set_boolean_option_null() {
TEST_ASSERT_FALSE(duo_set_boolean_option(NULL_STR));
}
/* Test duo_common_ini_handler pushinfo flag */
static void test_pushinfo_true() {
struct duo_config cfg = {0};
char *name = "pushinfo";
char *value = "true";
int expected_cfg_value = 1;
duo_common_ini_handler(&cfg, SECTION, name, value);
TEST_ASSERT_EQUAL(expected_cfg_value, cfg.pushinfo);
}
static void test_pushinfo_false() {
struct duo_config cfg = {0};
char *name = "pushinfo";
char *value = "false";
int expected_cfg_value = 0;
duo_common_ini_handler(&cfg, SECTION, name, value);
TEST_ASSERT_EQUAL(expected_cfg_value, cfg.pushinfo);
}
/* Test duo_common_ini_handler noverify flag */
static void test_noverify_true() {
struct duo_config cfg = {0};
char *name = "noverify";
char *value = "true";
int expected_cfg_value = 1;
duo_common_ini_handler(&cfg, SECTION, name, value);
TEST_ASSERT_EQUAL(expected_cfg_value, cfg.noverify);
}
static void test_noverify_false() {
struct duo_config cfg = {0};
char *name = "noverify";
char *value = "false";
int expected_cfg_value = 0;
duo_common_ini_handler(&cfg, SECTION, name, value);
TEST_ASSERT_EQUAL(expected_cfg_value, cfg.noverify);
}
/* Test duo_common_ini_handler autopush flag */
static void test_autopush_true() {
struct duo_config cfg = {0};
char *name = "autopush";
char *value = "true";
int expected_cfg_value = 1;
duo_common_ini_handler(&cfg, SECTION, name, value);
TEST_ASSERT_EQUAL(expected_cfg_value, cfg.autopush);
}
static void test_autopush_false() {
struct duo_config cfg = {0};
char *name = "autopush";
char *value = "false";
int expected_cfg_value = 0;
duo_common_ini_handler(&cfg, SECTION, name, value);
TEST_ASSERT_EQUAL(expected_cfg_value, cfg.autopush);
}
/* Test duo_common_ini_handler accept_env_factor flag */
static void test_accept_env_true() {
struct duo_config cfg = {0};
char *name = "accept_env_factor";
char *value = "true";
int expected_cfg_value = 1;
duo_common_ini_handler(&cfg, SECTION, name, value);
TEST_ASSERT_EQUAL(expected_cfg_value, cfg.accept_env);
}
static void test_accept_env_false() {
struct duo_config cfg = {0};
char *name = "accept_env_factor";
char *value = "false";
int expected_cfg_value = 0;
duo_common_ini_handler(&cfg, SECTION, name, value);
TEST_ASSERT_EQUAL(expected_cfg_value, cfg.accept_env);
}
/* Test duo_common_ini_handler fallback_local_ip flag */
static void test_fallback_local_ip_true() {
struct duo_config cfg = {0};
char *name = "fallback_local_ip";
char *value = "true";
int expected_cfg_value = 1;
duo_common_ini_handler(&cfg, SECTION, name, value);
TEST_ASSERT_EQUAL(expected_cfg_value, cfg.local_ip_fallback);
}
static void test_fallback_local_ip_false() {
struct duo_config cfg = {0};
char *name = "fallback_local_ip";
char *value = "false";
int expected_cfg_value = 0;
duo_common_ini_handler(&cfg, SECTION, name, value);
TEST_ASSERT_EQUAL(expected_cfg_value, cfg.local_ip_fallback);
}
/* Test dev_fips_mode flag */
static void test_dev_fips_mode_true() {
struct duo_config cfg = {0};
char *name = "dev_fips_mode";
char *value = "true";
int expected_cfg_value = 1;
duo_common_ini_handler(&cfg, SECTION, name, value);
TEST_ASSERT_EQUAL(expected_cfg_value, cfg.fips_mode);
}
static void test_dev_fips_mode_false() {
struct duo_config cfg = {0};
char *name = "dev_fips_mode";
char *value = "false";
int expected_cfg_value = 0;
duo_common_ini_handler(&cfg, SECTION, name, value);
TEST_ASSERT_EQUAL(expected_cfg_value, cfg.fips_mode);
}
int main() {
UNITY_BEGIN();
RUN_TEST(test_set_boolean_option_yes);
RUN_TEST(test_set_boolean_option_one);
RUN_TEST(test_set_boolean_option_true);
RUN_TEST(test_set_boolean_option_on);
RUN_TEST(test_set_boolean_option_off);
RUN_TEST(test_set_boolean_option_random);
RUN_TEST(test_set_boolean_option_empty);
RUN_TEST(test_set_boolean_option_null);
RUN_TEST(test_pushinfo_true);
RUN_TEST(test_pushinfo_false);
RUN_TEST(test_noverify_true);
RUN_TEST(test_noverify_false);
RUN_TEST(test_autopush_true);
RUN_TEST(test_autopush_false);
RUN_TEST(test_noverify_false);
RUN_TEST(test_accept_env_true);
RUN_TEST(test_accept_env_false);
RUN_TEST(test_fallback_local_ip_true);
RUN_TEST(test_fallback_local_ip_false);
RUN_TEST(test_dev_fips_mode_true);
RUN_TEST(test_dev_fips_mode_false);
return UNITY_END();
}
|