mirror of
https://github.com/ipxe/ipxe
synced 2025-12-12 23:15:10 +03:00
[test] Add tests for x509_check_name()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -852,6 +852,40 @@ static void x509_check_time_fail_okx ( struct x509_test_certificate *crt,
|
|||||||
#define x509_check_time_fail_ok( crt, time ) \
|
#define x509_check_time_fail_ok( crt, time ) \
|
||||||
x509_check_time_fail_okx ( crt, time, __FILE__, __LINE__ )
|
x509_check_time_fail_okx ( crt, time, __FILE__, __LINE__ )
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report certificate name validation test result
|
||||||
|
*
|
||||||
|
* @v crt Test certificate
|
||||||
|
* @v name Test name
|
||||||
|
* @v file Test code file
|
||||||
|
* @v line Test code line
|
||||||
|
*/
|
||||||
|
static void x509_check_name_okx ( struct x509_test_certificate *crt,
|
||||||
|
const char *name, const char *file,
|
||||||
|
unsigned int line ) {
|
||||||
|
|
||||||
|
okx ( x509_check_name ( crt->cert, name ) == 0, file, line );
|
||||||
|
}
|
||||||
|
#define x509_check_name_ok( crt, name ) \
|
||||||
|
x509_check_name_okx ( crt, name, __FILE__, __LINE__ )
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Report certificate name validation failure test result
|
||||||
|
*
|
||||||
|
* @v crt Test certificate
|
||||||
|
* @v name Test name
|
||||||
|
* @v file Test code file
|
||||||
|
* @v line Test code line
|
||||||
|
*/
|
||||||
|
static void x509_check_name_fail_okx ( struct x509_test_certificate *crt,
|
||||||
|
const char *name, const char *file,
|
||||||
|
unsigned int line ) {
|
||||||
|
|
||||||
|
okx ( x509_check_name ( crt->cert, name ) != 0, file, line );
|
||||||
|
}
|
||||||
|
#define x509_check_name_fail_ok( crt, name ) \
|
||||||
|
x509_check_name_fail_okx ( crt, name, __FILE__, __LINE__ )
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report certificate chain parsing test result
|
* Report certificate chain parsing test result
|
||||||
*
|
*
|
||||||
@@ -981,6 +1015,10 @@ static void x509_test_exec ( void ) {
|
|||||||
x509_check_time_ok ( &root_crt, test_expired );
|
x509_check_time_ok ( &root_crt, test_expired );
|
||||||
x509_check_time_fail_ok ( &root_crt, test_ca_expired );
|
x509_check_time_fail_ok ( &root_crt, test_ca_expired );
|
||||||
|
|
||||||
|
/* Check certificate names */
|
||||||
|
x509_check_name_ok ( &server_crt, "boot.test.ipxe.org" );
|
||||||
|
x509_check_name_fail_ok ( &server_crt, "incorrect.test.ipxe.org" );
|
||||||
|
|
||||||
/* Parse all certificate chains */
|
/* Parse all certificate chains */
|
||||||
x509_chain_ok ( &server_chain );
|
x509_chain_ok ( &server_chain );
|
||||||
x509_chain_ok ( &broken_server_chain );
|
x509_chain_ok ( &broken_server_chain );
|
||||||
|
|||||||
Reference in New Issue
Block a user