42#if defined(ENABLE_SYSTEMD)
44query_user_exec_systemd(
void)
68 const unsigned int flags,
const char *static_challenge)
75parse_line(
const char *line,
char **p,
const int n,
const char *file,
const int line_num,
130 assert_string_equal(up.
password,
"ok");
141 assert_string_equal(up.
password,
"cancel");
155 assert_string_equal(up.
username,
"iuser");
156 assert_string_equal(up.
password,
"ipassword");
165 get_user_pass_cr(&up,
"#iuser and 커뮤니티\n//ipasswörd!\nsome other content\nnot relevant",
168 assert_string_equal(up.
username,
"#iuser and 커뮤니티");
169 assert_string_equal(up.
password,
"//ipasswörd!");
178 assert_true(
get_user_pass_cr(&up,
"\tiuser\r\nipass\xffwo\x1erd",
"UT", flags, NULL));
180 assert_string_equal(up.
username,
"iuser");
181 assert_string_equal(up.
password,
"ipass\xffword");
190 assert_string_equal(up.
username,
"");
191 assert_string_equal(up.
password,
"");
201 assert_string_equal(up.
username,
"iuser");
202 assert_string_equal(up.
password,
"cpassword");
211 assert_string_equal(up.
username,
"user");
212 assert_string_equal(up.
password,
"ipassword");
223 assert_string_equal(up.
username,
"user");
224 assert_string_equal(up.
password,
"cpassword");
242 expect_assert_failure(
get_user_pass_cr(&up,
"\nipassword\n",
"UT", flags, NULL));
251 unsigned int flags = 0;
260 assert_string_equal(up.
username,
"cuser");
261 assert_string_equal(up.
password,
"cpassword");
271 assert_string_equal(up.
username,
"user");
272 assert_string_equal(up.
password,
"cpassword");
283 assert_string_equal(up.
username,
"user");
284 assert_string_equal(up.
password,
"");
295 unsigned int flags = 0;
311 unsigned int flags = 0;
313 char authfile[PATH_MAX] = { 0 };
320 assert_string_equal(up.
username,
"fuser");
321 assert_string_equal(up.
password,
"fpassword");
331 assert_string_equal(up.
username,
"");
332 assert_string_equal(up.
password,
"");
343 assert_string_equal(up.
username,
"fuser");
344 assert_string_equal(up.
password,
"cpassword");
354 assert_string_equal(up.
username,
"user");
355 assert_string_equal(up.
password,
"fuser");
358#ifdef ENABLE_MANAGEMENT
364 const char *challenge =
"CRV1:R,E:Om01u7Fh4LrGBS7uh0SWmzwabUiGiW6l:Y3Ix:Please enter token PIN";
368 "CHALLENGE: Please enter token PIN");
373 assert_string_equal(up.
username,
"cr1");
374 assert_string_equal(up.
password,
"CRV1::Om01u7Fh4LrGBS7uh0SWmzwabUiGiW6l::challenge_response");
382 const char *challenge =
"Please enter token PIN";
391 "CHALLENGE: Please enter token PIN");
396 assert_string_equal(up.
username,
"cuser");
398 assert_string_equal(up.
password,
"SCRV1:Y3Bhc3N3b3Jk:Y2hhbGxlbmdlX3Jlc3BvbnNl");
410 "CHALLENGE: Please enter token PIN");
415 assert_string_equal(up.
username,
"c1user");
417 assert_string_equal(up.
password,
"c1password0123456");
426 "CHALLENGE: Please enter token PIN");
429 assert_true(
get_user_pass_cr(&up,
"iuser\nipassword",
"UT", flags, challenge));
431 assert_string_equal(up.
username,
"iuser");
433 assert_string_equal(up.
password,
"SCRV1:aXBhc3N3b3Jk:Y2hhbGxlbmdlX3Jlc3BvbnNl");
445 unsigned int flags = 0;
447 char authfile[PATH_MAX] = { 0 };
466#ifdef ENABLE_MANAGEMENT
struct _query_user query_user[QUERY_USER_NUMSLOTS]
Global variable, declared in console.c.
#define QUERY_USER_NUMSLOTS
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.
#define GET_USER_PASS_STATIC_CHALLENGE_CONCAT
indicates password and response should be concatenated
#define GET_USER_PASS_PASSWORD_ONLY
#define GET_USER_PASS_INLINE_CREDS
indicates that auth_file is actually inline creds
#define GET_USER_PASS_STATIC_CHALLENGE
SCRV1 protocol – static challenge.
#define GET_USER_PASS_NEED_OK
#define GET_USER_PASS_DYNAMIC_CHALLENGE
CRV1 protocol – dynamic challenge.
char * response
The user's response.
Garbage collection arena used to keep track of dynamically allocated memory.
char password[USER_PASS_LEN]
char username[USER_PASS_LEN]
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...
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...
void management_auth_failure(struct management *man, const char *type, const char *reason)
struct management * management
int parse_line(const char *line, char **p, const int n, const char *file, const int line_num, msglvl_t msglevel, struct gc_arena *gc)
static void reset_user_pass(struct user_pass *up)
const struct CMUnitTest user_pass_tests[]
bool query_user_exec_builtin(void)
Loop through configured query_user slots, using the built-in method for querying the user.
bool protect_buffer_win32(char *buf, DWORD len)
Encrypt a region of memory using CryptProtectMemory() with access restricted to the current process.
static void test_get_user_pass_authfile_file_assertions(void **state)
bool unprotect_buffer_win32(char *buf, DWORD len)
Decrypt a previously encrypted region of memory using CryptUnProtectMemory() with access restricted t...
static void test_get_user_pass_defined(void **state)
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)
static void test_get_user_pass_authfile_stdin_assertions(void **state)
static void test_get_user_pass_authfile_stdin(void **state)
static void test_get_user_pass_needok(void **state)
static void test_get_user_pass_authfile_file(void **state)
static void test_get_user_pass_dynamic_challenge(void **state)
static void test_get_user_pass_inline_creds(void **state)
static void test_get_user_pass_inline_creds_assertions(void **state)