Lines Matching refs:fixture
46 static void tear_down(CMP_SES_TEST_FIXTURE *fixture) in tear_down() argument
48 OSSL_CMP_CTX_free(fixture->cmp_ctx); in tear_down()
49 ossl_cmp_mock_srv_free(fixture->srv_ctx); in tear_down()
50 sk_X509_free(fixture->caPubs); in tear_down()
51 OPENSSL_free(fixture); in tear_down()
56 CMP_SES_TEST_FIXTURE *fixture; in set_up() local
60 if (!TEST_ptr(fixture = OPENSSL_zalloc(sizeof(*fixture)))) in set_up()
62 fixture->test_case_name = test_case_name; in set_up()
63 if (!TEST_ptr(fixture->srv_ctx = ossl_cmp_mock_srv_new(libctx, NULL)) in set_up()
64 || !OSSL_CMP_SRV_CTX_set_accept_unprotected(fixture->srv_ctx, 1) in set_up()
65 || !ossl_cmp_mock_srv_set1_refCert(fixture->srv_ctx, client_cert) in set_up()
66 || !ossl_cmp_mock_srv_set1_certOut(fixture->srv_ctx, client_cert) in set_up()
68 OSSL_CMP_SRV_CTX_get0_cmp_ctx(fixture->srv_ctx)) == NULL in set_up()
72 if (!TEST_ptr(fixture->cmp_ctx = ctx = OSSL_CMP_CTX_new(libctx, NULL)) in set_up()
73 || !OSSL_CMP_CTX_set_log_cb(fixture->cmp_ctx, print_to_bio_out) in set_up()
75 || !OSSL_CMP_CTX_set_transfer_cb_arg(ctx, fixture->srv_ctx) in set_up()
84 fixture->req_type = -1; in set_up()
85 return fixture; in set_up()
88 tear_down(fixture); in set_up()
101 static int execute_exec_GENM_ses_test_single(CMP_SES_TEST_FIXTURE *fixture) in execute_exec_GENM_ses_test_single() argument
103 OSSL_CMP_CTX *ctx = fixture->cmp_ctx; in execute_exec_GENM_ses_test_single()
112 return TEST_int_eq(OSSL_CMP_CTX_get_status(ctx), fixture->expected) in execute_exec_GENM_ses_test_single()
113 && fixture->expected == OSSL_CMP_PKISTATUS_accepted ? in execute_exec_GENM_ses_test_single()
117 static int execute_exec_GENM_ses_test(CMP_SES_TEST_FIXTURE *fixture) in execute_exec_GENM_ses_test() argument
119 return execute_exec_GENM_ses_test_single(fixture) in execute_exec_GENM_ses_test()
120 && OSSL_CMP_CTX_reinit(fixture->cmp_ctx) in execute_exec_GENM_ses_test()
121 && execute_exec_GENM_ses_test_single(fixture); in execute_exec_GENM_ses_test()
124 static int execute_exec_certrequest_ses_test(CMP_SES_TEST_FIXTURE *fixture) in execute_exec_certrequest_ses_test() argument
126 OSSL_CMP_CTX *ctx = fixture->cmp_ctx; in execute_exec_certrequest_ses_test()
127 X509 *res = OSSL_CMP_exec_certreq(ctx, fixture->req_type, NULL); in execute_exec_certrequest_ses_test()
131 if (!TEST_int_eq(status, fixture->expected) in execute_exec_certrequest_ses_test()
132 && !(fixture->expected == OSSL_CMP_PKISTATUS_waiting in execute_exec_certrequest_ses_test()
135 if (fixture->expected != OSSL_CMP_PKISTATUS_accepted) in execute_exec_certrequest_ses_test()
140 if (fixture->caPubs != NULL) { in execute_exec_certrequest_ses_test()
141 STACK_OF(X509) *caPubs = OSSL_CMP_CTX_get1_caPubs(fixture->cmp_ctx); in execute_exec_certrequest_ses_test()
142 int ret = TEST_int_eq(STACK_OF_X509_cmp(fixture->caPubs, caPubs), 0); in execute_exec_certrequest_ses_test()
154 OSSL_CMP_CTX_set1_oldCert(fixture->cmp_ctx, NULL); in test_exec_RR_ses()
155 fixture->expected = request_error ? OSSL_CMP_PKISTATUS_request in test_exec_RR_ses()
174 ossl_cmp_mock_srv_set_statusInfo(fixture->srv_ctx, in test_exec_RR_ses_receive_error()
178 ossl_cmp_mock_srv_set_sendError(fixture->srv_ctx, OSSL_CMP_PKIBODY_RR); in test_exec_RR_ses_receive_error()
179 fixture->expected = OSSL_CMP_PKISTATUS_rejection; in test_exec_RR_ses_receive_error()
187 fixture->req_type = OSSL_CMP_PKIBODY_IR; in test_exec_IR_ses()
188 fixture->expected = OSSL_CMP_PKISTATUS_accepted; in test_exec_IR_ses()
189 fixture->caPubs = sk_X509_new_null(); in test_exec_IR_ses()
190 sk_X509_push(fixture->caPubs, server_cert); in test_exec_IR_ses()
191 sk_X509_push(fixture->caPubs, server_cert); in test_exec_IR_ses()
192 ossl_cmp_mock_srv_set1_caPubsOut(fixture->srv_ctx, fixture->caPubs); in test_exec_IR_ses()
202 fixture->req_type = req_type; in test_exec_REQ_ses_poll()
203 fixture->expected = expect; in test_exec_REQ_ses_poll()
204 ossl_cmp_mock_srv_set_checkAfterTime(fixture->srv_ctx, check_after); in test_exec_REQ_ses_poll()
205 ossl_cmp_mock_srv_set_pollCount(fixture->srv_ctx, poll_count); in test_exec_REQ_ses_poll()
206 OSSL_CMP_CTX_set_option(fixture->cmp_ctx, in test_exec_REQ_ses_poll()
241 fixture->req_type = OSSL_CMP_PKIBODY_CR; in test_exec_CR_ses()
242 OSSL_CMP_CTX_set_option(fixture->cmp_ctx, in test_exec_CR_ses()
244 OSSL_CMP_SRV_CTX_set_grant_implicit_confirm(fixture->srv_ctx, granted); in test_exec_CR_ses()
245 ossl_cmp_mock_srv_set_sendError(fixture->srv_ctx, in test_exec_CR_ses()
247 fixture->expected = reject ? OSSL_CMP_PKISTATUS_rejection in test_exec_CR_ses()
268 fixture->req_type = OSSL_CMP_PKIBODY_KUR; in test_exec_KUR_ses()
272 OSSL_CMP_CTX_set_transfer_cb_arg(fixture->cmp_ctx, NULL); in test_exec_KUR_ses()
277 OSSL_CMP_CTX_set0_newPkey(fixture->cmp_ctx, 0 /* not priv */, key); in test_exec_KUR_ses()
278 OSSL_CMP_SRV_CTX_set_accept_raverified(fixture->srv_ctx, 1); in test_exec_KUR_ses()
281 OSSL_CMP_CTX_set_option(fixture->cmp_ctx, OSSL_CMP_OPT_POPO_METHOD, in test_exec_KUR_ses()
283 fixture->expected = transfer_error ? OSSL_CMP_PKISTATUS_trans : in test_exec_KUR_ses()
336 fixture->req_type = OSSL_CMP_PKIBODY_P10CR; in test_exec_P10CR_ses()
337 fixture->expected = reject ? OSSL_CMP_PKISTATUS_rejection in test_exec_P10CR_ses()
339 ctx = fixture->cmp_ctx; in test_exec_P10CR_ses()
344 tear_down(fixture); in test_exec_P10CR_ses()
345 fixture = NULL; in test_exec_P10CR_ses()
362 static int execute_try_certreq_poll_test(CMP_SES_TEST_FIXTURE *fixture) in execute_try_certreq_poll_test() argument
364 OSSL_CMP_CTX *ctx = fixture->cmp_ctx; in execute_try_certreq_poll_test()
369 ossl_cmp_mock_srv_set_pollCount(fixture->srv_ctx, 3); in execute_try_certreq_poll_test()
370 ossl_cmp_mock_srv_set_checkAfterTime(fixture->srv_ctx, CHECK_AFTER); in execute_try_certreq_poll_test()
377 && TEST_int_eq(fixture->expected, in execute_try_certreq_poll_test()
386 fixture->expected = 1; in test_try_certreq_poll()
391 static int execute_try_certreq_poll_abort_test(CMP_SES_TEST_FIXTURE *fixture) in execute_try_certreq_poll_abort_test() argument
393 OSSL_CMP_CTX *ctx = fixture->cmp_ctx; in execute_try_certreq_poll_abort_test()
398 ossl_cmp_mock_srv_set_pollCount(fixture->srv_ctx, 3); in execute_try_certreq_poll_abort_test()
399 ossl_cmp_mock_srv_set_checkAfterTime(fixture->srv_ctx, CHECK_AFTER); in execute_try_certreq_poll_abort_test()
403 && TEST_int_eq(fixture->expected, in execute_try_certreq_poll_abort_test()
405 && TEST_ptr_eq(OSSL_CMP_CTX_get0_newCert(fixture->cmp_ctx), NULL); in execute_try_certreq_poll_abort_test()
411 fixture->expected = 1; in test_try_certreq_poll_abort()
440 OSSL_CMP_CTX_set_transfer_cb_arg(fixture->cmp_ctx, NULL); in test_exec_GENM_ses()
445 fixture->cmp_ctx->total_timeout = total_timeout; in test_exec_GENM_ses()
446 fixture->expected = expect; in test_exec_GENM_ses()
466 static int execute_exchange_certConf_test(CMP_SES_TEST_FIXTURE *fixture) in execute_exchange_certConf_test() argument
469 ossl_cmp_exchange_certConf(fixture->cmp_ctx, OSSL_CMP_CERTREQID, in execute_exchange_certConf_test()
473 return TEST_int_eq(fixture->expected, res); in execute_exchange_certConf_test()
476 static int execute_exchange_error_test(CMP_SES_TEST_FIXTURE *fixture) in execute_exchange_error_test() argument
479 ossl_cmp_exchange_error(fixture->cmp_ctx, in execute_exchange_error_test()
484 return TEST_int_eq(fixture->expected, res); in execute_exchange_error_test()
490 fixture->expected = 0; /* client should not send certConf immediately */ in test_exchange_certConf()
491 if (!ossl_cmp_ctx_set0_newCert(fixture->cmp_ctx, X509_dup(client_cert))) { in test_exchange_certConf()
492 tear_down(fixture); in test_exchange_certConf()
493 fixture = NULL; in test_exchange_certConf()
502 fixture->expected = 1; /* client may send error any time */ in test_exchange_error()