OpenVPN
|
#include "syshead.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <setjmp.h>
#include <cmocka.h>
#include "auth_token.c"
#include "test_common.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) |
void | auth_token_test_session_mismatch (void **state) |
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 54 of file test_auth_token.c.
References tls_multi::client_reason, and string_alloc().
|
static |
Definition at line 130 of file test_auth_token.c.
References 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 141 of file test_auth_token.c.
References 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 304 of file test_auth_token.c.
References 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 336 of file test_auth_token.c.
References add_session_token_env(), tls_multi::auth_token, AUTH_TOKEN_EXPIRED, AUTH_TOKEN_HMAC_OK, key_state::auth_token_state_flags, AUTH_TOKEN_VALID_EMPTYUSER, tls_session::key, KS_PRIMARY, lastsesion_statevalue, test_context::multi, now0key0, user_pass::password, test_context::session, tls_multi::session, TM_ACTIVE, and test_context::up.
Referenced by main().
|
static |
Definition at line 394 of file test_auth_token.c.
References allx01inline, 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 241 of file test_auth_token.c.
References tls_multi::auth_token, AUTH_TOKEN_HMAC_OK, tls_multi::auth_token_initial, 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 370 of file test_auth_token.c.
References tls_multi::auth_token, auth_token_init_secret(), tls_multi::auth_token_initial, 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().
void auth_token_test_session_mismatch | ( | void ** | state | ) |
Definition at line 272 of file test_auth_token.c.
References tls_multi::auth_token, AUTH_TOKEN_HMAC_OK, tls_multi::auth_token_initial, AUTH_TOKEN_SESSION_ID_BASE64_LEN, generate_auth_token(), test_context::multi, user_pass::password, test_context::session, SESSION_ID_PREFIX, test_context::up, verify_auth_token(), and wipe_auth_token().
Referenced by main().
|
static |
Definition at line 168 of file test_auth_token.c.
References tls_multi::auth_token, AUTH_TOKEN_EXPIRED, AUTH_TOKEN_HMAC_OK, tls_multi::auth_token_initial, tls_options::auth_token_lifetime, tls_options::auth_token_renewal, 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 409 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_session_mismatch(), auth_token_test_timeout(), openvpn_unit_test_setup(), 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.
Always pushes to the active session
multi | - The tls_multi structure belonging to the instance to push to |
Definition at line 49 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, send_control_channel_string_dowork(), tls_multi::session, and TM_ACTIVE.
void setenv_str | ( | struct env_set * | es, |
const char * | name, | ||
const char * | value | ||
) |
Definition at line 263 of file test_auth_token.c.
References CC_NAME, CC_PRINT, es, lastsesion_statevalue, setenv_str_ex(), and streq.
|
static |
Definition at line 85 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, tls_options::auth_token_renewal, 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, tls_multi::session, TM_ACTIVE, test_context::up, and user_pass::username.
Referenced by main().
|
static |
Definition at line 116 of file test_auth_token.c.
References tls_options::auth_token_key, 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 233 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 67 of file test_auth_token.c.
Referenced by auth_token_test_key_load().
|
static |
Definition at line 261 of file test_auth_token.c.
Referenced by auth_token_test_env(), and setenv_str().
|
static |
Definition at line 59 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 73 of file test_auth_token.c.
Referenced by auth_token_test_random_keys().
|
static |
Definition at line 81 of file test_auth_token.c.
Referenced by auth_token_test_random_keys().
|
static |
Definition at line 61 of file test_auth_token.c.
Referenced by auth_token_test_key_load().