The FreeRADIUS server $Id: f3670dba8951ca10eb4948feb3dc3db9423a334f $
Loading...
Searching...
No Matches
Macros | Functions | Variables
ldap_util_tests.c File Reference

Tests for the LDAP DN and filter escape functions. More...

#include <freeradius-devel/util/test/acutest_common_init.h>
#include <freeradius-devel/util/test/acutest_helpers.h>
#include <freeradius-devel/ldap/base.h>
+ Include dependency graph for ldap_util_tests.c:

Go to the source code of this file.

Macros

#define BOX_FROM_LITERAL(_str)   box_from_bytes(_str, sizeof(_str) - 1)
 Allocate a tainted string box from a literal, NUL bytes included.
 
#define TEST_CHECK_BOX_BYTES(_vb, _exp)
 Check a value box holds exactly the expected bytes, NUL bytes included.
 

Functions

static fr_value_box_t * box_from_bytes (char const *bytes, size_t len)
 
static void test_dn_box_escape_leading (void)
 
static void test_dn_box_escape_nul_length_collision (void)
 
static void test_dn_box_escape_plain (void)
 
static void test_dn_box_escape_specials (void)
 
static void test_dn_escape_sbuff (void)
 
static void test_dn_escape_sbuff_empty (void)
 
static void test_filter_afrom_dn_list (void)
 
static void test_filter_box_escape_empty (void)
 
static void test_filter_box_escape_nul_length_collision (void)
 
static void test_filter_box_escape_nul_truncation (void)
 
static void test_filter_box_escape_plain (void)
 
static void test_filter_box_escape_specials (void)
 
static void test_filter_escape_sbuff (void)
 
static void test_filter_escape_sbuff_no_space (void)
 

Variables

 TEST_LIST
 

Detailed Description

Tests for the LDAP DN and filter escape functions.

Definition in file ldap_util_tests.c.

Macro Definition Documentation

◆ BOX_FROM_LITERAL

#define BOX_FROM_LITERAL (   _str)    box_from_bytes(_str, sizeof(_str) - 1)

Allocate a tainted string box from a literal, NUL bytes included.

Definition at line 44 of file ldap_util_tests.c.

◆ TEST_CHECK_BOX_BYTES

#define TEST_CHECK_BOX_BYTES (   _vb,
  _exp 
)
Value:
do { \
fr_value_box_t const *_our_vb = (_vb); \
TEST_CHECK_LEN(_our_vb->vb_length, sizeof(_exp) - 1); \
TEST_CHECK(memcmp(_our_vb->vb_strvalue, _exp, sizeof(_exp) - 1) == 0); \
TEST_MSG("Expected : \"%s\"", _exp); \
TEST_MSG("Got : \"%s\"", _our_vb->vb_strvalue); \
} while (0)

Check a value box holds exactly the expected bytes, NUL bytes included.

A strcmp based check stops at the first NUL, which is the failure mode these tests exist to catch.

Definition at line 33 of file ldap_util_tests.c.

Function Documentation

◆ box_from_bytes()

static fr_value_box_t * box_from_bytes ( char const *  bytes,
size_t  len 
)
static

Definition at line 46 of file ldap_util_tests.c.

+ Here is the call graph for this function:

◆ test_dn_box_escape_leading()

static void test_dn_box_escape_leading ( void  )
static

Definition at line 138 of file ldap_util_tests.c.

+ Here is the call graph for this function:

◆ test_dn_box_escape_nul_length_collision()

static void test_dn_box_escape_nul_length_collision ( void  )
static

Definition at line 161 of file ldap_util_tests.c.

+ Here is the call graph for this function:

◆ test_dn_box_escape_plain()

static void test_dn_box_escape_plain ( void  )
static

Definition at line 116 of file ldap_util_tests.c.

+ Here is the call graph for this function:

◆ test_dn_box_escape_specials()

static void test_dn_box_escape_specials ( void  )
static

Definition at line 127 of file ldap_util_tests.c.

+ Here is the call graph for this function:

◆ test_dn_escape_sbuff()

static void test_dn_escape_sbuff ( void  )
static

Definition at line 202 of file ldap_util_tests.c.

+ Here is the call graph for this function:

◆ test_dn_escape_sbuff_empty()

static void test_dn_escape_sbuff_empty ( void  )
static

Definition at line 214 of file ldap_util_tests.c.

+ Here is the call graph for this function:

◆ test_filter_afrom_dn_list()

static void test_filter_afrom_dn_list ( void  )
static

Definition at line 225 of file ldap_util_tests.c.

+ Here is the call graph for this function:

◆ test_filter_box_escape_empty()

static void test_filter_box_escape_empty ( void  )
static

Definition at line 105 of file ldap_util_tests.c.

+ Here is the call graph for this function:

◆ test_filter_box_escape_nul_length_collision()

static void test_filter_box_escape_nul_length_collision ( void  )
static

Definition at line 90 of file ldap_util_tests.c.

+ Here is the call graph for this function:

◆ test_filter_box_escape_nul_truncation()

static void test_filter_box_escape_nul_truncation ( void  )
static

Definition at line 79 of file ldap_util_tests.c.

+ Here is the call graph for this function:

◆ test_filter_box_escape_plain()

static void test_filter_box_escape_plain ( void  )
static

Definition at line 57 of file ldap_util_tests.c.

+ Here is the call graph for this function:

◆ test_filter_box_escape_specials()

static void test_filter_box_escape_specials ( void  )
static

Definition at line 68 of file ldap_util_tests.c.

+ Here is the call graph for this function:

◆ test_filter_escape_sbuff()

static void test_filter_escape_sbuff ( void  )
static

Definition at line 176 of file ldap_util_tests.c.

+ Here is the call graph for this function:

◆ test_filter_escape_sbuff_no_space()

static void test_filter_escape_sbuff_no_space ( void  )
static

Definition at line 190 of file ldap_util_tests.c.

+ Here is the call graph for this function:

Variable Documentation

◆ TEST_LIST

TEST_LIST
Initial value:
= {
{ "filter_box_escape_plain", test_filter_box_escape_plain },
{ "filter_box_escape_specials", test_filter_box_escape_specials },
{ "filter_box_escape_nul_truncation", test_filter_box_escape_nul_truncation },
{ "filter_box_escape_nul_length_collision", test_filter_box_escape_nul_length_collision },
{ "filter_box_escape_empty", test_filter_box_escape_empty },
{ "dn_box_escape_plain", test_dn_box_escape_plain },
{ "dn_box_escape_specials", test_dn_box_escape_specials },
{ "dn_box_escape_leading", test_dn_box_escape_leading },
{ "dn_box_escape_nul_length_collision", test_dn_box_escape_nul_length_collision },
{ "filter_escape_sbuff", test_filter_escape_sbuff },
{ "filter_escape_sbuff_no_space", test_filter_escape_sbuff_no_space },
{ "dn_escape_sbuff", test_dn_escape_sbuff },
{ "dn_escape_sbuff_empty", test_dn_escape_sbuff_empty },
{ "filter_afrom_dn_list", test_filter_afrom_dn_list },
}
#define TEST_TERMINATOR
Definition acutest.h:64
static void test_filter_afrom_dn_list(void)
static void test_filter_escape_sbuff_no_space(void)
static void test_filter_box_escape_specials(void)
static void test_dn_escape_sbuff_empty(void)
static void test_dn_box_escape_plain(void)
static void test_dn_box_escape_nul_length_collision(void)
static void test_filter_box_escape_plain(void)
static void test_filter_box_escape_nul_length_collision(void)
static void test_filter_escape_sbuff(void)
static void test_filter_box_escape_nul_truncation(void)
static void test_filter_box_escape_empty(void)
static void test_dn_box_escape_specials(void)
static void test_dn_box_escape_leading(void)
static void test_dn_escape_sbuff(void)

Definition at line 242 of file ldap_util_tests.c.