Go to the documentation of this file.
68 const unsigned int flags,
69 const char *static_challenge)
76 parse_line(
const char *line,
char **p,
const int n,
const char *file,
77 const int line_num,
int msglevel,
struct gc_arena *gc)
117 assert_string_equal(up.
password,
"ok");
128 assert_string_equal(up.
password,
"cancel");
142 assert_string_equal(up.
username,
"iuser");
143 assert_string_equal(up.
password,
"ipassword");
151 assert_true(
get_user_pass_cr(&up,
"#iuser and 커뮤니티\n//ipasswörd!\nsome other content\nnot relevant",
"UT", flags, NULL));
153 assert_string_equal(up.
username,
"#iuser and 커뮤니티");
154 assert_string_equal(up.
password,
"//ipasswörd!");
163 assert_true(
get_user_pass_cr(&up,
"\tiuser\r\nipass\xffwo\x1erd",
"UT", flags, NULL));
165 assert_string_equal(up.
username,
"iuser");
166 assert_string_equal(up.
password,
"ipass\xffword");
176 assert_string_equal(up.
username,
"iuser");
177 assert_string_equal(up.
password,
"cpassword");
186 assert_string_equal(up.
username,
"user");
187 assert_string_equal(up.
password,
"ipassword");
198 assert_string_equal(up.
username,
"user");
199 assert_string_equal(up.
password,
"cpassword");
207 unsigned int flags = 0;
216 assert_string_equal(up.
username,
"cuser");
217 assert_string_equal(up.
password,
"cpassword");
227 assert_string_equal(up.
username,
"user");
228 assert_string_equal(up.
password,
"cpassword");
236 unsigned int flags = 0;
238 char authfile[PATH_MAX] = { 0 };
245 assert_string_equal(up.
username,
"fuser");
246 assert_string_equal(up.
password,
"fpassword");
257 assert_string_equal(up.
username,
"fuser");
258 assert_string_equal(up.
password,
"cpassword");
268 assert_string_equal(up.
username,
"user");
269 assert_string_equal(up.
password,
"fuser");
272 #ifdef ENABLE_MANAGEMENT
278 const char *challenge =
"CRV1:R,E:Om01u7Fh4LrGBS7uh0SWmzwabUiGiW6l:Y3Ix:Please enter token PIN";
286 assert_string_equal(up.
username,
"cr1");
287 assert_string_equal(up.
password,
"CRV1::Om01u7Fh4LrGBS7uh0SWmzwabUiGiW6l::challenge_response");
295 const char *challenge =
"Please enter token PIN";
308 assert_string_equal(up.
username,
"cuser");
310 assert_string_equal(up.
password,
"SCRV1:Y3Bhc3N3b3Jk:Y2hhbGxlbmdlX3Jlc3BvbnNl");
321 assert_true(
get_user_pass_cr(&up,
"iuser\nipassword",
"UT", flags, challenge));
323 assert_string_equal(up.
username,
"iuser");
325 assert_string_equal(up.
password,
"SCRV1:aXBhc3N3b3Jk:Y2hhbGxlbmdlX3Jlc3BvbnNl");
335 #ifdef ENABLE_MANAGEMENT
const struct CMUnitTest user_pass_tests[]
static void test_get_user_pass_defined(void **state)
bool get_user_pass_cr(struct user_pass *up, const char *auth_file, const char *prefix, const unsigned int flags, const char *auth_challenge)
Retrieves the user credentials from various sources depending on the flags.
static void test_get_user_pass_inline_creds(void **state)
char username[USER_PASS_LEN]
struct _query_user query_user[QUERY_USER_NUMSLOTS]
Global variable, declared in console.c.
static void test_get_user_pass_dynamic_challenge(void **state)
#define GET_USER_PASS_DYNAMIC_CHALLENGE
#define QUERY_USER_NUMSLOTS
static void test_get_user_pass_authfile_stdin(void **state)
static void test_get_user_pass_needok(void **state)
Garbage collection arena used to keep track of dynamically allocated memory.
int parse_line(const char *line, char **p, const int n, const char *file, const int line_num, int msglevel, struct gc_arena *gc)
static void openvpn_unit_test_setup(void)
Sets up the environment for unit tests like making both stderr and stdout non-buffered to avoid messa...
static void reset_user_pass(struct user_pass *up)
struct management * management
char * response
The user's response.
void management_auth_failure(struct management *man, const char *type, const char *reason)
#define GET_USER_PASS_PASSWORD_ONLY
#define GET_USER_PASS_NEED_OK
bool query_user_exec_builtin(void)
Executes a configured setup, using the built-in method for querying the user.
static void test_get_user_pass_authfile_file(void **state)
char password[USER_PASS_LEN]
#define GET_USER_PASS_INLINE_CREDS
static void test_get_user_pass_static_challenge(void **state)
bool management_query_user_pass(struct management *man, struct user_pass *up, const char *type, const unsigned int flags, const char *static_challenge)
#define GET_USER_PASS_STATIC_CHALLENGE
void openvpn_test_get_srcdir_dir(char *buf, size_t bufsize, const char *filename)
Helper function to get a file path from the unit test directory to open it or pass its path to anothe...