Skip to content

Commit 136f133

Browse files
committed
fix(pact-ffi): Update all dependencies + set default crypto provider in pactffi_init
1 parent d46ff92 commit 136f133

9 files changed

Lines changed: 51 additions & 128 deletions

File tree

rust/Cargo.lock

Lines changed: 2 additions & 91 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/pact_ffi/Cargo.toml

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,53 +15,52 @@ exclude = [
1515

1616
[dependencies]
1717
ansi_term = "0.12.1"
18-
anyhow = "1.0.100"
19-
bytes = "1.11.1"
20-
chrono = "0.4.42"
21-
either = "1.15.0"
22-
futures = "0.3.31"
23-
itertools = "0.14.0"
18+
anyhow = "1.0.104"
19+
bytes = "1.12.1"
20+
chrono = "0.4.45"
21+
either = "1.17.0"
22+
futures = "0.3.33"
23+
itertools = "0.15.0"
2424
lazy_static = "1.5.0"
25-
libc = "0.2.180"
26-
log = "0.4.29"
25+
libc = "0.2.189"
26+
log = "0.4.33"
2727
maplit = "1.0.2"
2828
multipart-2021 = { version = "0.19.0", default-features = false, features = ["client", "mock"] }
29-
onig = { version = "6.5.1", default-features = false }
29+
onig = { version = "6.5.3", default-features = false }
3030
# FFI Inmemory sink uses the global static `LOG_BUFFER` in the pact_matching crate. This is required to be the same
3131
# version as the mock server crate
3232
pact_matching = { version = "~2.0.9", path = "../pact_matching" }
3333
pact_mock_server = "~2.2.4"
3434
pact_models = { version = "~1.3.13" }
3535
pact-plugin-driver = { version = "~1.1.1" }
36-
pact_verifier = { version = "~1.4.4", path = "../pact_verifier" }
36+
pact_verifier = { version = "~1.4.5", path = "../pact_verifier" }
3737
panic-message = "0.3.0"
38-
rand = "0.9.2"
38+
rand = "0.9.5"
3939
rand_regex = "0.18.1"
40-
regex = "1.12.2"
41-
regex-syntax = "0.8.8"
42-
serde = { version = "1.0.228", features = ["derive"] }
43-
serde_json = "1.0.149"
40+
regex = "1.13.1"
41+
regex-syntax = "0.8.11"
42+
rustls = { version = "0.23.43", features = ["ring"] }
43+
serde = { version = "1.0.229", features = ["derive"] }
44+
serde_json = "1.0.151"
4445
serde_urlencoded = "0.7.1"
4546
sxd-document = "0.3.2"
46-
thiserror = "2.0.17"
47-
tokio = { version = "1.49.0", features = ["full"] }
48-
tracing = "0.1.41" # This needs to be the same version across all the libs (i.e. plugin driver)
49-
tracing-core = "0.1.33" # This needs to be the same version across all the pact libs (i.e. plugin driver)
47+
thiserror = "2.0.19"
48+
tokio = { version = "1.53.1", features = ["full"] }
49+
tracing = "0.1.44" # This needs to be the same version across all the libs (i.e. plugin driver)
50+
tracing-core = "0.1.36" # This needs to be the same version across all the pact libs (i.e. plugin driver)
5051
tracing-log = "0.2.0"
51-
tracing-subscriber = { version = "0.3.22", features = ["env-filter", "tracing-log"] }
52-
uuid = { version = "1.19.0", features = ["v4"] }
53-
zeroize = "1.8.2"
52+
tracing-subscriber = { version = "0.3.23", features = ["env-filter", "tracing-log"] }
53+
uuid = { version = "1.24.0", features = ["v4"] }
54+
zeroize = "1.9.0"
5455

5556
[dev-dependencies]
5657
expectest = "0.12.0"
5758
hamcrest2 = "0.3.0"
5859
pretty_assertions = "1.4.1"
59-
quickcheck = "1.0.3"
60-
reqwest = { version = "0.13.1", default-features = false, features = ["rustls", "blocking", "json", "multipart"] }
60+
reqwest = { version = "0.13.4", default-features = false, features = ["rustls-no-provider", "blocking", "json", "multipart"] }
6161
rstest = "0.26.1"
62-
rustls = { version = "0.23", features = ["ring"] }
63-
test-log = "0.2.19"
64-
tempfile = "3.24.0"
62+
test-log = "0.2.21"
63+
tempfile = "3.27.0"
6564

6665
[lib]
6766
crate-type = ["cdylib", "staticlib", "rlib"]

rust/pact_ffi/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub extern "C" fn pactffi_version() -> *const c_char {
6666

6767
/// Initialise the mock server library, can provide an environment variable name to use to
6868
/// set the log levels. This function should only be called once, as it tries to install a global
69-
/// tracing subscriber.
69+
/// tracing subscriber. It will also install a global crypto provider if one is not already set.
7070
///
7171
/// # Safety
7272
///
@@ -94,7 +94,14 @@ pub unsafe extern "C" fn pactffi_init(log_env_var: *const c_char) {
9494
if let Err(err) = tracing::subscriber::set_global_default(subscriber) {
9595
eprintln!("Failed to initialise global tracing subscriber - {err}");
9696
};
97+
9798
init_plugin_log_sink();
99+
100+
if rustls::crypto::CryptoProvider::get_default().is_none() {
101+
if let Err(_) = rustls::crypto::ring::default_provider().install_default() {
102+
warn!("failed to installed the default crypto provider");
103+
}
104+
}
98105
}
99106

100107
/// Initialises logging, and sets the log level explicitly. This function should only be called

rust/pact_ffi/src/mock_server/handles.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@
7171
//! expect!(pactffi_upon_receiving(interaction.clone(), description.as_ptr())).to(be_false());
7272
//!
7373
//! // Interact with the mock server
74+
//! if rustls::crypto::CryptoProvider::get_default().is_none() {
75+
//! let _ = rustls::crypto::ring::default_provider().install_default();
76+
//! }
7477
//! let client = Client::default();
7578
//! let result = client.post(format!("http://127.0.0.1:{}/request/9999?foo=baz", port).as_str())
7679
//! .header("Content-Type", "application/json")

rust/pact_ffi/src/mock_server/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ use either::Either;
5454
use libc::c_char;
5555
use onig::Regex;
5656
use rand::Rng;
57-
use serde_json::{json, Value};
57+
use serde_json::Value;
5858
use tracing::{error, info, warn};
5959
use uuid::Uuid;
6060

@@ -71,7 +71,6 @@ use pact_models::{
7171
pact::{Pact, ReadWritePact},
7272
time_utils::{parse_pattern, to_chrono_pattern}
7373
};
74-
use pact_plugin_driver::plugin_manager::get_mock_server_results;
7574

7675
use crate::{convert_cstr, ffi_fn, safe_str};
7776
use crate::log::fetch_buffer_contents;

rust/pact_ffi/src/util/string.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::ffi_fn;
21
use libc::c_char;
32
use std::ffi::{CStr, CString};
43
use std::ops::Not;

rust/pact_ffi/src/verifier/handle.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ mod tests {
353353
use expectest::prelude::*;
354354
use hamcrest2::prelude::*;
355355
use serde_json::Value;
356-
356+
use tracing::warn;
357357
use pact_models::pact::Pact;
358358
use pact_models::PactSpecification;
359359
use pact_models::v4::interaction::V4Interaction;
@@ -365,6 +365,12 @@ mod tests {
365365

366366
#[test]
367367
fn update_provider_info_sets_scheme_correctly() {
368+
if rustls::crypto::CryptoProvider::get_default().is_none() {
369+
if let Err(_) = rustls::crypto::ring::default_provider()
370+
.install_default() {
371+
warn!("failed to installed the default crypto provider");
372+
}
373+
}
368374
let mut handle = VerifierHandle::new_for_application("test", "0.0.0");
369375
handle.update_provider_info("Test".to_string(), "https".to_string(), "localhost".to_string(), 1234, "".to_string());
370376

rust/pact_ffi/src/verifier/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::ffi::CString;
77
use std::str::from_utf8;
88

99
use lazy_static::lazy_static;
10-
use libc::{c_char, c_int, c_uchar, c_uint, c_ulong, c_ushort, EXIT_FAILURE, EXIT_SUCCESS};
10+
use libc::{c_char, c_int, c_uchar, c_ulong, c_ushort, EXIT_FAILURE, EXIT_SUCCESS};
1111
use log::*;
1212
use pact_models::prelude::HttpAuth;
1313
use regex::Regex;

rust/pact_ffi/tests/tests.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,7 @@ fn merging_duplicate_http_interaction_without_state_with_pact_containing_two_htt
13631363
let result_2 = pactffi_pact_handle_write_file(pact_handle, tmp_dir.as_ptr(), false);
13641364

13651365
// Clear pact handle
1366-
let existing_pact_file: Option<String> = pact_default_file_name(&pact_handle);
1366+
let _existing_pact_file: Option<String> = pact_default_file_name(&pact_handle);
13671367
pactffi_free_pact_handle(pact_handle);
13681368

13691369
expect!(result_1).to(be_equal_to(0));
@@ -1632,7 +1632,7 @@ fn allow_creation_v4_spec_message() {
16321632
let message_handle = pactffi_new_message(message_pact_handle, description.as_ptr());
16331633
let body_bytes = request_body_with_matchers.as_bytes();
16341634
pactffi_message_with_contents(message_handle.clone(), content_type.as_ptr(), body_bytes.as_ptr(), body_bytes.len());
1635-
let res: *const c_char = pactffi_message_reify(message_handle.clone());
1635+
let _res: *const c_char = pactffi_message_reify(message_handle.clone());
16361636
let result_2 = pactffi_write_message_pact_file(message_pact_handle.clone(), tmp_dir.as_ptr(), false);
16371637
expect!(result_1).to(be_equal_to(0));
16381638
expect!(result_2).to(be_equal_to(0));
@@ -2146,7 +2146,6 @@ fn numeric_matcher_passing_test_sending_string_value() {
21462146
let interaction = pactffi_new_interaction(pact_handle.clone(), description.as_ptr());
21472147

21482148
let path = CString::new("/request").unwrap();
2149-
let content_type = CString::new("Content-Type").unwrap();
21502149
let request_body_with_matchers = CString::new("{\"value\":{\
21512150
\"key2\":{\"value\":321,\"pact:matcher:type\":\"number\"},\
21522151
\"key1\":{\"pact:matcher:type\":\"number\",\"value\":123.1}},\
@@ -2165,7 +2164,7 @@ fn numeric_matcher_passing_test_sending_string_value() {
21652164
expect!(port).to(be_greater_than(0));
21662165

21672166
let client = Client::default();
2168-
let result = client.post(format!("http://127.0.0.1:{}/request", port).as_str())
2167+
let _result = client.post(format!("http://127.0.0.1:{}/request", port).as_str())
21692168
.header("Content-Type", "application/json")
21702169
.body(r#"{"key2":"456","key1":"321.1"}"#)
21712170
.send();

0 commit comments

Comments
 (0)