diff options
author | Michael Brown | 2014-03-31 14:15:42 +0200 |
---|---|---|
committer | Michael Brown | 2014-03-31 14:16:46 +0200 |
commit | 357f23da9abdbf73feadd39ca0f6d03a67cf8050 (patch) | |
tree | 701115e93ec0d66786a4c17b46fab44225382cb9 /src/tests/x509_test.c | |
parent | [test] Rewrite CMS tests using okx() (diff) | |
download | ipxe-357f23da9abdbf73feadd39ca0f6d03a67cf8050.tar.gz ipxe-357f23da9abdbf73feadd39ca0f6d03a67cf8050.tar.xz ipxe-357f23da9abdbf73feadd39ca0f6d03a67cf8050.zip |
[test] Add tests for x509_check_name()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/tests/x509_test.c')
-rw-r--r-- | src/tests/x509_test.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/tests/x509_test.c b/src/tests/x509_test.c index 6496ac72..17f5d94c 100644 --- a/src/tests/x509_test.c +++ b/src/tests/x509_test.c @@ -853,6 +853,40 @@ static void x509_check_time_fail_okx ( struct x509_test_certificate *crt, 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 * * @v chn Test certificate chain @@ -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 ); |