OpenVPN
Data Structures | Functions | Variables
test_auth_token.c File Reference
#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"
Include dependency graph for test_auth_token.c:

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
 

Function Documentation

◆ auth_set_client_reason()

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"

Parameters
multiThe multi tls struct
client_reasonThe 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().

◆ auth_token_basic_test()

static void auth_token_basic_test ( void **  state)
static

◆ auth_token_fail_invalid_key()

static void auth_token_fail_invalid_key ( void **  state)
static

◆ auth_token_test_empty_user()

static void auth_token_test_empty_user ( void **  state)
static

◆ auth_token_test_env()

static void auth_token_test_env ( void **  state)
static

◆ auth_token_test_key_load()

static void auth_token_test_key_load ( void **  state)
static

◆ auth_token_test_known_keys()

static void auth_token_test_known_keys ( void **  state)
static

◆ auth_token_test_random_keys()

static void auth_token_test_random_keys ( void **  state)
static

◆ auth_token_test_session_mismatch()

void auth_token_test_session_mismatch ( void **  state)

◆ auth_token_test_timeout()

static void auth_token_test_timeout ( void **  state)
static

◆ main()

int main ( void  )

◆ send_push_reply_auth_token()

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

Parameters
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.

◆ setenv_str()

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.

◆ setup()

static int setup ( void **  state)
static

◆ teardown()

static int teardown ( void **  state)
static

◆ zerohmac()

static void zerohmac ( char *  token)
static

Variable Documentation

◆ allx01inline

const char* allx01inline
static
Initial value:
= "-----BEGIN OpenVPN auth-token server key-----\n"
"AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB\n"
"AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB\n"
"AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=\n"
"-----END OpenVPN auth-token server key-----"

Definition at line 67 of file test_auth_token.c.

Referenced by auth_token_test_key_load().

◆ lastsesion_statevalue

const char* lastsesion_statevalue
static

Definition at line 261 of file test_auth_token.c.

Referenced by auth_token_test_env(), and setenv_str().

◆ now0key0

const char* now0key0 = "SESS_ID_AT_0123456789abcdefAAAAAAAAAAAAAAAAAAAAAE5JsQJOVfo8jnI3RL3tBaR5NkE4yPfcylFUHmHSc5Bu"
static

◆ random_key

const char* random_key
static
Initial value:
= "-----BEGIN OpenVPN auth-token server key-----\n"
"+mmmf7IQ5cymtMVjKYTWk8IOcYanRlpQmV9Tb3EjkHYxueBVDg3yqRgzeBlVGzNLD//rAPiOVhau\n"
"3NDBjNOQB8951bfs7Cc2mYfay92Bh2gRJ5XEM/DMfzCWN+7uU6NWoTTHr4FuojnIQtjtqVAj/JS9\n"
"w+dTSp/vYHl+c7uHd19uVRu/qLqV85+rm4tUGIjO7FfYuwyPqwmhuIsi3hs9QkSimh888FmBpoKY\n"
"/tbKVTJZmSERKti9KEwtV2eVAR0znN5KW7lCB3mHVAhN7bUpcoDjfCzYIFARxwswTFu9gFkwqUMY\n"
"I1KUOgIsVNs4llACioeXplYekWETR+YkJwDc/A==\n"
"-----END OpenVPN auth-token server key-----"

Definition at line 73 of file test_auth_token.c.

Referenced by auth_token_test_random_keys().

◆ random_token

const char* random_token = "SESS_ID_AT_ThhRItzOKNKrh3dfAAAAAFwzHpwAAAAAXDMenDdrq0RoH3dkA1f7O3wO+7kZcx2DusVZrRmFlWQM9HOb"
static

Definition at line 81 of file test_auth_token.c.

Referenced by auth_token_test_random_keys().

◆ zeroinline

const char* zeroinline
static
Initial value:
= "-----BEGIN OpenVPN auth-token server key-----\n"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\n"
"-----END OpenVPN auth-token server key-----"

Definition at line 61 of file test_auth_token.c.

Referenced by auth_token_test_key_load().