aboutsummaryrefslogtreecommitdiff
path: root/test/provfetchtest.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2022-01-10 14:46:46 +0000
committerPauli <pauli@openssl.org>2022-01-12 10:55:15 +1100
commitf5e97b3702916e69873746108ac7c100a31d2241 (patch)
treef634e101841e0dcb524d78b2975a5d59b6551ee7 /test/provfetchtest.c
parentcd1981a0dc165ab6af5e2945beaaa9efe4484cee (diff)
downloadopenssl-f5e97b3702916e69873746108ac7c100a31d2241.zip
openssl-f5e97b3702916e69873746108ac7c100a31d2241.tar.gz
openssl-f5e97b3702916e69873746108ac7c100a31d2241.tar.bz2
Ensure we test fetching encoder/decoder/store loader with a query string
Although we had a test for fetching an encoder/decoder/store loader it did not use a query string. The issue highlighted by #17456 only occurs if a query string is used. Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17459)
Diffstat (limited to 'test/provfetchtest.c')
-rw-r--r--test/provfetchtest.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/test/provfetchtest.c b/test/provfetchtest.c
index b1f9d08..aae9b40 100644
--- a/test/provfetchtest.c
+++ b/test/provfetchtest.c
@@ -225,6 +225,7 @@ static int dummy_provider_init(const OSSL_CORE_HANDLE *handle,
* Test 1: Encoder
* Test 2: Store loader
* Test 3: EVP_RAND
+ * Test 4-7: As above, but additionally with a query string
*/
static int fetch_test(int tst)
{
@@ -236,6 +237,7 @@ static int fetch_test(int tst)
OSSL_STORE_LOADER *loader = NULL;
int testresult = 0;
unsigned char buf[32];
+ int query = tst > 3;
if (!TEST_ptr(libctx))
goto err;
@@ -246,24 +248,29 @@ static int fetch_test(int tst)
|| !TEST_ptr(dummyprov = OSSL_PROVIDER_load(libctx, "dummy-prov")))
goto err;
- switch (tst) {
+ switch (tst % 4) {
case 0:
- decoder = OSSL_DECODER_fetch(libctx, "DUMMY", NULL);
+ decoder = OSSL_DECODER_fetch(libctx, "DUMMY",
+ query ? "provider=dummy" : NULL);
if (!TEST_ptr(decoder))
goto err;
break;
case 1:
- encoder = OSSL_ENCODER_fetch(libctx, "DUMMY", NULL);
+ encoder = OSSL_ENCODER_fetch(libctx, "DUMMY",
+ query ? "provider=dummy" : NULL);
if (!TEST_ptr(encoder))
goto err;
break;
case 2:
- loader = OSSL_STORE_LOADER_fetch(libctx, "DUMMY", NULL);
+ loader = OSSL_STORE_LOADER_fetch(libctx, "DUMMY",
+ query ? "provider=dummy" : NULL);
if (!TEST_ptr(loader))
goto err;
break;
case 3:
- if (!TEST_true(RAND_set_DRBG_type(libctx, "DUMMY", NULL, NULL, NULL))
+ if (!TEST_true(RAND_set_DRBG_type(libctx, "DUMMY",
+ query ? "provider=dummy" : NULL,
+ NULL, NULL))
|| !TEST_int_ge(RAND_bytes_ex(libctx, buf, sizeof(buf), 0), 1))
goto err;
break;
@@ -284,7 +291,7 @@ static int fetch_test(int tst)
int setup_tests(void)
{
- ADD_ALL_TESTS(fetch_test, 4);
+ ADD_ALL_TESTS(fetch_test, 8);
return 1;
}