diff options
author | Shane Lontis <shane.lontis@oracle.com> | 2020-05-14 12:32:44 +1000 |
---|---|---|
committer | Dr. David von Oheimb <David.von.Oheimb@siemens.com> | 2020-08-21 09:04:11 +0200 |
commit | ab28b59064b3f46c7a62b540cd17cad718738108 (patch) | |
tree | 2959690fe059a4fbf66b38661e94046aa91000af /test | |
parent | 97e00da90282dddfc572c84d8468d85ab1925fba (diff) | |
download | openssl-ab28b59064b3f46c7a62b540cd17cad718738108.zip openssl-ab28b59064b3f46c7a62b540cd17cad718738108.tar.gz openssl-ab28b59064b3f46c7a62b540cd17cad718738108.tar.bz2 |
Add libctx/provider support to cmp_server_test
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/11808)
Diffstat (limited to 'test')
-rw-r--r-- | test/cmp_server_test.c | 18 | ||||
-rw-r--r-- | test/recipes/65-test_cmp_server.t | 30 |
2 files changed, 40 insertions, 8 deletions
diff --git a/test/cmp_server_test.c b/test/cmp_server_test.c index dc52a25..4b3525d 100644 --- a/test/cmp_server_test.c +++ b/test/cmp_server_test.c @@ -18,6 +18,8 @@ typedef struct test_fixture { OSSL_CMP_MSG *req; } CMP_SRV_TEST_FIXTURE; +static OPENSSL_CTX *libctx = NULL; +static OSSL_PROVIDER *default_null_provider = NULL, *provider = NULL; static OSSL_CMP_MSG *request = NULL; static void tear_down(CMP_SRV_TEST_FIXTURE *fixture) @@ -33,7 +35,7 @@ static CMP_SRV_TEST_FIXTURE *set_up(const char *const test_case_name) if (!TEST_ptr(fixture = OPENSSL_zalloc(sizeof(*fixture)))) return NULL; fixture->test_case_name = test_case_name; - if (!TEST_ptr(fixture->srv_ctx = OSSL_CMP_SRV_CTX_new(NULL, NULL))) + if (!TEST_ptr(fixture->srv_ctx = OSSL_CMP_SRV_CTX_new(libctx, NULL))) goto err; return fixture; @@ -67,7 +69,7 @@ static int execute_test_handle_request(CMP_SRV_TEST_FIXTURE *fixture) OSSL_CMP_ERRORMSGCONTENT *errorContent; int res = 0; - if (!TEST_ptr(client_ctx = OSSL_CMP_CTX_new(NULL, NULL)) + if (!TEST_ptr(client_ctx = OSSL_CMP_CTX_new(libctx, NULL)) || !TEST_true(OSSL_CMP_CTX_set_transfer_cb_arg(client_ctx, ctx))) goto end; @@ -119,9 +121,16 @@ static int test_handle_request(void) void cleanup_tests(void) { OSSL_CMP_MSG_free(request); + OSSL_PROVIDER_unload(default_null_provider); + OSSL_PROVIDER_unload(provider); + OPENSSL_CTX_free(libctx); return; } +#define USAGE \ + "CR_protected_PBM_1234.der module_name [module_conf_file]\n" +OPT_TEST_DECLARE_USAGE(USAGE) + int setup_tests(void) { const char *request_f; @@ -132,10 +141,13 @@ int setup_tests(void) } if (!TEST_ptr(request_f = test_get_argument(0))) { - TEST_error("usage: cmp_server_test CR_protected_PBM_1234.der\n"); + TEST_error("usage: cmp_server_test %s", USAGE); return 0; } + if (!test_get_libctx(&libctx, &default_null_provider, &provider, 1, USAGE)) + return 0; + if (!TEST_ptr(request = load_pkimsg(request_f))) { cleanup_tests(); return 0; diff --git a/test/recipes/65-test_cmp_server.t b/test/recipes/65-test_cmp_server.t index 87dbdb1..5864163 100644 --- a/test/recipes/65-test_cmp_server.t +++ b/test/recipes/65-test_cmp_server.t @@ -9,10 +9,18 @@ # https://www.openssl.org/source/license.html use strict; -use OpenSSL::Test qw/:DEFAULT data_file/; +use OpenSSL::Test qw/:DEFAULT data_file srctop_file srctop_dir bldtop_file bldtop_dir/; use OpenSSL::Test::Utils; -setup("test_cmp_server"); +BEGIN { + setup("test_cmp_server"); +} + +use lib srctop_dir('Configurations'); +use lib bldtop_dir('.'); +use platform; + +my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0); plan skip_all => "This test is not supported in a no-cmp build" if disabled("cmp"); @@ -20,7 +28,19 @@ plan skip_all => "This test is not supported in a no-cmp build" plan skip_all => "This test is not supported in a no-ec build" if disabled("ec"); -plan tests => 1; +plan tests => 2 + ($no_fips ? 0 : 2); #fips install + fips test + +my @basic_cmd = ("cmp_server_test", data_file("CR_protected_PBM_1234.der")); + +ok(run(test([@basic_cmd, "none"]))); + +ok(run(test([@basic_cmd, "default", srctop_file("test", "default.cnf")]))); + +unless ($no_fips) { + ok(run(app(['openssl', 'fipsinstall', + '-out', bldtop_file('providers', 'fipsmodule.cnf'), + '-module', bldtop_file('providers', platform->dso('fips'))])), + "fipsinstall"); -ok(run(test(["cmp_server_test", - data_file("CR_protected_PBM_1234.der")]))); + ok(run(test([@basic_cmd, "fips", srctop_file("test", "fips.cnf")]))); +} |