From bd5466ab7e11a2f40b685c7fc76e3b78d051714b Mon Sep 17 00:00:00 2001 From: Thomas Daubney Date: Tue, 31 May 2022 14:16:42 +0100 Subject: [PATCH] Add test for accessor Add test logic for accessor. Signed-off-by: Thomas Daubney --- tests/suites/test_suite_x509parse.function | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/suites/test_suite_x509parse.function b/tests/suites/test_suite_x509parse.function index fea02f362c..6ed5ea121f 100644 --- a/tests/suites/test_suite_x509parse.function +++ b/tests/suites/test_suite_x509parse.function @@ -400,6 +400,22 @@ int parse_crt_ext_cb( void *p_ctx, mbedtls_x509_crt const *crt, mbedtls_x509_buf * END_DEPENDENCIES */ +/* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_WRITE_C */ +void x509_accessor_ext_types( int ext_type, int has_ext_type ) +{ + mbedtls_x509_crt crt; + int expected_result = ext_type & has_ext_type; + + mbedtls_x509_crt_init( &crt ); + + crt.ext_types = ext_type; + + TEST_ASSERT( mbedtls_x509_crt_has_ext_type( &crt, has_ext_type ) == expected_result ); + + mbedtls_x509_crt_free( &crt ); +} +/* END_CASE */ + /* BEGIN_CASE depends_on:MBEDTLS_FS_IO:MBEDTLS_X509_CRT_PARSE_C */ void x509_parse_san( char * crt_file, char * result_str ) {