Lines Matching full:fixture
43 static void tear_down(CMP_VFY_TEST_FIXTURE *fixture) in tear_down() argument
45 OSSL_CMP_MSG_free(fixture->msg); in tear_down()
46 OSSL_CMP_CTX_free(fixture->cmp_ctx); in tear_down()
47 OPENSSL_free(fixture); in tear_down()
55 CMP_VFY_TEST_FIXTURE *fixture; in set_up() local
57 if (!TEST_ptr(fixture = OPENSSL_zalloc(sizeof(*fixture)))) in set_up()
61 fixture->test_case_name = test_case_name; in set_up()
63 || !TEST_ptr(fixture->cmp_ctx = OSSL_CMP_CTX_new(libctx, NULL)) in set_up()
64 || !OSSL_CMP_CTX_set0_trustedStore(fixture->cmp_ctx, ts) in set_up()
65 || !OSSL_CMP_CTX_set_log_cb(fixture->cmp_ctx, print_to_bio_out)) { in set_up()
66 tear_down(fixture); in set_up()
72 return fixture; in set_up()
100 static int execute_verify_popo_test(CMP_VFY_TEST_FIXTURE *fixture) in execute_verify_popo_test() argument
102 if ((fixture->msg = load_pkimsg(ir_protected_f, libctx)) == NULL) in execute_verify_popo_test()
104 if (fixture->expected == 0) { in execute_verify_popo_test()
105 const OSSL_CRMF_MSGS *reqs = fixture->msg->body->value.ir; in execute_verify_popo_test()
110 return TEST_int_eq(fixture->expected, in execute_verify_popo_test()
111 ossl_cmp_verify_popo(fixture->cmp_ctx, fixture->msg, in execute_verify_popo_test()
112 fixture->additional_arg)); in execute_verify_popo_test()
118 fixture->expected = 1; in test_verify_popo()
127 fixture->expected = 0; in test_verify_popo_bad()
133 static int execute_validate_msg_test(CMP_VFY_TEST_FIXTURE *fixture) in execute_validate_msg_test() argument
135 return TEST_int_eq(fixture->expected, in execute_validate_msg_test()
136 ossl_cmp_msg_check_update(fixture->cmp_ctx, fixture->msg, in execute_validate_msg_test()
140 static int execute_validate_cert_path_test(CMP_VFY_TEST_FIXTURE *fixture) in execute_validate_cert_path_test() argument
142 X509_STORE *ts = OSSL_CMP_CTX_get0_trustedStore(fixture->cmp_ctx); in execute_validate_cert_path_test()
143 int res = TEST_int_eq(fixture->expected, in execute_validate_cert_path_test()
144 OSSL_CMP_validate_cert_path(fixture->cmp_ctx, in execute_validate_cert_path_test()
145 ts, fixture->cert)); in execute_validate_cert_path_test()
147 OSSL_CMP_CTX_print_errors(fixture->cmp_ctx); in execute_validate_cert_path_test()
155 fixture->expected = !miss && !wrong; in test_validate_msg_mac_alg_protection()
156 if (!TEST_true(miss ? OSSL_CMP_CTX_set0_trustedStore(fixture->cmp_ctx, NULL) in test_validate_msg_mac_alg_protection()
157 : OSSL_CMP_CTX_set1_secretValue(fixture->cmp_ctx, sec_1, in test_validate_msg_mac_alg_protection()
159 || !TEST_ptr(fixture->msg = load_pkimsg(ip_waiting_f, libctx))) { in test_validate_msg_mac_alg_protection()
160 tear_down(fixture); in test_validate_msg_mac_alg_protection()
161 fixture = NULL; in test_validate_msg_mac_alg_protection()
191 fixture->expected = 0; in test_validate_msg_mac_alg_protection_bad()
193 if (!TEST_true(OSSL_CMP_CTX_set1_secretValue(fixture->cmp_ctx, sec_bad, in test_validate_msg_mac_alg_protection_bad()
195 || !TEST_ptr(fixture->msg = load_pkimsg(ip_waiting_f, libctx))) { in test_validate_msg_mac_alg_protection_bad()
196 tear_down(fixture); in test_validate_msg_mac_alg_protection_bad()
197 fixture = NULL; in test_validate_msg_mac_alg_protection_bad()
221 ts = OSSL_CMP_CTX_get0_trustedStore(fixture->cmp_ctx); in test_validate_msg_signature_partial_chain()
222 fixture->expected = !expired; in test_validate_msg_signature_partial_chain()
224 || !TEST_ptr(fixture->msg = load_pkimsg(ir_protected_f, libctx)) in test_validate_msg_signature_partial_chain()
225 || !add_trusted(fixture->cmp_ctx, srvcert)) { in test_validate_msg_signature_partial_chain()
226 tear_down(fixture); in test_validate_msg_signature_partial_chain()
227 fixture = NULL; in test_validate_msg_signature_partial_chain()
253 fixture->cert = srvcert; in test_validate_msg_signature_srvcert()
254 fixture->expected = !bad_sig && !wrong && !miss; in test_validate_msg_signature_srvcert()
255 if (!TEST_ptr(fixture->msg = load_pkimsg(ir_protected_f, libctx)) in test_validate_msg_signature_srvcert()
256 || !TEST_true(miss ? OSSL_CMP_CTX_set1_secretValue(fixture->cmp_ctx, in test_validate_msg_signature_srvcert()
258 : OSSL_CMP_CTX_set1_srvCert(fixture->cmp_ctx, in test_validate_msg_signature_srvcert()
260 || (bad_sig && !flip_bit(fixture->msg->protection))) { in test_validate_msg_signature_srvcert()
261 tear_down(fixture); in test_validate_msg_signature_srvcert()
262 fixture = NULL; in test_validate_msg_signature_srvcert()
293 fixture->expected = 1; in test_validate_msg_signature_sender_cert_untrusted()
294 if (!TEST_ptr(fixture->msg = load_pkimsg(ir_protected_0_extracerts, libctx)) in test_validate_msg_signature_sender_cert_untrusted()
295 || !add_trusted(fixture->cmp_ctx, instaca_cert) in test_validate_msg_signature_sender_cert_untrusted()
296 || !add_untrusted(fixture->cmp_ctx, insta_cert)) { in test_validate_msg_signature_sender_cert_untrusted()
297 tear_down(fixture); in test_validate_msg_signature_sender_cert_untrusted()
298 fixture = NULL; in test_validate_msg_signature_sender_cert_untrusted()
307 fixture->expected = 1; in test_validate_msg_signature_sender_cert_trusted()
308 if (!TEST_ptr(fixture->msg = load_pkimsg(ir_protected_0_extracerts, libctx)) in test_validate_msg_signature_sender_cert_trusted()
309 || !add_trusted(fixture->cmp_ctx, instaca_cert) in test_validate_msg_signature_sender_cert_trusted()
310 || !add_trusted(fixture->cmp_ctx, insta_cert)) { in test_validate_msg_signature_sender_cert_trusted()
311 tear_down(fixture); in test_validate_msg_signature_sender_cert_trusted()
312 fixture = NULL; in test_validate_msg_signature_sender_cert_trusted()
321 fixture->expected = 1; in test_validate_msg_signature_sender_cert_extracert()
322 if (!TEST_ptr(fixture->msg = load_pkimsg(ir_protected_2_extracerts, libctx)) in test_validate_msg_signature_sender_cert_extracert()
323 || !add_trusted(fixture->cmp_ctx, instaca_cert)) { in test_validate_msg_signature_sender_cert_extracert()
324 tear_down(fixture); in test_validate_msg_signature_sender_cert_extracert()
325 fixture = NULL; in test_validate_msg_signature_sender_cert_extracert()
336 fixture->expected = 0; in test_validate_msg_signature_sender_cert_absent()
337 if (!TEST_ptr(fixture->msg = load_pkimsg(ir_protected_0_extracerts, libctx))) { in test_validate_msg_signature_sender_cert_absent()
338 tear_down(fixture); in test_validate_msg_signature_sender_cert_absent()
339 fixture = NULL; in test_validate_msg_signature_sender_cert_absent()
349 fixture->expected = expected; in test_validate_with_sender()
350 if (!TEST_ptr(fixture->msg = load_pkimsg(ir_protected_f, libctx)) in test_validate_with_sender()
351 || !TEST_true(OSSL_CMP_CTX_set1_expected_sender(fixture->cmp_ctx, name)) in test_validate_with_sender()
352 || !TEST_true(OSSL_CMP_CTX_set1_srvCert(fixture->cmp_ctx, srvcert))) { in test_validate_with_sender()
353 tear_down(fixture); in test_validate_with_sender()
354 fixture = NULL; in test_validate_with_sender()
374 fixture->expected = 0; in test_validate_msg_unprotected_request()
375 if (!TEST_ptr(fixture->msg = load_pkimsg(ir_unprotected_f, libctx))) { in test_validate_msg_unprotected_request()
376 tear_down(fixture); in test_validate_msg_unprotected_request()
377 fixture = NULL; in test_validate_msg_unprotected_request()
384 static void setup_path(CMP_VFY_TEST_FIXTURE **fixture, X509 *wrong, int expired) in setup_path() argument
386 (*fixture)->cert = endentity2; in setup_path()
387 (*fixture)->expected = wrong == NULL && !expired; in setup_path()
389 X509_STORE *ts = OSSL_CMP_CTX_get0_trustedStore((*fixture)->cmp_ctx); in setup_path()
393 if (!add_trusted((*fixture)->cmp_ctx, wrong == NULL ? root : wrong) in setup_path()
394 || !add_untrusted((*fixture)->cmp_ctx, endentity1) in setup_path()
395 || !add_untrusted((*fixture)->cmp_ctx, intermediate)) { in setup_path()
396 tear_down((*fixture)); in setup_path()
397 (*fixture) = NULL; in setup_path()
404 setup_path(&fixture, NULL, 0); in test_validate_cert_path_ok()
412 setup_path(&fixture, srvcert /* wrong/non-root cert */, 0); in test_validate_cert_path_wrong_anchor()
420 setup_path(&fixture, NULL, 1); in test_validate_cert_path_expired()
425 static int execute_msg_check_test(CMP_VFY_TEST_FIXTURE *fixture) in execute_msg_check_test() argument
427 const OSSL_CMP_PKIHEADER *hdr = OSSL_CMP_MSG_get0_header(fixture->msg); in execute_msg_check_test()
430 if (!TEST_int_eq(fixture->expected, in execute_msg_check_test()
431 ossl_cmp_msg_check_update(fixture->cmp_ctx, in execute_msg_check_test()
432 fixture->msg, in execute_msg_check_test()
433 fixture->allow_unprotected_cb, in execute_msg_check_test()
434 fixture->additional_arg))) in execute_msg_check_test()
437 if (fixture->expected == 0) /* error expected aready during above check */ in execute_msg_check_test()
442 fixture->cmp_ctx->recipNonce)) in execute_msg_check_test()
445 fixture->cmp_ctx->transactionID)); in execute_msg_check_test()
454 static void setup_check_update(CMP_VFY_TEST_FIXTURE **fixture, int expected, in setup_check_update() argument
459 OSSL_CMP_CTX *ctx = (*fixture)->cmp_ctx; in setup_check_update()
462 (*fixture)->expected = expected; in setup_check_update()
463 (*fixture)->allow_unprotected_cb = cb; in setup_check_update()
464 (*fixture)->additional_arg = arg; in setup_check_update()
465 (*fixture)->msg = OSSL_CMP_MSG_dup(ir_rmprotection); in setup_check_update()
466 if ((*fixture)->msg == NULL in setup_check_update()
470 tear_down((*fixture)); in setup_check_update()
471 (*fixture) = NULL; in setup_check_update()
478 tear_down((*fixture)); in setup_check_update()
479 (*fixture) = NULL; in setup_check_update()
489 setup_check_update(&fixture, 0, NULL, 0, NULL, NULL); in test_msg_check_no_protection_no_cb()
497 setup_check_update(&fixture, 0, allow_unprotected, 0, NULL, NULL); in test_msg_check_no_protection_restrictive_cb()
506 setup_check_update(&fixture, 1, allow_unprotected, 1, NULL, NULL); in test_msg_check_no_protection_permissive_cb()
520 setup_check_update(&fixture, 1, allow_unprotected, 1, trans_id, NULL); in test_msg_check_transaction_id()
529 setup_check_update(&fixture, 0, allow_unprotected, 1, rand_data, NULL); in test_msg_check_transaction_id_bad()
544 setup_check_update(&fixture, 1, allow_unprotected, 1, NULL, rec_nonce); in test_msg_check_recipient_nonce()
553 setup_check_update(&fixture, 0, allow_unprotected, 1, NULL, rand_data); in test_msg_check_recipient_nonce_bad()