@@ -14,7 +14,7 @@ use chrono::Local;
1414use expectest:: prelude:: * ;
1515use itertools:: Itertools ;
1616use libc:: c_char;
17- use log:: LevelFilter ;
17+ use log:: { warn , LevelFilter } ;
1818use maplit:: * ;
1919use multipart_2021 as multipart;
2020use pretty_assertions:: assert_eq;
@@ -483,6 +483,8 @@ fn add_interaction_reference() {
483483
484484#[ test_log:: test]
485485fn http_consumer_feature_test ( ) {
486+ init_crypto ( ) ;
487+
486488 let consumer_name = CString :: new ( "http-consumer" ) . unwrap ( ) ;
487489 let provider_name = CString :: new ( "http-provider" ) . unwrap ( ) ;
488490 let pact_handle = pactffi_new_pact ( consumer_name. as_ptr ( ) , provider_name. as_ptr ( ) ) ;
@@ -560,6 +562,8 @@ fn http_consumer_feature_test() {
560562#[ test]
561563#[ allow( deprecated) ]
562564fn http_xml_consumer_feature_test ( ) {
565+ init_crypto ( ) ;
566+
563567 let consumer_name = CString :: new ( "http-consumer" ) . unwrap ( ) ;
564568 let provider_name = CString :: new ( "http-provider" ) . unwrap ( ) ;
565569 let pact_handle = pactffi_new_pact ( consumer_name. as_ptr ( ) , provider_name. as_ptr ( ) ) ;
@@ -682,6 +686,8 @@ fn message_xml_consumer_feature_test() {
682686
683687#[ test]
684688fn http_xml_consumer_with_examples_and_content_test ( ) {
689+ init_crypto ( ) ;
690+
685691 let consumer_name = CString :: new ( "http-consumer" ) . unwrap ( ) ;
686692 let provider_name = CString :: new ( "http-provider" ) . unwrap ( ) ;
687693 let pact_handle = pactffi_new_pact ( consumer_name. as_ptr ( ) , provider_name. as_ptr ( ) ) ;
@@ -857,6 +863,8 @@ fn pactffi_with_binary_file_feature_test(specification: PactSpecification, expec
857863#[ test_log:: test]
858864#[ allow( deprecated) ]
859865fn http_verification_from_directory_feature_test ( ) {
866+ init_crypto ( ) ;
867+
860868 let name = CString :: new ( "tests" ) . unwrap ( ) ;
861869 let version = CString :: new ( "1.0.0" ) . unwrap ( ) ;
862870 let handle = pactffi_verifier_new_for_application ( name. as_ptr ( ) , version. as_ptr ( ) ) ;
@@ -908,6 +916,8 @@ fn test_missing_plugin() {
908916// Issue #299
909917#[ test_log:: test]
910918fn each_value_matcher ( ) {
919+ init_crypto ( ) ;
920+
911921 let consumer_name = CString :: new ( "each_value_matcher-consumer" ) . unwrap ( ) ;
912922 let provider_name = CString :: new ( "each_value_matcher-provider" ) . unwrap ( ) ;
913923 let pact_handle = pactffi_new_pact ( consumer_name. as_ptr ( ) , provider_name. as_ptr ( ) ) ;
@@ -973,6 +983,8 @@ fn each_value_matcher() {
973983// Issue #301
974984#[ test_log:: test]
975985fn each_key_matcher ( ) {
986+ init_crypto ( ) ;
987+
976988 let consumer_name = CString :: new ( "each_key_matcher-consumer" ) . unwrap ( ) ;
977989 let provider_name = CString :: new ( "each_key_matcher-provider" ) . unwrap ( ) ;
978990 let pact_handle = pactffi_new_pact ( consumer_name. as_ptr ( ) , provider_name. as_ptr ( ) ) ;
@@ -1046,6 +1058,8 @@ fn each_key_matcher() {
10461058// Issue #324
10471059#[ test_log:: test]
10481060fn array_contains_matcher ( ) {
1061+ init_crypto ( ) ;
1062+
10491063 let consumer_name = CString :: new ( "array_contains_matcher-consumer" ) . unwrap ( ) ;
10501064 let provider_name = CString :: new ( "array_contains_matcher-provider" ) . unwrap ( ) ;
10511065 let pact_handle = pactffi_new_pact ( consumer_name. as_ptr ( ) , provider_name. as_ptr ( ) ) ;
@@ -1122,6 +1136,14 @@ fn array_contains_matcher() {
11221136 ] ) ) ) ;
11231137}
11241138
1139+ fn init_crypto ( ) {
1140+ if rustls:: crypto:: CryptoProvider :: get_default ( ) . is_none ( ) {
1141+ if let Err ( _) = rustls:: crypto:: ring:: default_provider ( ) . install_default ( ) {
1142+ warn ! ( "failed to installed the default crypto provider" ) ;
1143+ }
1144+ }
1145+ }
1146+
11251147// Issue #332
11261148#[ test_log:: test]
11271149#[ allow( deprecated) ]
@@ -1795,6 +1817,8 @@ fn provider_states_ignoring_parameter_types() {
17951817// Issue #399
17961818#[ test_log:: test]
17971819fn combined_each_key_and_each_value_matcher ( ) {
1820+ init_crypto ( ) ;
1821+
17981822 let consumer_name = CString :: new ( "combined_matcher-consumer" ) . unwrap ( ) ;
17991823 let provider_name = CString :: new ( "combined_matcher-provider" ) . unwrap ( ) ;
18001824 let pact_handle = pactffi_new_pact ( consumer_name. as_ptr ( ) , provider_name. as_ptr ( ) ) ;
@@ -1991,6 +2015,8 @@ fn returns_mock_server_logs() {
19912015#[ test]
19922016#[ allow( deprecated) ]
19932017fn http_form_urlencoded_consumer_feature_test ( ) {
2018+ init_crypto ( ) ;
2019+
19942020 let consumer_name = CString :: new ( "http-consumer" ) . unwrap ( ) ;
19952021 let provider_name = CString :: new ( "http-provider" ) . unwrap ( ) ;
19962022 let pact_handle = pactffi_new_pact ( consumer_name. as_ptr ( ) , provider_name. as_ptr ( ) ) ;
@@ -2303,6 +2329,8 @@ fn mime_multipart() {
23032329// Response returns current date in the provided format when pact:generator:type is present in date matcher
23042330#[ test_log:: test]
23052331fn date_matcher_in_response_body_with_generator_type ( ) {
2332+ init_crypto ( ) ;
2333+
23062334 let consumer_name = CString :: new ( "date-consumer" ) . unwrap ( ) ;
23072335 let provider_name = CString :: new ( "date-provider" ) . unwrap ( ) ;
23082336 let pact_handle = pactffi_new_pact ( consumer_name. as_ptr ( ) , provider_name. as_ptr ( ) ) ;
@@ -2378,6 +2406,8 @@ fn date_matcher_in_response_body_with_generator_type() {
23782406// Response returns provided date value itself when pact:generator:type is not provided in date matcher
23792407#[ test_log:: test]
23802408fn date_matcher_in_response_body_without_generator_type ( ) {
2409+ init_crypto ( ) ;
2410+
23812411 let consumer_name = CString :: new ( "date-consumer" ) . unwrap ( ) ;
23822412 let provider_name = CString :: new ( "date-provider" ) . unwrap ( ) ;
23832413 let pact_handle = pactffi_new_pact ( consumer_name. as_ptr ( ) , provider_name. as_ptr ( ) ) ;
0 commit comments