aboutsummaryrefslogtreecommitdiff
path: root/test/cmp_client_test.c
diff options
context:
space:
mode:
authorRajeev Ranjan <ranjan.rajeev@siemens.com>2023-03-13 09:16:57 +0100
committerDr. David von Oheimb <dev@ddvo.net>2023-12-21 22:53:35 +0100
commit192bfec487b27ee9398138ce5f0c5b00f536dc95 (patch)
treef8b1dbf16ab04f2542cb372dd0d89361d368ada4 /test/cmp_client_test.c
parent682fd21afb5428b5716e62eaefb09a7419f9cfd7 (diff)
downloadopenssl-192bfec487b27ee9398138ce5f0c5b00f536dc95.zip
openssl-192bfec487b27ee9398138ce5f0c5b00f536dc95.tar.gz
openssl-192bfec487b27ee9398138ce5f0c5b00f536dc95.tar.bz2
crypto/cmp/,apps/lib/cmp_mock_srv.c: add delayed delivery for all types of responses
Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com> (Merged from https://github.com/openssl/openssl/pull/20727)
Diffstat (limited to 'test/cmp_client_test.c')
-rw-r--r--test/cmp_client_test.c68
1 files changed, 52 insertions, 16 deletions
diff --git a/test/cmp_client_test.c b/test/cmp_client_test.c
index 44c369b..ad78c86 100644
--- a/test/cmp_client_test.c
+++ b/test/cmp_client_test.c
@@ -184,7 +184,7 @@ static int test_exec_RR_ses_receive_error(void)
static int test_exec_IR_ses(void)
{
SETUP_TEST_FIXTURE(CMP_SES_TEST_FIXTURE, set_up);
- fixture->req_type = OSSL_CMP_IR;
+ fixture->req_type = OSSL_CMP_PKIBODY_IR;
fixture->expected = OSSL_CMP_PKISTATUS_accepted;
fixture->caPubs = sk_X509_new_null();
sk_X509_push(fixture->caPubs, server_cert);
@@ -194,42 +194,55 @@ static int test_exec_IR_ses(void)
return result;
}
-static int test_exec_IR_ses_poll(int check_after, int poll_count,
- int total_timeout, int expect)
+static int test_exec_any_ses_poll(int req_type, int check_after,
+ int poll_count, int total_timeout,
+ int expect)
{
SETUP_TEST_FIXTURE(CMP_SES_TEST_FIXTURE, set_up);
- fixture->req_type = OSSL_CMP_IR;
+ fixture->req_type = req_type;
fixture->expected = expect;
ossl_cmp_mock_srv_set_checkAfterTime(fixture->srv_ctx, check_after);
ossl_cmp_mock_srv_set_pollCount(fixture->srv_ctx, poll_count);
OSSL_CMP_CTX_set_option(fixture->cmp_ctx,
OSSL_CMP_OPT_TOTAL_TIMEOUT, total_timeout);
- EXECUTE_TEST(execute_exec_certrequest_ses_test, tear_down);
+
+ if (req_type == OSSL_CMP_PKIBODY_IR || req_type == OSSL_CMP_PKIBODY_CR
+ || req_type == OSSL_CMP_PKIBODY_KUR
+ || req_type == OSSL_CMP_PKIBODY_P10CR) {
+ EXECUTE_TEST(execute_exec_certrequest_ses_test, tear_down);
+ } else if (req_type == OSSL_CMP_PKIBODY_GENM) {
+ EXECUTE_TEST(execute_exec_GENM_ses_test, tear_down);
+ } else {
+ result = 0;
+ }
return result;
}
static int checkAfter = 1;
static int test_exec_IR_ses_poll_ok(void)
{
- return test_exec_IR_ses_poll(checkAfter, 2, 0, OSSL_CMP_PKISTATUS_accepted);
+ return test_exec_any_ses_poll(OSSL_CMP_PKIBODY_IR, checkAfter, 2, 0,
+ OSSL_CMP_PKISTATUS_accepted);
}
static int test_exec_IR_ses_poll_no_timeout(void)
{
- return test_exec_IR_ses_poll(checkAfter, 1 /* pollCount */, checkAfter + 1,
- OSSL_CMP_PKISTATUS_accepted);
+ return test_exec_any_ses_poll(OSSL_CMP_PKIBODY_IR, checkAfter,
+ 2 /* pollCount */, checkAfter + 4,
+ OSSL_CMP_PKISTATUS_accepted);
}
static int test_exec_IR_ses_poll_total_timeout(void)
{
- return test_exec_IR_ses_poll(checkAfter + 1, 2 /* pollCount */, checkAfter,
- OSSL_CMP_PKISTATUS_waiting);
+ return !test_exec_any_ses_poll(OSSL_CMP_PKIBODY_IR, checkAfter + 1,
+ 3 /* pollCount */, checkAfter + 6,
+ OSSL_CMP_PKISTATUS_waiting);
}
static int test_exec_CR_ses(int implicit_confirm, int granted, int reject)
{
SETUP_TEST_FIXTURE(CMP_SES_TEST_FIXTURE, set_up);
- fixture->req_type = OSSL_CMP_CR;
+ fixture->req_type = OSSL_CMP_PKIBODY_CR;
OSSL_CMP_CTX_set_option(fixture->cmp_ctx,
OSSL_CMP_OPT_IMPLICIT_CONFIRM, implicit_confirm);
OSSL_CMP_SRV_CTX_set_grant_implicit_confirm(fixture->srv_ctx, granted);
@@ -256,7 +269,7 @@ static int test_exec_CR_ses_implicit_confirm(void)
static int test_exec_KUR_ses(int transfer_error, int pubkey, int raverified)
{
SETUP_TEST_FIXTURE(CMP_SES_TEST_FIXTURE, set_up);
- fixture->req_type = OSSL_CMP_KUR;
+ fixture->req_type = OSSL_CMP_PKIBODY_KUR;
/* ctx->oldCert has already been set */
if (transfer_error)
@@ -324,7 +337,7 @@ static int test_exec_P10CR_ses(int reject)
X509_REQ *csr = NULL;
SETUP_TEST_FIXTURE(CMP_SES_TEST_FIXTURE, set_up);
- fixture->req_type = OSSL_CMP_P10CR;
+ fixture->req_type = OSSL_CMP_PKIBODY_P10CR;
fixture->expected = reject ? OSSL_CMP_PKISTATUS_rejection
: OSSL_CMP_PKISTATUS_accepted;
ctx = fixture->cmp_ctx;
@@ -354,8 +367,8 @@ static int execute_try_certreq_poll_test(CMP_SES_TEST_FIXTURE *fixture)
{
OSSL_CMP_CTX *ctx = fixture->cmp_ctx;
int check_after;
- const int CHECK_AFTER = 5;
- const int TYPE = OSSL_CMP_KUR;
+ const int CHECK_AFTER = 0;
+ const int TYPE = OSSL_CMP_PKIBODY_KUR;
ossl_cmp_mock_srv_set_pollCount(fixture->srv_ctx, 3);
ossl_cmp_mock_srv_set_checkAfterTime(fixture->srv_ctx, CHECK_AFTER);
@@ -384,7 +397,7 @@ static int execute_try_certreq_poll_abort_test(CMP_SES_TEST_FIXTURE *fixture)
OSSL_CMP_CTX *ctx = fixture->cmp_ctx;
int check_after;
const int CHECK_AFTER = 99;
- const int TYPE = OSSL_CMP_CR;
+ const int TYPE = OSSL_CMP_PKIBODY_CR;
ossl_cmp_mock_srv_set_pollCount(fixture->srv_ctx, 3);
ossl_cmp_mock_srv_set_checkAfterTime(fixture->srv_ctx, CHECK_AFTER);
@@ -404,6 +417,26 @@ static int test_try_certreq_poll_abort(void)
return result;
}
+static int test_exec_GENM_ses_poll_ok(void)
+{
+ return test_exec_any_ses_poll(OSSL_CMP_PKIBODY_GENM, checkAfter, 2, 0,
+ OSSL_CMP_PKISTATUS_accepted);
+}
+
+static int test_exec_GENM_ses_poll_no_timeout(void)
+{
+ return test_exec_any_ses_poll(OSSL_CMP_PKIBODY_GENM, checkAfter,
+ 1 /* pollCount */, checkAfter + 1,
+ OSSL_CMP_PKISTATUS_accepted);
+}
+
+static int test_exec_GENM_ses_poll_total_timeout(void)
+{
+ return test_exec_any_ses_poll(OSSL_CMP_PKIBODY_GENM, checkAfter + 1,
+ 3 /* pollCount */, checkAfter + 2,
+ OSSL_CMP_PKISTATUS_waiting);
+}
+
static int test_exec_GENM_ses(int transfer_error, int total_timeout, int expect)
{
SETUP_TEST_FIXTURE(CMP_SES_TEST_FIXTURE, set_up);
@@ -539,6 +572,9 @@ int setup_tests(void)
ADD_TEST(test_exec_GENM_ses_ok);
ADD_TEST(test_exec_GENM_ses_transfer_error);
ADD_TEST(test_exec_GENM_ses_total_timeout);
+ ADD_TEST(test_exec_GENM_ses_poll_ok);
+ ADD_TEST(test_exec_GENM_ses_poll_no_timeout);
+ ADD_TEST(test_exec_GENM_ses_poll_total_timeout);
ADD_TEST(test_exchange_certConf);
ADD_TEST(test_exchange_error);
return 1;