Go to the documentation of this file.
66 const unsigned int flags,
67 const char *static_challenge)
74 parse_line(
const char *line,
char **p,
const int n,
const char *file,
75 const int line_num,
int msglevel,
struct gc_arena *gc)
115 assert_string_equal(up.
password,
"ok");
126 assert_string_equal(up.
password,
"cancel");
140 assert_string_equal(up.
username,
"iuser");
141 assert_string_equal(up.
password,
"ipassword");
149 assert_true(
get_user_pass_cr(&up,
"#iuser and 커뮤니티\n//ipasswörd!\nsome other content\nnot relevant",
"UT", flags, NULL));
151 assert_string_equal(up.
username,
"#iuser and 커뮤니티");
152 assert_string_equal(up.
password,
"//ipasswörd!");
161 assert_true(
get_user_pass_cr(&up,
"\tiuser\r\nipass\xffwo\x1erd",
"UT", flags, NULL));
163 assert_string_equal(up.
username,
"iuser");
164 assert_string_equal(up.
password,
"ipass\xffword");
174 assert_string_equal(up.
username,
"iuser");
175 assert_string_equal(up.
password,
"cpassword");
184 assert_string_equal(up.
username,
"user");
185 assert_string_equal(up.
password,
"ipassword");
196 assert_string_equal(up.
username,
"user");
197 assert_string_equal(up.
password,
"cpassword");
205 unsigned int flags = 0;
214 assert_string_equal(up.
username,
"cuser");
215 assert_string_equal(up.
password,
"cpassword");
225 assert_string_equal(up.
username,
"user");
226 assert_string_equal(up.
password,
"cpassword");
234 unsigned int flags = 0;
236 char authfile[PATH_MAX] = { 0 };
243 assert_string_equal(up.
username,
"fuser");
244 assert_string_equal(up.
password,
"fpassword");
255 assert_string_equal(up.
username,
"fuser");
256 assert_string_equal(up.
password,
"cpassword");
266 assert_string_equal(up.
username,
"user");
267 assert_string_equal(up.
password,
"fuser");
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)
static void openvpn_unit_test_setup()
Sets up the environment for unit tests like making both stderr and stdout non-buffered to avoid messa...
char username[USER_PASS_LEN]
struct _query_user query_user[QUERY_USER_NUMSLOTS]
Global variable, declared in console.c.
#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 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
bool management_query_user_pass(struct management *man, struct user_pass *up, const char *type, const unsigned int flags, const char *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...