BSL v1.1.1 - 19.g31939de
AMMOS Bundle Protocol Security Library (BSL)
Loading...
Searching...
No Matches
TestUtils.h File Reference
#include <m-string.h>
#include <backend/PublicInterfaceImpl.h>
#include <backend/SecOperation.h>
#include <backend/IdValPair.h>
#include <backend/SecurityActionSet.h>
#include <mock_bpa/ctr.h>
+ Include dependency graph for TestUtils.h:
+ This graph shows which files directly or indirectly include this file:

Data Structures

struct  BSL_TestContext_t
 

Macros

#define TEST_CASE(...)
 
#define TEST_RANGE(...)
 
#define TEST_MATRIX(...)
 

Functions

int BSL_TestContext_Init (BSL_TestContext_t *ctx)
 
int BSL_TestContext_Deinit (BSL_TestContext_t *ctx)
 
int BSL_TestUtils_LoadBundleFromCBOR (BSL_TestContext_t *test_ctx, const char *cborhex)
 
BSL_HostEIDPattern_t BSL_TestUtils_GetEidPatternFromText (const char *text)
 
void BSL_TestUtils_PrintHexToBuffer (const char *message, uint8_t *buff, size_t bufflen)
 
bool BSL_TestUtils_IsB16StrEqualTo (const char *b16_string, BSL_Data_t encoded_val)
 
int BSL_TestUtils_EncodeBase16 (string_t output, const BSL_Data_t *input, bool uppercase)
 Encode to base16 text form.
 
int BSL_TestUtils_DecodeBase16 (BSL_Data_t *output, const string_t input)
 Decode base16 text form.
 
int BSL_TestUtils_DecodeBase16_cstr (BSL_Data_t *output, const char *input)
 
int BSL_TestUtils_ModifyEIDs (BSL_BundleRef_t *input_bundle, const char *src_eid, const char *dest_eid, const char *report_to_eid)
 Modify bundle's source eid, destination eid, and report-to eid.
 
BSL_SeqReader_t * BSL_TestUtils_FlatReader (const void *buf, size_t bufsize)
 Initialize a flat-buffer reader object.
 
BSL_SeqWriter_t * BSL_TestUtils_FlatWriter (void **buf, size_t *bufsize)
 Initialize a flat-buffer reader object.
 

Macro Definition Documentation

◆ TEST_CASE

#define TEST_CASE (   ...)

◆ TEST_MATRIX

#define TEST_MATRIX (   ...)

◆ TEST_RANGE

#define TEST_RANGE (   ...)

Function Documentation

◆ BSL_TestContext_Deinit()

int BSL_TestContext_Deinit ( BSL_TestContext_t ctx)

◆ BSL_TestContext_Init()

int BSL_TestContext_Init ( BSL_TestContext_t ctx)

References BSL_API_InitLib(), BSL_SUCCESS, ctx, and mock_bpa_ctr_init().

Referenced by _setUp(), and setUp().

◆ BSL_TestUtils_DecodeBase16()

int BSL_TestUtils_DecodeBase16 ( BSL_Data_t output,
const string_t  input 
)

Decode base16 text form.

This is defined in Section 8 of RFC 4648 [15].

Note
This function uses heap allocation for its output.
Parameters
[out]outputThe output buffer, which will be sized to its data.
[in]inputThe input buffer to read, which must be null terminated. Whitespace in the input must have already been removed with strip_space().
Returns
Zero upon success.

References BSL_CHKERR1, BSL_Data_Resize(), BSL_TestUtils_DecodeBase16_char(), and BSL_Data_t::ptr.

Referenced by BSL_TestUtils_DecodeBase16_cstr(), BSL_TestUtils_IsB16StrEqualTo(), BSL_TestUtils_LoadBundleFromCBOR(), test_bsl_loopback_eid(), test_bsl_mock_encode_canonical(), test_bsl_mock_encode_primary(), test_BSL_TestUtils_DecodeBase16_valid(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), test_DecodeBase16(), test_mock_bpa_crc_crc16(), test_mock_bpa_crc_crc32c(), test_mock_bpa_ctr_decode_invalid(), test_qcbor_decode_array_nested(), test_qcbor_decode_only_head(), test_qcbor_decode_with_head(), test_qcbor_decode_without_head(), test_sec_accept_keyunwrap(), and test_sec_source_keywrap().

◆ BSL_TestUtils_DecodeBase16_cstr()

int BSL_TestUtils_DecodeBase16_cstr ( BSL_Data_t output,
const char *  input 
)

◆ BSL_TestUtils_EncodeBase16()

int BSL_TestUtils_EncodeBase16 ( string_t  output,
const BSL_Data_t input,
bool  uppercase 
)

Encode to base16 text form.

This is defined in Section 8 of RFC 4648 [15].

Note
This function uses heap allocation for its output.
Parameters
[out]outputThe output buffer, which will be appended to.
[in]inputThe input buffer to read.
uppercaseTrue to use upper-case letters, false to use lower-case.
Returns
Zero upon success.

References BSL_Data_t::len, and BSL_Data_t::ptr.

Referenced by printencoded().

◆ BSL_TestUtils_FlatReader()

◆ BSL_TestUtils_FlatWriter()

◆ BSL_TestUtils_GetEidPatternFromText()

BSL_HostEIDPattern_t BSL_TestUtils_GetEidPatternFromText ( const char *  text)

◆ BSL_TestUtils_IsB16StrEqualTo()

◆ BSL_TestUtils_LoadBundleFromCBOR()

◆ BSL_TestUtils_ModifyEIDs()

int BSL_TestUtils_ModifyEIDs ( BSL_BundleRef_t input_bundle,
const char *  src_eid,
const char *  dest_eid,
const char *  report_to_eid 
)

Modify bundle's source eid, destination eid, and report-to eid.

Parameters
[in,out]input_bundlebundle to modify
[in]src_eidEID to set bundle source EID to. Set to NULL if bundle source EID should remain unchanged.
[in]dest_eidEID to set bundle destination EID to. Set to NULL if bundle destination EID should remain unchanged.
[in]report_to_eidEID to set bundle report-to EID to. Set to NULL if bundle report-to EID should remain unchanged.

References BSL_BundleCtx_GetBundleMetadata(), BSL_PrimaryBlock_deinit(), BSL_PrimaryBlock_t::field_dest_eid, BSL_PrimaryBlock_t::field_report_to_eid, BSL_PrimaryBlock_t::field_src_node_id, and mock_bpa_eid_from_text().

Referenced by n_test_BSL_6(), test_BSL_32(), TEST_CASE(), and test_dyn_mem_cbs_BSL_32().

◆ BSL_TestUtils_PrintHexToBuffer()

void BSL_TestUtils_PrintHexToBuffer ( const char *  message,
uint8_t *  buff,
size_t  bufflen 
)