From bf343b2530a4c30e3843565e5bdc2dca6273fe75 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 17 Jul 2024 11:09:16 +1000 Subject: [PATCH 01/17] update changelog for release 1.2.2 --- rust/pact_models/CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rust/pact_models/CHANGELOG.md b/rust/pact_models/CHANGELOG.md index 3e2835f3..21c12bd8 100644 --- a/rust/pact_models/CHANGELOG.md +++ b/rust/pact_models/CHANGELOG.md @@ -1,5 +1,11 @@ To generate the log, run `git log --pretty='* %h - %s (%an, %ad)' TAGNAME..HEAD .` replacing TAGNAME and HEAD as appropriate. +# 1.2.2 - Maintenance Release + +* 2e2580f6 - feat(pact_consumer): Improve the mock server error output (Ronald Holshausen, Wed Jul 10 15:23:48 2024 +1000) +* efa1295a - feat(pact_verifier): Allow provider state generator to fall back to the provider state parameters #441 (Ronald Holshausen, Tue Jul 9 17:27:09 2024 +1000) +* 86704a82 - bump version to 1.2.2 (Ronald Holshausen, Wed Jun 12 15:17:57 2024 +1000) + # 1.2.1 - Bugfix Release * ab80cd2b - fix: merge pact duplicates with diff desc/same prov state fix: merge message / sync pacts with no provider state (Yousaf Nabi, Sat Jun 8 23:48:30 2024 +0100) From 57f057751d766cec1c0d8a3f1c6fa27eeed3baa5 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 17 Jul 2024 11:10:27 +1000 Subject: [PATCH 02/17] bump version to 1.2.3 --- rust/Cargo.lock | 2 +- rust/pact_models/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index d4ac2de2..a94f05f6 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -2283,7 +2283,7 @@ dependencies = [ [[package]] name = "pact_models" -version = "1.2.2" +version = "1.2.3" dependencies = [ "anyhow", "ariadne", diff --git a/rust/pact_models/Cargo.toml b/rust/pact_models/Cargo.toml index 28ce9c91..55fe19a5 100644 --- a/rust/pact_models/Cargo.toml +++ b/rust/pact_models/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pact_models" -version = "1.2.2" +version = "1.2.3" authors = ["Ronald Holshausen "] edition = "2021" description = "Pact-Rust support library that provides the core models for dealing with Pact files" From fd9ff70acf715c4044771aa58414dbc6fcbe6edf Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 17 Jul 2024 11:15:34 +1000 Subject: [PATCH 03/17] chore: Upgrade pact_models to 1.2.2 --- compatibility-suite/Cargo.toml | 2 +- rust/Cargo.toml | 2 +- rust/pact_consumer/Cargo.toml | 2 +- rust/pact_ffi/Cargo.toml | 2 +- rust/pact_matching/Cargo.toml | 2 +- rust/pact_verifier/Cargo.toml | 2 +- rust/pact_verifier_cli/Cargo.toml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/compatibility-suite/Cargo.toml b/compatibility-suite/Cargo.toml index da34c2a9..8a8ed30e 100644 --- a/compatibility-suite/Cargo.toml +++ b/compatibility-suite/Cargo.toml @@ -13,7 +13,7 @@ futures = "0.3.29" itertools = "0.12.1" lazy_static = "1.4.0" maplit = "1.0.2" -pact_models = { version = "~1.2.1" } +pact_models = { version = "~1.2.2" } pact_matching = { version = "1.2.4", path = "../rust/pact_matching" } pact_mock_server = { version = "1.2.8" } pact_verifier = { version = "1.2.2", path = "../rust/pact_verifier" } diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 46d1604a..cdb51f4c 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -19,7 +19,7 @@ tracing-subscriber = { git = "https://github.com/tokio-rs/tracing.git", tag = "t # version across all crates (i.e. mock server crate). pact_matching = { version = "~1.2.4", path = "./pact_matching" } # Issue 389 - Pull change into other crates -pact_models = { version = "~1.2.1", path = "./pact_models" } +pact_models = { version = "~1.2.2", path = "./pact_models" } [profile.release] strip = true diff --git a/rust/pact_consumer/Cargo.toml b/rust/pact_consumer/Cargo.toml index 2e757b20..7289d076 100644 --- a/rust/pact_consumer/Cargo.toml +++ b/rust/pact_consumer/Cargo.toml @@ -32,7 +32,7 @@ lazy_static = "1.4.0" maplit = "1.0.2" pact_matching = { version = "~1.2.4", path = "../pact_matching", default-features = false } pact_mock_server = { version = "~1.2.8", default-features = false } -pact_models = { version = "~1.2.1", default-features = false } +pact_models = { version = "~1.2.2", default-features = false } pact-plugin-driver = { version = "~0.7.0", optional = true, default-features = false } regex = "1.10.4" serde_json = "1.0.115" diff --git a/rust/pact_ffi/Cargo.toml b/rust/pact_ffi/Cargo.toml index bbbe6f75..78f512a5 100644 --- a/rust/pact_ffi/Cargo.toml +++ b/rust/pact_ffi/Cargo.toml @@ -32,7 +32,7 @@ multipart = { version = "0.18.0", default-features = false, features = ["client" onig = { version = "6.4.0", default-features = false } pact_matching = { version = "~1.2.4", path = "../pact_matching" } pact_mock_server = { version = "~1.2.8" } -pact_models = { version = "~1.2.1" } +pact_models = { version = "~1.2.2" } pact-plugin-driver = { version = "~0.7.0" } pact_verifier = { version = "~1.2.2", path = "../pact_verifier" } panic-message = "0.3.0" diff --git a/rust/pact_matching/Cargo.toml b/rust/pact_matching/Cargo.toml index de1f318d..326457f5 100644 --- a/rust/pact_matching/Cargo.toml +++ b/rust/pact_matching/Cargo.toml @@ -41,7 +41,7 @@ mime = "0.3.17" multer = { version = "3.0.0", features = ["all"], optional = true } nom = "7.1.3" onig = { version = "6.4.0", default-features = false } -pact_models = { version = "~1.2.1", default-features = false } +pact_models = { version = "~1.2.2", default-features = false } pact-plugin-driver = { version = "~0.7.0", optional = true, default-features = false } rand = "0.8.5" reqwest = { version = "0.12.3", default-features = false, features = ["rustls-tls-native-roots", "json"] } diff --git a/rust/pact_verifier/Cargo.toml b/rust/pact_verifier/Cargo.toml index 32be4756..fe8114eb 100644 --- a/rust/pact_verifier/Cargo.toml +++ b/rust/pact_verifier/Cargo.toml @@ -36,7 +36,7 @@ lazy_static = "1.4.0" maplit = "1.0.2" mime = "0.3.17" pact_matching = { version = "~1.2.4", path = "../pact_matching", default-features = false } -pact_models = { version = "~1.2.1", default-features = false } +pact_models = { version = "~1.2.2", default-features = false } pact-plugin-driver = { version = "~0.7.0", optional = true, default-features = false } regex = "1.10.4" reqwest = { version = "0.12.3", default-features = false, features = ["rustls-tls-native-roots", "blocking", "json"] } diff --git a/rust/pact_verifier_cli/Cargo.toml b/rust/pact_verifier_cli/Cargo.toml index de398ec4..68c5764f 100644 --- a/rust/pact_verifier_cli/Cargo.toml +++ b/rust/pact_verifier_cli/Cargo.toml @@ -30,7 +30,7 @@ junit-report = { version = "0.8.3", optional = true } lazy_static = "1.5.0" log = "0.4.20" maplit = "1.0.2" -pact_models = { version = "~1.2.1", default-features = false } +pact_models = { version = "~1.2.2", default-features = false } pact_verifier = { version = "~1.2.2", path = "../pact_verifier", default-features = false } regex = "1.10.2" reqwest = { version = "0.12.4", default-features = false, features = ["rustls-tls-native-roots", "blocking", "json"] } From 9ae753119eda16dfbb0dfe28ca059878df1805f6 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 17 Jul 2024 11:54:32 +1000 Subject: [PATCH 04/17] update changelog for release 1.2.5 --- rust/pact_matching/CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rust/pact_matching/CHANGELOG.md b/rust/pact_matching/CHANGELOG.md index 661905d2..2165aed5 100644 --- a/rust/pact_matching/CHANGELOG.md +++ b/rust/pact_matching/CHANGELOG.md @@ -1,5 +1,14 @@ To generate the log, run `git log --pretty='* %h - %s (%an, %ad)' TAGNAME..HEAD .` replacing TAGNAME and HEAD as appropriate. +# 1.2.5 - Bugfix Release + +* fd9ff70a - chore: Upgrade pact_models to 1.2.2 (Ronald Holshausen, Wed Jul 17 11:15:34 2024 +1000) +* e8b62f98 - chore: Upgrade pact-plugin-driver to 0.7.0 (Ronald Holshausen, Wed Jul 17 10:45:34 2024 +1000) +* efa1295a - feat(pact_verifier): Allow provider state generator to fall back to the provider state parameters #441 (Ronald Holshausen, Tue Jul 9 17:27:09 2024 +1000) +* 42e2ba68 - fix(pact_verifier): Take context paths into account when fetching the root HAL resource #420 (Ronald Holshausen, Tue Jul 9 11:37:04 2024 +1000) +* da869ddb - fix: reduce log level for matching to debug (Matt Fellows, Fri Jul 5 00:13:50 2024 +1000) +* 2163476d - bump version to 1.2.5 (Ronald Holshausen, Fri Jun 14 10:07:48 2024 +1000) + # 1.2.4 - Maintenance Release * 30998a95 - chore: Upgrade pact_models to 1.2.1 (Ronald Holshausen, Wed Jun 12 15:26:49 2024 +1000) From c6df3fcc56b5d9e623c2449d4295ece91499e629 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 17 Jul 2024 11:56:14 +1000 Subject: [PATCH 05/17] bump version to 1.2.6 --- rust/Cargo.lock | 2 +- rust/pact_matching/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index a94f05f6..d77ac63a 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -2205,7 +2205,7 @@ dependencies = [ [[package]] name = "pact_matching" -version = "1.2.5" +version = "1.2.6" dependencies = [ "ansi_term", "anyhow", diff --git a/rust/pact_matching/Cargo.toml b/rust/pact_matching/Cargo.toml index 326457f5..ba298537 100644 --- a/rust/pact_matching/Cargo.toml +++ b/rust/pact_matching/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pact_matching" -version = "1.2.5" +version = "1.2.6" authors = ["Ronald Holshausen "] edition = "2021" description = "Pact-Rust support library that implements request and response matching logic" From 47754035b39cabdd3c7a3221a012063f35059f6c Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Tue, 16 Jul 2024 10:08:22 +1000 Subject: [PATCH 06/17] fix(ffi): shared processing of body The logic of processing the body within the `pactffi_with_body` was not consistent across the various interaction types. This refactors the logic out into a separate `process_body` function. Note that as a result of this change, the behaviour of the FFI _may_ change. Signed-off-by: JP-Ellis --- rust/pact_ffi/src/mock_server/handles.rs | 404 +++++++++++++---------- 1 file changed, 237 insertions(+), 167 deletions(-) diff --git a/rust/pact_ffi/src/mock_server/handles.rs b/rust/pact_ffi/src/mock_server/handles.rs index 4c27c1d9..0106620e 100644 --- a/rust/pact_ffi/src/mock_server/handles.rs +++ b/rust/pact_ffi/src/mock_server/handles.rs @@ -119,7 +119,7 @@ use libc::{c_char, c_int, c_uint, c_ushort, EXIT_FAILURE, EXIT_SUCCESS, size_t}; use maplit::*; use pact_models::{Consumer, PactSpecification, Provider}; use pact_models::bodies::OptionalBody; -use pact_models::content_types::{ContentType, detect_content_type_from_string, JSON, TEXT, XML}; +use pact_models::content_types::{detect_content_type_from_string, ContentType, TEXT}; use pact_models::generators::{generators_from_json, Generator, Generators}; use pact_models::headers::parse_header; use pact_models::http_parts::HttpPart; @@ -1650,183 +1650,253 @@ pub extern fn pactffi_response_status_v2(interaction: InteractionHandle, status: }).unwrap_or(false) } -/// Adds the body for the interaction. Returns false if the interaction or Pact can't be -/// modified (i.e. the mock server for it has already started) +/// Process the body, including generators and matching rules. /// -/// * `part` - The part of the interaction to add the body to (Request or Response). -/// * `content_type` - The content type of the body. Defaults to `text/plain`. Will be ignored if a content type -/// header is already set. -/// * `body` - The body contents. For JSON payloads, matching rules can be embedded in the body. See -/// [IntegrationJson.md](https://github.com/pact-foundation/pact-reference/blob/master/rust/pact_ffi/IntegrationJson.md) +/// As the body may contain embedded generators and matching rules, we must use +/// `process_json` and `process_xml` to ensure they are processed correctly and +/// added to the `generators` and `matching_rules`. /// -/// For HTTP and async message interactions, this will overwrite the body. With asynchronous messages, the -/// part parameter will be ignored. With synchronous messages, the request contents will be overwritten, -/// while a new response will be appended to the message. +/// The content type is obtained from a number of sources, in the following +/// order: +/// +/// - The `content_type` parameter, if provided; or, +/// - The `content_type_hint` parameter, if provided (e.g. from the +/// `Content-Type` header); or, +/// - From the body itself; or, +/// - Defaults to `text/plain` as a last resort. +fn process_body( + body: &str, + content_type: &Option, + content_type_hint: &Option, + matching_rules: &mut MatchingRules, + generators: &mut Generators, +) -> OptionalBody { + trace!( + ">>> process_body({:?}, {:?}, {:?}, {:?}, {:?})", + body, + content_type, + content_type_hint, + matching_rules, + generators + ); + let detected_type = detect_content_type_from_string(body); + let content_type = content_type + .clone() + .or_else(|| content_type_hint.clone()) + .or_else(|| detected_type.clone()) + .or_else(|| Some(TEXT.clone())); + trace!( + "Detected content type: {:?}; Resulting content type: {:?}", + detected_type, + content_type + ); + + match content_type { + Some(ct) if ct.is_json() => { + trace!("Processing JSON body"); + // As the JSON body may contain embedded generators and matching + // rules, we must use `process_json` to ensure they are processed + // correctly and added to the `generators` and `matching_rules`. + let category = matching_rules.add_category("body"); + OptionalBody::Present( + Bytes::from(process_json(body.to_string(), category, generators)), + Some(ct), + None, + ) + } + Some(ct) if ct.is_xml() => { + // The XML payload may contain one of two cases: + // 1. A raw XML payload + // 2. A JSON payload describing the XML payload, including any + // embedded generators and matching rules. + match detected_type { + Some(detected_ct) if detected_ct.is_json() => { + trace!("Processing JSON description for XML body"); + let category = matching_rules.add_category("body"); + OptionalBody::Present( + Bytes::from( + process_xml(body.to_string(), category, generators).unwrap_or_default(), + ), + Some(ct), // Note to use the provided content type, not the detected one + None, + ) + } + _ => { + trace!("Raw XML body left as is"); + OptionalBody::from(body) + } + } + } + _ => { + // We either have no content type, or an unsupported content type. + trace!("Raw body"); + OptionalBody::from(body) + } + } +} + +/// Adds the body for the interaction. Returns false if the interaction or Pact +/// can't be modified (i.e. the mock server for it has already started) +/// +/// * `part` - The part of the interaction to add the body to (Request or +/// Response). This is ignored for asynchronous message interactions. +/// * `content_type` - The content type of the body, or `NULL` to use the +/// internal logic. +/// * `body` - The body contents. For JSON payloads, matching rules can be +/// embedded in the body. See +/// [IntegrationJson.md](https://github.com/pact-foundation/pact-reference/blob/master/rust/pact_ffi/IntegrationJson.md) +/// +/// If the `content_type` is determined as follows, whichever is first: +/// +/// - The `content_type` argument to this function +/// - The `Content-Type` header for HTTP interaction, or `contentType` metadata +/// entry for message interactions. +/// - From automatic detection of the body contents. +/// - Defaults to `text/plain` as a last resort. +/// +/// Furthermore, the `Content-Type` header or `contentType` metadata entry will +/// be updated with the above determined content type, _unless_ it is already +/// set. +/// +/// This function will overwrite the body contents if they exist, with the +/// exception of the response part of synchronous message interactions, where a +/// new response will be appended. /// /// # Safety /// -/// The interaction contents and content type must either be NULL pointers, or point to valid -/// UTF-8 encoded NULL-terminated strings. Otherwise, behaviour is undefined. +/// The interaction contents and content type must either be NULL pointers, or +/// point to valid UTF-8 encoded NULL-terminated strings. Otherwise, behaviour +/// is undefined. /// /// # Error Handling /// -/// If the contents is a NULL pointer, it will set the body contents as null. If the content -/// type is a null pointer, or can't be parsed, it will set the content type as TEXT. -/// Returns false if the interaction or Pact can't be modified (i.e. the mock server for it has -/// already started) or an error has occurred. +/// If the contents is a NULL pointer, it will set the body contents as null. If +/// the content type is a null pointer, or can't be parsed, it will set the +/// content type as TEXT. Returns false if the interaction or Pact can't be +/// modified (i.e. the mock server for it has already started) or an error has +/// occurred. #[no_mangle] -pub extern fn pactffi_with_body( - interaction: InteractionHandle, - part: InteractionPart, - content_type: *const c_char, - body: *const c_char +pub extern "C" fn pactffi_with_body( + interaction: InteractionHandle, + part: InteractionPart, + content_type: *const c_char, + body: *const c_char, ) -> bool { - trace!(">>> pactffi_with_body({:?}, {:?}, {:?}, {:?})", interaction, part, content_type, body); - let content_type = convert_cstr("content_type", content_type).unwrap_or("text/plain"); - let body = convert_cstr("body", body).unwrap_or_default(); - let content_type_header = "Content-Type".to_string(); - - interaction.with_interaction(&|_, mock_server_started, inner| { - if let Some(reqres) = inner.as_v4_http_mut() { - match part { - InteractionPart::Request => { - trace!("Setting up the request body"); - if !reqres.request.has_header(&content_type_header) { - match reqres.request.headers { - Some(ref mut headers) => { - headers.insert(content_type_header.clone(), vec![content_type.to_string()]); - }, - None => { - reqres.request.headers = Some(hashmap! { content_type_header.clone() => vec![ content_type.to_string() ]}); - } - } - } - let body = if reqres.request.content_type().unwrap_or_default().is_json() { - let category = reqres.request.matching_rules.add_category("body"); - OptionalBody::Present(Bytes::from(process_json(body.to_string(), category, &mut reqres.request.generators)), - Some(ContentType::parse(content_type).unwrap()), None) - } else if reqres.request.content_type().unwrap_or_default().is_xml() { - // Try detect the intermediate JSON format - trace!("Content type is XML, try sniff the provided body format"); - if let Some(ct) = detect_content_type_from_string(body) { - trace!("Detected body body format is {}", ct); - if ct.is_json() { - // Process the intermediate JSON into XML - trace!("Body is in JSON format, processing the intermediate JSON into XML"); - let category = reqres.request.matching_rules.add_category("body"); - OptionalBody::Present(Bytes::from(process_xml(body.to_string(), category, &mut reqres.request.generators).unwrap_or(vec![])), - Some(XML.clone()), None) - } else { - // Assume raw XML - OptionalBody::from(body) - } - } else { - // Assume raw XML - OptionalBody::from(body) - } - } else { - OptionalBody::from(body) - }; - reqres.request.body = body; - }, - InteractionPart::Response => { - trace!("Setting up the response body"); - if !reqres.response.has_header(&content_type_header) { - match reqres.response.headers { - Some(ref mut headers) => { - headers.insert(content_type_header.clone(), vec![content_type.to_string()]); - }, - None => { - reqres.response.headers = Some(hashmap! { content_type_header.clone() => vec![ content_type.to_string() ]}); - } - } - } - let body = if reqres.response.content_type().unwrap_or_default().is_json() { - let category = reqres.response.matching_rules.add_category("body"); - OptionalBody::Present(Bytes::from(process_json(body.to_string(), category, &mut reqres.response.generators)), - Some(JSON.clone()), None) - } else if reqres.response.content_type().unwrap_or_default().is_xml() { - trace!("Content type is XML, try sniff the provided body format"); - // Try detect the intermediate JSON format - if let Some(ct) = detect_content_type_from_string(body) { - trace!("Detected body body format is {}", ct); - if ct.is_json() { - // Process the intermediate XML into JSON - trace!("Body is in JSON format, processing the intermediate JSON into XML"); - let category = reqres.response.matching_rules.add_category("body"); - OptionalBody::Present(Bytes::from(process_xml(body.to_string(), category, &mut reqres.response.generators).unwrap_or(vec![])), - Some(XML.clone()), None) - } else { - // Assume raw XML - OptionalBody::from(body) - } + trace!( + ">>> pactffi_with_body({:?}, {:?}, {:?}, {:?})", + interaction, + part, + content_type, + body + ); + let content_type = + convert_cstr("content_type", content_type).map(|ct| ContentType::parse(ct).unwrap()); + trace!(?content_type); + let content_type_header = "Content-Type".to_string(); + let body = convert_cstr("body", body).unwrap_or_default(); + + interaction + .with_interaction(&|_, mock_server_started, inner| { + if let Some(http) = inner.as_v4_http_mut() { + match part { + InteractionPart::Request => { + trace!("Processing HTTP request body"); + http.request.body = process_body( + body, + &content_type, + &http.request.content_type(), + &mut http.request.matching_rules, + &mut http.request.generators, + ); + if let Some(ct) = http.request.content_type() { + trace!( + "Setting request content type header to '{}' (if not already set)", + ct + ); + if let Some(headers) = http.request.headers.as_mut() { + headers + .entry(content_type_header.to_string()) + .or_insert_with(|| vec![ct.to_string()]); + } else { + http.request.headers = Some(hashmap! { + content_type_header.clone() => vec![ct.to_string()] + }); + } + } + } + InteractionPart::Response => { + trace!("Processing HTTP response body"); + http.response.body = process_body( + body, + &content_type, + &http.response.content_type(), + &mut http.response.matching_rules, + &mut http.response.generators, + ); + if let Some(ct) = http.response.content_type() { + trace!( + "Setting response content type header to '{}' (if not already set)", + ct + ); + if let Some(headers) = http.response.headers.as_mut() { + headers + .entry(content_type_header.to_string()) + .or_insert_with(|| vec![ct.to_string()]); + } else { + http.response.headers = Some(hashmap! { + content_type_header.clone() => vec![ct.to_string()] + }); + } + } + } + }; + !mock_server_started + } else if let Some(message) = inner.as_v4_async_message_mut() { + trace!("Processing async message body"); + message.contents.contents = process_body( + body, + &content_type, + &None, + &mut message.contents.matching_rules, + &mut message.contents.generators, + ); + if let Some(ct) = message.contents.content_type() { + message + .contents + .metadata + .entry("contentType".to_string()) + .or_insert(json!(ct.to_string())); + } + !mock_server_started + } else if let Some(message) = inner.as_v4_sync_message_mut() { + trace!("Processing sync message body"); + let contents = match part { + InteractionPart::Request => &mut message.request, + InteractionPart::Response => { + message.response.push(MessageContents::default()); + message.response.last_mut().unwrap() + } + }; + contents.contents = process_body( + body, + &content_type, + &None, + &mut contents.matching_rules, + &mut contents.generators, + ); + if let Some(ct) = contents.content_type() { + contents + .metadata + .entry("contentType".to_string()) + .or_insert(json!(ct.to_string())); + } + !mock_server_started } else { - // Assume raw XML - OptionalBody::from(body) + error!("Interaction is an unknown type, is {}", inner.type_of()); + false } - } else { - OptionalBody::from(body) - }; - reqres.response.body = body; - } - }; - !mock_server_started - } else if let Some(message) = inner.as_v4_async_message_mut() { - let ct = ContentType::parse(content_type).unwrap_or_else(|_| TEXT.clone()); - let body = if ct.is_json() { - let category = message.contents.matching_rules.add_category("body"); - OptionalBody::Present(Bytes::from(process_json(body.to_string(), category, &mut message.contents.generators)), - Some(JSON.clone()), None) - } else if ct.is_xml() { - let category = message.contents.matching_rules.add_category("body"); - OptionalBody::Present(Bytes::from(process_xml(body.to_string(), category, &mut message.contents.generators).unwrap_or(vec![])), - Some(XML.clone()), None) - } else { - OptionalBody::from(body) - }; - message.contents.contents = body; - message.contents.metadata.insert("contentType".to_string(), json!(content_type)); - true - } else if let Some(message) = inner.as_v4_sync_message_mut() { - let ct = ContentType::parse(content_type).unwrap_or_else(|_| TEXT.clone()); - match part { - InteractionPart::Request => { - let category = message.request.matching_rules.add_category("body"); - let body = if ct.is_json() { - OptionalBody::Present(Bytes::from(process_json(body.to_string(), category, &mut message.request.generators)), - Some(JSON.clone()), None) - } else if ct.is_xml() { - OptionalBody::Present(Bytes::from(process_xml(body.to_string(), category, &mut message.request.generators).unwrap_or(vec![])), - Some(XML.clone()), None) - } else { - OptionalBody::from(body) - }; - message.request.contents = body; - message.request.metadata.insert("contentType".to_string(), json!(content_type)); - } - InteractionPart::Response => { - let mut response = MessageContents::default(); - let category = response.matching_rules.add_category("body"); - let body = if ct.is_json() { - OptionalBody::Present(Bytes::from(process_json(body.to_string(), category, &mut response.generators)), - Some(JSON.clone()), None) - } else if ct.is_xml() { - OptionalBody::Present(Bytes::from(process_xml(body.to_string(), category, &mut response.generators).unwrap_or(vec![])), - Some(XML.clone()), None) - } else { - OptionalBody::from(body) - }; - response.contents = body; - response.metadata.insert("contentType".to_string(), json!(content_type)); - message.response.push(response); - } - } - true - } else { - error!("Interaction is an unknown type, is {}", inner.type_of()); - false - } - }).unwrap_or(false) + }) + .unwrap_or(false) } /// Adds the body for the interaction. Returns false if the interaction or Pact can't be @@ -3090,7 +3160,7 @@ mod tests { use either::Either; use expectest::prelude::*; use maplit::hashmap; - use pact_models::content_types::JSON; + use pact_models::content_types::{JSON, XML}; use pact_models::{generators, matchingrules, HttpStatus}; use pact_models::matchingrules::{Category, MatchingRule}; use pact_models::path_exp::DocPath; From bb9fc1be7e22d56b413e9ce2b9a2e65b2d74148d Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 17 Jul 2024 14:34:04 +1000 Subject: [PATCH 07/17] chore: Upgrade pact_matching to 1.2.5 --- compatibility-suite/Cargo.toml | 2 +- rust/pact_consumer/Cargo.toml | 2 +- rust/pact_ffi/Cargo.toml | 2 +- rust/pact_verifier/Cargo.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compatibility-suite/Cargo.toml b/compatibility-suite/Cargo.toml index 8a8ed30e..78f79b85 100644 --- a/compatibility-suite/Cargo.toml +++ b/compatibility-suite/Cargo.toml @@ -14,7 +14,7 @@ itertools = "0.12.1" lazy_static = "1.4.0" maplit = "1.0.2" pact_models = { version = "~1.2.2" } -pact_matching = { version = "1.2.4", path = "../rust/pact_matching" } +pact_matching = { version = "1.2.5", path = "../rust/pact_matching" } pact_mock_server = { version = "1.2.8" } pact_verifier = { version = "1.2.2", path = "../rust/pact_verifier" } pact_consumer = { version = "1.2.2", path = "../rust/pact_consumer" } diff --git a/rust/pact_consumer/Cargo.toml b/rust/pact_consumer/Cargo.toml index 7289d076..bfe88d0f 100644 --- a/rust/pact_consumer/Cargo.toml +++ b/rust/pact_consumer/Cargo.toml @@ -30,7 +30,7 @@ futures = "0.3.30" itertools = "0.13.0" lazy_static = "1.4.0" maplit = "1.0.2" -pact_matching = { version = "~1.2.4", path = "../pact_matching", default-features = false } +pact_matching = { version = "~1.2.5", path = "../pact_matching", default-features = false } pact_mock_server = { version = "~1.2.8", default-features = false } pact_models = { version = "~1.2.2", default-features = false } pact-plugin-driver = { version = "~0.7.0", optional = true, default-features = false } diff --git a/rust/pact_ffi/Cargo.toml b/rust/pact_ffi/Cargo.toml index 78f512a5..d4cbcc96 100644 --- a/rust/pact_ffi/Cargo.toml +++ b/rust/pact_ffi/Cargo.toml @@ -30,7 +30,7 @@ log = "0.4.20" maplit = "1.0.2" multipart = { version = "0.18.0", default-features = false, features = ["client", "mock"] } onig = { version = "6.4.0", default-features = false } -pact_matching = { version = "~1.2.4", path = "../pact_matching" } +pact_matching = { version = "~1.2.5", path = "../pact_matching" } pact_mock_server = { version = "~1.2.8" } pact_models = { version = "~1.2.2" } pact-plugin-driver = { version = "~0.7.0" } diff --git a/rust/pact_verifier/Cargo.toml b/rust/pact_verifier/Cargo.toml index fe8114eb..a7537730 100644 --- a/rust/pact_verifier/Cargo.toml +++ b/rust/pact_verifier/Cargo.toml @@ -35,7 +35,7 @@ itertools = "0.13.0" lazy_static = "1.4.0" maplit = "1.0.2" mime = "0.3.17" -pact_matching = { version = "~1.2.4", path = "../pact_matching", default-features = false } +pact_matching = { version = "~1.2.5", path = "../pact_matching", default-features = false } pact_models = { version = "~1.2.2", default-features = false } pact-plugin-driver = { version = "~0.7.0", optional = true, default-features = false } regex = "1.10.4" From 51c6cb05fdbc44f303be31b834bf456f72d1b8c3 Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Wed, 17 Jul 2024 13:14:04 +1000 Subject: [PATCH 08/17] chore(ffi): deprecate `pactffi_with_binary_file` The `pactffi_with_binary_file` is functionally replaced by the combination of `pactffi_with_binary_body` and `pactffi_with_matching_ruless`. These two functions should be preferred over this one. Furthermore, this function's naming (especially when compared to `pactffi_with_binary_body`) which might suggest it merely sets the body by reading a specific binary file. Signed-off-by: JP-Ellis --- rust/pact_ffi/src/mock_server/handles.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rust/pact_ffi/src/mock_server/handles.rs b/rust/pact_ffi/src/mock_server/handles.rs index 0106620e..6f261e23 100644 --- a/rust/pact_ffi/src/mock_server/handles.rs +++ b/rust/pact_ffi/src/mock_server/handles.rs @@ -1996,6 +1996,14 @@ pub extern fn pactffi_with_binary_body( }).unwrap_or(false) } +///
+/// +/// This function is deprecated. Use [`pactffi_with_binary_body`] in order to +/// set the binary body, and use [`pactffi_with_matching_rules`] to set the +/// matching rules to ensure that only the content type is being matched. +/// +///
+/// /// Adds a binary file as the body with the expected content type and example contents. Will use /// a mime type matcher to match the body. Returns false if the interaction or Pact can't be /// modified (i.e. the mock server for it has already started) @@ -2022,6 +2030,7 @@ pub extern fn pactffi_with_binary_body( /// Returns false if the interaction or Pact can't be modified (i.e. the mock server for it has /// already started) or an error has occurred. #[no_mangle] +#[deprecated(note = "Use `pactffi_with_binary_body` and `pactffi_with_matching_rules` instead")] pub extern fn pactffi_with_binary_file( interaction: InteractionHandle, part: InteractionPart, From 3c96c31b07a1fb24f809017bef0ac55f6654fdd1 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 17 Jul 2024 14:54:40 +1000 Subject: [PATCH 09/17] chore: Upgrade pact_mock_server to 1.2.9 --- compatibility-suite/Cargo.toml | 2 +- rust/Cargo.lock | 416 +++------------------------------ rust/pact_consumer/Cargo.toml | 2 +- rust/pact_ffi/Cargo.toml | 2 +- rust/pact_models/Cargo.toml | 2 +- 5 files changed, 38 insertions(+), 386 deletions(-) diff --git a/compatibility-suite/Cargo.toml b/compatibility-suite/Cargo.toml index 78f79b85..21d78e4a 100644 --- a/compatibility-suite/Cargo.toml +++ b/compatibility-suite/Cargo.toml @@ -15,7 +15,7 @@ lazy_static = "1.4.0" maplit = "1.0.2" pact_models = { version = "~1.2.2" } pact_matching = { version = "1.2.5", path = "../rust/pact_matching" } -pact_mock_server = { version = "1.2.8" } +pact_mock_server = { version = "1.2.9" } pact_verifier = { version = "1.2.2", path = "../rust/pact_verifier" } pact_consumer = { version = "1.2.2", path = "../rust/pact_consumer" } pretty_assertions = "1.4.0" diff --git a/rust/Cargo.lock b/rust/Cargo.lock index d77ac63a..b266c7a3 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -215,34 +215,6 @@ dependencies = [ "syn 2.0.71", ] -[[package]] -name = "axum" -version = "0.6.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" -dependencies = [ - "async-trait", - "axum-core 0.3.4", - "bitflags 1.3.2", - "bytes", - "futures-util", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.30", - "itoa", - "matchit", - "memchr", - "mime", - "percent-encoding", - "pin-project-lite", - "rustversion", - "serde", - "sync_wrapper 0.1.2", - "tower", - "tower-layer", - "tower-service", -] - [[package]] name = "axum" version = "0.7.5" @@ -250,7 +222,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" dependencies = [ "async-trait", - "axum-core 0.4.3", + "axum-core", "bytes", "futures-util", "http 1.1.0", @@ -270,23 +242,6 @@ dependencies = [ "tower-service", ] -[[package]] -name = "axum-core" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" -dependencies = [ - "async-trait", - "bytes", - "futures-util", - "http 0.2.12", - "http-body 0.4.6", - "mime", - "rustversion", - "tower-layer", - "tower-service", -] - [[package]] name = "axum-core" version = "0.4.3" @@ -334,12 +289,6 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - [[package]] name = "beef" version = "0.5.2" @@ -566,12 +515,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "constant_time_eq" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" - [[package]] name = "constant_time_eq" version = "0.3.0" @@ -1345,18 +1288,6 @@ dependencies = [ "tower-service", ] -[[package]] -name = "hyper-timeout" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" -dependencies = [ - "hyper 0.14.30", - "pin-project-lite", - "tokio", - "tokio-io-timeout", -] - [[package]] name = "hyper-timeout" version = "0.5.1" @@ -2030,48 +1961,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" -[[package]] -name = "pact-plugin-driver" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dafb1371bf02e0fa25212061d41cc5cbc4ad1116d1e988a86eede5e5bb338931" -dependencies = [ - "anyhow", - "async-trait", - "backtrace", - "bytes", - "chrono", - "flate2", - "futures-util", - "home", - "indicatif", - "itertools 0.12.1", - "lazy_static", - "log", - "maplit", - "md5", - "os_info", - "pact_models", - "prost 0.12.6", - "prost-types 0.12.6", - "regex", - "reqwest 0.12.5", - "semver", - "serde", - "serde_json", - "sha2", - "sysinfo", - "tar", - "tokio", - "toml", - "tonic 0.11.0", - "tonic-build 0.11.0", - "tracing", - "tracing-core", - "uuid", - "zip 0.6.6", -] - [[package]] name = "pact-plugin-driver" version = "0.7.0" @@ -2094,10 +1983,10 @@ dependencies = [ "md5", "os_info", "pact_models", - "prost 0.13.1", - "prost-types 0.13.1", + "prost", + "prost-types", "regex", - "reqwest 0.12.5", + "reqwest", "semver", "serde", "serde_json", @@ -2106,12 +1995,12 @@ dependencies = [ "tar", "tokio", "toml", - "tonic 0.12.0", - "tonic-build 0.12.0", + "tonic", + "tonic-build", "tracing", "tracing-core", "uuid", - "zip 2.1.3", + "zip", ] [[package]] @@ -2127,7 +2016,7 @@ dependencies = [ "itertools 0.13.0", "lazy_static", "maplit", - "pact-plugin-driver 0.7.0", + "pact-plugin-driver", "pact_matching", "pact_mock_server", "pact_models", @@ -2135,7 +2024,7 @@ dependencies = [ "quickcheck", "rand", "regex", - "reqwest 0.12.5", + "reqwest", "serde", "serde_json", "termsize", @@ -2173,7 +2062,7 @@ dependencies = [ "multipart", "onig", "os_info", - "pact-plugin-driver 0.7.0", + "pact-plugin-driver", "pact_matching", "pact_mock_server", "pact_models", @@ -2185,7 +2074,7 @@ dependencies = [ "rand_regex", "regex", "regex-syntax 0.6.29", - "reqwest 0.12.5", + "reqwest", "rstest 0.19.0", "serde", "serde_json", @@ -2230,12 +2119,12 @@ dependencies = [ "nom", "ntest", "onig", - "pact-plugin-driver 0.7.0", + "pact-plugin-driver", "pact_models", "pretty_assertions", "quickcheck", "rand", - "reqwest 0.12.5", + "reqwest", "rstest 0.19.0", "semver", "serde", @@ -2253,19 +2142,19 @@ dependencies = [ [[package]] name = "pact_mock_server" -version = "1.2.8" +version = "1.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c30ce7d0fb6daf3bd3d60ab0781ca618ac76f53354e48967a48b846f05288cf" +checksum = "392cbfdaa5a60b8edc1f53ae2cad06afce6a32a4f1667c53f4f2e342ed765539" dependencies = [ "anyhow", "bytes", "futures", "hyper 0.14.30", "hyper-rustls 0.24.2", - "itertools 0.12.1", + "itertools 0.13.0", "lazy_static", "maplit", - "pact-plugin-driver 0.6.1", + "pact-plugin-driver", "pact_matching", "pact_models", "rustls 0.21.12", @@ -2313,7 +2202,7 @@ dependencies = [ "rand_regex", "regex", "regex-syntax 0.6.29", - "reqwest 0.11.27", + "reqwest", "rstest 0.19.0", "semver", "serde", @@ -2348,14 +2237,14 @@ dependencies = [ "lazy_static", "maplit", "mime", - "pact-plugin-driver 0.7.0", + "pact-plugin-driver", "pact_consumer", "pact_matching", "pact_models", "pretty_assertions", "quickcheck", "regex", - "reqwest 0.12.5", + "reqwest", "serde", "serde_json", "serde_with", @@ -2385,7 +2274,7 @@ dependencies = [ "pact_models", "pact_verifier", "regex", - "reqwest 0.12.5", + "reqwest", "rstest 0.21.0", "serde_json", "strip-ansi-escapes", @@ -2436,29 +2325,6 @@ dependencies = [ "regex", ] -[[package]] -name = "password-hash" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" -dependencies = [ - "base64ct", - "rand_core", - "subtle", -] - -[[package]] -name = "pbkdf2" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" -dependencies = [ - "digest", - "hmac", - "password-hash", - "sha2", -] - [[package]] name = "pbkdf2" version = "0.12.2" @@ -2632,16 +2498,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "prost" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" -dependencies = [ - "bytes", - "prost-derive 0.12.6", -] - [[package]] name = "prost" version = "0.13.1" @@ -2649,28 +2505,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e13db3d3fde688c61e2446b4d843bc27a7e8af269a69440c0308021dc92333cc" dependencies = [ "bytes", - "prost-derive 0.13.1", -] - -[[package]] -name = "prost-build" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" -dependencies = [ - "bytes", - "heck", - "itertools 0.12.1", - "log", - "multimap", - "once_cell", - "petgraph", - "prettyplease", - "prost 0.12.6", - "prost-types 0.12.6", - "regex", - "syn 2.0.71", - "tempfile", + "prost-derive", ] [[package]] @@ -2687,26 +2522,13 @@ dependencies = [ "once_cell", "petgraph", "prettyplease", - "prost 0.13.1", - "prost-types 0.13.1", + "prost", + "prost-types", "regex", "syn 2.0.71", "tempfile", ] -[[package]] -name = "prost-derive" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" -dependencies = [ - "anyhow", - "itertools 0.12.1", - "proc-macro2 1.0.86", - "quote 1.0.36", - "syn 2.0.71", -] - [[package]] name = "prost-derive" version = "0.13.1" @@ -2720,22 +2542,13 @@ dependencies = [ "syn 2.0.71", ] -[[package]] -name = "prost-types" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" -dependencies = [ - "prost 0.12.6", -] - [[package]] name = "prost-types" version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cee5168b05f49d4b0ca581206eb14a7b22fafd963efe729ac48eb03266e25cc2" dependencies = [ - "prost 0.13.1", + "prost", ] [[package]] @@ -2951,47 +2764,6 @@ version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba39f3699c378cd8970968dcbff9c43159ea4cfbd88d43c00b22f2ef10a435d2" -[[package]] -name = "reqwest" -version = "0.11.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62" -dependencies = [ - "base64 0.21.7", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2 0.3.26", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.30", - "hyper-rustls 0.24.2", - "ipnet", - "js-sys", - "log", - "mime", - "once_cell", - "percent-encoding", - "pin-project-lite", - "rustls 0.21.12", - "rustls-native-certs 0.6.3", - "rustls-pemfile 1.0.4", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper 0.1.2", - "system-configuration", - "tokio", - "tokio-rustls 0.24.1", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winreg 0.50.0", -] - [[package]] name = "reqwest" version = "0.12.5" @@ -3035,7 +2807,7 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", - "winreg 0.52.0", + "winreg", ] [[package]] @@ -3635,27 +3407,6 @@ dependencies = [ "windows", ] -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "tar" version = "0.4.41" @@ -3816,16 +3567,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "tokio-io-timeout" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" -dependencies = [ - "pin-project-lite", - "tokio", -] - [[package]] name = "tokio-macros" version = "2.3.0" @@ -3940,33 +3681,6 @@ dependencies = [ "winnow 0.6.13", ] -[[package]] -name = "tonic" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" -dependencies = [ - "async-stream", - "async-trait", - "axum 0.6.20", - "base64 0.21.7", - "bytes", - "h2 0.3.26", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.30", - "hyper-timeout 0.4.1", - "percent-encoding", - "pin-project", - "prost 0.12.6", - "tokio", - "tokio-stream", - "tower", - "tower-layer", - "tower-service", - "tracing", -] - [[package]] name = "tonic" version = "0.12.0" @@ -3975,7 +3689,7 @@ checksum = "f738b6a169a29bca4e39656db89c44a08e09c5b700b896ee9e7459f0652e81dd" dependencies = [ "async-stream", "async-trait", - "axum 0.7.5", + "axum", "base64 0.22.1", "bytes", "h2 0.4.5", @@ -3983,11 +3697,11 @@ dependencies = [ "http-body 1.0.1", "http-body-util", "hyper 1.4.1", - "hyper-timeout 0.5.1", + "hyper-timeout", "hyper-util", "percent-encoding", "pin-project", - "prost 0.13.1", + "prost", "socket2", "tokio", "tokio-stream", @@ -3997,19 +3711,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "tonic-build" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4ef6dd70a610078cb4e338a0f79d06bc759ff1b22d2120c2ff02ae264ba9c2" -dependencies = [ - "prettyplease", - "proc-macro2 1.0.86", - "prost-build 0.12.6", - "quote 1.0.36", - "syn 2.0.71", -] - [[package]] name = "tonic-build" version = "0.12.0" @@ -4018,7 +3719,7 @@ checksum = "690943cc223adcdd67bb597a2e573ead1b88e999ba37528fe8e6356bf44b29b6" dependencies = [ "prettyplease", "proc-macro2 1.0.86", - "prost-build 0.13.1", + "prost-build", "quote 1.0.36", "syn 2.0.71", ] @@ -4626,16 +4327,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "winreg" -version = "0.50.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "winreg" version = "0.52.0" @@ -4689,26 +4380,6 @@ dependencies = [ "syn 2.0.71", ] -[[package]] -name = "zip" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" -dependencies = [ - "aes", - "byteorder", - "bzip2", - "constant_time_eq 0.1.5", - "crc32fast", - "crossbeam-utils", - "flate2", - "hmac", - "pbkdf2 0.11.0", - "sha1", - "time", - "zstd 0.11.2+zstd.1.5.2", -] - [[package]] name = "zip" version = "2.1.3" @@ -4718,7 +4389,7 @@ dependencies = [ "aes", "arbitrary", "bzip2", - "constant_time_eq 0.3.0", + "constant_time_eq", "crc32fast", "crossbeam-utils", "deflate64", @@ -4728,14 +4399,14 @@ dependencies = [ "indexmap 2.2.6", "lzma-rs", "memchr", - "pbkdf2 0.12.2", + "pbkdf2", "rand", "sha1", "thiserror", "time", "zeroize", "zopfli", - "zstd 0.13.2", + "zstd", ] [[package]] @@ -4752,32 +4423,13 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "zstd" -version = "0.11.2+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" -dependencies = [ - "zstd-safe 5.0.2+zstd.1.5.2", -] - [[package]] name = "zstd" version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcf2b778a664581e31e389454a7072dab1647606d44f7feea22cd5abb9c9f3f9" dependencies = [ - "zstd-safe 7.2.0", -] - -[[package]] -name = "zstd-safe" -version = "5.0.2+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" -dependencies = [ - "libc", - "zstd-sys", + "zstd-safe", ] [[package]] diff --git a/rust/pact_consumer/Cargo.toml b/rust/pact_consumer/Cargo.toml index bfe88d0f..86812721 100644 --- a/rust/pact_consumer/Cargo.toml +++ b/rust/pact_consumer/Cargo.toml @@ -31,7 +31,7 @@ itertools = "0.13.0" lazy_static = "1.4.0" maplit = "1.0.2" pact_matching = { version = "~1.2.5", path = "../pact_matching", default-features = false } -pact_mock_server = { version = "~1.2.8", default-features = false } +pact_mock_server = { version = "~1.2.9", default-features = false } pact_models = { version = "~1.2.2", default-features = false } pact-plugin-driver = { version = "~0.7.0", optional = true, default-features = false } regex = "1.10.4" diff --git a/rust/pact_ffi/Cargo.toml b/rust/pact_ffi/Cargo.toml index d4cbcc96..8ac75f14 100644 --- a/rust/pact_ffi/Cargo.toml +++ b/rust/pact_ffi/Cargo.toml @@ -31,7 +31,7 @@ maplit = "1.0.2" multipart = { version = "0.18.0", default-features = false, features = ["client", "mock"] } onig = { version = "6.4.0", default-features = false } pact_matching = { version = "~1.2.5", path = "../pact_matching" } -pact_mock_server = { version = "~1.2.8" } +pact_mock_server = { version = "~1.2.9" } pact_models = { version = "~1.2.2" } pact-plugin-driver = { version = "~0.7.0" } pact_verifier = { version = "~1.2.2", path = "../pact_verifier" } diff --git a/rust/pact_models/Cargo.toml b/rust/pact_models/Cargo.toml index 55fe19a5..c613c41e 100644 --- a/rust/pact_models/Cargo.toml +++ b/rust/pact_models/Cargo.toml @@ -50,7 +50,7 @@ tracing = "0.1.40" # This needs to be the same version across all the libs (i.e. [target.'cfg(not(target_family = "wasm"))'.dependencies] fs2 = "0.4.3" onig = { version = "6.4.0", default-features = false } -reqwest = { version = "0.11.18", default-features = false, features = ["rustls-tls-native-roots", "blocking", "json"] } +reqwest = { version = "0.12.5", default-features = false, features = ["rustls-tls-native-roots", "blocking", "json"] } uuid = { version = "1.3.3", features = ["v4"] } [target.'cfg(target_family = "wasm")'.dependencies] From b3503cb5281b824a84ab0f8396a4c0f89a395efd Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 17 Jul 2024 15:09:15 +1000 Subject: [PATCH 10/17] update changelog for release 1.2.3 --- rust/pact_verifier/CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rust/pact_verifier/CHANGELOG.md b/rust/pact_verifier/CHANGELOG.md index a7342d09..232ce639 100644 --- a/rust/pact_verifier/CHANGELOG.md +++ b/rust/pact_verifier/CHANGELOG.md @@ -1,5 +1,17 @@ To generate the log, run `git log --pretty='* %h - %s (%an, %ad)' TAGNAME..HEAD .` replacing TAGNAME and HEAD as appropriate. +# 1.2.3 - Bugfix Release + +* bb9fc1be - chore: Upgrade pact_matching to 1.2.5 (Ronald Holshausen, Wed Jul 17 14:34:04 2024 +1000) +* fd9ff70a - chore: Upgrade pact_models to 1.2.2 (Ronald Holshausen, Wed Jul 17 11:15:34 2024 +1000) +* e8b62f98 - chore: Upgrade pact-plugin-driver to 0.7.0 (Ronald Holshausen, Wed Jul 17 10:45:34 2024 +1000) +* f03cd0d3 - feat(pact_verifier_cli): Parse consumer version selector JSON when evaluating CLI args so errors are reported earlier (Ronald Holshausen, Wed Jul 10 12:13:11 2024 +1000) +* efa1295a - feat(pact_verifier): Allow provider state generator to fall back to the provider state parameters #441 (Ronald Holshausen, Tue Jul 9 17:27:09 2024 +1000) +* 42e2ba68 - fix(pact_verifier): Take context paths into account when fetching the root HAL resource #420 (Ronald Holshausen, Tue Jul 9 11:37:04 2024 +1000) +* efc54d26 - fix(FFI): update_provider_info was not setting the transport scheme correctly (Ronald Holshausen, Mon Jun 24 11:35:57 2024 +1000) +* 0e2e1b8a - chore: Cleanup compiler deprecation warnings (Ronald Holshausen, Fri Jun 14 11:25:56 2024 +1000) +* 570b1425 - bump version to 1.2.3 (Ronald Holshausen, Fri Jun 14 11:17:36 2024 +1000) + # 1.2.2 - Feature Release * 7f741c7e - chore(pact_verifier): Update dependencies (Ronald Holshausen, Fri Jun 14 10:50:11 2024 +1000) From c8d297f27632755f27d361253cff0679b6314b63 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 17 Jul 2024 15:12:16 +1000 Subject: [PATCH 11/17] bump version to 1.2.4 --- rust/pact_verifier/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/pact_verifier/Cargo.toml b/rust/pact_verifier/Cargo.toml index a7537730..a590d2c1 100644 --- a/rust/pact_verifier/Cargo.toml +++ b/rust/pact_verifier/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pact_verifier" -version = "1.2.3" +version = "1.2.4" authors = ["Ronald Holshausen "] edition = "2021" description = "Pact-Rust support library that implements provider verification functions" From 25fd9c561c32b37b9ab60b5824222d1b38a8bb15 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 17 Jul 2024 15:12:37 +1000 Subject: [PATCH 12/17] chore: Update release script --- rust/pact_verifier/release.groovy | 2 -- 1 file changed, 2 deletions(-) diff --git a/rust/pact_verifier/release.groovy b/rust/pact_verifier/release.groovy index 30429ba1..170897b5 100755 --- a/rust/pact_verifier/release.groovy +++ b/rust/pact_verifier/release.groovy @@ -99,8 +99,6 @@ ask('Publish library to crates.io?: [Y]') { executeOnShell 'cargo publish' } -executeOnShell "cargo build --release" - def nextVer = Version.valueOf(releaseVer).incrementPatchVersion() ask("Bump version to $nextVer?: [Y]") { executeOnShell "sed -i -e 's/^version = \"${releaseVer}\"/version = \"${nextVer}\"/' Cargo.toml" From 4257ed1ef5646f180af54f01186de47ce4d1a1de Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 17 Jul 2024 15:19:58 +1000 Subject: [PATCH 13/17] chore: Upgrade pact_verifier to 1.2.3 --- rust/Cargo.lock | 2 +- rust/pact_ffi/Cargo.toml | 2 +- rust/pact_verifier_cli/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index b266c7a3..26da400a 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -2218,7 +2218,7 @@ dependencies = [ [[package]] name = "pact_verifier" -version = "1.2.3" +version = "1.2.4" dependencies = [ "ansi_term", "anyhow", diff --git a/rust/pact_ffi/Cargo.toml b/rust/pact_ffi/Cargo.toml index 8ac75f14..d49bc51a 100644 --- a/rust/pact_ffi/Cargo.toml +++ b/rust/pact_ffi/Cargo.toml @@ -34,7 +34,7 @@ pact_matching = { version = "~1.2.5", path = "../pact_matching" } pact_mock_server = { version = "~1.2.9" } pact_models = { version = "~1.2.2" } pact-plugin-driver = { version = "~0.7.0" } -pact_verifier = { version = "~1.2.2", path = "../pact_verifier" } +pact_verifier = { version = "~1.2.3", path = "../pact_verifier" } panic-message = "0.3.0" rand = "0.8.5" rand_regex = "0.15.1" diff --git a/rust/pact_verifier_cli/Cargo.toml b/rust/pact_verifier_cli/Cargo.toml index 68c5764f..f6b6d4b7 100644 --- a/rust/pact_verifier_cli/Cargo.toml +++ b/rust/pact_verifier_cli/Cargo.toml @@ -31,7 +31,7 @@ lazy_static = "1.5.0" log = "0.4.20" maplit = "1.0.2" pact_models = { version = "~1.2.2", default-features = false } -pact_verifier = { version = "~1.2.2", path = "../pact_verifier", default-features = false } +pact_verifier = { version = "~1.2.3", path = "../pact_verifier", default-features = false } regex = "1.10.2" reqwest = { version = "0.12.4", default-features = false, features = ["rustls-tls-native-roots", "blocking", "json"] } serde_json = "1.0.108" From 9659c982be34b0c85367881aeec907f2d0cc6520 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 17 Jul 2024 15:20:24 +1000 Subject: [PATCH 14/17] chore(pact_consumer): Update dependencies --- rust/pact_consumer/Cargo.toml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/rust/pact_consumer/Cargo.toml b/rust/pact_consumer/Cargo.toml index 86812721..de830325 100644 --- a/rust/pact_consumer/Cargo.toml +++ b/rust/pact_consumer/Cargo.toml @@ -23,35 +23,35 @@ tls = ["pact_mock_server/tls"] colour = ["dep:yansi"] [dependencies] -anyhow = "1.0.82" -async-trait = "0.1.80" -bytes = "1.6.0" +anyhow = "1.0.86" +async-trait = "0.1.81" +bytes = "1.6.1" futures = "0.3.30" itertools = "0.13.0" -lazy_static = "1.4.0" +lazy_static = "1.5.0" maplit = "1.0.2" pact_matching = { version = "~1.2.5", path = "../pact_matching", default-features = false } pact_mock_server = { version = "~1.2.9", default-features = false } pact_models = { version = "~1.2.2", default-features = false } pact-plugin-driver = { version = "~0.7.0", optional = true, default-features = false } -regex = "1.10.4" -serde_json = "1.0.115" +regex = "1.10.5" +serde_json = "1.0.120" termsize = "0.1.8" -tokio = { version = "1.37.0", features = ["full"] } +tokio = { version = "1.38.0", features = ["full"] } tracing = "0.1.40" tracing-core = "0.1.32" -url = "2.5.0" -uuid = { version = "1.8.0", features = ["v4"] } +url = "2.5.2" +uuid = { version = "1.10.0", features = ["v4"] } yansi = { version = "1.0.1", optional = true } [dev-dependencies] quickcheck = "1.0.3" env_logger = "0.11.3" expectest = "0.12.0" -reqwest = { version = "0.12.3", default-features = false, features = ["rustls-tls-native-roots", "blocking", "json"] } -serde = { version = "^1.0", features = ["derive"] } +reqwest = { version = "0.12.5", default-features = false, features = ["rustls-tls-native-roots", "blocking", "json"] } +serde = { version = "1.0.204", features = ["derive"] } rand = "0.8.5" tokio-test = "0.4.4" -test-log = { version = "0.2.15", features = ["trace"] } +test-log = { version = "0.2.16", features = ["trace"] } tracing-subscriber = { version = "0.3.18", features = ["env-filter", "tracing-log", "fmt"] } pretty_assertions = "1.4.0" From 9d894998d6df3a302c00f56e8a8a4393517acda3 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 17 Jul 2024 15:23:40 +1000 Subject: [PATCH 15/17] update changelog for release 1.2.3 --- rust/pact_consumer/CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/rust/pact_consumer/CHANGELOG.md b/rust/pact_consumer/CHANGELOG.md index efb593e9..4e0d638b 100644 --- a/rust/pact_consumer/CHANGELOG.md +++ b/rust/pact_consumer/CHANGELOG.md @@ -1,5 +1,18 @@ To generate the log, run `git log --pretty='* %h - %s (%an, %ad)' TAGNAME..HEAD .` replacing TAGNAME and HEAD as appropriate. +# 1.2.3 - Maintenance Release + +* 9659c982 - chore(pact_consumer): Update dependencies (Ronald Holshausen, Wed Jul 17 15:20:24 2024 +1000) +* 3c96c31b - chore: Upgrade pact_mock_server to 1.2.9 (Ronald Holshausen, Wed Jul 17 14:54:40 2024 +1000) +* bb9fc1be - chore: Upgrade pact_matching to 1.2.5 (Ronald Holshausen, Wed Jul 17 14:34:04 2024 +1000) +* fd9ff70a - chore: Upgrade pact_models to 1.2.2 (Ronald Holshausen, Wed Jul 17 11:15:34 2024 +1000) +* e8b62f98 - chore: Upgrade pact-plugin-driver to 0.7.0 (Ronald Holshausen, Wed Jul 17 10:45:34 2024 +1000) +* 57c0bc85 - feat(pact_consumer): Improve output of mock server errors with ANSI colour (Ronald Holshausen, Thu Jul 11 10:34:14 2024 +1000) +* dee42806 - fix(pact_consumer): Fix for attempt to subtract with overflow error (Ronald Holshausen, Wed Jul 10 15:45:23 2024 +1000) +* 2e2580f6 - feat(pact_consumer): Improve the mock server error output (Ronald Holshausen, Wed Jul 10 15:23:48 2024 +1000) +* c70c1072 - chore(pact_consumer): Update dependencies (Ronald Holshausen, Fri Jun 14 10:35:55 2024 +1000) +* 55f584bf - bump version to 1.2.3 (Ronald Holshausen, Fri Jun 14 10:30:00 2024 +1000) + # 1.2.2 - Maintenance Release * 29c3b5f0 - chore: Upgrade pact_matching to 1.2.4 (Ronald Holshausen, Fri Jun 14 10:18:26 2024 +1000) From 3665a9215b14cfc3716f2d0c0d62e27507bbe2e3 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 17 Jul 2024 15:25:27 +1000 Subject: [PATCH 16/17] bump version to 1.2.4 --- rust/Cargo.lock | 2 +- rust/pact_consumer/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 26da400a..452aecb3 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -2005,7 +2005,7 @@ dependencies = [ [[package]] name = "pact_consumer" -version = "1.2.3" +version = "1.2.4" dependencies = [ "anyhow", "async-trait", diff --git a/rust/pact_consumer/Cargo.toml b/rust/pact_consumer/Cargo.toml index de830325..0473e92b 100644 --- a/rust/pact_consumer/Cargo.toml +++ b/rust/pact_consumer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pact_consumer" -version = "1.2.3" +version = "1.2.4" authors = ["Ronald Holshausen ", "Eric Kidd "] edition = "2021" description = "Pact-Rust module that provides support for writing consumer pact tests" From 56c953b444fe547f174048e9b0f0fe9b7ab658d9 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 17 Jul 2024 15:28:49 +1000 Subject: [PATCH 17/17] chore: Upgrade pact_consumer to 1.2.3 --- compatibility-suite/Cargo.toml | 4 ++-- rust/pact_verifier/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compatibility-suite/Cargo.toml b/compatibility-suite/Cargo.toml index 21d78e4a..f487bbc9 100644 --- a/compatibility-suite/Cargo.toml +++ b/compatibility-suite/Cargo.toml @@ -16,8 +16,8 @@ maplit = "1.0.2" pact_models = { version = "~1.2.2" } pact_matching = { version = "1.2.5", path = "../rust/pact_matching" } pact_mock_server = { version = "1.2.9" } -pact_verifier = { version = "1.2.2", path = "../rust/pact_verifier" } -pact_consumer = { version = "1.2.2", path = "../rust/pact_consumer" } +pact_verifier = { version = "1.2.3", path = "../rust/pact_verifier" } +pact_consumer = { version = "1.2.3", path = "../rust/pact_consumer" } pretty_assertions = "1.4.0" regex = "1.10.2" reqwest = { version = "0.12.3", default-features = false, features = ["rustls-tls-native-roots", "json"] } diff --git a/rust/pact_verifier/Cargo.toml b/rust/pact_verifier/Cargo.toml index a590d2c1..88236dda 100644 --- a/rust/pact_verifier/Cargo.toml +++ b/rust/pact_verifier/Cargo.toml @@ -57,7 +57,7 @@ crate-type = ["cdylib", "rlib"] quickcheck = "1.0.3" expectest = "0.12.0" env_logger = "0.11.3" -pact_consumer = { version = "~1.2.2", path = "../pact_consumer" } +pact_consumer = { version = "~1.2.3", path = "../pact_consumer" } test-log = { version = "0.2.15", features = ["trace"] } tracing-subscriber = { version = "0.3.18", features = ["env-filter", "tracing-log", "fmt"] } chrono = "0.4.38"