43#if defined(ENABLE_SYSTEMD)
45query_user_exec_systemd(
void)
71 const unsigned int flags,
72 const char *static_challenge)
79parse_line(
const char *line,
char **p,
const int n,
const char *file,
80 const int line_num,
int msglevel,
struct gc_arena *
gc)
132 assert_string_equal(up.
password,
"ok");
143 assert_string_equal(up.
password,
"cancel");
157 assert_string_equal(up.
username,
"iuser");
158 assert_string_equal(up.
password,
"ipassword");
166 assert_true(
get_user_pass_cr(&up,
"#iuser and 커뮤니티\n//ipasswörd!\nsome other content\nnot relevant",
"UT", flags, NULL));
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");
191 assert_string_equal(up.
username,
"iuser");
192 assert_string_equal(up.
password,
"cpassword");
201 assert_string_equal(up.
username,
"user");
202 assert_string_equal(up.
password,
"ipassword");
213 assert_string_equal(up.
username,
"user");
214 assert_string_equal(up.
password,
"cpassword");
222 unsigned int flags = 0;
231 assert_string_equal(up.
username,
"cuser");
232 assert_string_equal(up.
password,
"cpassword");
242 assert_string_equal(up.
username,
"user");
243 assert_string_equal(up.
password,
"cpassword");
251 unsigned int flags = 0;
253 char authfile[PATH_MAX] = { 0 };
260 assert_string_equal(up.
username,
"fuser");
261 assert_string_equal(up.
password,
"fpassword");
272 assert_string_equal(up.
username,
"fuser");
273 assert_string_equal(up.
password,
"cpassword");
283 assert_string_equal(up.
username,
"user");
284 assert_string_equal(up.
password,
"fuser");
287#ifdef ENABLE_MANAGEMENT
293 const char *challenge =
"CRV1:R,E:Om01u7Fh4LrGBS7uh0SWmzwabUiGiW6l:Y3Ix:Please enter token PIN";
301 assert_string_equal(up.
username,
"cr1");
302 assert_string_equal(up.
password,
"CRV1::Om01u7Fh4LrGBS7uh0SWmzwabUiGiW6l::challenge_response");
310 const char *challenge =
"Please enter token PIN";
323 assert_string_equal(up.
username,
"cuser");
325 assert_string_equal(up.
password,
"SCRV1:Y3Bhc3N3b3Jk:Y2hhbGxlbmdlX3Jlc3BvbnNl");
341 assert_string_equal(up.
username,
"c1user");
343 assert_string_equal(up.
password,
"c1password0123456");
354 assert_true(
get_user_pass_cr(&up,
"iuser\nipassword",
"UT", flags, challenge));
356 assert_string_equal(up.
username,
"iuser");
358 assert_string_equal(up.
password,
"SCRV1:aXBhc3N3b3Jk:Y2hhbGxlbmdlX3Jlc3BvbnNl");
368#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
#define GET_USER_PASS_PASSWORD_ONLY
#define GET_USER_PASS_INLINE_CREDS
#define GET_USER_PASS_STATIC_CHALLENGE
#define GET_USER_PASS_NEED_OK
#define GET_USER_PASS_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
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 unprotect_buffer_win32(char *buf, size_t len)
Decrypt a previously encrypted region of memory using CryptUnProtectMemory() with access restricted t...
bool protect_buffer_win32(char *buf, size_t len)
Encrypt a region of memory using CryptProtectMemory() with access restricted to the current process.
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(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)
int parse_line(const char *line, char **p, const int n, const char *file, const int line_num, int msglevel, struct gc_arena *gc)