OpenVPN
|
#include "syshead.h"
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <setjmp.h>
#include <cmocka.h>
#include "auth_token.c"
#include "mock_msg.h"
Go to the source code of this file.
Data Structures | |
struct | test_context |
Functions | |
void | send_push_reply_auth_token (struct tls_multi *multi) |
Sends a push reply message only containin the auth-token to update the auth-token on the client. More... | |
void | auth_set_client_reason (struct tls_multi *multi, const char *reason) |
Sets the reason why authentication of a client failed. More... | |
static int | setup (void **state) |
static int | teardown (void **state) |
static void | auth_token_basic_test (void **state) |
static void | auth_token_fail_invalid_key (void **state) |
static void | auth_token_test_timeout (void **state) |
static void | zerohmac (char *token) |
static void | auth_token_test_known_keys (void **state) |
void | setenv_str (struct env_set *es, const char *name, const char *value) |
static void | auth_token_test_empty_user (void **state) |
static void | auth_token_test_env (void **state) |
static void | auth_token_test_random_keys (void **state) |
static void | auth_token_test_key_load (void **state) |
int | main (void) |
Variables | |
static const char * | now0key0 = "SESS_ID_AT_0123456789abcdefAAAAAAAAAAAAAAAAAAAAAE5JsQJOVfo8jnI3RL3tBaR5NkE4yPfcylFUHmHSc5Bu" |
static const char * | zeroinline |
static const char * | allx01inline |
static const char * | random_key |
static const char * | random_token = "SESS_ID_AT_ThhRItzOKNKrh3dfAAAAAFwzHpwAAAAAXDMenDdrq0RoH3dkA1f7O3wO+7kZcx2DusVZrRmFlWQM9HOb" |
static const char * | lastsesion_statevalue |
void auth_set_client_reason | ( | struct tls_multi * | multi, |
const char * | client_reason | ||
) |
Sets the reason why authentication of a client failed.
This be will send to the client when the AUTH_FAILED message is sent An example would be "SESSION: Token expired"
multi | The multi tls struct |
client_reason | The string to send to the client as part of AUTH_FAILED |
Definition at line 58 of file test_auth_token.c.
References tls_multi::client_reason, free, and string_alloc().
|
static |
Definition at line 132 of file test_auth_token.c.
References assert_int_equal, tls_multi::auth_token, AUTH_TOKEN_HMAC_OK, generate_auth_token(), test_context::multi, user_pass::password, test_context::session, test_context::up, and verify_auth_token().
Referenced by main().
|
static |
Definition at line 143 of file test_auth_token.c.
References assert_int_equal, tls_multi::auth_token, AUTH_TOKEN_HMAC_OK, tls_options::auth_token_key, free_key_ctx(), generate_auth_token(), init_key_ctx(), test_context::kt, test_context::multi, tls_multi::opt, user_pass::password, test_context::session, test_context::up, and verify_auth_token().
Referenced by main().
|
static |
Definition at line 271 of file test_auth_token.c.
References assert_int_equal, tls_multi::auth_token, AUTH_TOKEN_EXPIRED, AUTH_TOKEN_HMAC_OK, AUTH_TOKEN_VALID_EMPTYUSER, CLEAR, generate_auth_token(), test_context::multi, now, user_pass::password, test_context::session, test_context::up, user_pass::username, verify_auth_token(), and zerohmac().
Referenced by main().
|
static |
Definition at line 303 of file test_auth_token.c.
References add_session_token_env(), assert_string_equal, tls_multi::auth_token, AUTH_TOKEN_EXPIRED, AUTH_TOKEN_HMAC_OK, tls_multi::auth_token_state_flags, AUTH_TOKEN_VALID_EMPTYUSER, lastsesion_statevalue, test_context::multi, now0key0, user_pass::password, test_context::session, and test_context::up.
Referenced by main().
|
static |
Definition at line 359 of file test_auth_token.c.
References allx01inline, assert_false, assert_true, auth_token_init_secret(), tls_options::auth_token_key, free_key_ctx(), test_context::multi, now0key0, tls_multi::opt, user_pass::password, test_context::session, test_context::up, verify_auth_token(), and zeroinline.
Referenced by main().
|
static |
Definition at line 240 of file test_auth_token.c.
References assert_int_equal, assert_string_equal, tls_multi::auth_token, AUTH_TOKEN_HMAC_OK, generate_auth_token(), test_context::multi, now, now0key0, user_pass::password, test_context::session, test_context::up, verify_auth_token(), and zerohmac().
Referenced by main().
|
static |
Definition at line 335 of file test_auth_token.c.
References assert_string_equal, assert_true, tls_multi::auth_token, auth_token_init_secret(), tls_options::auth_token_key, free_key_ctx(), generate_auth_token(), test_context::multi, now, tls_multi::opt, user_pass::password, random_key, random_token, test_context::session, test_context::up, verify_auth_token(), and zerohmac().
Referenced by main().
|
static |
Definition at line 170 of file test_auth_token.c.
References assert_int_equal, tls_multi::auth_token, AUTH_TOKEN_EXPIRED, AUTH_TOKEN_HMAC_OK, tls_multi::auth_token_initial, tls_options::auth_token_lifetime, free, generate_auth_token(), test_context::multi, now, tls_session::opt, tls_multi::opt, user_pass::password, tls_options::renegotiate_seconds, test_context::session, test_context::up, and verify_auth_token().
Referenced by main().
int main | ( | void | ) |
Definition at line 374 of file test_auth_token.c.
References auth_token_basic_test(), auth_token_fail_invalid_key(), auth_token_test_empty_user(), auth_token_test_env(), auth_token_test_key_load(), auth_token_test_known_keys(), auth_token_test_random_keys(), auth_token_test_timeout(), cmocka_run_group_tests_name, cmocka_unit_test_setup_teardown, setup(), and teardown().
void send_push_reply_auth_token | ( | struct tls_multi * | multi | ) |
Sends a push reply message only containin the auth-token to update the auth-token on the client.
multi | - The tls_multi structure belonging to the instance to push to |
Definition at line 53 of file test_auth_token.c.
References alloc_buf_gc(), ASSERT, BSTR, buf_printf(), D_PUSH, push_entry::enable, gc_free(), gc_new(), push_list::head, push_entry::option, prepare_auth_token_push_reply(), PUSH_BUNDLE_SIZE, push_reply_cmd, and send_control_channel_string_dowork().
void setenv_str | ( | struct env_set * | es, |
const char * | name, | ||
const char * | value | ||
) |
Definition at line 262 of file test_auth_token.c.
References CC_NAME, CC_PRINT, lastsesion_statevalue, setenv_str_ex(), and streq.
|
static |
Definition at line 89 of file test_auth_token.c.
References tls_options::auth_token_generate, tls_options::auth_token_key, auth_token_kt(), tls_options::auth_token_lifetime, key_type::digest, init_key_ctx(), test_context::kt, test_context::multi, now, tls_session::opt, tls_multi::opt, user_pass::password, tls_options::renegotiate_seconds, test_context::session, test_context::up, and user_pass::username.
Referenced by main().
|
static |
Definition at line 118 of file test_auth_token.c.
References tls_options::auth_token_key, free, free_key_ctx(), test_context::multi, tls_session::opt, tls_multi::opt, test_context::session, and wipe_auth_token().
Referenced by main().
|
static |
Definition at line 232 of file test_auth_token.c.
References AUTH_TOKEN_SESSION_ID_LEN, and SESSION_ID_PREFIX.
Referenced by auth_token_test_empty_user(), auth_token_test_known_keys(), and auth_token_test_random_keys().
|
static |
Definition at line 71 of file test_auth_token.c.
Referenced by auth_token_test_key_load().
|
static |
Definition at line 260 of file test_auth_token.c.
Referenced by auth_token_test_env(), and setenv_str().
|
static |
Definition at line 63 of file test_auth_token.c.
Referenced by auth_token_test_env(), auth_token_test_key_load(), and auth_token_test_known_keys().
|
static |
Definition at line 77 of file test_auth_token.c.
Referenced by auth_token_test_random_keys().
|
static |
Definition at line 85 of file test_auth_token.c.
Referenced by auth_token_test_random_keys().
|
static |
Definition at line 65 of file test_auth_token.c.
Referenced by auth_token_test_key_load().