david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[test] Add tests for x509_check_name()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2014-03-31 13:15:42 +01:00
parent 7945542fb0
commit 357f23da9a
1 changed files with 38 additions and 0 deletions

View File

@ -852,6 +852,40 @@ static void x509_check_time_fail_okx ( struct x509_test_certificate *crt,
#define x509_check_time_fail_ok( crt, time ) \
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
*
@ -981,6 +1015,10 @@ static void x509_test_exec ( void ) {
x509_check_time_ok ( &root_crt, test_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 */
x509_chain_ok ( &server_chain );
x509_chain_ok ( &broken_server_chain );