From 77814aef9498d029616ac9bbd2f42dce54fe7902 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 31 Jul 2024 15:08:00 +1000 Subject: [PATCH 01/53] fix(pact_models): fix: when writing pact specs in V2 format, header matchers must be pluralised #449 --- rust/pact_models/src/matchingrules/mod.rs | 44 ++++++++++++++++++----- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/rust/pact_models/src/matchingrules/mod.rs b/rust/pact_models/src/matchingrules/mod.rs index e8d48a1f8..18bd1ec23 100644 --- a/rust/pact_models/src/matchingrules/mod.rs +++ b/rust/pact_models/src/matchingrules/mod.rs @@ -699,6 +699,15 @@ pub enum Category { METADATA } +impl Category { + pub(crate) fn v2_form(&self) -> String { + match self { + Category::HEADER => "headers".to_string(), + _ => self.to_string() + } + } +} + impl FromStr for Category { type Err = String; @@ -880,12 +889,12 @@ impl MatchingRuleCategory { } Category::HEADER | Category::QUERY => for (k, v) in &self.rules { let mut path = DocPath::root(); - path.push_field(self.name.to_string()); + path.push_field(self.name.v2_form()); path.push_path(k); map.insert(path.to_string(), v.to_v2_json()); } _ => for (k, v) in &self.rules { - map.insert(format!("$.{}.{}", self.name, k), v.to_v2_json()); + map.insert(format!("$.{}.{}", self.name.v2_form(), k), v.to_v2_json()); } }; @@ -1749,15 +1758,32 @@ mod tests { })); } + #[test] + fn loads_v2_header_matching_rules_with_correct_pluralisation() { + let matching_rules_json = Value::from_str(r#"{"matchingRules": { + "$.headers.HEADERY": {"match": "include", "value": "ValueA"} + }}"#).unwrap(); + + let matching_rules = matchers_from_json(&matching_rules_json, &None).unwrap(); + + expect!(matching_rules.rules.iter()).to_not(be_empty()); + expect!(matching_rules.categories()).to(be_equal_to(hashset!{ Category::HEADER })); + expect!(matching_rules.rules_for_category("header")).to(be_some().value(MatchingRuleCategory { + name: "header".into(), + rules: hashmap!{ DocPath::new_unwrap("HEADERY") => RuleList { rules: vec![ + MatchingRule::Include("ValueA".to_string()) ], rule_logic: RuleLogic::And, cascaded: false } } + })); + } + #[test] fn load_from_v2_map_supports_headers_and_query_parameters_in_encoded_format() { let matching_rules_json = json!({ "$.query.Q1": { "match": "regex", "regex": "1" }, "$.query.x-test": { "match": "regex", "regex": "2" }, "$.query['x-test-2']": { "match": "regex", "regex": "3" }, - "$.header.HEADERY": { "match": "regex", "regex": "4" }, - "$.header.x-test": { "match": "regex", "regex": "5" }, - "$.header['x-test-2']": { "match": "regex", "regex": "6" } + "$.headers.HEADERY": { "match": "regex", "regex": "4" }, + "$.headers.x-test": { "match": "regex", "regex": "5" }, + "$.headers['x-test-2']": { "match": "regex", "regex": "6" } }); let matching_rules_map = matching_rules_json.as_object().unwrap(); @@ -1903,8 +1929,8 @@ mod tests { it "generates V2 matcher format" { pretty_assertions::assert_eq!(matchers.to_v2_json().to_string(), "{\"$.body.a.b\":{\"match\":\"type\"},\ - \"$.header.item1\":{\"match\":\"regex\",\"regex\":\"5\"},\ - \"$.header['principal_identifier[account_id]']\":{\"match\":\"regex\",\"regex\":\"\\\\w+\"},\ + \"$.headers.item1\":{\"match\":\"regex\",\"regex\":\"5\"},\ + \"$.headers['principal_identifier[account_id]']\":{\"match\":\"regex\",\"regex\":\"\\\\w+\"},\ \"$.path\":{\"match\":\"regex\",\"regex\":\"/path/\\\\d+\"},\ \"$.query.a\":{\"match\":\"regex\",\"regex\":\"\\\\w+\"},\ \"$.query['principal_identifier[account_id]']\":{\"match\":\"regex\",\"regex\":\"\\\\w+\"}\ @@ -2390,10 +2416,10 @@ mod tests { let json = matchers_to_json(&matching_rules, &PactSpecification::V2); assert_eq!(json, json!({ - "$.header.A": { + "$.headers.A": { "match": "type" }, - "$.header['se-token']": { + "$.headers['se-token']": { "match": "type" }, "$.query.A": { From 2ca9a9ae1330a5811c7165e404a5723984cdc0ee Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Thu, 1 Aug 2024 16:07:31 +1000 Subject: [PATCH 02/53] chore(pact_models): Improve the matching rule expression parser error messages --- .../src/matchingrules/expressions.rs | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/rust/pact_models/src/matchingrules/expressions.rs b/rust/pact_models/src/matchingrules/expressions.rs index df0092429..15f0fffa5 100644 --- a/rust/pact_models/src/matchingrules/expressions.rs +++ b/rust/pact_models/src/matchingrules/expressions.rs @@ -117,7 +117,7 @@ use bytes::{BufMut, BytesMut}; use itertools::Either; use logos::{Lexer, Logos, Span}; use semver::Version; -use tracing::{trace, warn}; +use tracing::{instrument, trace, warn}; use crate::generators::Generator; use crate::matchingrules::MatchingRule; @@ -288,6 +288,7 @@ enum MatcherDefinitionToken { /// * `matching(type,'Name')` - type matcher /// * `matching(number,100)` - number matcher /// * `matching(datetime, 'yyyy-MM-dd','2000-01-01')` - datetime matcher with format string +#[instrument(level = "debug", ret)] pub fn parse_matcher_def(v: &str) -> anyhow::Result { if v.is_empty() { Err(anyhow!("Expected a matching rule definition, but got an empty string")) @@ -517,10 +518,10 @@ fn parse_each_key(lex: &mut Lexer, v: &str) -> anyhow::R // LEFT_BRACKET primitiveValue RIGHT_BRACKET fn parse_not_empty(lex: &mut Lexer, v: &str) -> anyhow::Result<(String, ValueType)> { - let next = lex.next().ok_or_else(|| anyhow!("expected '('"))?; + let next = lex.next().ok_or_else(|| end_of_expression(v, "'('"))?; if let Ok(MatcherDefinitionToken::LeftBracket) = next { let result = parse_primitive_value(lex, v)?; - let next = lex.next().ok_or_else(|| anyhow!("expected ')'"))?; + let next = lex.next().ok_or_else(|| end_of_expression(v, "')'"))?; if let Ok(MatcherDefinitionToken::RightBracket) = next { Ok(result) } else { @@ -533,17 +534,17 @@ fn parse_not_empty(lex: &mut Lexer, v: &str) -> anyhow:: // LEFT_BRACKET matchingRule RIGHT_BRACKET fn parse_matching(lex: &mut Lexer, v: &str) -> anyhow::Result<(String, ValueType, Option, Option, Option)> { - let next = lex.next().ok_or_else(|| anyhow!("expected '('"))?; + let next = lex.next().ok_or_else(|| end_of_expression(v, "'('"))?; if let Ok(MatcherDefinitionToken::LeftBracket) = next { let result = parse_matching_rule(lex, v)?; - let next = lex.next().ok_or_else(|| anyhow!("expected ')'"))?; + let next = lex.next().ok_or_else(|| end_of_expression(v, "')'"))?; if let Ok(MatcherDefinitionToken::RightBracket) = next { Ok(result) } else { - Err(anyhow!("expected closing bracket, got '{}'", lex.slice())) + Err(anyhow!(error_message(lex, v, "Expected a closing bracket", "Expected a closing bracket before this")?)) } } else { - Err(anyhow!("expected '(', got '{}'", lex.remainder())) + Err(anyhow!(error_message(lex, v, "Expected an opening bracket", "Expected an opening bracket before this")?)) } } @@ -721,8 +722,8 @@ fn parse_content_type(lex: &mut Lexer, v: &str) -> anyho // } // | 'null' // ; -fn parse_primitive_value(lex: &mut Lexer, _v: &str) -> anyhow::Result<(String, ValueType)> { - let next = lex.next().ok_or_else(|| anyhow!("expected a primitive value"))?; +fn parse_primitive_value(lex: &mut Lexer, v: &str) -> anyhow::Result<(String, ValueType)> { + let next = lex.next().ok_or_else(|| end_of_expression(v, "expected a primitive value"))?; match next { Ok(MatcherDefinitionToken::String) => Ok((lex.slice().trim_matches('\'').to_string(), ValueType::String)), Ok(MatcherDefinitionToken::Null) => Ok((String::new(), ValueType::String)), @@ -731,7 +732,7 @@ fn parse_primitive_value(lex: &mut Lexer, _v: &str) -> a // remaining pattern if it is a decimal if lex.remainder().starts_with('.') { let int_part = lex.slice(); - let _ = lex.next().ok_or_else(|| anyhow!("expected a number"))?; + let _ = lex.next().ok_or_else(|| end_of_expression(v, "expected a number"))?; Ok((format!("{}{}", int_part, lex.slice()), ValueType::Decimal)) } else { Ok((lex.slice().to_string(), ValueType::Integer)) @@ -742,7 +743,7 @@ fn parse_primitive_value(lex: &mut Lexer, _v: &str) -> a // remaining pattern if it is a decimal if lex.remainder().starts_with('.') { let int_part = lex.slice(); - let _ = lex.next().ok_or_else(|| anyhow!("expected a number"))?; + let _ = lex.next().ok_or_else(|| end_of_expression(v, "expected a number"))?; Ok((format!("{}{}", int_part, lex.slice()), ValueType::Decimal)) } else { Ok((lex.slice().to_string(), ValueType::Integer)) @@ -750,7 +751,7 @@ fn parse_primitive_value(lex: &mut Lexer, _v: &str) -> a }, Ok(MatcherDefinitionToken::Decimal) => Ok((lex.slice().to_string(), ValueType::Decimal)), Ok(MatcherDefinitionToken::Boolean) => Ok((lex.slice().to_string(), ValueType::Boolean)), - _ => Err(anyhow!("expected a primitive value, got '{}'", lex.slice())) + _ => Err(anyhow!(error_message(lex, v, "Expected a primitive value", "Expected a primitive value here")?)) } } @@ -758,7 +759,7 @@ fn parse_primitive_value(lex: &mut Lexer, _v: &str) -> a #[allow(clippy::if_same_then_else)] fn parse_number(lex: &mut Lexer, v: &str) -> anyhow::Result<(String, ValueType, Option, Option, Option)> { parse_comma(lex, v)?; - let next = lex.next().ok_or_else(|| anyhow!("expected a number"))?; + let next = lex.next().ok_or_else(|| end_of_expression(v, "expected a number"))?; if let Ok(MatcherDefinitionToken::Decimal) = next { Ok((lex.slice().to_string(), ValueType::Number, Some(MatchingRule::Number), None, None)) } else if let Ok(MatcherDefinitionToken::Int(_) | MatcherDefinitionToken::Num(_)) = next { @@ -766,24 +767,24 @@ fn parse_number(lex: &mut Lexer, v: &str) -> anyhow::Res // remaining pattern if it is a decimal if lex.remainder().starts_with('.') { let int_part = lex.slice(); - let _ = lex.next().ok_or_else(|| anyhow!("expected a number"))?; + let _ = lex.next().ok_or_else(|| end_of_expression(v, "expected a number"))?; Ok((format!("{}{}", int_part, lex.slice()), ValueType::Number, Some(MatchingRule::Number), None, None)) } else { Ok((lex.slice().to_string(), ValueType::Number, Some(MatchingRule::Number), None, None)) } } else { - Err(anyhow!("expected a number, got '{}'", lex.slice())) + Err(anyhow!(error_message(lex, v, "Expected a number", "Expected a number here")?)) } } // COMMA val=INTEGER_LITERAL { $value = $val.getText(); $type = ValueType.Integer; } fn parse_integer(lex: &mut Lexer, v: &str) -> anyhow::Result<(String, ValueType, Option, Option, Option)> { parse_comma(lex, v)?; - let next = lex.next().ok_or_else(|| anyhow!("expected an integer"))?; + let next = lex.next().ok_or_else(|| end_of_expression(v, "expected an integer"))?; if let Ok(MatcherDefinitionToken::Int(_) | MatcherDefinitionToken::Num(_)) = next { Ok((lex.slice().to_string(), ValueType::Integer, Some(MatchingRule::Integer), None, None)) } else { - Err(anyhow!("expected an integer, got '{}'", lex.slice())) + Err(anyhow!(error_message(lex, v, "Expected an integer", "Expected an integer here")?)) } } @@ -791,13 +792,13 @@ fn parse_integer(lex: &mut Lexer, v: &str) -> anyhow::Re #[allow(clippy::if_same_then_else)] fn parse_decimal(lex: &mut Lexer, v: &str) -> anyhow::Result<(String, ValueType, Option, Option, Option)> { parse_comma(lex, v)?; - let next = lex.next().ok_or_else(|| anyhow!("expected a decimal number"))?; + let next = lex.next().ok_or_else(|| end_of_expression(v, "expected a decimal number"))?; if let Ok(MatcherDefinitionToken::Int(_) | MatcherDefinitionToken::Num(_)) = next { // Logos is returning an INT token when a Decimal should match. We need to now parse the // remaining pattern if it is a decimal if lex.remainder().starts_with('.') { let int_part = lex.slice(); - let _ = lex.next().ok_or_else(|| anyhow!("expected a number"))?; + let _ = lex.next().ok_or_else(|| end_of_expression(v, "expected a number"))?; Ok((format!("{}{}", int_part, lex.slice()), ValueType::Decimal, Some(MatchingRule::Decimal), None, None)) } else { Ok((lex.slice().to_string(), ValueType::Decimal, Some(MatchingRule::Decimal), None, None)) @@ -805,18 +806,18 @@ fn parse_decimal(lex: &mut Lexer, v: &str) -> anyhow::Re } else if let Ok(MatcherDefinitionToken::Decimal) = next { Ok((lex.slice().to_string(), ValueType::Decimal, Some(MatchingRule::Decimal), None, None)) } else { - Err(anyhow!("expected a decimal number, got '{}'", lex.slice())) + Err(anyhow!(error_message(lex, v, "Expected a decimal number", "Expected a decimal number here")?)) } } // COMMA BOOLEAN_LITERAL { $rule = BooleanMatcher.INSTANCE; $value = $BOOLEAN_LITERAL.getText(); $type = ValueType.Boolean; } fn parse_boolean(lex: &mut Lexer, v: &str) -> anyhow::Result<(String, ValueType, Option, Option, Option)> { parse_comma(lex, v)?; - let next = lex.next().ok_or_else(|| anyhow!("expected a boolean"))?; + let next = lex.next().ok_or_else(|| end_of_expression(v, "expected a boolean"))?; if let Ok(MatcherDefinitionToken::Boolean) = next { Ok((lex.slice().to_string(), ValueType::Boolean, Some(MatchingRule::Boolean), None, None)) } else { - Err(anyhow!("expected a boolean, got '{}'", lex.slice())) + Err(anyhow!(error_message(lex, v, "Expected a boolean", "Expected a boolean here")?)) } } From 033a50ab2cba937ab69567b68a42fdf17703f556 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Fri, 2 Aug 2024 10:06:52 +1000 Subject: [PATCH 03/53] feat: Update the matching rule expression parser to support values from provider states --- rust/pact_ffi/src/models/expressions.rs | 4 +- .../src/matchingrules/expressions.rs | 180 ++++++++++++++---- 2 files changed, 147 insertions(+), 37 deletions(-) diff --git a/rust/pact_ffi/src/models/expressions.rs b/rust/pact_ffi/src/models/expressions.rs index dd4b245bb..7b2be195b 100644 --- a/rust/pact_ffi/src/models/expressions.rs +++ b/rust/pact_ffi/src/models/expressions.rs @@ -635,7 +635,7 @@ mod tests { let error = pactffi_matcher_definition_error(result); let string = unsafe { CString::from_raw(error as *mut c_char) }; - expect!(string.to_string_lossy()).to(be_equal_to("expected a primitive value")); + expect!(string.to_string_lossy().contains("expected a primitive value")).to(be_true()); let value = pactffi_matcher_definition_value(result); expect!(value.is_null()).to(be_true()); @@ -647,7 +647,7 @@ mod tests { expect!(value_type).to(be_equal_to(ExpressionValueType::Unknown)); let definition = unsafe { Box::from_raw(result as *mut MatchingRuleDefinitionResult) }; - expect!(definition.result.left()).to(be_some().value("expected a primitive value")); + expect!(definition.result.left().unwrap().contains("expected a primitive value")).to(be_true()); } #[test_log::test] diff --git a/rust/pact_models/src/matchingrules/expressions.rs b/rust/pact_models/src/matchingrules/expressions.rs index 15f0fffa5..80f39cc66 100644 --- a/rust/pact_models/src/matchingrules/expressions.rs +++ b/rust/pact_models/src/matchingrules/expressions.rs @@ -119,7 +119,9 @@ use logos::{Lexer, Logos, Span}; use semver::Version; use tracing::{instrument, trace, warn}; +use crate::expression_parser::DataType; use crate::generators::Generator; +use crate::generators::Generator::ProviderStateGenerator; use crate::matchingrules::MatchingRule; use crate::matchingrules::MatchingRule::{MaxType, MinType, NotEmpty}; @@ -169,6 +171,19 @@ impl ValueType { } } +impl Into for ValueType { + fn into(self) -> DataType { + match self { + ValueType::Unknown => DataType::RAW, + ValueType::String => DataType::STRING, + ValueType::Number => DataType::DECIMAL, + ValueType::Integer => DataType::INTEGER, + ValueType::Decimal => DataType::DECIMAL, + ValueType::Boolean => DataType::BOOLEAN + } + } +} + /// Reference to another attribute that defines the structure of the matching rule #[derive(Clone, Debug, PartialEq, Eq)] pub struct MatchingReference { @@ -371,12 +386,12 @@ fn matching_definition_exp(lex: &mut Lexer, v: &str) -> }) } } else if token == &MatcherDefinitionToken::NotEmpty { - let (value, value_type) = parse_not_empty(lex, v)?; + let (value, value_type, generator) = parse_not_empty(lex, v)?; Ok(MatchingRuleDefinition { value, value_type, rules: vec![Either::Left(NotEmpty)], - generator: None + generator }) } else if token == &MatcherDefinitionToken::EachKey { let definition = parse_each_key(lex, v)?; @@ -517,10 +532,13 @@ fn parse_each_key(lex: &mut Lexer, v: &str) -> anyhow::R } // LEFT_BRACKET primitiveValue RIGHT_BRACKET -fn parse_not_empty(lex: &mut Lexer, v: &str) -> anyhow::Result<(String, ValueType)> { +fn parse_not_empty( + lex: &mut Lexer, + v: &str +) -> anyhow::Result<(String, ValueType, Option)> { let next = lex.next().ok_or_else(|| end_of_expression(v, "'('"))?; if let Ok(MatcherDefinitionToken::LeftBracket) = next { - let result = parse_primitive_value(lex, v)?; + let result = parse_primitive_value(lex, v, false)?; let next = lex.next().ok_or_else(|| end_of_expression(v, "')'"))?; if let Ok(MatcherDefinitionToken::RightBracket) = next { Ok(result) @@ -644,10 +662,13 @@ fn parse_semver(lex: &mut Lexer, v: &str) -> anyhow::Res } // COMMA v=primitiveValue { $value = $v.value; $type = $v.type; } ) -fn parse_equality(lex: &mut Lexer, v: &str) -> anyhow::Result<(String, ValueType, Option, Option, Option)> { +fn parse_equality( + lex: &mut Lexer, + v: &str +) -> anyhow::Result<(String, ValueType, Option, Option, Option)> { parse_comma(lex, v)?; - let (value, value_type) = parse_primitive_value(lex, v)?; - Ok((value, value_type, Some(MatchingRule::Equality), None, None)) + let (value, value_type, generator) = parse_primitive_value(lex, v, false)?; + Ok((value, value_type, Some(MatchingRule::Equality), generator, None)) } // COMMA r=string COMMA s=string { $rule = new RegexMatcher($r.contents); $value = $s.contents; $type = ValueType.String; } @@ -660,37 +681,64 @@ fn parse_regex(lex: &mut Lexer, v: &str) -> anyhow::Resu } // COMMA v=primitiveValue { $value = $v.value; $type = $v.type; } ) -fn parse_type(lex: &mut Lexer, v: &str) -> anyhow::Result<(String, ValueType, Option, Option, Option)> { +fn parse_type( + lex: &mut Lexer, + v: &str +) -> anyhow::Result<(String, ValueType, Option, Option, Option)> { parse_comma(lex, v)?; - let (value, value_type) = parse_primitive_value(lex, v)?; - Ok((value, value_type, Some(MatchingRule::Type), None, None)) + let (value, value_type, generator) = parse_primitive_value(lex, v, false)?; + Ok((value, value_type, Some(MatchingRule::Type), generator, None)) } -// COMMA format=string COMMA s=string { $value = $s.contents; $type = ValueType.String; } +// COMMA format=string COMMA s=(string | 'fromProviderState' fromProviderState) fn parse_datetime(lex: &mut Lexer, v: &str) -> anyhow::Result<(String, ValueType, Option, Option, Option)> { parse_comma(lex, v)?; let format = parse_string(lex, v)?; parse_comma(lex, v)?; - let value = parse_string(lex, v)?; - Ok((value, ValueType::String, Some(MatchingRule::Timestamp(format.clone())), Some(Generator::DateTime(Some(format), None)), None)) + + let remainder = lex.remainder().trim_start(); + let (value, value_type, generator) = if remainder.starts_with("fromProviderState") { + lex.next(); + from_provider_state(lex, v)? + } else { + (parse_string(lex, v)?, ValueType::String, Some(Generator::DateTime(Some(format.clone()), None))) + }; + + Ok((value, value_type, Some(MatchingRule::Timestamp(format.clone())), generator, None)) } -// COMMA format=string COMMA s=string { $value = $s.contents; $type = ValueType.String; } +// COMMA format=string COMMA s=(string | 'fromProviderState' fromProviderState) fn parse_date(lex: &mut Lexer, v: &str) -> anyhow::Result<(String, ValueType, Option, Option, Option)> { parse_comma(lex, v)?; let format = parse_string(lex, v)?; parse_comma(lex, v)?; - let value = parse_string(lex, v)?; - Ok((value, ValueType::String, Some(MatchingRule::Date(format.clone())), Some(Generator::Date(Some(format), None)), None)) + + let remainder = lex.remainder().trim_start(); + let (value, value_type, generator) = if remainder.starts_with("fromProviderState") { + lex.next(); + from_provider_state(lex, v)? + } else { + (parse_string(lex, v)?, ValueType::String, Some(Generator::Date(Some(format.clone()), None))) + }; + + Ok((value, value_type, Some(MatchingRule::Date(format.clone())), generator, None)) } -// COMMA format=string COMMA s=string { $value = $s.contents; $type = ValueType.String; } +// COMMA format=string COMMA s=(string | 'fromProviderState' fromProviderState) fn parse_time(lex: &mut Lexer, v: &str) -> anyhow::Result<(String, ValueType, Option, Option, Option)> { parse_comma(lex, v)?; let format = parse_string(lex, v)?; parse_comma(lex, v)?; - let value = parse_string(lex, v)?; - Ok((value, ValueType::String, Some(MatchingRule::Time(format.clone())), Some(Generator::Time(Some(format), None)), None)) + + let remainder = lex.remainder().trim_start(); + let (value, value_type, generator) = if remainder.starts_with("fromProviderState") { + lex.next(); + from_provider_state(lex, v)? + } else { + (parse_string(lex, v)?, ValueType::String, Some(Generator::Time(Some(format.clone()), None))) + }; + + Ok((value, value_type, Some(MatchingRule::Time(format.clone())), generator, None)) } // COMMA s=string { $rule = new IncludeMatcher($s.contents); $value = $s.contents; $type = ValueType.String; } @@ -714,28 +762,31 @@ fn parse_content_type(lex: &mut Lexer, v: &str) -> anyho // | v=DECIMAL_LITERAL { $value = $v.getText(); $type = ValueType.Decimal; } // | v=INTEGER_LITERAL { $value = $v.getText(); $type = ValueType.Integer; } // | v=BOOLEAN_LITERAL { $value = $v.getText(); $type = ValueType.Boolean; } -// ; -// string returns [ String contents ] : -// STRING_LITERAL { +// | STRING_LITERAL { // String contents = $STRING_LITERAL.getText(); // $contents = contents.substring(1, contents.length() - 1); // } // | 'null' +// | 'fromProviderState' fromProviderState // ; -fn parse_primitive_value(lex: &mut Lexer, v: &str) -> anyhow::Result<(String, ValueType)> { +fn parse_primitive_value( + lex: &mut Lexer, + v: &str, + already_called: bool +) -> anyhow::Result<(String, ValueType, Option)> { let next = lex.next().ok_or_else(|| end_of_expression(v, "expected a primitive value"))?; match next { - Ok(MatcherDefinitionToken::String) => Ok((lex.slice().trim_matches('\'').to_string(), ValueType::String)), - Ok(MatcherDefinitionToken::Null) => Ok((String::new(), ValueType::String)), + Ok(MatcherDefinitionToken::String) => Ok((lex.slice().trim_matches('\'').to_string(), ValueType::String, None)), + Ok(MatcherDefinitionToken::Null) => Ok((String::new(), ValueType::String, None)), Ok(MatcherDefinitionToken::Int(_)) => { // Logos is returning an INT token when a Decimal should match. We need to now parse the // remaining pattern if it is a decimal if lex.remainder().starts_with('.') { let int_part = lex.slice(); let _ = lex.next().ok_or_else(|| end_of_expression(v, "expected a number"))?; - Ok((format!("{}{}", int_part, lex.slice()), ValueType::Decimal)) + Ok((format!("{}{}", int_part, lex.slice()), ValueType::Decimal, None)) } else { - Ok((lex.slice().to_string(), ValueType::Integer)) + Ok((lex.slice().to_string(), ValueType::Integer, None)) } }, Ok(MatcherDefinitionToken::Num(_)) => { @@ -744,18 +795,21 @@ fn parse_primitive_value(lex: &mut Lexer, v: &str) -> an if lex.remainder().starts_with('.') { let int_part = lex.slice(); let _ = lex.next().ok_or_else(|| end_of_expression(v, "expected a number"))?; - Ok((format!("{}{}", int_part, lex.slice()), ValueType::Decimal)) + Ok((format!("{}{}", int_part, lex.slice()), ValueType::Decimal, None)) } else { - Ok((lex.slice().to_string(), ValueType::Integer)) + Ok((lex.slice().to_string(), ValueType::Integer, None)) } }, - Ok(MatcherDefinitionToken::Decimal) => Ok((lex.slice().to_string(), ValueType::Decimal)), - Ok(MatcherDefinitionToken::Boolean) => Ok((lex.slice().to_string(), ValueType::Boolean)), + Ok(MatcherDefinitionToken::Decimal) => Ok((lex.slice().to_string(), ValueType::Decimal, None)), + Ok(MatcherDefinitionToken::Boolean) => Ok((lex.slice().to_string(), ValueType::Boolean, None)), + Ok(MatcherDefinitionToken::Id) if lex.slice() == "fromProviderState" && !already_called => { + from_provider_state(lex, v) + }, _ => Err(anyhow!(error_message(lex, v, "Expected a primitive value", "Expected a primitive value here")?)) } } -// COMMA val=( DECIMAL_LITERAL | INTEGER_LITERAL ) { $value = $val.getText(); $type = ValueType.Number; } +// COMMA val=( DECIMAL_LITERAL | INTEGER_LITERAL | 'fromProviderState' fromProviderState) #[allow(clippy::if_same_then_else)] fn parse_number(lex: &mut Lexer, v: &str) -> anyhow::Result<(String, ValueType, Option, Option, Option)> { parse_comma(lex, v)?; @@ -772,6 +826,13 @@ fn parse_number(lex: &mut Lexer, v: &str) -> anyhow::Res } else { Ok((lex.slice().to_string(), ValueType::Number, Some(MatchingRule::Number), None, None)) } + } else if let Ok(MatcherDefinitionToken::Id) = next { + if lex.slice() == "fromProviderState" { + let (value, value_type, generator) = from_provider_state(lex, v)?; + Ok((value, value_type, Some(MatchingRule::Number), generator, None)) + } else { + Err(anyhow!(error_message(lex, v, "Expected a number", "Expected a number here")?)) + } } else { Err(anyhow!(error_message(lex, v, "Expected a number", "Expected a number here")?)) } @@ -783,6 +844,13 @@ fn parse_integer(lex: &mut Lexer, v: &str) -> anyhow::Re let next = lex.next().ok_or_else(|| end_of_expression(v, "expected an integer"))?; if let Ok(MatcherDefinitionToken::Int(_) | MatcherDefinitionToken::Num(_)) = next { Ok((lex.slice().to_string(), ValueType::Integer, Some(MatchingRule::Integer), None, None)) + } else if let Ok(MatcherDefinitionToken::Id) = next { + if lex.slice() == "fromProviderState" { + let (value, value_type, generator) = from_provider_state(lex, v)?; + Ok((value, value_type, Some(MatchingRule::Integer), generator, None)) + } else { + Err(anyhow!(error_message(lex, v, "Expected an integer", "Expected an integer here")?)) + } } else { Err(anyhow!(error_message(lex, v, "Expected an integer", "Expected an integer here")?)) } @@ -805,6 +873,13 @@ fn parse_decimal(lex: &mut Lexer, v: &str) -> anyhow::Re } } else if let Ok(MatcherDefinitionToken::Decimal) = next { Ok((lex.slice().to_string(), ValueType::Decimal, Some(MatchingRule::Decimal), None, None)) + } else if let Ok(MatcherDefinitionToken::Id) = next { + if lex.slice() == "fromProviderState" { + let (value, value_type, generator) = from_provider_state(lex, v)?; + Ok((value, value_type, Some(MatchingRule::Number), generator, None)) + } else { + Err(anyhow!(error_message(lex, v, "Expected a decimal number", "Expected a decimal number here")?)) + } } else { Err(anyhow!(error_message(lex, v, "Expected a decimal number", "Expected a decimal number here")?)) } @@ -981,6 +1056,24 @@ fn parse_length_param(lex: &mut Lexer, v: &str) -> anyho } } +// '(' exp=STRING_LITERAL COMMA v=primitiveValue ')' +fn from_provider_state(lex: &mut Lexer, v: &str) -> anyhow::Result<(String, ValueType, Option)> { + let next = lex.next().ok_or_else(|| end_of_expression(v, "'('"))?; + if let Ok(MatcherDefinitionToken::LeftBracket) = next { + let expression = parse_string(lex, v)?; + parse_comma(lex, v)?; + let (value, val_type, _) = parse_primitive_value(lex, v, true)?; + let next = lex.next().ok_or_else(|| end_of_expression(v, "')'"))?; + if let Ok(MatcherDefinitionToken::RightBracket) = next { + Ok((value, val_type, Some(ProviderStateGenerator(expression, Some(val_type.into()))))) + } else { + Err(anyhow!(error_message(lex, v, "Expected a closing bracket", "Expected a closing bracket before this")?)) + } + } else { + Err(anyhow!(error_message(lex, v, "Expected an opening bracket", "Expected an opening bracket before this")?)) + } +} + #[cfg(test)] mod test { use expectest::prelude::*; @@ -1007,12 +1100,15 @@ mod test { #[test] fn parse_type_matcher() { - expect!(super::parse_matcher_def("matching(type,'Name')").unwrap()).to( + expect!(parse_matcher_def("matching(type,'Name')").unwrap()).to( be_equal_to(MatchingRuleDefinition::new("Name".to_string(), ValueType::String, MatchingRule::Type, None))); - expect!(super::parse_matcher_def("matching( type, 'Name' )").unwrap()).to( + expect!(parse_matcher_def("matching( type, 'Name' )").unwrap()).to( be_equal_to(MatchingRuleDefinition::new("Name".to_string(), ValueType::String, MatchingRule::Type, None))); - expect!(super::parse_matcher_def("matching(type,123.4)").unwrap()).to( + expect!(parse_matcher_def("matching(type,123.4)").unwrap()).to( be_equal_to(MatchingRuleDefinition::new("123.4".to_string(), ValueType::Decimal, MatchingRule::Type, None))); + expect!(parse_matcher_def("matching(type, fromProviderState('exp', 3))").unwrap()).to( + be_equal_to(MatchingRuleDefinition::new("3".to_string(), ValueType::Integer, MatchingRule::Type, + Some(ProviderStateGenerator("exp".to_string(), Some(DataType::INTEGER)))))); } #[test] @@ -1027,6 +1123,9 @@ mod test { be_equal_to(MatchingRuleDefinition::new("100".to_string(), ValueType::Decimal, MatchingRule::Decimal, None))); expect!(super::parse_matcher_def("matching(decimal,100.22)").unwrap()).to( be_equal_to(MatchingRuleDefinition::new("100.22".to_string(), ValueType::Decimal, MatchingRule::Decimal, None))); + expect!(parse_matcher_def("matching(number, fromProviderState('exp', 3))").unwrap()).to( + be_equal_to(MatchingRuleDefinition::new("3".to_string(), ValueType::Integer, MatchingRule::Number, + Some(ProviderStateGenerator("exp".to_string(), Some(DataType::INTEGER)))))); } #[test] @@ -1046,6 +1145,11 @@ mod test { ValueType::String, MatchingRule::Time("HH:mm:ss".to_string()), Some(Time(Some("HH:mm:ss".to_string()), None))))); + expect!(super::parse_matcher_def("matching(datetime, 'yyyy-MM-dd', fromProviderState('exp', '2000-01-01'))").unwrap()).to( + be_equal_to(MatchingRuleDefinition::new("2000-01-01".to_string(), + ValueType::String, + MatchingRule::Timestamp("yyyy-MM-dd".to_string()), + Some(ProviderStateGenerator("exp".to_string(), Some(DataType::STRING)))))); } #[test] @@ -1087,6 +1191,9 @@ mod test { ValueType::Decimal, MatchingRule::Equality, None))); + expect!(parse_matcher_def("matching(equalTo, fromProviderState('exp', 3))").unwrap()).to( + be_equal_to(MatchingRuleDefinition::new("3".to_string(), ValueType::Integer, MatchingRule::Equality, + Some(ProviderStateGenerator("exp".to_string(), Some(DataType::INTEGER)))))); } #[test] @@ -1110,6 +1217,9 @@ mod test { ValueType::Integer, MatchingRule::NotEmpty, None))); + expect!(parse_matcher_def("notEmpty(fromProviderState('exp', 3))").unwrap()).to( + be_equal_to(MatchingRuleDefinition::new("3".to_string(), ValueType::Integer, MatchingRule::NotEmpty, + Some(ProviderStateGenerator("exp".to_string(), Some(DataType::INTEGER)))))); } #[test] From 4d7295a45183541797b7fa7150df234517a300c0 Mon Sep 17 00:00:00 2001 From: "M. J. W-H. Campman" Date: Sat, 3 Aug 2024 13:49:18 -0400 Subject: [PATCH 04/53] feat: allow non-object matchers for array-contains --- rust/pact_ffi/src/mock_server/bodies.rs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/rust/pact_ffi/src/mock_server/bodies.rs b/rust/pact_ffi/src/mock_server/bodies.rs index 98fd86db2..71f806644 100644 --- a/rust/pact_ffi/src/mock_server/bodies.rs +++ b/rust/pact_ffi/src/mock_server/bodies.rs @@ -8,7 +8,7 @@ use either::Either; use lazy_static::lazy_static; use regex::Regex; use serde_json::{Map, Value}; -use tracing::{debug, error, trace, warn}; +use tracing::{debug, error, trace}; use pact_models::bodies::OptionalBody; use pact_models::content_types::ContentTypeHint; @@ -113,9 +113,11 @@ fn process_matcher( Value::Object(map) => { process_object(map, &mut category, &mut generators, DocPath::root(), false) } + Value::Array(arr) => { + process_array(arr, &mut category, &mut generators, DocPath::root(), false, false) + } _ => { - warn!("arrayContains: JSON for variant {} is not correctly formed: {}", index, variant); - Value::Null + variant.clone() } }; json_values.push(value); @@ -423,16 +425,19 @@ fn format_multipart_error(e: std::io::Error) -> String { #[cfg(test)] mod test { - use expectest::prelude::*; + use std::collections::HashMap; + +use expectest::prelude::*; use maplit::hashmap; - use pretty_assertions::assert_eq; + use pact_models::prelude::Category; +use pretty_assertions::assert_eq; use rstest::rstest; use serde_json::json; use pact_models::{generators, HttpStatus, matchingrules_list}; use pact_models::content_types::ContentType; use pact_models::generators::{Generator, Generators}; - use pact_models::matchingrules::{MatchingRule, MatchingRuleCategory}; + use pact_models::matchingrules::{MatchingRule, MatchingRuleCategory, RuleList}; use pact_models::matchingrules::expressions::{MatchingRuleDefinition, ValueType}; use pact_models::path_exp::DocPath; @@ -860,6 +865,12 @@ mod test { #[case(json!({ "pact:matcher:type": "content-type", "value": "text/plain" }), vec![MatchingRule::ContentType("text/plain".to_string())])] #[case(json!({ "pact:matcher:type": "arrayContains", "variants": [] }), vec![MatchingRule::ArrayContains(vec![])])] #[case(json!({ "pact:matcher:type": "array-contains", "variants": [] }), vec![MatchingRule::ArrayContains(vec![])])] + #[case(json!({ "pact:matcher:type": "array-contains", "variants": ["Thing1", "Thing2"] }), vec![ + MatchingRule::ArrayContains(vec![ + (0, MatchingRuleCategory{name: Category::BODY, rules: HashMap::from([ (DocPath::empty(), RuleList::equality()) ]) }, std::collections::HashMap::default()), + (0, MatchingRuleCategory{name: Category::BODY, rules: HashMap::from([ (DocPath::empty(), RuleList::equality()) ]) }, std::collections::HashMap::default()) + ]) + ])] #[case(json!({ "pact:matcher:type": "values" }), vec![MatchingRule::Values])] #[case(json!({ "pact:matcher:type": "statusCode" }), vec![MatchingRule::StatusCode(HttpStatus::Success)])] #[case(json!({ "pact:matcher:type": "statusCode" }), vec![MatchingRule::StatusCode(HttpStatus::StatusCodes(vec![200]))])] From 9dda5390d7bc9d646f4dd2381c88317ec9ff9644 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 6 Aug 2024 10:53:05 +1000 Subject: [PATCH 05/53] update changelog for release 1.2.3 --- rust/pact_models/CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rust/pact_models/CHANGELOG.md b/rust/pact_models/CHANGELOG.md index 21c12bd84..40a88f658 100644 --- a/rust/pact_models/CHANGELOG.md +++ b/rust/pact_models/CHANGELOG.md @@ -1,5 +1,13 @@ To generate the log, run `git log --pretty='* %h - %s (%an, %ad)' TAGNAME..HEAD .` replacing TAGNAME and HEAD as appropriate. +# 1.2.3 - Support for provider state injected values in plugins + +* 033a50ab - feat: Update the matching rule expression parser to support values from provider states (Ronald Holshausen, Fri Aug 2 10:06:52 2024 +1000) +* 2ca9a9ae - chore(pact_models): Improve the matching rule expression parser error messages (Ronald Holshausen, Thu Aug 1 16:07:31 2024 +1000) +* 77814aef - fix(pact_models): fix: when writing pact specs in V2 format, header matchers must be pluralised #449 (Ronald Holshausen, Wed Jul 31 15:08:00 2024 +1000) +* 3c96c31b - chore: Upgrade pact_mock_server to 1.2.9 (Ronald Holshausen, Wed Jul 17 14:54:40 2024 +1000) +* 57f05775 - bump version to 1.2.3 (Ronald Holshausen, Wed Jul 17 11:10:27 2024 +1000) + # 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) From 42911cfda5b850b752275327a3fe09523a2e8439 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 6 Aug 2024 10:54:23 +1000 Subject: [PATCH 06/53] bump version to 1.2.4 --- rust/Cargo.lock | 210 ++++++++++++++++++++++++------------ rust/pact_models/Cargo.toml | 2 +- 2 files changed, 144 insertions(+), 68 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index d13173066..c68da8d03 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -330,9 +330,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.1" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" dependencies = [ "serde", ] @@ -360,9 +360,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" +checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" dependencies = [ "jobserver", "libc", @@ -471,18 +471,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.11" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35723e6a11662c2afb578bcf0b88bf6ea8e21282a953428f240574fcc3a2b5b3" +checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.11" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49eb96cbfa7cfa35017b7cd548c75b14c3118c98b423041d70562665e07fb0fa" +checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99" dependencies = [ "anstream", "anstyle", @@ -723,9 +723,9 @@ dependencies = [ [[package]] name = "dunce" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "either" @@ -832,9 +832,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920" dependencies = [ "crc32fast", "miniz_oxide", @@ -1023,7 +1023,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.2.6", + "indexmap 2.3.0", "slab", "tokio", "tokio-util", @@ -1042,7 +1042,7 @@ dependencies = [ "futures-core", "futures-sink", "http 1.1.0", - "indexmap 2.2.6", + "indexmap 2.3.0", "slab", "tokio", "tokio-util", @@ -1375,9 +1375,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" dependencies = [ "equivalent", "hashbrown 0.14.5", @@ -1386,9 +1386,27 @@ dependencies = [ [[package]] name = "indextree" -version = "4.6.1" +version = "4.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6f7e29c1619ec492f411b021ac9f30649d5f522ca6f287f2467ee48c8dfe10" +checksum = "c9f0421c6fe77186886dd647787132a907887e9fc3ce508aea6628dbaf9a4fcb" +dependencies = [ + "indextree-macros", +] + +[[package]] +name = "indextree-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1dd5776fe91eb9371383a6db7068fcfe80bd1d6d756aebebb92d80526065676" +dependencies = [ + "either", + "itertools 0.13.0", + "proc-macro2 1.0.86", + "quote 1.0.36", + "strum", + "syn 2.0.72", + "thiserror", +] [[package]] name = "indicatif" @@ -1940,12 +1958,12 @@ dependencies = [ [[package]] name = "os_pipe" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29d73ba8daf8fac13b0501d1abeddcfe21ba7401ada61a819144b6c2a4f32209" +checksum = "5ffd2b0a5634335b135d5728d84c5e0fd726954b87111f7506a61c502280d982" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2184,7 +2202,7 @@ dependencies = [ "pact_models", "rcgen", "rustls 0.23.12", - "rustls-pemfile 2.1.2", + "rustls-pemfile 2.1.3", "rustls-webpki 0.102.6", "serde", "serde_json", @@ -2199,7 +2217,7 @@ dependencies = [ [[package]] name = "pact_models" -version = "1.2.3" +version = "1.2.4" dependencies = [ "anyhow", "ariadne", @@ -2291,7 +2309,7 @@ version = "1.1.4" dependencies = [ "ansi_term", "anyhow", - "clap 4.5.11", + "clap 4.5.13", "env_logger 0.11.5", "expectest", "junit-report", @@ -2391,7 +2409,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.2.6", + "indexmap 2.3.0", ] [[package]] @@ -2484,9 +2502,12 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "pretty_assertions" @@ -2610,9 +2631,9 @@ dependencies = [ [[package]] name = "quinn" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4ceeeeabace7857413798eb1ffa1e9c905a9946a57d81fb69b4b71c4d8eb3ad" +checksum = "b22d8e7369034b9a7132bc2008cac12f2013c8132b45e0554e6e20e2617f2156" dependencies = [ "bytes", "pin-project-lite", @@ -2620,6 +2641,7 @@ dependencies = [ "quinn-udp", "rustc-hash", "rustls 0.23.12", + "socket2", "thiserror", "tokio", "tracing", @@ -2627,9 +2649,9 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.3" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddf517c03a109db8100448a4be38d498df8a210a99fe0e1b9eaf39e78c640efe" +checksum = "ba92fb39ec7ad06ca2582c0ca834dfeadcaf06ddfc8e635c80aa7e1c05315fdd" dependencies = [ "bytes", "rand", @@ -2651,6 +2673,7 @@ dependencies = [ "libc", "once_cell", "socket2", + "tracing", "windows-sys 0.52.0", ] @@ -2765,9 +2788,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.5" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", @@ -2841,7 +2864,7 @@ dependencies = [ "quinn", "rustls 0.23.12", "rustls-native-certs 0.7.1", - "rustls-pemfile 2.1.2", + "rustls-pemfile 2.1.3", "rustls-pki-types", "serde", "serde_json", @@ -2941,9 +2964,9 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" -version = "1.1.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" [[package]] name = "rustc_version" @@ -3013,7 +3036,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a88d6d420651b496bdd98684116959239430022a115c1240e6c3993be0b15fba" dependencies = [ "openssl-probe", - "rustls-pemfile 2.1.2", + "rustls-pemfile 2.1.3", "rustls-pki-types", "schannel", "security-framework", @@ -3030,9 +3053,9 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.2" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" dependencies = [ "base64 0.22.1", "rustls-pki-types", @@ -3162,9 +3185,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.121" +version = "1.0.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609" +checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" dependencies = [ "itoa", "memchr", @@ -3203,7 +3226,7 @@ dependencies = [ "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.2.6", + "indexmap 2.3.0", "serde", "serde_derive", "serde_json", @@ -3382,6 +3405,28 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "strum" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +dependencies = [ + "heck", + "proc-macro2 1.0.86", + "quote 1.0.36", + "rustversion", + "syn 2.0.72", +] + [[package]] name = "subtle" version = "2.6.1" @@ -3471,12 +3516,13 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.10.1" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53" dependencies = [ "cfg-if", "fastrand", + "once_cell", "rustix", "windows-sys 0.52.0", ] @@ -3687,21 +3733,21 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.16" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81967dd0dd2c1ab0bc3468bd7caecc32b8a4aa47d0c8c695d8c2b2108168d62c" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.17", + "toml_edit 0.22.20", ] [[package]] name = "toml_datetime" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8fb9f64314842840f1d940ac544da178732128f1c78c21772e876579e0da1db" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" dependencies = [ "serde", ] @@ -3712,22 +3758,22 @@ version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.3.0", "toml_datetime", "winnow 0.5.40", ] [[package]] name = "toml_edit" -version = "0.22.17" +version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d9f8729f5aea9562aac1cc0441f5d6de3cff1ee0c5d67293eeca5eb36ee7c16" +checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.3.0", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.16", + "winnow 0.6.18", ] [[package]] @@ -3913,7 +3959,7 @@ dependencies = [ "serde", "shlex", "snapbox", - "toml_edit 0.22.17", + "toml_edit 0.22.20", ] [[package]] @@ -4196,11 +4242,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -4246,6 +4292,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -4378,9 +4433,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.16" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b480ae9340fc261e6be3e95a1ba86d54ae3f9171132a73ce8d4bbaf68339507c" +checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" dependencies = [ "memchr", ] @@ -4427,6 +4482,27 @@ dependencies = [ "time", ] +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2 1.0.86", + "quote 1.0.36", + "syn 2.0.72", +] + [[package]] name = "zeroize" version = "1.8.1" @@ -4449,9 +4525,9 @@ dependencies = [ [[package]] name = "zip" -version = "2.1.5" +version = "2.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b895748a3ebcb69b9d38dcfdf21760859a4b0d0b0015277640c2ef4c69640e6f" +checksum = "40dd8c92efc296286ce1fbd16657c5dbefff44f1b4ca01cc5f517d8b7b3d3e2e" dependencies = [ "aes", "arbitrary", @@ -4463,7 +4539,7 @@ dependencies = [ "displaydoc", "flate2", "hmac", - "indexmap 2.2.6", + "indexmap 2.3.0", "lzma-rs", "memchr", "pbkdf2", @@ -4501,18 +4577,18 @@ dependencies = [ [[package]] name = "zstd-safe" -version = "7.2.0" +version = "7.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa556e971e7b568dc775c136fc9de8c779b1c2fc3a63defaafadffdbd3181afa" +checksum = "54a3ab4db68cea366acc5c897c7b4d4d1b8994a9cd6e6f841f8964566a419059" dependencies = [ "zstd-sys", ] [[package]] name = "zstd-sys" -version = "2.0.12+zstd.1.5.6" +version = "2.0.13+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4e40c320c3cb459d9a9ff6de98cff88f4751ee9275d140e2be94a2b74e4c13" +checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" dependencies = [ "cc", "pkg-config", diff --git a/rust/pact_models/Cargo.toml b/rust/pact_models/Cargo.toml index c613c41e4..a661eecf3 100644 --- a/rust/pact_models/Cargo.toml +++ b/rust/pact_models/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pact_models" -version = "1.2.3" +version = "1.2.4" authors = ["Ronald Holshausen "] edition = "2021" description = "Pact-Rust support library that provides the core models for dealing with Pact files" From bcf4db6df1ab6382eadcecf643b8e7ef99d4f77b Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 6 Aug 2024 11:06:22 +1000 Subject: [PATCH 07/53] chore: Upgrade pact_models to 1.2.3 --- 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 f487bbc92..a46aeaf61 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.2" } +pact_models = { version = "~1.2.3" } pact_matching = { version = "1.2.5", path = "../rust/pact_matching" } pact_mock_server = { version = "1.2.9" } pact_verifier = { version = "1.2.3", path = "../rust/pact_verifier" } diff --git a/rust/Cargo.toml b/rust/Cargo.toml index cdb51f4ca..1b3d71451 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.2", path = "./pact_models" } +pact_models = { version = "~1.2.3", path = "./pact_models" } [profile.release] strip = true diff --git a/rust/pact_consumer/Cargo.toml b/rust/pact_consumer/Cargo.toml index 4157aa884..a5c6ccd75 100644 --- a/rust/pact_consumer/Cargo.toml +++ b/rust/pact_consumer/Cargo.toml @@ -32,7 +32,7 @@ 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 = "~2.0.0", default-features = false } -pact_models = { version = "~1.2.2", default-features = false } +pact_models = { version = "~1.2.3", default-features = false } pact-plugin-driver = { version = "~0.7.0", optional = true, default-features = false } regex = "1.10.5" serde_json = "1.0.120" diff --git a/rust/pact_ffi/Cargo.toml b/rust/pact_ffi/Cargo.toml index d4bc68ff9..33b603cd8 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.5", path = "../pact_matching" } pact_mock_server = { version = "~1.2.9" } -pact_models = { version = "~1.2.2" } +pact_models = { version = "~1.2.3" } pact-plugin-driver = { version = "~0.7.0" } pact_verifier = { version = "~1.2.3", path = "../pact_verifier" } panic-message = "0.3.0" diff --git a/rust/pact_matching/Cargo.toml b/rust/pact_matching/Cargo.toml index ba2985378..b544c0b31 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.2", default-features = false } +pact_models = { version = "~1.2.3", 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 18c22d468..3760a62c6 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.5", path = "../pact_matching", default-features = false } -pact_models = { version = "~1.2.2", default-features = false } +pact_models = { version = "~1.2.3", 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 f6b6d4b77..23dd23a05 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.2", default-features = false } +pact_models = { version = "~1.2.3", 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"] } From 8387b9e18022351a4d3b996100d9f3bfff4589f8 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 6 Aug 2024 11:49:19 +1000 Subject: [PATCH 08/53] fix(pact_models): ProviderStateGenerator name was not correct --- rust/pact_models/src/generators/mod.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/rust/pact_models/src/generators/mod.rs b/rust/pact_models/src/generators/mod.rs index 897f4e4a6..026a645b9 100644 --- a/rust/pact_models/src/generators/mod.rs +++ b/rust/pact_models/src/generators/mod.rs @@ -252,7 +252,7 @@ impl Generator { Generator::Time(_, _) => "Time", Generator::DateTime(_, _) => "DateTime", Generator::RandomBoolean => "RandomBoolean", - Generator::ProviderStateGenerator(_, _) => "ProviderStateGenerator", + Generator::ProviderStateGenerator(_, _) => "ProviderState", Generator::MockServerURL(_, _) => "MockServerURL", Generator::ArrayContains(_) => "ArrayContains", }.to_string() @@ -2425,7 +2425,7 @@ mod tests2 { use serde_json::{json, Value}; use crate::expression_parser::DataType; - use crate::generators::generate_value_from_context; + use crate::generators::{generate_value_from_context, Generator}; #[rstest] // expression, value, data_type, expected @@ -2456,4 +2456,22 @@ mod tests2 { let result_value = result.unwrap(); expect!(result_value.as_json().unwrap()).to(be_equal_to(expected)); } + + #[rstest] + #[case(Generator::RandomInt(0, 1), "RandomInt")] + #[case(Generator::Uuid(None), "Uuid")] + #[case(Generator::RandomDecimal(0), "RandomDecimal")] + #[case(Generator::RandomHexadecimal(0), "RandomHexadecimal")] + #[case(Generator::RandomString(0), "RandomString")] + #[case(Generator::Regex("".to_string()), "Regex")] + #[case(Generator::Date(None, None), "Date")] + #[case(Generator::Time(None, None), "Time")] + #[case(Generator::DateTime(None, None), "DateTime")] + #[case(Generator::RandomBoolean, "RandomBoolean")] + #[case(Generator::ProviderStateGenerator("".to_string(), None), "ProviderState")] + #[case(Generator::MockServerURL("".to_string(), "".to_string()), "MockServerURL")] + #[case(Generator::ArrayContains(vec![]), "ArrayContains")] + fn generator_name_test(#[case] generator: Generator, #[case] name: &str) { + expect!(generator.name()).to(be_equal_to(name)); + } } From 80b7bb5815c25a5c11254166b6b56484151e951a Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 7 Aug 2024 16:06:54 +1000 Subject: [PATCH 09/53] fix(pact_verifier): Provider state values should be passed to any plugins under a providerState key --- rust/pact_verifier/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rust/pact_verifier/src/lib.rs b/rust/pact_verifier/src/lib.rs index ec32a63c7..85360fd0b 100644 --- a/rust/pact_verifier/src/lib.rs +++ b/rust/pact_verifier/src/lib.rs @@ -38,7 +38,7 @@ use pact_models::v4::interaction::V4Interaction; #[cfg(feature = "plugins")] use pact_plugin_driver::verification::{InteractionVerificationData, InteractionVerificationDetails}; use regex::Regex; use reqwest::Client; -use serde_json::Value; +use serde_json::{Map, Value}; #[cfg(feature = "plugins")] use serde_json::json; use tracing::{debug, debug_span, error, info, Instrument, instrument, trace, warn}; @@ -518,9 +518,11 @@ async fn verify_interaction_using_transport<'a, F: RequestFilterExecutor>( context.insert("port".to_string(), json!(port)); } + let mut psc = Map::new(); for (k, v) in config { - context.insert(k.to_string(), v.clone()); + psc.insert(k.to_string(), v.clone()); } + context.insert("providerState".to_string(), Value::Object(psc)); // Get plugin to prepare the request data let v4_interaction = interaction.as_v4().unwrap(); From 50fc022cabb0f93a8cca1be5d8f13695db43bd5d Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Thu, 8 Aug 2024 11:53:23 +1000 Subject: [PATCH 10/53] fix(pact_models): Provider state values may be passed in under a "providerState" key --- rust/pact_models/src/generators/mod.rs | 47 +++++++++++++++++++++----- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/rust/pact_models/src/generators/mod.rs b/rust/pact_models/src/generators/mod.rs index 026a645b9..bd68b1913 100644 --- a/rust/pact_models/src/generators/mod.rs +++ b/rust/pact_models/src/generators/mod.rs @@ -19,6 +19,7 @@ use rand::prelude::*; #[cfg(target_family = "wasm")] use regex::{Captures, Regex}; use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; +use serde_json::Value::Object; use tracing::{debug, instrument, trace, warn}; use uuid::Uuid; @@ -825,11 +826,21 @@ impl GenerateValue for Generator { ) -> anyhow::Result { match self { &Generator::RandomInt(min, max) => Ok(rand::thread_rng().gen_range(min as u16..(max as u16).saturating_add(1))), - &Generator::ProviderStateGenerator(ref exp, ref dt) => - match generate_value_from_context(exp, context, dt) { + &Generator::ProviderStateGenerator(ref exp, ref dt) => { + // Provider state values may come under a "providerState" key + let provider_state_config = if let Some(Object(psc)) = context.get("providerState") { + psc + .iter() + .map(|(k, v)| (k.as_str(), v.clone())) + .collect() + } else { + context.clone() + }; + match generate_value_from_context(exp, &provider_state_config, dt) { Ok(val) => u16::try_from(val), Err(err) => Err(err) - }, + } + } _ => Err(anyhow!("Could not generate a u16 value from {} using {:?}", value, self)) } } @@ -973,8 +984,18 @@ impl GenerateValue for Generator { } } Generator::RandomBoolean => Ok(format!("{}", rnd.gen::())), - Generator::ProviderStateGenerator(ref exp, ref dt) => - generate_value_from_context(exp, context, dt).map(|val| val.to_string()), + Generator::ProviderStateGenerator(ref exp, ref dt) => { + // Provider state values may come under a "providerState" key + let provider_state_config = if let Some(Object(psc)) = context.get("providerState") { + psc + .iter() + .map(|(k, v)| (k.as_str(), v.clone())) + .collect() + } else { + context.clone() + }; + generate_value_from_context(exp, &provider_state_config, dt).map(|val| val.to_string()) + } Generator::MockServerURL(example, regex) => if let Some(mock_server_details) = context.get("mockServer") { debug!("Generating URL from Mock Server details"); match mock_server_details.as_object() { @@ -1140,11 +1161,21 @@ impl GenerateValue for Generator { } }, Generator::RandomBoolean => Ok(json!(rand::thread_rng().gen::())), - Generator::ProviderStateGenerator(ref exp, ref dt) => - match generate_value_from_context(exp, context, dt) { + Generator::ProviderStateGenerator(ref exp, ref dt) => { + // Provider state values may come under a "providerState" key + let provider_state_config = if let Some(Object(psc)) = context.get("providerState") { + psc + .iter() + .map(|(k, v)| (k.as_str(), v.clone())) + .collect() + } else { + context.clone() + }; + match generate_value_from_context(exp, &provider_state_config, dt) { Ok(val) => val.as_json(), Err(err) => Err(err) - }, + } + } Generator::MockServerURL(example, regex) => { debug!("context = {:?}", context); if let Some(mock_server_details) = context.get("mockServer") { From ae7d2a9ce95f2df9613788508308c247f2c3c9b3 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 13 Aug 2024 11:13:51 +1000 Subject: [PATCH 11/53] fix(pact_verifier): Plugin feature was not enabled in the verifier --- rust/Cargo.lock | 187 +++++++++++++++++----------------- rust/pact_verifier/Cargo.toml | 2 +- 2 files changed, 96 insertions(+), 93 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index c68da8d03..865330971 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -167,7 +167,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.36", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -178,7 +178,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.36", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -212,7 +212,7 @@ checksum = "edf3ee19dbc0a46d740f6f0926bde8c50f02bdbc7b536842da28f6ac56513a8b" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.36", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -360,9 +360,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.7" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" +checksum = "e9e8aabfac534be767c909e0690571677d49f41bd8465ae876fe043d52ba5292" dependencies = [ "jobserver", "libc", @@ -471,18 +471,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.13" +version = "4.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc" +checksum = "11d8838454fda655dafd3accb2b6e2bea645b9e4078abe84a22ceb947235c5cc" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.13" +version = "4.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99" +checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" dependencies = [ "anstream", "anstyle", @@ -542,15 +542,15 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" dependencies = [ "libc", ] @@ -635,7 +635,7 @@ dependencies = [ "proc-macro2 1.0.86", "quote 1.0.36", "strsim 0.11.1", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -646,7 +646,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote 1.0.36", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -684,7 +684,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.36", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -718,7 +718,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.36", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -814,14 +814,14 @@ checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "filetime" -version = "0.2.23" +version = "0.2.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" +checksum = "bf401df4a4e3872c4fe8151134cf483738e74b67fc934d6532c882b3d24a4550" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.4.1", - "windows-sys 0.52.0", + "libredox", + "windows-sys 0.59.0", ] [[package]] @@ -921,7 +921,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.36", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -1305,9 +1305,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" +checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" dependencies = [ "bytes", "futures-channel", @@ -1386,25 +1386,25 @@ dependencies = [ [[package]] name = "indextree" -version = "4.7.0" +version = "4.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9f0421c6fe77186886dd647787132a907887e9fc3ce508aea6628dbaf9a4fcb" +checksum = "6c6e002b713904e29de1b722742f7e681ee8629a56ce581ce6e32222f4ea64f3" dependencies = [ "indextree-macros", ] [[package]] name = "indextree-macros" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1dd5776fe91eb9371383a6db7068fcfe80bd1d6d756aebebb92d80526065676" +checksum = "357230c23ee6024223892ce0de19888a04139ca5bb94f5becb04d38b75a4bccf" dependencies = [ "either", "itertools 0.13.0", "proc-macro2 1.0.86", "quote 1.0.36", "strum", - "syn 2.0.72", + "syn 2.0.74", "thiserror", ] @@ -1504,9 +1504,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" dependencies = [ "wasm-bindgen", ] @@ -1564,6 +1564,17 @@ version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.6.0", + "libc", + "redox_syscall", +] + [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -1612,7 +1623,7 @@ dependencies = [ "proc-macro2 1.0.86", "quote 1.0.36", "regex-syntax 0.6.29", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -1700,9 +1711,9 @@ dependencies = [ [[package]] name = "mio" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ "hermit-abi 0.3.9", "libc", @@ -1906,9 +1917,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.36.2" +version = "0.36.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" +checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" dependencies = [ "memchr", ] @@ -2309,7 +2320,7 @@ version = "1.1.4" dependencies = [ "ansi_term", "anyhow", - "clap 4.5.13", + "clap 4.5.15", "env_logger 0.11.5", "expectest", "junit-report", @@ -2356,7 +2367,7 @@ checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.3", + "redox_syscall", "smallvec", "windows-targets 0.52.6", ] @@ -2467,7 +2478,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.36", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -2526,7 +2537,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ "proc-macro2 1.0.86", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -2583,7 +2594,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.72", + "syn 2.0.74", "tempfile", ] @@ -2597,7 +2608,7 @@ dependencies = [ "itertools 0.13.0", "proc-macro2 1.0.86", "quote 1.0.36", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -2768,15 +2779,6 @@ dependencies = [ "yasna", ] -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_syscall" version = "0.5.3" @@ -2934,7 +2936,7 @@ dependencies = [ "regex", "relative-path", "rustc_version", - "syn 2.0.72", + "syn 2.0.74", "unicode-ident", ] @@ -2952,7 +2954,7 @@ dependencies = [ "regex", "relative-path", "rustc_version", - "syn 2.0.72", + "syn 2.0.74", "unicode-ident", ] @@ -3063,9 +3065,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" +checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" [[package]] name = "rustls-webpki" @@ -3165,29 +3167,29 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.204" +version = "1.0.207" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "5665e14a49a4ea1b91029ba7d3bca9f299e1f7cfa194388ccc20f14743e784f2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.207" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "6aea2634c86b0e8ef2cfdc0c340baede54ec27b1e46febd7f80dffb2aa44a00e" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.36", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] name = "serde_json" -version = "1.0.122" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" +checksum = "66ad62847a56b3dba58cc891acd13884b9c61138d330c0d7b6181713d4fce38d" dependencies = [ "itoa", "memchr", @@ -3243,7 +3245,7 @@ dependencies = [ "darling", "proc-macro2 1.0.86", "quote 1.0.36", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -3424,7 +3426,7 @@ dependencies = [ "proc-macro2 1.0.86", "quote 1.0.36", "rustversion", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -3467,9 +3469,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.72" +version = "2.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +checksum = "1fceb41e3d546d0bd83421d3409b1460cc7444cd389341a4c880fe7a042cb3d7" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.36", @@ -3516,15 +3518,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.11.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ "cfg-if", "fastrand", "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3556,7 +3558,7 @@ checksum = "5999e24eaa32083191ba4e425deb75cdf25efefabe5aaccb7446dd0d4122a3f5" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.36", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -3585,7 +3587,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.36", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -3670,7 +3672,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.36", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -3816,7 +3818,7 @@ dependencies = [ "proc-macro2 1.0.86", "prost-build", "quote 1.0.36", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -3869,7 +3871,7 @@ source = "git+https://github.com/tokio-rs/tracing.git?tag=tracing-subscriber-0.3 dependencies = [ "proc-macro2 1.0.86", "quote 1.0.36", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -4128,34 +4130,35 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2 1.0.86", "quote 1.0.36", - "syn 2.0.72", + "syn 2.0.74", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.42" +version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" dependencies = [ "cfg-if", "js-sys", @@ -4165,9 +4168,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote 1.0.36", "wasm-bindgen-macro-support", @@ -4175,22 +4178,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.36", - "syn 2.0.72", + "syn 2.0.74", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "wasm-streams" @@ -4207,9 +4210,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" dependencies = [ "js-sys", "wasm-bindgen", @@ -4500,7 +4503,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.36", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -4520,7 +4523,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.36", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] diff --git a/rust/pact_verifier/Cargo.toml b/rust/pact_verifier/Cargo.toml index 3760a62c6..71c77ce76 100644 --- a/rust/pact_verifier/Cargo.toml +++ b/rust/pact_verifier/Cargo.toml @@ -18,7 +18,7 @@ exclude = [ default = ["datetime", "xml", "plugins", "multipart"] datetime = ["pact_models/datetime", "pact-plugin-driver?/datetime", "pact_matching/datetime"] # Support for date/time matchers and expressions xml = ["pact_models/xml", "pact-plugin-driver?/xml", "pact_matching/xml"] # support for matching XML documents -plugins = ["dep:pact-plugin-driver"] +plugins = ["dep:pact-plugin-driver", "pact_matching/plugins"] multipart = ["pact_matching/multipart"] # suport for MIME multipart bodies [dependencies] From 05c27197c2a7ffde3721e3d18d7d07c133a9cd40 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 13 Aug 2024 11:14:40 +1000 Subject: [PATCH 12/53] chore(pact_matching): Update trace level instrumentation --- rust/pact_matching/src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/rust/pact_matching/src/lib.rs b/rust/pact_matching/src/lib.rs index 48551d7ed..35aa8e85f 100644 --- a/rust/pact_matching/src/lib.rs +++ b/rust/pact_matching/src/lib.rs @@ -1465,6 +1465,7 @@ fn group_by(items: I, f: F) -> HashMap> m } +#[instrument(level = "trace", ret, skip(expected, actual))] pub(crate) async fn compare_bodies( content_type: &ContentType, expected: &(dyn HttpPart + Send + Sync), @@ -1473,6 +1474,8 @@ pub(crate) async fn compare_bodies( ) -> BodyMatchResult { let mut mismatches = vec![]; + trace!(?content_type, "Comparing bodies"); + #[cfg(feature = "plugins")] { match find_content_matcher(content_type) { @@ -1579,6 +1582,7 @@ fn compare_bodies_core( mismatches } +#[instrument(level = "trace", ret, skip(expected, actual))] async fn match_body_content( content_type: &ContentType, expected: &(dyn HttpPart + Send + Sync), @@ -1793,7 +1797,7 @@ fn setup_plugin_config<'a>( } /// Matches the actual message contents to the expected one. This takes into account the content type of each. -#[allow(unused_variables)] +#[instrument(level = "trace")] pub async fn match_message_contents( expected: &MessageContents, actual: &MessageContents, @@ -1835,6 +1839,7 @@ pub async fn match_message_contents( } /// Matches the actual message metadata to the expected one. +#[instrument(level = "trace")] pub fn match_message_metadata( expected: &MessageContents, actual: &MessageContents, From cfa9e85de84bd8ba5b63e9a5a275ef0ff55534ff Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 13 Aug 2024 11:44:37 +1000 Subject: [PATCH 13/53] update changelog for release 1.2.4 --- 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 40a88f658..dc6dc5313 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.4 - Bugfix Release + +* 50fc022c - fix(pact_models): Provider state values may be passed in under a "providerState" key (Ronald Holshausen, Thu Aug 8 11:53:23 2024 +1000) +* 8387b9e1 - fix(pact_models): ProviderStateGenerator name was not correct (Ronald Holshausen, Tue Aug 6 11:49:19 2024 +1000) +* 42911cfd - bump version to 1.2.4 (Ronald Holshausen, Tue Aug 6 10:54:23 2024 +1000) + # 1.2.3 - Support for provider state injected values in plugins * 033a50ab - feat: Update the matching rule expression parser to support values from provider states (Ronald Holshausen, Fri Aug 2 10:06:52 2024 +1000) From 60ce3bc6362c821f6e6e4e8141a6c979a415446d Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 13 Aug 2024 11:45:30 +1000 Subject: [PATCH 14/53] bump version to 1.2.5 --- 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 865330971..8644f2a5f 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -2228,7 +2228,7 @@ dependencies = [ [[package]] name = "pact_models" -version = "1.2.4" +version = "1.2.5" dependencies = [ "anyhow", "ariadne", diff --git a/rust/pact_models/Cargo.toml b/rust/pact_models/Cargo.toml index a661eecf3..d9441928a 100644 --- a/rust/pact_models/Cargo.toml +++ b/rust/pact_models/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pact_models" -version = "1.2.4" +version = "1.2.5" authors = ["Ronald Holshausen "] edition = "2021" description = "Pact-Rust support library that provides the core models for dealing with Pact files" From 9a7eef750a7ecec33cc1d942db9a3de789b184de Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 13 Aug 2024 11:51:06 +1000 Subject: [PATCH 15/53] chore: Upgrade pact_models to 1.2.4 --- 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 a46aeaf61..e645d9e72 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.3" } +pact_models = { version = "~1.2.4" } pact_matching = { version = "1.2.5", path = "../rust/pact_matching" } pact_mock_server = { version = "1.2.9" } pact_verifier = { version = "1.2.3", path = "../rust/pact_verifier" } diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 1b3d71451..5caef460e 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.3", path = "./pact_models" } +pact_models = { version = "~1.2.4", path = "./pact_models" } [profile.release] strip = true diff --git a/rust/pact_consumer/Cargo.toml b/rust/pact_consumer/Cargo.toml index a5c6ccd75..926c3fac7 100644 --- a/rust/pact_consumer/Cargo.toml +++ b/rust/pact_consumer/Cargo.toml @@ -32,7 +32,7 @@ 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 = "~2.0.0", default-features = false } -pact_models = { version = "~1.2.3", default-features = false } +pact_models = { version = "~1.2.4", default-features = false } pact-plugin-driver = { version = "~0.7.0", optional = true, default-features = false } regex = "1.10.5" serde_json = "1.0.120" diff --git a/rust/pact_ffi/Cargo.toml b/rust/pact_ffi/Cargo.toml index 33b603cd8..8e6e85349 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.5", path = "../pact_matching" } pact_mock_server = { version = "~1.2.9" } -pact_models = { version = "~1.2.3" } +pact_models = { version = "~1.2.4" } pact-plugin-driver = { version = "~0.7.0" } pact_verifier = { version = "~1.2.3", path = "../pact_verifier" } panic-message = "0.3.0" diff --git a/rust/pact_matching/Cargo.toml b/rust/pact_matching/Cargo.toml index b544c0b31..6f3af88ca 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.3", default-features = false } +pact_models = { version = "~1.2.4", 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 71c77ce76..259525b9a 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.5", path = "../pact_matching", default-features = false } -pact_models = { version = "~1.2.3", default-features = false } +pact_models = { version = "~1.2.4", 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 23dd23a05..3b2d1dec6 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.3", default-features = false } +pact_models = { version = "~1.2.4", 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"] } From f50454ff9d693b8b94da5bb0fa248a5d283af7fb Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 13 Aug 2024 11:54:59 +1000 Subject: [PATCH 16/53] chore: Upgrade test dependencies --- rust/Cargo.lock | 18 +++++++++--------- rust/pact_ffi/Cargo.toml | 4 ++-- rust/pact_matching/Cargo.toml | 2 +- rust/pact_verifier_cli/Cargo.toml | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 8644f2a5f..db2694bcc 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -2076,7 +2076,7 @@ dependencies = [ "expectest", "futures", "home", - "itertools 0.12.1", + "itertools 0.13.0", "lazy_static", "libc", "log", @@ -2097,7 +2097,7 @@ dependencies = [ "regex", "regex-syntax 0.6.29", "reqwest", - "rstest 0.19.0", + "rstest 0.22.0", "serde", "serde_json", "sxd-document", @@ -2147,7 +2147,7 @@ dependencies = [ "quickcheck", "rand", "reqwest", - "rstest 0.19.0", + "rstest 0.22.0", "semver", "serde", "serde_json", @@ -2331,7 +2331,7 @@ dependencies = [ "pact_verifier", "regex", "reqwest", - "rstest 0.21.0", + "rstest 0.22.0", "serde_json", "strip-ansi-escapes", "time", @@ -2913,13 +2913,13 @@ dependencies = [ [[package]] name = "rstest" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afd55a67069d6e434a95161415f5beeada95a01c7b815508a82dcb0e1593682" +checksum = "7b423f0e62bdd61734b67cd21ff50871dfaeb9cc74f869dcd6af974fbcb19936" dependencies = [ "futures", "futures-timer", - "rstest_macros 0.21.0", + "rstest_macros 0.22.0", "rustc_version", ] @@ -2942,9 +2942,9 @@ dependencies = [ [[package]] name = "rstest_macros" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4165dfae59a39dd41d8dec720d3cbfbc71f69744efb480a3920f5d4e0cc6798d" +checksum = "c5e1711e7d14f74b12a58411c542185ef7fb7f2e7f8ee6e2940a883628522b42" dependencies = [ "cfg-if", "glob", diff --git a/rust/pact_ffi/Cargo.toml b/rust/pact_ffi/Cargo.toml index 8e6e85349..2cb636fc4 100644 --- a/rust/pact_ffi/Cargo.toml +++ b/rust/pact_ffi/Cargo.toml @@ -23,7 +23,7 @@ clap = "2.34.0" either = "1.9.0" env_logger = "0.11.3" futures = "0.3.29" -itertools = "0.12.0" +itertools = "0.13.0" lazy_static = "1.4.0" libc = "0.2.151" log = "0.4.20" @@ -61,7 +61,7 @@ test-log = "0.2.14" tempfile = "3.8.1" home = "0.5.9" pretty_assertions = "1.4.0" -rstest = "0.19.0" +rstest = "0.22.0" [lib] crate-type = ["cdylib", "staticlib", "rlib"] diff --git a/rust/pact_matching/Cargo.toml b/rust/pact_matching/Cargo.toml index 6f3af88ca..2aa7c4455 100644 --- a/rust/pact_matching/Cargo.toml +++ b/rust/pact_matching/Cargo.toml @@ -65,4 +65,4 @@ test-log = { version = "0.2.15", features = ["trace"] } tracing-subscriber = { version = "0.3.18", features = ["env-filter", "tracing-log", "fmt"] } ntest = "0.9.0" pretty_assertions = "1.4.0" -rstest = "0.19.0" +rstest = "0.22.0" diff --git a/rust/pact_verifier_cli/Cargo.toml b/rust/pact_verifier_cli/Cargo.toml index 3b2d1dec6..92d96a510 100644 --- a/rust/pact_verifier_cli/Cargo.toml +++ b/rust/pact_verifier_cli/Cargo.toml @@ -45,5 +45,5 @@ tracing-subscriber = { version = "0.3.18", features = ["env-filter", "tracing-lo [dev-dependencies] expectest = "0.12.0" -rstest = "0.21.0" +rstest = "0.22.0" trycmd = "0.15.0" From ab836e18e2fc2c84ab7c0842cd0cfdd5c5bc4fe7 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 13 Aug 2024 15:01:16 +1000 Subject: [PATCH 17/53] chore(pact_matching): Update dependencies --- rust/pact_matching/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/pact_matching/Cargo.toml b/rust/pact_matching/Cargo.toml index 2aa7c4455..0d42d0ff4 100644 --- a/rust/pact_matching/Cargo.toml +++ b/rust/pact_matching/Cargo.toml @@ -31,8 +31,8 @@ difference = "2.0.0" futures = "0.3.30" hex = "0.4.3" http = "1.1.0" -infer = "0.15.0" -itertools = "0.12.1" +infer = "0.16.0" +itertools = "0.13.0" lazy_static = "1.4.0" lenient_semver = "0.4.2" maplit = "1.0.2" From 6798e745504d8a58d4e03d7654a8a5b5ab4cc04e Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 13 Aug 2024 15:16:42 +1000 Subject: [PATCH 18/53] chore(pact_matching): Update dependencies --- rust/Cargo.lock | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index db2694bcc..116cf5cf3 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1423,9 +1423,9 @@ dependencies = [ [[package]] name = "infer" -version = "0.15.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb33622da908807a06f9513c19b3c1ad50fab3e4137d82a78107d502075aa199" +checksum = "bc150e5ce2330295b8616ce0e3f53250e53af31759a9dbedad1621ba29151847" dependencies = [ "cfb", ] @@ -1469,15 +1469,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.13.0" @@ -2131,7 +2122,7 @@ dependencies = [ "hex", "http 1.1.0", "infer", - "itertools 0.12.1", + "itertools 0.13.0", "lazy_static", "lenient_semver", "maplit", From 5c81e0da191a9623da2b38a9da88c30f34e8cc84 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 13 Aug 2024 15:19:53 +1000 Subject: [PATCH 19/53] update changelog for release 1.2.6 --- 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 2165aed50..28425aae9 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.6 - Maintenance Release + +* ab836e18 - chore(pact_matching): Update dependencies (Ronald Holshausen, Tue Aug 13 15:01:16 2024 +1000) +* f50454ff - chore: Upgrade test dependencies (Ronald Holshausen, Tue Aug 13 11:54:59 2024 +1000) +* 9a7eef75 - chore: Upgrade pact_models to 1.2.4 (Ronald Holshausen, Tue Aug 13 11:51:06 2024 +1000) +* 05c27197 - chore(pact_matching): Update trace level instrumentation (Ronald Holshausen, Tue Aug 13 11:14:40 2024 +1000) +* bcf4db6d - chore: Upgrade pact_models to 1.2.3 (Ronald Holshausen, Tue Aug 6 11:06:22 2024 +1000) +* c6df3fcc - bump version to 1.2.6 (Ronald Holshausen, Wed Jul 17 11:56:14 2024 +1000) + # 1.2.5 - Bugfix Release * fd9ff70a - chore: Upgrade pact_models to 1.2.2 (Ronald Holshausen, Wed Jul 17 11:15:34 2024 +1000) From 9f6a8c358f1d34aab16961e3e6dfe707204c88ea Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 13 Aug 2024 15:21:05 +1000 Subject: [PATCH 20/53] bump version to 1.2.7 --- 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 116cf5cf3..88043e1e9 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -2107,7 +2107,7 @@ dependencies = [ [[package]] name = "pact_matching" -version = "1.2.6" +version = "1.2.7" dependencies = [ "ansi_term", "anyhow", diff --git a/rust/pact_matching/Cargo.toml b/rust/pact_matching/Cargo.toml index 0d42d0ff4..3b2d4ec10 100644 --- a/rust/pact_matching/Cargo.toml +++ b/rust/pact_matching/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pact_matching" -version = "1.2.6" +version = "1.2.7" authors = ["Ronald Holshausen "] edition = "2021" description = "Pact-Rust support library that implements request and response matching logic" From 978677cc30c3e28937f7d033aa56296719880f6d Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 13 Aug 2024 15:27:49 +1000 Subject: [PATCH 21/53] chore: Upgrade pact_matching to 1.2.6 --- compatibility-suite/Cargo.toml | 2 +- rust/Cargo.toml | 2 +- rust/pact_consumer/Cargo.toml | 2 +- rust/pact_ffi/Cargo.toml | 2 +- rust/pact_verifier/Cargo.toml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compatibility-suite/Cargo.toml b/compatibility-suite/Cargo.toml index e645d9e72..ba41471c8 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.4" } -pact_matching = { version = "1.2.5", path = "../rust/pact_matching" } +pact_matching = { version = "1.2.6", path = "../rust/pact_matching" } pact_mock_server = { version = "1.2.9" } pact_verifier = { version = "1.2.3", path = "../rust/pact_verifier" } pact_consumer = { version = "1.2.3", path = "../rust/pact_consumer" } diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 5caef460e..e912d7814 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -17,7 +17,7 @@ tracing-core = { git = "https://github.com/tokio-rs/tracing.git", tag = "tracing tracing-subscriber = { git = "https://github.com/tokio-rs/tracing.git", tag = "tracing-subscriber-0.3.18" } # FFI Inmemory sink uses the global static `LOG_BUFFER` in the pact_matching crate. This is required to be the same # version across all crates (i.e. mock server crate). -pact_matching = { version = "~1.2.4", path = "./pact_matching" } +pact_matching = { version = "~1.2.6", path = "./pact_matching" } # Issue 389 - Pull change into other crates pact_models = { version = "~1.2.4", path = "./pact_models" } diff --git a/rust/pact_consumer/Cargo.toml b/rust/pact_consumer/Cargo.toml index 926c3fac7..93ceb8547 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.5.0" maplit = "1.0.2" -pact_matching = { version = "~1.2.5", path = "../pact_matching", default-features = false } +pact_matching = { version = "~1.2.6", path = "../pact_matching", default-features = false } pact_mock_server = { version = "~2.0.0", default-features = false } pact_models = { version = "~1.2.4", 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 2cb636fc4..9cac77a8f 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.5", path = "../pact_matching" } +pact_matching = { version = "~1.2.6", path = "../pact_matching" } pact_mock_server = { version = "~1.2.9" } pact_models = { version = "~1.2.4" } pact-plugin-driver = { version = "~0.7.0" } diff --git a/rust/pact_verifier/Cargo.toml b/rust/pact_verifier/Cargo.toml index 259525b9a..76c7d132b 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.5", path = "../pact_matching", default-features = false } +pact_matching = { version = "~1.2.6", path = "../pact_matching", default-features = false } pact_models = { version = "~1.2.4", default-features = false } pact-plugin-driver = { version = "~0.7.0", optional = true, default-features = false } regex = "1.10.4" From 0c64270672012d1c705caef58f008c04b6805dc1 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 13 Aug 2024 15:38:20 +1000 Subject: [PATCH 22/53] update changelog for release 1.2.4 --- 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 232ce639e..333ba20ef 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.4 - Bugfix Release + +* 978677cc - chore: Upgrade pact_matching to 1.2.6 (Ronald Holshausen, Tue Aug 13 15:27:49 2024 +1000) +* 9a7eef75 - chore: Upgrade pact_models to 1.2.4 (Ronald Holshausen, Tue Aug 13 11:51:06 2024 +1000) +* ae7d2a9c - fix(pact_verifier): Plugin feature was not enabled in the verifier (Ronald Holshausen, Tue Aug 13 11:13:51 2024 +1000) +* 80b7bb58 - fix(pact_verifier): Provider state values should be passed to any plugins under a providerState key (Ronald Holshausen, Wed Aug 7 16:06:54 2024 +1000) +* bcf4db6d - chore: Upgrade pact_models to 1.2.3 (Ronald Holshausen, Tue Aug 6 11:06:22 2024 +1000) +* 111a18cd - Feat(pact_consumer): Upgrade pact_mock_server to the new 2.0.0 version (Ronald Holshausen, Thu Jul 18 17:12:55 2024 +1000) +* 56c953b4 - chore: Upgrade pact_consumer to 1.2.3 (Ronald Holshausen, Wed Jul 17 15:28:49 2024 +1000) +* 25fd9c56 - chore: Update release script (Ronald Holshausen, Wed Jul 17 15:12:37 2024 +1000) +* c8d297f2 - bump version to 1.2.4 (Ronald Holshausen, Wed Jul 17 15:12:16 2024 +1000) + # 1.2.3 - Bugfix Release * bb9fc1be - chore: Upgrade pact_matching to 1.2.5 (Ronald Holshausen, Wed Jul 17 14:34:04 2024 +1000) From b33fa12696f70e1f3c21477d587cde5443ada647 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 13 Aug 2024 15:39:33 +1000 Subject: [PATCH 23/53] bump version to 1.2.5 --- 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 76c7d132b..58e0451e0 100644 --- a/rust/pact_verifier/Cargo.toml +++ b/rust/pact_verifier/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pact_verifier" -version = "1.2.4" +version = "1.2.5" authors = ["Ronald Holshausen "] edition = "2021" description = "Pact-Rust support library that implements provider verification functions" From fa02c30b9d7d74759206cf01307067bed996cec9 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 13 Aug 2024 15:42:48 +1000 Subject: [PATCH 24/53] chore: Upgrade pact_verifier to 1.2.4 --- compatibility-suite/Cargo.toml | 2 +- rust/Cargo.lock | 2 +- rust/pact_ffi/Cargo.toml | 2 +- rust/pact_verifier_cli/Cargo.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compatibility-suite/Cargo.toml b/compatibility-suite/Cargo.toml index ba41471c8..d9efbefe0 100644 --- a/compatibility-suite/Cargo.toml +++ b/compatibility-suite/Cargo.toml @@ -16,7 +16,7 @@ maplit = "1.0.2" pact_models = { version = "~1.2.4" } pact_matching = { version = "1.2.6", path = "../rust/pact_matching" } pact_mock_server = { version = "1.2.9" } -pact_verifier = { version = "1.2.3", path = "../rust/pact_verifier" } +pact_verifier = { version = "1.2.4", path = "../rust/pact_verifier" } pact_consumer = { version = "1.2.3", path = "../rust/pact_consumer" } pretty_assertions = "1.4.0" regex = "1.10.2" diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 88043e1e9..32d999033 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -2265,7 +2265,7 @@ dependencies = [ [[package]] name = "pact_verifier" -version = "1.2.4" +version = "1.2.5" dependencies = [ "ansi_term", "anyhow", diff --git a/rust/pact_ffi/Cargo.toml b/rust/pact_ffi/Cargo.toml index 9cac77a8f..c2f44e55c 100644 --- a/rust/pact_ffi/Cargo.toml +++ b/rust/pact_ffi/Cargo.toml @@ -34,7 +34,7 @@ pact_matching = { version = "~1.2.6", path = "../pact_matching" } pact_mock_server = { version = "~1.2.9" } pact_models = { version = "~1.2.4" } pact-plugin-driver = { version = "~0.7.0" } -pact_verifier = { version = "~1.2.3", path = "../pact_verifier" } +pact_verifier = { version = "~1.2.4", 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 92d96a510..9cbb8ff0f 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.4", default-features = false } -pact_verifier = { version = "~1.2.3", path = "../pact_verifier", default-features = false } +pact_verifier = { version = "~1.2.4", 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 7c47cf4c094ae6ea1b2eae4081620525726dad92 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 13 Aug 2024 15:47:24 +1000 Subject: [PATCH 25/53] update changelog for release 1.1.4 --- rust/pact_verifier_cli/CHANGELOG.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/rust/pact_verifier_cli/CHANGELOG.md b/rust/pact_verifier_cli/CHANGELOG.md index a0c0c286e..8d908aa1e 100644 --- a/rust/pact_verifier_cli/CHANGELOG.md +++ b/rust/pact_verifier_cli/CHANGELOG.md @@ -1,5 +1,24 @@ To generate the log, run `git log --pretty='* %h - %s (%an, %ad)' TAGNAME..HEAD .` replacing TAGNAME and HEAD as appropriate. +# 1.1.4 - Bugfix Release + +* fa02c30b - chore: Upgrade pact_verifier to 1.2.4 (Ronald Holshausen, Tue Aug 13 15:42:48 2024 +1000) +* f50454ff - chore: Upgrade test dependencies (Ronald Holshausen, Tue Aug 13 11:54:59 2024 +1000) +* 9a7eef75 - chore: Upgrade pact_models to 1.2.4 (Ronald Holshausen, Tue Aug 13 11:51:06 2024 +1000) +* bcf4db6d - chore: Upgrade pact_models to 1.2.3 (Ronald Holshausen, Tue Aug 6 11:06:22 2024 +1000) +* 4257ed1e - chore: Upgrade pact_verifier to 1.2.3 (Ronald Holshausen, Wed Jul 17 15:19:58 2024 +1000) +* fd9ff70a - chore: Upgrade pact_models to 1.2.2 (Ronald Holshausen, Wed Jul 17 11:15:34 2024 +1000) +* 5ba47b96 - docs(pact_verifier_cli): Update README with returning values from provider state callbacks #441 (Ronald Holshausen, Thu Jul 11 15:52:55 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) +* de31b4ea - fix(pact_verifier_cli): Allow transport base-paths to be defined from the CLI #418 (Ronald Holshausen, Mon Jul 8 17:19:37 2024 +1000) +* a5ba0cb8 - doc(pact_verifier_cli): Update Rust docs from README content #418 (Ronald Holshausen, Mon Jul 8 16:37:48 2024 +1000) +* a830e491 - doc(pact_verifier_cli): Fix grammar #418 (Ronald Holshausen, Mon Jul 8 16:27:57 2024 +1000) +* 8cc4c148 - doc(pact_verifier_cli): Update docs for verifying mixed V4 Pacts #418 (Ronald Holshausen, Mon Jul 8 16:26:00 2024 +1000) +* bab814c8 - doc(pact_verifier_cli): Fix grammar #418 (Ronald Holshausen, Mon Jul 8 15:43:21 2024 +1000) +* fbb7825d - doc(pact_verifier_cli): Add some emphasis to example values #418 (Ronald Holshausen, Mon Jul 8 15:41:25 2024 +1000) +* 4775fdfd - doc(pact_verifier_cli): Update the CLI docs to explain the provider state calls #418 (Ronald Holshausen, Mon Jul 8 15:25:23 2024 +1000) +* 37bc38f1 - bump version to 1.1.4 (Ronald Holshausen, Fri Jun 14 11:51:24 2024 +1000) + # 1.1.3 - Feature + Bugfix release * dad482f5 - chore: Upgrade pact_verifier to 1.2.2 (Ronald Holshausen, Fri Jun 14 11:21:54 2024 +1000) From 791db1fcf2d112be54da2246b67fe8238f1c4cd1 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 13 Aug 2024 15:48:54 +1000 Subject: [PATCH 26/53] bump version to 1.1.5 --- rust/Cargo.lock | 2 +- rust/pact_verifier_cli/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 32d999033..ba7895d6a 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -2307,7 +2307,7 @@ dependencies = [ [[package]] name = "pact_verifier_cli" -version = "1.1.4" +version = "1.1.5" dependencies = [ "ansi_term", "anyhow", diff --git a/rust/pact_verifier_cli/Cargo.toml b/rust/pact_verifier_cli/Cargo.toml index 9cbb8ff0f..e4315778f 100644 --- a/rust/pact_verifier_cli/Cargo.toml +++ b/rust/pact_verifier_cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pact_verifier_cli" -version = "1.1.4" +version = "1.1.5" authors = ["Ronald Holshausen "] edition = "2021" description = "Standalone pact verifier for provider pact verification" From 9cc38a2f3da5b24cce9a9e39073799b7d05fe8c1 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 27 Aug 2024 11:23:43 +1000 Subject: [PATCH 27/53] chore: do not write empty matching rules to the Pact file --- rust/pact_models/src/matchingrules/mod.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rust/pact_models/src/matchingrules/mod.rs b/rust/pact_models/src/matchingrules/mod.rs index 18bd1ec23..606766dfb 100644 --- a/rust/pact_models/src/matchingrules/mod.rs +++ b/rust/pact_models/src/matchingrules/mod.rs @@ -1260,7 +1260,12 @@ impl MatchingRules { map.insert(name.to_string(), rules.to_v3_json()); } _ => { - map.insert(name.to_string(), sub_category.to_v3_json()); + let value = sub_category.to_v3_json(); + if let Some(values) = value.as_object() { + if !values.is_empty() { + map.insert(name.to_string(), value); + } + } } } map @@ -1922,7 +1927,8 @@ mod tests { "header" => { "item1" => [ MatchingRule::Regex("5".to_string()) ], "$['principal_identifier[account_id]']" => [ MatchingRule::Regex("\\w+".to_string()) ] - } + }, + "metadata" => {} }; } From e6f8ae463dda126051c997d39774e1b57dccf21d Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 27 Aug 2024 14:32:37 +1000 Subject: [PATCH 28/53] fix(plugins): Plugin config needs to have seperate values for HTTP request and response parts --- rust/pact_matching/src/lib.rs | 46 ++-- rust/pact_matching/src/plugin_support.rs | 291 +++++++++++++++++++++++ 2 files changed, 306 insertions(+), 31 deletions(-) create mode 100644 rust/pact_matching/src/plugin_support.rs diff --git a/rust/pact_matching/src/lib.rs b/rust/pact_matching/src/lib.rs index 35aa8e85f..0f0752814 100644 --- a/rust/pact_matching/src/lib.rs +++ b/rust/pact_matching/src/lib.rs @@ -367,6 +367,11 @@ use bytes::Bytes; use itertools::{Either, Itertools}; use lazy_static::*; use maplit::{hashmap, hashset}; +#[cfg(feature = "plugins")] use pact_plugin_driver::catalogue_manager::find_content_matcher; +#[cfg(feature = "plugins")] use pact_plugin_driver::plugin_models::PluginInteractionConfig; +use serde_json::{json, Value}; +#[allow(unused_imports)] use tracing::{debug, error, info, instrument, trace, warn}; + use pact_models::bodies::OptionalBody; use pact_models::content_types::ContentType; use pact_models::generators::{apply_generators, GenerateValue, GeneratorCategory, GeneratorTestMode, VariantMatcher}; @@ -380,18 +385,14 @@ use pact_models::path_exp::DocPath; use pact_models::v4::http_parts::{HttpRequest, HttpResponse}; use pact_models::v4::message_parts::MessageContents; use pact_models::v4::sync_message::SynchronousMessage; -#[cfg(feature = "plugins")] use pact_plugin_driver::catalogue_manager::find_content_matcher; -#[cfg(feature = "plugins")] use pact_plugin_driver::plugin_models::PluginInteractionConfig; -use serde::__private::from_utf8_lossy; -use serde_json::{json, Value}; -#[allow(unused_imports)] use tracing::{debug, error, info, instrument, trace, warn}; -use crate::generators::DefaultVariantMatcher; use crate::generators::bodies::generators_process_body; +use crate::generators::DefaultVariantMatcher; use crate::headers::{match_header_value, match_headers}; #[cfg(feature = "plugins")] use crate::json::match_json; use crate::matchers::*; use crate::matchingrules::DisplayForMismatch; +#[cfg(feature = "plugins")] use crate::plugin_support::{InteractionPart, setup_plugin_config}; use crate::query::match_query_maps; /// Simple macro to convert a string slice to a `String` struct. @@ -415,6 +416,7 @@ pub mod binary_utils; pub mod headers; pub mod query; pub mod form_urlencoded; +#[cfg(feature = "plugins")] mod plugin_support; #[cfg(not(feature = "plugins"))] #[derive(Clone, Debug, PartialEq)] @@ -859,8 +861,8 @@ impl From for CommonMismatch { }, Mismatch::BodyMismatch { path, expected, actual, mismatch } => CommonMismatch { path: path.clone(), - expected: from_utf8_lossy(expected.unwrap_or_default().as_ref()).to_string(), - actual: from_utf8_lossy(actual.unwrap_or_default().as_ref()).to_string(), + expected: String::from_utf8_lossy(expected.unwrap_or_default().as_ref()).to_string(), + actual: String::from_utf8_lossy(actual.unwrap_or_default().as_ref()).to_string(), description: mismatch.clone() }, Mismatch::MetadataMismatch { key, expected, actual, mismatch } => CommonMismatch { @@ -1674,7 +1676,7 @@ pub async fn match_request<'a>( #[allow(unused_mut, unused_assignments)] let mut plugin_data = hashmap!{}; #[cfg(feature = "plugins")] { - plugin_data = setup_plugin_config(pact, interaction); + plugin_data = setup_plugin_config(pact, interaction, InteractionPart::Request); }; trace!("plugin_data = {:?}", plugin_data); @@ -1745,7 +1747,7 @@ pub async fn match_response<'a>( #[allow(unused_mut, unused_assignments)] let mut plugin_data = hashmap!{}; #[cfg(feature = "plugins")] { - plugin_data = setup_plugin_config(pact, interaction); + plugin_data = setup_plugin_config(pact, interaction, InteractionPart::Response); }; trace!("plugin_data = {:?}", plugin_data); @@ -1778,24 +1780,6 @@ pub async fn match_response<'a>( mismatches } -#[cfg(feature = "plugins")] -fn setup_plugin_config<'a>( - pact: &Box, - interaction: &Box -) -> HashMap { - pact.plugin_data().iter().map(|data| { - let interaction_config = if let Some(v4_interaction) = interaction.as_v4() { - v4_interaction.plugin_config().get(&data.name).cloned().unwrap_or_default() - } else { - hashmap! {} - }; - (data.name.clone(), PluginInteractionConfig { - pact_configuration: data.configuration.clone(), - interaction_configuration: interaction_config - }) - }).collect() -} - /// Matches the actual message contents to the expected one. This takes into account the content type of each. #[instrument(level = "trace")] pub async fn match_message_contents( @@ -1917,7 +1901,7 @@ pub async fn match_message<'a>( #[allow(unused_mut, unused_assignments)] let mut plugin_data = hashmap!{}; #[cfg(feature = "plugins")] { - plugin_data = setup_plugin_config(pact, expected); + plugin_data = setup_plugin_config(pact, expected, InteractionPart::None); }; let body_context = if expected.is_v4() { @@ -1976,7 +1960,7 @@ pub async fn match_sync_message_request<'a>( #[allow(unused_mut, unused_assignments)] let mut plugin_data = hashmap!{}; #[cfg(feature = "plugins")] { - plugin_data = setup_plugin_config(pact, &expected.boxed()); + plugin_data = setup_plugin_config(pact, &expected.boxed(), InteractionPart::None); }; let body_context = CoreMatchingContext { @@ -2034,7 +2018,7 @@ pub async fn match_sync_message_response<'a>( #[allow(unused_mut, unused_assignments)] let mut plugin_data = hashmap!{}; #[cfg(feature = "plugins")] { - plugin_data = setup_plugin_config(pact, &expected.boxed()); + plugin_data = setup_plugin_config(pact, &expected.boxed(), InteractionPart::None); }; for (expected_response, actual_response) in expected_responses.iter().zip(actual_responses) { let matching_rules = &expected_response.matching_rules; diff --git a/rust/pact_matching/src/plugin_support.rs b/rust/pact_matching/src/plugin_support.rs new file mode 100644 index 000000000..d5f21a9e8 --- /dev/null +++ b/rust/pact_matching/src/plugin_support.rs @@ -0,0 +1,291 @@ +//! Support functions for dealing with content from plugins + +use std::collections::HashMap; +use std::panic::RefUnwindSafe; + +use maplit::hashmap; +use pact_plugin_driver::plugin_models::PluginInteractionConfig; +use serde_json::Map; + +use pact_models::interaction::Interaction; +use pact_models::pact::Pact; + +/// Which part of the interaction should the config be extracted +#[derive(Clone, Copy, Debug, Default)] +pub(crate) enum InteractionPart { + /// No part, use the whole config + #[default] None, + /// Request part under the "request" key + Request, + /// Response part under the "response" key + Response +} + +pub(crate) fn setup_plugin_config<'a>( + pact: &Box, + interaction: &Box, + part: InteractionPart +) -> HashMap { + pact.plugin_data().iter().map(|data| { + let interaction_config = if let Some(v4_interaction) = interaction.as_v4() { + if let Some(config) = v4_interaction.plugin_config().get(&data.name) { + // In some cases, depending on how the interaction is setup, the plugin configuration + // could be stored under a request or response key. + match part { + InteractionPart::None => config.clone(), + InteractionPart::Request => if let Some(request_config) = config.get("request") { + request_config + .as_object() + .cloned() + .unwrap_or_else(|| Map::new()) + .iter() + .map(|(k, v)| (k.clone(), v.clone())) + .collect() + } else { + config.clone() + } + InteractionPart::Response => if let Some(response_config) = config.get("response") { + response_config + .as_object() + .cloned() + .unwrap_or_else(|| Map::new()) + .iter() + .map(|(k, v)| (k.clone(), v.clone())) + .collect() + } else { + config.clone() + } + } + } else { + hashmap!{} + } + } else { + hashmap!{} + }; + (data.name.clone(), PluginInteractionConfig { + pact_configuration: data.configuration.clone(), + interaction_configuration: interaction_config + }) + }).collect() +} + +#[cfg(test)] +mod tests { + use expectest::prelude::*; + use maplit::hashmap; + use pact_plugin_driver::plugin_models::PluginInteractionConfig; + use serde_json::json; + use pact_models::interaction::Interaction; + use pact_models::pact::Pact; + use pact_models::plugins::PluginData; + use pact_models::v4::interaction::V4Interaction; + use pact_models::v4::pact::V4Pact; + use pact_models::v4::synch_http::SynchronousHttp; + + use crate::plugin_support::{InteractionPart, setup_plugin_config}; + + #[test] + fn setup_plugin_config_extracts_plugin_data_from_the_pact_object_for_the_interaction() { + let plugin1 = PluginData { + name: "plugin1".to_string(), + version: "1".to_string(), + configuration: hashmap!{ + "a".to_string() => json!(100) + } + }; + let plugin2 = PluginData { + name: "plugin2".to_string(), + version: "2".to_string(), + configuration: hashmap!{ + "b".to_string() => json!(200) + } + }; + let interaction1 = SynchronousHttp { + plugin_config: hashmap!{ + "plugin1".to_string() => hashmap!{ + "ia".to_string() => json!(1000) + } + }, + .. SynchronousHttp::default() + }; + let interaction2 = SynchronousHttp { + plugin_config: hashmap!{ + "plugin2".to_string() => hashmap!{ + "ib".to_string() => json!(2000) + } + }, + .. SynchronousHttp::default() + }; + let pact = V4Pact { + interactions: vec![interaction1.boxed_v4(), interaction2.boxed_v4()], + plugin_data: vec![plugin1, plugin2], + .. V4Pact::default() + }; + + let result = setup_plugin_config(&pact.boxed(), &interaction1.boxed(), InteractionPart::None); + expect!(result).to(be_equal_to(hashmap!{ + "plugin1".to_string() => PluginInteractionConfig { + pact_configuration: hashmap!{ + "a".to_string() => json!(100) + }, + interaction_configuration: hashmap!{ + "ia".to_string() => json!(1000) + } + }, + "plugin2".to_string() => PluginInteractionConfig { + pact_configuration: hashmap!{ + "b".to_string() => json!(200) + }, + interaction_configuration: hashmap!{} + } + })); + + let result = setup_plugin_config(&pact.boxed(), &interaction2.boxed(), InteractionPart::None); + expect!(result).to(be_equal_to(hashmap!{ + "plugin1".to_string() => PluginInteractionConfig { + pact_configuration: hashmap!{ + "a".to_string() => json!(100) + }, + interaction_configuration: hashmap!{} + }, + "plugin2".to_string() => PluginInteractionConfig { + pact_configuration: hashmap!{ + "b".to_string() => json!(200) + }, + interaction_configuration: hashmap!{ + "ib".to_string() => json!(2000) + } + } + })); + + let result = setup_plugin_config(&pact.boxed(), &interaction1.boxed(), InteractionPart::Request); + expect!(result).to(be_equal_to(hashmap!{ + "plugin1".to_string() => PluginInteractionConfig { + pact_configuration: hashmap!{ + "a".to_string() => json!(100) + }, + interaction_configuration: hashmap!{ + "ia".to_string() => json!(1000) + } + }, + "plugin2".to_string() => PluginInteractionConfig { + pact_configuration: hashmap!{ + "b".to_string() => json!(200) + }, + interaction_configuration: hashmap!{} + } + })); + } + + #[test] + fn setup_plugin_config_extracts_plugin_data_from_the_request_part_for_the_interaction() { + let plugin1 = PluginData { + name: "plugin1".to_string(), + version: "1".to_string(), + configuration: hashmap!{ + "a".to_string() => json!(100) + } + }; + let interaction1 = SynchronousHttp { + plugin_config: hashmap!{ + "plugin1".to_string() => hashmap!{ + "ia".to_string() => json!(1000), + "request".to_string() => json!({ + "req": "req_value" + }), + "response".to_string() => json!({ + "res": "res_value" + }) + } + }, + .. SynchronousHttp::default() + }; + let pact = V4Pact { + interactions: vec![interaction1.boxed_v4()], + plugin_data: vec![plugin1], + .. V4Pact::default() + }; + + let result = setup_plugin_config(&pact.boxed(), &interaction1.boxed(), InteractionPart::None); + expect!(result).to(be_equal_to(hashmap!{ + "plugin1".to_string() => PluginInteractionConfig { + pact_configuration: hashmap!{ + "a".to_string() => json!(100) + }, + interaction_configuration: hashmap!{ + "ia".to_string() => json!(1000), + "request".to_string() => json!({"req": "req_value"}), + "response".to_string() => json!({"res": "res_value"}) + } + } + })); + + let result = setup_plugin_config(&pact.boxed(), &interaction1.boxed(), InteractionPart::Request); + expect!(result).to(be_equal_to(hashmap!{ + "plugin1".to_string() => PluginInteractionConfig { + pact_configuration: hashmap!{ + "a".to_string() => json!(100) + }, + interaction_configuration: hashmap!{ + "req".to_string() => json!("req_value") + } + } + })); + } + + #[test] + fn setup_plugin_config_extracts_plugin_data_from_the_response_part_for_the_interaction() { + let plugin1 = PluginData { + name: "plugin1".to_string(), + version: "1".to_string(), + configuration: hashmap!{ + "a".to_string() => json!(100) + } + }; + let interaction1 = SynchronousHttp { + plugin_config: hashmap!{ + "plugin1".to_string() => hashmap!{ + "ia".to_string() => json!(1000), + "request".to_string() => json!({ + "req": "req_value" + }), + "response".to_string() => json!({ + "res": "res_value" + }) + } + }, + .. SynchronousHttp::default() + }; + let pact = V4Pact { + interactions: vec![interaction1.boxed_v4()], + plugin_data: vec![plugin1], + .. V4Pact::default() + }; + + let result = setup_plugin_config(&pact.boxed(), &interaction1.boxed(), InteractionPart::None); + expect!(result).to(be_equal_to(hashmap!{ + "plugin1".to_string() => PluginInteractionConfig { + pact_configuration: hashmap!{ + "a".to_string() => json!(100) + }, + interaction_configuration: hashmap!{ + "ia".to_string() => json!(1000), + "request".to_string() => json!({"req": "req_value"}), + "response".to_string() => json!({"res": "res_value"}) + } + } + })); + + let result = setup_plugin_config(&pact.boxed(), &interaction1.boxed(), InteractionPart::Response); + expect!(result).to(be_equal_to(hashmap!{ + "plugin1".to_string() => PluginInteractionConfig { + pact_configuration: hashmap!{ + "a".to_string() => json!(100) + }, + interaction_configuration: hashmap!{ + "res".to_string() => json!("res_value") + } + } + })); + } +} From 0d9301f977b13be3ae6f3264b2264bc5788ae687 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 27 Aug 2024 14:46:45 +1000 Subject: [PATCH 29/53] update changelog for release 1.2.7 --- rust/pact_matching/CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rust/pact_matching/CHANGELOG.md b/rust/pact_matching/CHANGELOG.md index 28425aae9..8c95f8787 100644 --- a/rust/pact_matching/CHANGELOG.md +++ b/rust/pact_matching/CHANGELOG.md @@ -1,5 +1,10 @@ To generate the log, run `git log --pretty='* %h - %s (%an, %ad)' TAGNAME..HEAD .` replacing TAGNAME and HEAD as appropriate. +# 1.2.7 - Bugfix Release + +* e6f8ae46 - fix(plugins): Plugin config needs to have seperate values for HTTP request and response parts (Ronald Holshausen, Tue Aug 27 14:32:37 2024 +1000) +* 9f6a8c35 - bump version to 1.2.7 (Ronald Holshausen, Tue Aug 13 15:21:05 2024 +1000) + # 1.2.6 - Maintenance Release * ab836e18 - chore(pact_matching): Update dependencies (Ronald Holshausen, Tue Aug 13 15:01:16 2024 +1000) From 08288e323368de86ab8ace8e6e299827d563fb54 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 27 Aug 2024 14:48:23 +1000 Subject: [PATCH 30/53] bump version to 1.2.8 --- rust/Cargo.lock | 393 ++++++++++++++++------------------ rust/pact_matching/Cargo.toml | 2 +- 2 files changed, 184 insertions(+), 211 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index ba7895d6a..1be3357c0 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -17,6 +17,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + [[package]] name = "aes" version = "0.8.4" @@ -166,8 +172,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2 1.0.86", - "quote 1.0.36", - "syn 2.0.74", + "quote 1.0.37", + "syn 2.0.76", ] [[package]] @@ -177,8 +183,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2 1.0.86", - "quote 1.0.36", - "syn 2.0.74", + "quote 1.0.37", + "syn 2.0.76", ] [[package]] @@ -211,8 +217,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edf3ee19dbc0a46d740f6f0926bde8c50f02bdbc7b536842da28f6ac56513a8b" dependencies = [ "proc-macro2 1.0.86", - "quote 1.0.36", - "syn 2.0.74", + "quote 1.0.37", + "syn 2.0.76", ] [[package]] @@ -272,7 +278,7 @@ dependencies = [ "cc", "cfg-if", "libc", - "miniz_oxide", + "miniz_oxide 0.7.4", "object", "rustc-demangle", ] @@ -360,12 +366,13 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.10" +version = "1.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9e8aabfac534be767c909e0690571677d49f41bd8465ae876fe043d52ba5292" +checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" dependencies = [ "jobserver", "libc", + "shlex", ] [[package]] @@ -397,7 +404,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets 0.52.6", + "windows-targets", ] [[package]] @@ -471,9 +478,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.15" +version = "4.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d8838454fda655dafd3accb2b6e2bea645b9e4078abe84a22ceb947235c5cc" +checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019" dependencies = [ "clap_builder", ] @@ -517,9 +524,9 @@ dependencies = [ [[package]] name = "constant_time_eq" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" [[package]] name = "content_inspector" @@ -633,9 +640,9 @@ dependencies = [ "fnv", "ident_case", "proc-macro2 1.0.86", - "quote 1.0.36", + "quote 1.0.37", "strsim 0.11.1", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -645,8 +652,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", - "quote 1.0.36", - "syn 2.0.74", + "quote 1.0.37", + "syn 2.0.76", ] [[package]] @@ -672,7 +679,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a2c35ab6e03642397cdda1dd58abbc05d418aef8e36297f336d5aba060fe8df" dependencies = [ "proc-macro2 1.0.86", - "quote 1.0.36", + "quote 1.0.37", "syn 1.0.109", ] @@ -683,8 +690,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2 1.0.86", - "quote 1.0.36", - "syn 2.0.74", + "quote 1.0.37", + "syn 2.0.76", ] [[package]] @@ -717,8 +724,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2 1.0.86", - "quote 1.0.36", - "syn 2.0.74", + "quote 1.0.37", + "syn 2.0.76", ] [[package]] @@ -808,9 +815,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "filetime" @@ -832,12 +839,12 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.31" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920" +checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" dependencies = [ "crc32fast", - "miniz_oxide", + "miniz_oxide 0.8.0", ] [[package]] @@ -920,8 +927,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2 1.0.86", - "quote 1.0.36", - "syn 2.0.74", + "quote 1.0.37", + "syn 2.0.76", ] [[package]] @@ -1023,7 +1030,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.3.0", + "indexmap 2.4.0", "slab", "tokio", "tokio-util", @@ -1032,9 +1039,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" dependencies = [ "atomic-waker", "bytes", @@ -1042,7 +1049,7 @@ dependencies = [ "futures-core", "futures-sink", "http 1.1.0", - "indexmap 2.3.0", + "indexmap 2.4.0", "slab", "tokio", "tokio-util", @@ -1242,7 +1249,7 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.5", + "h2 0.4.6", "http 1.1.0", "http-body 1.0.1", "httparse", @@ -1282,7 +1289,7 @@ dependencies = [ "hyper-util", "log", "rustls 0.23.12", - "rustls-native-certs 0.7.1", + "rustls-native-certs 0.7.2", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -1375,9 +1382,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", "hashbrown 0.14.5", @@ -1386,9 +1393,9 @@ dependencies = [ [[package]] name = "indextree" -version = "4.7.1" +version = "4.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c6e002b713904e29de1b722742f7e681ee8629a56ce581ce6e32222f4ea64f3" +checksum = "0d6f1b8dbc8f1e5a0f45e05b9293c42cbab79086baeb3e914d3936f8149edc4f" dependencies = [ "indextree-macros", ] @@ -1402,9 +1409,9 @@ dependencies = [ "either", "itertools 0.13.0", "proc-macro2 1.0.86", - "quote 1.0.36", + "quote 1.0.37", "strum", - "syn 2.0.74", + "syn 2.0.76", "thiserror", ] @@ -1551,9 +1558,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.155" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "libredox" @@ -1612,9 +1619,9 @@ dependencies = [ "beef", "fnv", "proc-macro2 1.0.86", - "quote 1.0.36", + "quote 1.0.37", "regex-syntax 0.6.29", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -1700,6 +1707,15 @@ dependencies = [ "adler", ] +[[package]] +name = "miniz_oxide" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", +] + [[package]] name = "mio" version = "1.0.2" @@ -1792,7 +1808,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16d0d3f2a488592e5368ebbe996e7f1d44aa13156efad201f5b4d84e150eaa93" dependencies = [ "proc-macro2 1.0.86", - "quote 1.0.36", + "quote 1.0.37", "syn 1.0.109", ] @@ -1804,7 +1820,7 @@ checksum = "fcc7c92f190c97f79b4a332f5e81dcf68c8420af2045c936c9be0bc9de6f63b5" dependencies = [ "proc-macro-crate", "proc-macro2 1.0.86", - "quote 1.0.36", + "quote 1.0.37", "syn 1.0.109", ] @@ -2107,7 +2123,7 @@ dependencies = [ [[package]] name = "pact_matching" -version = "1.2.7" +version = "1.2.8" dependencies = [ "ansi_term", "anyhow", @@ -2311,7 +2327,7 @@ version = "1.1.5" dependencies = [ "ansi_term", "anyhow", - "clap 4.5.15", + "clap 4.5.16", "env_logger 0.11.5", "expectest", "junit-report", @@ -2360,7 +2376,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets 0.52.6", + "windows-targets", ] [[package]] @@ -2411,7 +2427,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.3.0", + "indexmap 2.4.0", ] [[package]] @@ -2468,8 +2484,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2 1.0.86", - "quote 1.0.36", - "syn 2.0.74", + "quote 1.0.37", + "syn 2.0.76", ] [[package]] @@ -2523,12 +2539,12 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.20" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" +checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" dependencies = [ "proc-macro2 1.0.86", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -2585,7 +2601,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.74", + "syn 2.0.76", "tempfile", ] @@ -2598,8 +2614,8 @@ dependencies = [ "anyhow", "itertools 0.13.0", "proc-macro2 1.0.86", - "quote 1.0.36", - "syn 2.0.74", + "quote 1.0.37", + "syn 2.0.76", ] [[package]] @@ -2690,9 +2706,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2 1.0.86", ] @@ -2831,9 +2847,9 @@ checksum = "ba39f3699c378cd8970968dcbff9c43159ea4cfbd88d43c00b22f2ef10a435d2" [[package]] name = "reqwest" -version = "0.12.5" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" +checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" dependencies = [ "async-compression", "base64 0.22.1", @@ -2856,7 +2872,7 @@ dependencies = [ "pin-project-lite", "quinn", "rustls 0.23.12", - "rustls-native-certs 0.7.1", + "rustls-native-certs 0.7.2", "rustls-pemfile 2.1.3", "rustls-pki-types", "serde", @@ -2872,7 +2888,7 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", - "winreg", + "windows-registry", ] [[package]] @@ -2923,11 +2939,11 @@ dependencies = [ "cfg-if", "glob", "proc-macro2 1.0.86", - "quote 1.0.36", + "quote 1.0.37", "regex", "relative-path", "rustc_version", - "syn 2.0.74", + "syn 2.0.76", "unicode-ident", ] @@ -2941,11 +2957,11 @@ dependencies = [ "glob", "proc-macro-crate", "proc-macro2 1.0.86", - "quote 1.0.36", + "quote 1.0.37", "regex", "relative-path", "rustc_version", - "syn 2.0.74", + "syn 2.0.76", "unicode-ident", ] @@ -3024,9 +3040,9 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a88d6d420651b496bdd98684116959239430022a115c1240e6c3993be0b15fba" +checksum = "04182dffc9091a404e0fc069ea5cd60e5b866c3adf881eff99a32d048242dffa" dependencies = [ "openssl-probe", "rustls-pemfile 2.1.3", @@ -3158,29 +3174,29 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.207" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5665e14a49a4ea1b91029ba7d3bca9f299e1f7cfa194388ccc20f14743e784f2" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.207" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aea2634c86b0e8ef2cfdc0c340baede54ec27b1e46febd7f80dffb2aa44a00e" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2 1.0.86", - "quote 1.0.36", - "syn 2.0.74", + "quote 1.0.37", + "syn 2.0.76", ] [[package]] name = "serde_json" -version = "1.0.124" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66ad62847a56b3dba58cc891acd13884b9c61138d330c0d7b6181713d4fce38d" +checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ "itoa", "memchr", @@ -3219,7 +3235,7 @@ dependencies = [ "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.3.0", + "indexmap 2.4.0", "serde", "serde_derive", "serde_json", @@ -3235,8 +3251,8 @@ checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" dependencies = [ "darling", "proc-macro2 1.0.86", - "quote 1.0.36", - "syn 2.0.74", + "quote 1.0.37", + "syn 2.0.76", ] [[package]] @@ -3320,9 +3336,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "snapbox" -version = "0.6.16" +version = "0.6.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "027c936207f85d10d015e21faf5c676c7e08c453ed371adf55c0874c443ca77a" +checksum = "840b73eb3148bc3cbc10ebe00ec9bc6d96033e658d022c4adcbf3f35596fd64a" dependencies = [ "anstream", "anstyle", @@ -3337,7 +3353,7 @@ dependencies = [ "tempfile", "wait-timeout", "walkdir", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3415,9 +3431,9 @@ checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ "heck", "proc-macro2 1.0.86", - "quote 1.0.36", + "quote 1.0.37", "rustversion", - "syn 2.0.74", + "syn 2.0.76", ] [[package]] @@ -3454,18 +3470,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2 1.0.86", - "quote 1.0.36", + "quote 1.0.37", "unicode-ident", ] [[package]] name = "syn" -version = "2.0.74" +version = "2.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fceb41e3d546d0bd83421d3409b1460cc7444cd389341a4c880fe7a042cb3d7" +checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" dependencies = [ "proc-macro2 1.0.86", - "quote 1.0.36", + "quote 1.0.37", "unicode-ident", ] @@ -3480,6 +3496,9 @@ name = "sync_wrapper" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +dependencies = [ + "futures-core", +] [[package]] name = "sysinfo" @@ -3548,8 +3567,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5999e24eaa32083191ba4e425deb75cdf25efefabe5aaccb7446dd0d4122a3f5" dependencies = [ "proc-macro2 1.0.86", - "quote 1.0.36", - "syn 2.0.74", + "quote 1.0.37", + "syn 2.0.76", ] [[package]] @@ -3577,8 +3596,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2 1.0.86", - "quote 1.0.36", - "syn 2.0.74", + "quote 1.0.37", + "syn 2.0.76", ] [[package]] @@ -3639,9 +3658,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.2" +version = "1.39.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" +checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" dependencies = [ "backtrace", "bytes", @@ -3662,8 +3681,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2 1.0.86", - "quote 1.0.36", - "syn 2.0.74", + "quote 1.0.37", + "syn 2.0.76", ] [[package]] @@ -3751,7 +3770,7 @@ version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap 2.3.0", + "indexmap 2.4.0", "toml_datetime", "winnow 0.5.40", ] @@ -3762,7 +3781,7 @@ version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ - "indexmap 2.3.0", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -3771,16 +3790,16 @@ dependencies = [ [[package]] name = "tonic" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38659f4a91aba8598d27821589f5db7dddd94601e7a01b1e485a50e5484c7401" +checksum = "c6f6ba989e4b2c58ae83d862d3a3e27690b6e3ae630d0deb59f3697f32aa88ad" dependencies = [ "async-stream", "async-trait", "axum", "base64 0.22.1", "bytes", - "h2 0.4.5", + "h2 0.4.6", "http 1.1.0", "http-body 1.0.1", "http-body-util", @@ -3801,15 +3820,15 @@ dependencies = [ [[package]] name = "tonic-build" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "568392c5a2bd0020723e3f387891176aabafe36fd9fcd074ad309dfa0c8eb964" +checksum = "fe4ee8877250136bd7e3d2331632810a4df4ea5e004656990d8d66d2f5ee8a67" dependencies = [ "prettyplease", "proc-macro2 1.0.86", "prost-build", - "quote 1.0.36", - "syn 2.0.74", + "quote 1.0.37", + "syn 2.0.76", ] [[package]] @@ -3834,15 +3853,15 @@ dependencies = [ [[package]] name = "tower-layer" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" @@ -3861,8 +3880,8 @@ version = "0.1.27" source = "git+https://github.com/tokio-rs/tracing.git?tag=tracing-subscriber-0.3.18#8b7a1dde69797b33ecfa20da71e72eb5e61f0b25" dependencies = [ "proc-macro2 1.0.86", - "quote 1.0.36", - "syn 2.0.74", + "quote 1.0.37", + "syn 2.0.76", ] [[package]] @@ -4082,7 +4101,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e369bee1b05d510a7b4ed645f5faa90619e05437111783ea5848f28d97d3c2e" dependencies = [ "proc-macro2 1.0.86", - "quote 1.0.36", + "quote 1.0.37", ] [[package]] @@ -4140,8 +4159,8 @@ dependencies = [ "log", "once_cell", "proc-macro2 1.0.86", - "quote 1.0.36", - "syn 2.0.74", + "quote 1.0.37", + "syn 2.0.76", "wasm-bindgen-shared", ] @@ -4163,7 +4182,7 @@ version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ - "quote 1.0.36", + "quote 1.0.37", "wasm-bindgen-macro-support", ] @@ -4174,8 +4193,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2 1.0.86", - "quote 1.0.36", - "syn 2.0.74", + "quote 1.0.37", + "syn 2.0.76", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4256,7 +4275,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" dependencies = [ "windows-core", - "windows-targets 0.52.6", + "windows-targets", ] [[package]] @@ -4265,49 +4284,55 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.6", + "windows-targets", ] [[package]] -name = "windows-sys" -version = "0.48.0" +name = "windows-registry" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" dependencies = [ - "windows-targets 0.48.5", + "windows-result", + "windows-strings", + "windows-targets", ] [[package]] -name = "windows-sys" -version = "0.52.0" +name = "windows-result" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" dependencies = [ - "windows-targets 0.52.6", + "windows-result", + "windows-targets", ] [[package]] name = "windows-sys" -version = "0.59.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.6", + "windows-targets", ] [[package]] -name = "windows-targets" -version = "0.48.5" +name = "windows-sys" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows-targets", ] [[package]] @@ -4316,46 +4341,28 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -4368,48 +4375,24 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -4434,16 +4417,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "winreg" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "xattr" version = "1.3.1" @@ -4493,8 +4466,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2 1.0.86", - "quote 1.0.36", - "syn 2.0.74", + "quote 1.0.37", + "syn 2.0.76", ] [[package]] @@ -4513,15 +4486,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2 1.0.86", - "quote 1.0.36", - "syn 2.0.74", + "quote 1.0.37", + "syn 2.0.76", ] [[package]] name = "zip" -version = "2.1.6" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40dd8c92efc296286ce1fbd16657c5dbefff44f1b4ca01cc5f517d8b7b3d3e2e" +checksum = "dc5e4288ea4057ae23afc69a4472434a87a2495cafce6632fd1c4ec9f5cf3494" dependencies = [ "aes", "arbitrary", @@ -4533,7 +4506,7 @@ dependencies = [ "displaydoc", "flate2", "hmac", - "indexmap 2.3.0", + "indexmap 2.4.0", "lzma-rs", "memchr", "pbkdf2", diff --git a/rust/pact_matching/Cargo.toml b/rust/pact_matching/Cargo.toml index 3b2d4ec10..b76369a9d 100644 --- a/rust/pact_matching/Cargo.toml +++ b/rust/pact_matching/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pact_matching" -version = "1.2.7" +version = "1.2.8" authors = ["Ronald Holshausen "] edition = "2021" description = "Pact-Rust support library that implements request and response matching logic" From dc441709bef81550c8c0a1c9a3919c615a64220e Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 27 Aug 2024 14:57:12 +1000 Subject: [PATCH 31/53] chore: Upgrade pact_matching to 1.2.7 --- rust/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/rust/Cargo.toml b/rust/Cargo.toml index e912d7814..46001c2cd 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -17,7 +17,7 @@ tracing-core = { git = "https://github.com/tokio-rs/tracing.git", tag = "tracing tracing-subscriber = { git = "https://github.com/tokio-rs/tracing.git", tag = "tracing-subscriber-0.3.18" } # FFI Inmemory sink uses the global static `LOG_BUFFER` in the pact_matching crate. This is required to be the same # version across all crates (i.e. mock server crate). -pact_matching = { version = "~1.2.6", path = "./pact_matching" } +pact_matching = { version = "~1.2.7", path = "./pact_matching" } # Issue 389 - Pull change into other crates pact_models = { version = "~1.2.4", path = "./pact_models" } diff --git a/rust/pact_consumer/Cargo.toml b/rust/pact_consumer/Cargo.toml index 93ceb8547..edc6238e6 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.5.0" maplit = "1.0.2" -pact_matching = { version = "~1.2.6", path = "../pact_matching", default-features = false } +pact_matching = { version = "~1.2.7", path = "../pact_matching", default-features = false } pact_mock_server = { version = "~2.0.0", default-features = false } pact_models = { version = "~1.2.4", 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 c2f44e55c..635a2e7fa 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.6", path = "../pact_matching" } +pact_matching = { version = "~1.2.7", path = "../pact_matching" } pact_mock_server = { version = "~1.2.9" } pact_models = { version = "~1.2.4" } pact-plugin-driver = { version = "~0.7.0" } diff --git a/rust/pact_verifier/Cargo.toml b/rust/pact_verifier/Cargo.toml index 58e0451e0..1d0701d9e 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.6", path = "../pact_matching", default-features = false } +pact_matching = { version = "~1.2.7", path = "../pact_matching", default-features = false } pact_models = { version = "~1.2.4", default-features = false } pact-plugin-driver = { version = "~0.7.0", optional = true, default-features = false } regex = "1.10.4" From dae427a7aa3367cefc879832d54d2359adfd3958 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 27 Aug 2024 15:23:18 +1000 Subject: [PATCH 32/53] chore: Upgrade pact_mock_server to 2.0.1 --- rust/Cargo.lock | 6 +++--- rust/pact_consumer/Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 1be3357c0..950a62e78 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -2047,7 +2047,7 @@ dependencies = [ "maplit", "pact-plugin-driver", "pact_matching", - "pact_mock_server 2.0.0", + "pact_mock_server 2.0.1", "pact_models", "pretty_assertions", "quickcheck", @@ -2201,9 +2201,9 @@ dependencies = [ [[package]] name = "pact_mock_server" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57011d5e96c0b2206ee618ed96671a46df19f2cd13bbf46648ffde3a3776b2ec" +checksum = "35d2863820744a8c361fc23a8cafbc11798a6e5856410e0ec9c66a0d34599a71" dependencies = [ "anyhow", "bytes", diff --git a/rust/pact_consumer/Cargo.toml b/rust/pact_consumer/Cargo.toml index edc6238e6..deceac73d 100644 --- a/rust/pact_consumer/Cargo.toml +++ b/rust/pact_consumer/Cargo.toml @@ -31,7 +31,7 @@ itertools = "0.13.0" lazy_static = "1.5.0" maplit = "1.0.2" pact_matching = { version = "~1.2.7", path = "../pact_matching", default-features = false } -pact_mock_server = { version = "~2.0.0", default-features = false } +pact_mock_server = { version = "~2.0.1", default-features = false } pact_models = { version = "~1.2.4", default-features = false } pact-plugin-driver = { version = "~0.7.0", optional = true, default-features = false } regex = "1.10.5" From 941e445539dfb9483ad5e9492b814ce003c7d343 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 27 Aug 2024 15:35:16 +1000 Subject: [PATCH 33/53] fix(pact_consumer): Plugin config needs to be stored for both the request and response part of HTTP interactions --- .../src/builders/interaction_builder.rs | 73 ++++++++++++++++++- .../src/builders/request_builder.rs | 15 +++- .../src/builders/response_builder.rs | 15 +++- 3 files changed, 95 insertions(+), 8 deletions(-) diff --git a/rust/pact_consumer/src/builders/interaction_builder.rs b/rust/pact_consumer/src/builders/interaction_builder.rs index 926e0b0f5..9d990d389 100644 --- a/rust/pact_consumer/src/builders/interaction_builder.rs +++ b/rust/pact_consumer/src/builders/interaction_builder.rs @@ -1,11 +1,12 @@ use std::collections::HashMap; use maplit::hashmap; +use serde_json::{json, Value}; +use tracing::debug; +use pact_models::json_utils::json_deep_merge; use pact_models::provider_states::ProviderState; use pact_models::sync_interaction::RequestResponseInteraction; use pact_models::v4::synch_http::SynchronousHttp; -use serde_json::{json, Value}; -use tracing::debug; use super::request_builder::RequestBuilder; use super::response_builder::ResponseBuilder; @@ -162,13 +163,23 @@ impl InteractionBuilder { let request_config = self.request.plugin_config(); if !request_config.is_empty() { for (key, value) in request_config { - config.insert(key.clone(), value.interaction_configuration.clone()); + config.insert(key, value.interaction_configuration); } } let response_config = self.response.plugin_config(); if !response_config.is_empty() { for (key, value) in response_config { - config.insert(key.clone(), value.interaction_configuration.clone()); + let value_config = value.interaction_configuration.clone(); + config.entry(key) + .and_modify(|entry| { + for (k, v) in value_config { + entry + .entry(k) + .and_modify(|e| *e = json_deep_merge(e, &v)) + .or_insert(v); + } + }) + .or_insert(value.interaction_configuration); } } } @@ -195,3 +206,57 @@ impl InteractionBuilder { config } } + +#[cfg(all(test, feature = "plugins"))] +mod plugin_tests { + use expectest::prelude::*; + use maplit::hashmap; + use pact_plugin_driver::content::PluginConfiguration; + use serde_json::json; + + use crate::builders::InteractionBuilder; + + #[test] + fn plugin_config_merges_config_from_request_and_response_parts() { + let mut builder = InteractionBuilder::new("test", ""); + builder.request.plugin_config = hashmap!{ + "plugin1".to_string() => PluginConfiguration { + interaction_configuration: hashmap!{ + "other".to_string() => json!(100), + "request".to_string() => json!({ + "descriptorKey": "d58838959e37498cddf51805bedf4dca", + "message": ".area_calculator.ShapeMessage" + }) + }, + pact_configuration: Default::default() + } + }; + builder.response.plugin_config = hashmap!{ + "plugin1".to_string() => PluginConfiguration { + interaction_configuration: hashmap!{ + "other".to_string() => json!(200), + "response".to_string() => json!({ + "descriptorKey": "d58838959e37498cddf51805bedf4dca", + "message": ".area_calculator.AreaResponse" + }) + }, + pact_configuration: Default::default() + } + }; + + let config = builder.plugin_config(); + expect!(config).to(be_equal_to(hashmap!{ + "plugin1".to_string() => hashmap!{ + "other".to_string() => json!(200), + "request".to_string() => json!({ + "descriptorKey": "d58838959e37498cddf51805bedf4dca", + "message": ".area_calculator.ShapeMessage" + }), + "response".to_string() => json!({ + "descriptorKey": "d58838959e37498cddf51805bedf4dca", + "message": ".area_calculator.AreaResponse" + }) + } + })); + } +} diff --git a/rust/pact_consumer/src/builders/request_builder.rs b/rust/pact_consumer/src/builders/request_builder.rs index d6b4e05ec..c9385db49 100644 --- a/rust/pact_consumer/src/builders/request_builder.rs +++ b/rust/pact_consumer/src/builders/request_builder.rs @@ -36,7 +36,7 @@ struct PluginConfiguration {} #[derive(Clone, Debug)] pub struct RequestBuilder { request: HttpRequest, - #[allow(dead_code)] plugin_config: HashMap, + #[allow(dead_code)] pub(crate) plugin_config: HashMap, interaction_markup: InteractionMarkup } @@ -208,7 +208,18 @@ impl RequestBuilder { request.generators.add_generators(generators.clone()); } if !contents.plugin_config.is_empty() { - self.plugin_config.insert(matcher.plugin_name(), contents.plugin_config.clone()); + let plugin_config = PluginConfiguration { + interaction_configuration: hashmap!{ + "request".to_string() => Value::Object( + contents.plugin_config.interaction_configuration + .iter() + .map(|(k, v)| (k.clone(), v.clone())) + .collect() + ) + }, + pact_configuration: contents.plugin_config.pact_configuration.clone(), + }; + self.plugin_config.insert(matcher.plugin_name(), plugin_config); } self.interaction_markup = InteractionMarkup { markup: contents.interaction_markup.clone(), diff --git a/rust/pact_consumer/src/builders/response_builder.rs b/rust/pact_consumer/src/builders/response_builder.rs index e11b9b913..bd462a857 100644 --- a/rust/pact_consumer/src/builders/response_builder.rs +++ b/rust/pact_consumer/src/builders/response_builder.rs @@ -25,7 +25,7 @@ struct PluginConfiguration {} #[derive(Clone, Debug)] pub struct ResponseBuilder { response: HttpResponse, - #[allow(dead_code)] plugin_config: HashMap, + #[allow(dead_code)] pub(crate) plugin_config: HashMap, interaction_markup: InteractionMarkup } @@ -138,7 +138,18 @@ impl ResponseBuilder { response.generators.add_generators(generators.clone()); } if !contents.plugin_config.is_empty() { - self.plugin_config.insert(matcher.plugin_name(), contents.plugin_config.clone()); + let plugin_config = PluginConfiguration { + interaction_configuration: hashmap!{ + "response".to_string() => Value::Object( + contents.plugin_config.interaction_configuration + .iter() + .map(|(k, v)| (k.clone(), v.clone())) + .collect() + ) + }, + pact_configuration: contents.plugin_config.pact_configuration.clone(), + }; + self.plugin_config.insert(matcher.plugin_name(), plugin_config); } self.interaction_markup = InteractionMarkup { markup: contents.interaction_markup.clone(), From 2564abd8498fbe675142de60ead9f5654ee4c34f Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 27 Aug 2024 15:39:49 +1000 Subject: [PATCH 34/53] update changelog for release 1.3.1 --- rust/pact_consumer/CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rust/pact_consumer/CHANGELOG.md b/rust/pact_consumer/CHANGELOG.md index 28fe5cb6b..c569d637b 100644 --- a/rust/pact_consumer/CHANGELOG.md +++ b/rust/pact_consumer/CHANGELOG.md @@ -1,5 +1,16 @@ To generate the log, run `git log --pretty='* %h - %s (%an, %ad)' TAGNAME..HEAD .` replacing TAGNAME and HEAD as appropriate. +# 1.3.1 - Bugfix Release + +* 941e4455 - fix(pact_consumer): Plugin config needs to be stored for both the request and response part of HTTP interactions (Ronald Holshausen, Tue Aug 27 15:35:16 2024 +1000) +* dae427a7 - chore: Upgrade pact_mock_server to 2.0.1 (Ronald Holshausen, Tue Aug 27 15:23:18 2024 +1000) +* dc441709 - chore: Upgrade pact_matching to 1.2.7 (Ronald Holshausen, Tue Aug 27 14:57:12 2024 +1000) +* 978677cc - chore: Upgrade pact_matching to 1.2.6 (Ronald Holshausen, Tue Aug 13 15:27:49 2024 +1000) +* 9a7eef75 - chore: Upgrade pact_models to 1.2.4 (Ronald Holshausen, Tue Aug 13 11:51:06 2024 +1000) +* bcf4db6d - chore: Upgrade pact_models to 1.2.3 (Ronald Holshausen, Tue Aug 6 11:06:22 2024 +1000) +* 00efcb56 - chore: Update readme (Ronald Holshausen, Mon Jul 29 11:01:32 2024 +1000) +* c91bb0ca - bump version to 1.3.1 (Ronald Holshausen, Mon Jul 29 10:27:31 2024 +1000) + # 1.3.0 - Update to 2.0 Pact mock server * d46af23e - feat(pact-consumer): Give each mock server 2 worker threads (Ronald Holshausen, Mon Jul 29 10:03:38 2024 +1000) From 73a1910038f518b93361219eb6e432dbab3a8f7d Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 27 Aug 2024 15:40:56 +1000 Subject: [PATCH 35/53] bump version to 1.3.2 --- 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 950a62e78..72aab729a 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -2034,7 +2034,7 @@ dependencies = [ [[package]] name = "pact_consumer" -version = "1.3.1" +version = "1.3.2" dependencies = [ "anyhow", "async-trait", diff --git a/rust/pact_consumer/Cargo.toml b/rust/pact_consumer/Cargo.toml index deceac73d..9ed052661 100644 --- a/rust/pact_consumer/Cargo.toml +++ b/rust/pact_consumer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pact_consumer" -version = "1.3.1" +version = "1.3.2" authors = ["Ronald Holshausen ", "Eric Kidd "] edition = "2021" description = "Pact-Rust module that provides support for writing consumer pact tests" From eb687a551b9752ac2cec4622284fb6b8e8d17d70 Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Fri, 30 Aug 2024 13:01:02 +1000 Subject: [PATCH 36/53] fix(ffi): annotate body in raw body branch If the content type was not otherwise handled, `OptionalBody::from(&str)` was used. This sets the content type associated with the body to `None` irrespective of the content type passed through to `process_body`. This fixes the issue by ensuring the `OptionalBody::Present` is created with the appropriate content type. Signed-off-by: JP-Ellis --- rust/pact_ffi/src/mock_server/handles.rs | 42 +++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/rust/pact_ffi/src/mock_server/handles.rs b/rust/pact_ffi/src/mock_server/handles.rs index 6f261e230..56da1796a 100644 --- a/rust/pact_ffi/src/mock_server/handles.rs +++ b/rust/pact_ffi/src/mock_server/handles.rs @@ -1730,7 +1730,11 @@ fn process_body( _ => { // We either have no content type, or an unsupported content type. trace!("Raw body"); - OptionalBody::from(body) + if body.is_empty() { + OptionalBody::Empty + } else { + OptionalBody::Present(Bytes::from(body.to_owned()), content_type, None) + } } } } @@ -4305,5 +4309,41 @@ mod tests { "$.id" => Generator::RandomInt(0, 1000) } }); + } + + /// See https://github.com/pact-foundation/pact-php/pull/626 + /// and https://github.com/pact-foundation/pact-reference/pull/461 + #[test] + fn annotate_raw_body_branch() { + let pact_handle = PactHandle::new("Consumer", "Provider"); + let description = CString::new("Generator Test").unwrap(); + let i_handle = pactffi_new_interaction(pact_handle, description.as_ptr()); + + let body = CString::new("a=1&b=2&c=3").unwrap(); + let content_type = CString::new("application/x-www-form-urlencoded").unwrap(); + let result = pactffi_with_body( + i_handle, + InteractionPart::Request, + content_type.as_ptr(), + body.as_ptr(), + ); + assert!(result); + + let interaction = i_handle + .with_interaction(&|_, _, inner| inner.as_v4_http().unwrap()) + .unwrap(); + + assert_eq!( + interaction + .request + .headers + .expect("no headers found") + .get("Content-Type"), + Some(&vec!["application/x-www-form-urlencoded".to_string()]) + ); + assert_eq!( + interaction.request.body.value(), + Some(Bytes::from("a=1&b=2&c=3")) + ) } } From bedea2aea9f713c52d1f6e93e490d64c558eb135 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 3 Sep 2024 15:44:39 +1000 Subject: [PATCH 37/53] chore: Update dependencies --- rust/Cargo.lock | 185 ++++++++++++++++++++++-------------------------- 1 file changed, 83 insertions(+), 102 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 72aab729a..de440248b 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -173,18 +173,18 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] name = "async-trait" -version = "0.1.81" +version = "0.1.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -218,7 +218,7 @@ checksum = "edf3ee19dbc0a46d740f6f0926bde8c50f02bdbc7b536842da28f6ac56513a8b" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -642,7 +642,7 @@ dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", "strsim 0.11.1", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -653,7 +653,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote 1.0.37", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -691,7 +691,7 @@ checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -725,7 +725,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -821,9 +821,9 @@ checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "filetime" -version = "0.2.24" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf401df4a4e3872c4fe8151134cf483738e74b67fc934d6532c882b3d24a4550" +checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" dependencies = [ "cfg-if", "libc", @@ -928,7 +928,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -1030,7 +1030,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.4.0", + "indexmap 2.5.0", "slab", "tokio", "tokio-util", @@ -1049,7 +1049,7 @@ dependencies = [ "futures-core", "futures-sink", "http 1.1.0", - "indexmap 2.4.0", + "indexmap 2.5.0", "slab", "tokio", "tokio-util", @@ -1289,7 +1289,7 @@ dependencies = [ "hyper-util", "log", "rustls 0.23.12", - "rustls-native-certs 0.7.2", + "rustls-native-certs 0.7.3", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -1382,9 +1382,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" +checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ "equivalent", "hashbrown 0.14.5", @@ -1411,7 +1411,7 @@ dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", "strum", - "syn 2.0.76", + "syn 2.0.77", "thiserror", ] @@ -1621,7 +1621,7 @@ dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", "regex-syntax 0.6.29", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -1924,9 +1924,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.36.3" +version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" +checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" dependencies = [ "memchr", ] @@ -1992,9 +1992,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "pact-plugin-driver" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "337cfac055cf94b9679170821a6ab0e474ec88b129897921ad770467028bfea5" +checksum = "d522f37b56bea8d219fde70740a7cfe1c6c5f2f81ad03cab49121da6bf0d2477" dependencies = [ "anyhow", "async-trait", @@ -2221,7 +2221,7 @@ dependencies = [ "rcgen", "rustls 0.23.12", "rustls-pemfile 2.1.3", - "rustls-webpki 0.102.6", + "rustls-webpki 0.102.7", "serde", "serde_json", "thiserror", @@ -2427,7 +2427,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.4.0", + "indexmap 2.5.0", ] [[package]] @@ -2485,7 +2485,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -2544,16 +2544,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" dependencies = [ "proc-macro2 1.0.86", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] name = "proc-macro-crate" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ - "toml_edit 0.21.1", + "toml_edit", ] [[package]] @@ -2576,9 +2576,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13db3d3fde688c61e2446b4d843bc27a7e8af269a69440c0308021dc92333cc" +checksum = "3b2ecbe40f08db5c006b5764a2645f7f3f141ce756412ac9e1dd6087e6d32995" dependencies = [ "bytes", "prost-derive", @@ -2586,9 +2586,9 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bb182580f71dd070f88d01ce3de9f4da5021db7115d2e1c3605a754153b77c1" +checksum = "f8650aabb6c35b860610e9cff5dc1af886c9e25073b7b1712a68972af4281302" dependencies = [ "bytes", "heck", @@ -2601,28 +2601,28 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.76", + "syn 2.0.77", "tempfile", ] [[package]] name = "prost-derive" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18bec9b0adc4eba778b33684b7ba3e7137789434769ee3ce3930463ef904cfca" +checksum = "acf0c195eebb4af52c752bec4f52f645da98b6e92077a04110c7f349477ae5ac" dependencies = [ "anyhow", "itertools 0.13.0", "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] name = "prost-types" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee5168b05f49d4b0ca581206eb14a7b22fafd963efe729ac48eb03266e25cc2" +checksum = "60caa6738c7369b940c3d49246a8d1749323674c65cb13010134f5c9bad5b519" dependencies = [ "prost", ] @@ -2649,9 +2649,9 @@ dependencies = [ [[package]] name = "quinn" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b22d8e7369034b9a7132bc2008cac12f2013c8132b45e0554e6e20e2617f2156" +checksum = "a2d2fb862b7ba45e615c1429def928f2e15f815bdf933b27a2d3824e224c1f46" dependencies = [ "bytes", "pin-project-lite", @@ -2667,9 +2667,9 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.6" +version = "0.11.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba92fb39ec7ad06ca2582c0ca834dfeadcaf06ddfc8e635c80aa7e1c05315fdd" +checksum = "ea0a9b3a42929fad8a7c3de7f86ce0814cfa893328157672680e9fb1145549c5" dependencies = [ "bytes", "rand", @@ -2872,7 +2872,7 @@ dependencies = [ "pin-project-lite", "quinn", "rustls 0.23.12", - "rustls-native-certs 0.7.2", + "rustls-native-certs 0.7.3", "rustls-pemfile 2.1.3", "rustls-pki-types", "serde", @@ -2943,7 +2943,7 @@ dependencies = [ "regex", "relative-path", "rustc_version", - "syn 2.0.76", + "syn 2.0.77", "unicode-ident", ] @@ -2961,7 +2961,7 @@ dependencies = [ "regex", "relative-path", "rustc_version", - "syn 2.0.76", + "syn 2.0.77", "unicode-ident", ] @@ -2979,18 +2979,18 @@ checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver", ] [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "a85d50532239da68e9addb745ba38ff4612a242c1c7ceea689c4bc7c2f43c36f" dependencies = [ "bitflags 2.6.0", "errno", @@ -3021,7 +3021,7 @@ dependencies = [ "once_cell", "ring", "rustls-pki-types", - "rustls-webpki 0.102.6", + "rustls-webpki 0.102.7", "subtle", "zeroize", ] @@ -3040,9 +3040,9 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04182dffc9091a404e0fc069ea5cd60e5b866c3adf881eff99a32d048242dffa" +checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" dependencies = [ "openssl-probe", "rustls-pemfile 2.1.3", @@ -3088,9 +3088,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.6" +version = "0.102.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e" +checksum = "84678086bd54edf2b415183ed7a94d0efb049f1b646a33e22a36f3794be6ae56" dependencies = [ "ring", "rustls-pki-types", @@ -3189,7 +3189,7 @@ checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3235,7 +3235,7 @@ dependencies = [ "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.4.0", + "indexmap 2.5.0", "serde", "serde_derive", "serde_json", @@ -3252,7 +3252,7 @@ dependencies = [ "darling", "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3433,7 +3433,7 @@ dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", "rustversion", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3476,9 +3476,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.76" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", @@ -3568,7 +3568,7 @@ checksum = "5999e24eaa32083191ba4e425deb75cdf25efefabe5aaccb7446dd0d4122a3f5" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3597,7 +3597,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3658,9 +3658,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.3" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", @@ -3682,7 +3682,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3752,7 +3752,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.20", + "toml_edit", ] [[package]] @@ -3764,28 +3764,17 @@ dependencies = [ "serde", ] -[[package]] -name = "toml_edit" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" -dependencies = [ - "indexmap 2.4.0", - "toml_datetime", - "winnow 0.5.40", -] - [[package]] name = "toml_edit" version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ - "indexmap 2.4.0", + "indexmap 2.5.0", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.18", + "winnow", ] [[package]] @@ -3828,7 +3817,7 @@ dependencies = [ "proc-macro2 1.0.86", "prost-build", "quote 1.0.37", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3881,7 +3870,7 @@ source = "git+https://github.com/tokio-rs/tracing.git?tag=tracing-subscriber-0.3 dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3959,10 +3948,11 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "trycmd" -version = "0.15.6" +version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e8673f1dc45acdff8e25a06cc62f8e529563e8acd84237ce83d5a28e2befa12" +checksum = "288c25d9be00f5ac52a3b3ff7720248c223096534ec34e870188f1bc93f2465c" dependencies = [ + "anstream", "automod", "glob", "humantime", @@ -3971,7 +3961,7 @@ dependencies = [ "serde", "shlex", "snapbox", - "toml_edit 0.22.20", + "toml_edit", ] [[package]] @@ -4160,7 +4150,7 @@ dependencies = [ "once_cell", "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.76", + "syn 2.0.77", "wasm-bindgen-shared", ] @@ -4194,7 +4184,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.76", + "syn 2.0.77", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4230,9 +4220,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.3" +version = "0.26.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" +checksum = "0bd24728e5af82c6c4ec1b66ac4844bdf8156257fccda846ec58b42cd0cdbe6a" dependencies = [ "rustls-pki-types", ] @@ -4399,15 +4389,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "winnow" -version = "0.5.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" -dependencies = [ - "memchr", -] - [[package]] name = "winnow" version = "0.6.18" @@ -4467,7 +4448,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -4487,7 +4468,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -4506,7 +4487,7 @@ dependencies = [ "displaydoc", "flate2", "hmac", - "indexmap 2.4.0", + "indexmap 2.5.0", "lzma-rs", "memchr", "pbkdf2", From c1a00dd805dbe5db049c0035e82b637ea0310f18 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Tue, 3 Sep 2024 15:47:22 +1000 Subject: [PATCH 38/53] chore: Upgrade pact-plugin-driver to 0.7.1 --- rust/pact_consumer/Cargo.toml | 2 +- rust/pact_ffi/Cargo.toml | 2 +- rust/pact_matching/Cargo.toml | 2 +- rust/pact_verifier/Cargo.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rust/pact_consumer/Cargo.toml b/rust/pact_consumer/Cargo.toml index 9ed052661..93bf1fc1c 100644 --- a/rust/pact_consumer/Cargo.toml +++ b/rust/pact_consumer/Cargo.toml @@ -33,7 +33,7 @@ maplit = "1.0.2" pact_matching = { version = "~1.2.7", path = "../pact_matching", default-features = false } pact_mock_server = { version = "~2.0.1", default-features = false } pact_models = { version = "~1.2.4", default-features = false } -pact-plugin-driver = { version = "~0.7.0", optional = true, default-features = false } +pact-plugin-driver = { version = "~0.7.1", optional = true, default-features = false } regex = "1.10.5" serde_json = "1.0.120" termsize = "0.1.8" diff --git a/rust/pact_ffi/Cargo.toml b/rust/pact_ffi/Cargo.toml index 635a2e7fa..df29a407e 100644 --- a/rust/pact_ffi/Cargo.toml +++ b/rust/pact_ffi/Cargo.toml @@ -33,7 +33,7 @@ onig = { version = "6.4.0", default-features = false } pact_matching = { version = "~1.2.7", path = "../pact_matching" } pact_mock_server = { version = "~1.2.9" } pact_models = { version = "~1.2.4" } -pact-plugin-driver = { version = "~0.7.0" } +pact-plugin-driver = { version = "~0.7.1" } pact_verifier = { version = "~1.2.4", path = "../pact_verifier" } panic-message = "0.3.0" rand = "0.8.5" diff --git a/rust/pact_matching/Cargo.toml b/rust/pact_matching/Cargo.toml index b76369a9d..73f40c34c 100644 --- a/rust/pact_matching/Cargo.toml +++ b/rust/pact_matching/Cargo.toml @@ -42,7 +42,7 @@ 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.4", default-features = false } -pact-plugin-driver = { version = "~0.7.0", optional = true, default-features = false } +pact-plugin-driver = { version = "~0.7.1", optional = true, default-features = false } rand = "0.8.5" reqwest = { version = "0.12.3", default-features = false, features = ["rustls-tls-native-roots", "json"] } semver = "1.0.22" diff --git a/rust/pact_verifier/Cargo.toml b/rust/pact_verifier/Cargo.toml index 1d0701d9e..c92994959 100644 --- a/rust/pact_verifier/Cargo.toml +++ b/rust/pact_verifier/Cargo.toml @@ -37,7 +37,7 @@ maplit = "1.0.2" mime = "0.3.17" pact_matching = { version = "~1.2.7", path = "../pact_matching", default-features = false } pact_models = { version = "~1.2.4", default-features = false } -pact-plugin-driver = { version = "~0.7.0", optional = true, default-features = false } +pact-plugin-driver = { version = "~0.7.1", optional = true, default-features = false } regex = "1.10.4" reqwest = { version = "0.12.3", default-features = false, features = ["rustls-tls-native-roots", "blocking", "json"] } serde = "1.0.197" From cbd167b63ed70cca58621c9dd5a276daf4e4109b Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 4 Sep 2024 10:59:27 +1000 Subject: [PATCH 39/53] chore(pact_consumer): Upgrade pact_mock_server to 2.0.2 --- rust/Cargo.lock | 26 +++++++++++++------------- rust/pact_consumer/Cargo.toml | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index de440248b..9ce2d8d15 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -2047,7 +2047,7 @@ dependencies = [ "maplit", "pact-plugin-driver", "pact_matching", - "pact_mock_server 2.0.1", + "pact_mock_server 2.0.2", "pact_models", "pretty_assertions", "quickcheck", @@ -2093,7 +2093,7 @@ dependencies = [ "os_info", "pact-plugin-driver", "pact_matching", - "pact_mock_server 1.2.9", + "pact_mock_server 1.2.10", "pact_models", "pact_verifier", "panic-message", @@ -2171,9 +2171,9 @@ dependencies = [ [[package]] name = "pact_mock_server" -version = "1.2.9" +version = "1.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "392cbfdaa5a60b8edc1f53ae2cad06afce6a32a4f1667c53f4f2e342ed765539" +checksum = "c5174092ffb815793abdbf8ade73f2d4aad4e4e21c247ee2f28ec783487eed3a" dependencies = [ "anyhow", "bytes", @@ -2201,9 +2201,9 @@ dependencies = [ [[package]] name = "pact_mock_server" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35d2863820744a8c361fc23a8cafbc11798a6e5856410e0ec9c66a0d34599a71" +checksum = "9edf52ddfc8b2d6c9a38066b66a7775e69b93aaaf6def1b23efa04cdd3d25554" dependencies = [ "anyhow", "bytes", @@ -2649,9 +2649,9 @@ dependencies = [ [[package]] name = "quinn" -version = "0.11.4" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2d2fb862b7ba45e615c1429def928f2e15f815bdf933b27a2d3824e224c1f46" +checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" dependencies = [ "bytes", "pin-project-lite", @@ -2667,9 +2667,9 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.7" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea0a9b3a42929fad8a7c3de7f86ce0814cfa893328157672680e9fb1145549c5" +checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" dependencies = [ "bytes", "rand", @@ -2684,15 +2684,15 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bffec3605b73c6f1754535084a85229fa8a30f86014e6c81aeec4abb68b0285" +checksum = "4fe68c2e9e1a1234e218683dbdf9f9dfcb094113c5ac2b938dfcb9bab4c4140b" dependencies = [ "libc", "once_cell", "socket2", "tracing", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] diff --git a/rust/pact_consumer/Cargo.toml b/rust/pact_consumer/Cargo.toml index 93bf1fc1c..e347cb457 100644 --- a/rust/pact_consumer/Cargo.toml +++ b/rust/pact_consumer/Cargo.toml @@ -31,7 +31,7 @@ itertools = "0.13.0" lazy_static = "1.5.0" maplit = "1.0.2" pact_matching = { version = "~1.2.7", path = "../pact_matching", default-features = false } -pact_mock_server = { version = "~2.0.1", default-features = false } +pact_mock_server = { version = "~2.0.2", default-features = false } pact_models = { version = "~1.2.4", default-features = false } pact-plugin-driver = { version = "~0.7.1", optional = true, default-features = false } regex = "1.10.5" From 4604729dde28c5ac051be75f1c7ed6988d17b1f3 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 4 Sep 2024 11:01:33 +1000 Subject: [PATCH 40/53] chore(pact_consumer): Update dependencies --- rust/pact_consumer/Cargo.toml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/rust/pact_consumer/Cargo.toml b/rust/pact_consumer/Cargo.toml index e347cb457..c0ded63eb 100644 --- a/rust/pact_consumer/Cargo.toml +++ b/rust/pact_consumer/Cargo.toml @@ -24,8 +24,8 @@ colour = ["dep:yansi"] [dependencies] anyhow = "1.0.86" -async-trait = "0.1.81" -bytes = "1.6.1" +async-trait = "0.1.82" +bytes = "1.7.1" futures = "0.3.30" itertools = "0.13.0" lazy_static = "1.5.0" @@ -34,10 +34,10 @@ pact_matching = { version = "~1.2.7", path = "../pact_matching", default-feature pact_mock_server = { version = "~2.0.2", default-features = false } pact_models = { version = "~1.2.4", default-features = false } pact-plugin-driver = { version = "~0.7.1", optional = true, default-features = false } -regex = "1.10.5" -serde_json = "1.0.120" -termsize = "0.1.8" -tokio = { version = "1.38.0", features = ["full"] } +regex = "1.10.6" +serde_json = "1.0.127" +termsize = "0.1.9" +tokio = { version = "1.40.0", features = ["full"] } tracing = "0.1.40" tracing-core = "0.1.32" url = "2.5.2" @@ -46,10 +46,10 @@ yansi = { version = "1.0.1", optional = true } [dev-dependencies] quickcheck = "1.0.3" -env_logger = "0.11.3" +env_logger = "0.11.5" expectest = "0.12.0" -reqwest = { version = "0.12.5", default-features = false, features = ["rustls-tls-native-roots", "blocking", "json"] } -serde = { version = "1.0.204", features = ["derive"] } +reqwest = { version = "0.12.7", default-features = false, features = ["rustls-tls-native-roots", "blocking", "json"] } +serde = { version = "1.0.209", features = ["derive"] } rand = "0.8.5" tokio-test = "0.4.4" test-log = { version = "0.2.16", features = ["trace"] } From 3cb09550b402f002fcebc0e568216bc3209291bd Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 4 Sep 2024 11:09:27 +1000 Subject: [PATCH 41/53] chore(pact_ffi): Update dependencies --- rust/pact_ffi/Cargo.toml | 42 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/rust/pact_ffi/Cargo.toml b/rust/pact_ffi/Cargo.toml index df29a407e..3cb59281d 100644 --- a/rust/pact_ffi/Cargo.toml +++ b/rust/pact_ffi/Cargo.toml @@ -15,50 +15,50 @@ exclude = [ [dependencies] ansi_term = "0.12.1" -anyhow = "1.0.75" -bytes = "1.5.0" -chrono = "0.4.31" +anyhow = "1.0.86" +bytes = "1.7.1" +chrono = "0.4.38" chrono-tz = "0.9.0" clap = "2.34.0" -either = "1.9.0" -env_logger = "0.11.3" -futures = "0.3.29" +either = "1.13.0" +env_logger = "0.11.5" +futures = "0.3.30" itertools = "0.13.0" -lazy_static = "1.4.0" -libc = "0.2.151" -log = "0.4.20" +lazy_static = "1.5.0" +libc = "0.2.158" +log = "0.4.22" 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.7", path = "../pact_matching" } -pact_mock_server = { version = "~1.2.9" } +pact_mock_server = { version = "~1.2.10" } pact_models = { version = "~1.2.4" } pact-plugin-driver = { version = "~0.7.1" } pact_verifier = { version = "~1.2.4", path = "../pact_verifier" } panic-message = "0.3.0" rand = "0.8.5" rand_regex = "0.15.1" -regex = "1.10.2" +regex = "1.10.6" regex-syntax = "0.6.29" -serde = { version = "1.0.193", features = ["derive"] } -serde_json = "1.0.108" +serde = { version = "1.0.209", features = ["derive"] } +serde_json = "1.0.127" sxd-document = "0.3.2" -thiserror = "1.0.51" -tokio = { version = "1.35.1", features = ["full"] } +thiserror = "1.0.63" +tokio = { version = "1.40.0", features = ["full"] } tokio-rustls = "0.24.1" tracing = "0.1.40" # This needs to be the same version across all the libs (i.e. plugin driver) tracing-core = "0.1.32" # This needs to be the same version across all the pact libs (i.e. plugin driver) tracing-log = "0.2.0" tracing-subscriber = { version = "0.3.18", features = ["env-filter", "tracing-log"] } -uuid = { version = "1.6.1", features = ["v4"] } -zeroize = "1.7.0" +uuid = { version = "1.10.0", features = ["v4"] } +zeroize = "1.8.1" [dev-dependencies] expectest = "0.12.0" -reqwest = { version = "0.12.4", default-features = false, features = ["rustls-tls-native-roots", "blocking", "json"] } +reqwest = { version = "0.12.7", default-features = false, features = ["rustls-tls-native-roots", "blocking", "json"] } quickcheck = "1.0.3" -test-log = "0.2.14" -tempfile = "3.8.1" +test-log = "0.2.16" +tempfile = "3.12.0" home = "0.5.9" pretty_assertions = "1.4.0" rstest = "0.22.0" @@ -67,4 +67,4 @@ rstest = "0.22.0" crate-type = ["cdylib", "staticlib", "rlib"] [build-dependencies] -os_info = { version = "3.7.0", default-features = false } +os_info = { version = "3.8.2", default-features = false } From dd9891262a1344964c0f945f6ef15c69bd730b2c Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 4 Sep 2024 15:18:17 +1000 Subject: [PATCH 42/53] update changelog for release 0.4.23 --- rust/pact_ffi/CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/rust/pact_ffi/CHANGELOG.md b/rust/pact_ffi/CHANGELOG.md index 3466b6b0e..3b71f5c77 100644 --- a/rust/pact_ffi/CHANGELOG.md +++ b/rust/pact_ffi/CHANGELOG.md @@ -1,5 +1,20 @@ To generate the log, run `git log --pretty='* %h - %s (%an, %ad)' TAGNAME..HEAD .` replacing TAGNAME and HEAD as appropriate. +# 0.4.23 - Bugfix Release + +* 3cb09550 - chore(pact_ffi): Update dependencies (Ronald Holshausen, Wed Sep 4 11:09:27 2024 +1000) +* c1a00dd8 - chore: Upgrade pact-plugin-driver to 0.7.1 (Ronald Holshausen, Tue Sep 3 15:47:22 2024 +1000) +* eb687a55 - fix(ffi): annotate body in raw body branch (JP-Ellis, Fri Aug 30 13:01:02 2024 +1000) +* dc441709 - chore: Upgrade pact_matching to 1.2.7 (Ronald Holshausen, Tue Aug 27 14:57:12 2024 +1000) +* fa02c30b - chore: Upgrade pact_verifier to 1.2.4 (Ronald Holshausen, Tue Aug 13 15:42:48 2024 +1000) +* 978677cc - chore: Upgrade pact_matching to 1.2.6 (Ronald Holshausen, Tue Aug 13 15:27:49 2024 +1000) +* f50454ff - chore: Upgrade test dependencies (Ronald Holshausen, Tue Aug 13 11:54:59 2024 +1000) +* 9a7eef75 - chore: Upgrade pact_models to 1.2.4 (Ronald Holshausen, Tue Aug 13 11:51:06 2024 +1000) +* bcf4db6d - chore: Upgrade pact_models to 1.2.3 (Ronald Holshausen, Tue Aug 6 11:06:22 2024 +1000) +* 4d7295a4 - feat: allow non-object matchers for array-contains (M. J. W-H. Campman, Sat Aug 3 13:49:18 2024 -0400) +* 033a50ab - feat: Update the matching rule expression parser to support values from provider states (Ronald Holshausen, Fri Aug 2 10:06:52 2024 +1000) +* fd1ba0c3 - bump version to 0.4.23 (Ronald Holshausen, Thu Jul 18 15:51:48 2024 +1000) + # 0.4.22 - Bugfix Release * 4257ed1e - chore: Upgrade pact_verifier to 1.2.3 (Ronald Holshausen, Wed Jul 17 15:19:58 2024 +1000) From 8350e4d363d1eec52be79377bd22ab4ea8161b3c Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 4 Sep 2024 15:19:59 +1000 Subject: [PATCH 43/53] bump version to 0.4.24 --- rust/Cargo.lock | 2 +- rust/pact_ffi/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 9ce2d8d15..b6d0de285 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -2070,7 +2070,7 @@ dependencies = [ [[package]] name = "pact_ffi" -version = "0.4.23" +version = "0.4.24" dependencies = [ "ansi_term", "anyhow", diff --git a/rust/pact_ffi/Cargo.toml b/rust/pact_ffi/Cargo.toml index 3cb59281d..865df2c23 100644 --- a/rust/pact_ffi/Cargo.toml +++ b/rust/pact_ffi/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pact_ffi" -version = "0.4.23" +version = "0.4.24" authors = ["Ronald Holshausen ", "Matt Fellows ", "Andrew Lilley Brinker ", "Caleb Stepanian "] edition = "2021" description = "Pact interface for foreign languages." From 187701071a5c08e703e5eb345981f2237b9a3f3e Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 4 Sep 2024 15:44:03 +1000 Subject: [PATCH 44/53] chore: Add deprecation notice to the functions that use LOG_ID --- rust/pact_matching/src/logging.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rust/pact_matching/src/logging.rs b/rust/pact_matching/src/logging.rs index afc37ee33..818b72ff5 100644 --- a/rust/pact_matching/src/logging.rs +++ b/rust/pact_matching/src/logging.rs @@ -17,16 +17,19 @@ lazy_static! { /// Accumulates the log entries against a task local ID. If the ID is not set, accumulates against /// the "global" ID. /// cbindgen:ignore + #[deprecated(note = "This must be moved to the FFI crate")] static ref LOG_BUFFER: Mutex> = Mutex::new(HashMap::new()); } task_local! { /// Log ID to accumulate logs against #[allow(missing_docs)] + #[deprecated(note = "This must be moved to the FFI crate")] pub static LOG_ID: String; } /// Fetches the contents from the id scoped in-memory buffer and empties the buffer. +#[deprecated(note = "This must be moved to the FFI crate")] pub fn fetch_buffer_contents(id: &str) -> Bytes { let mut inner = LOG_BUFFER.lock().unwrap(); let buffer = inner.entry(id.to_string()) @@ -36,6 +39,7 @@ pub fn fetch_buffer_contents(id: &str) -> Bytes { /// Writes the provided bytes to the task local ID scoped in-memory buffer. If there is no /// task local ID set, will write to the "global" buffer. +#[deprecated(note = "This must be moved to the FFI crate")] pub fn write_to_log_buffer(buf: &[u8]) { let id = LOG_ID.try_with(|id| id.clone()).unwrap_or_else(|_| "global".into()); let mut inner = LOG_BUFFER.lock().unwrap(); From 8a5150e05aad256e2f0a7cb9270619732f60f579 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 4 Sep 2024 15:50:51 +1000 Subject: [PATCH 45/53] chore: Copy the in-mem logging functions to the FFI crate --- rust/pact_ffi/src/log/inmem_buffer.rs | 43 +++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/rust/pact_ffi/src/log/inmem_buffer.rs b/rust/pact_ffi/src/log/inmem_buffer.rs index aa97c01d1..bbf978718 100644 --- a/rust/pact_ffi/src/log/inmem_buffer.rs +++ b/rust/pact_ffi/src/log/inmem_buffer.rs @@ -1,10 +1,14 @@ //! In-memory buffer for logging output. +use std::collections::HashMap; use std::io; use std::io::Write; -use tracing_subscriber::fmt::MakeWriter; +use std::sync::Mutex; -use pact_matching::logging::write_to_log_buffer; +use bytes::{BufMut, Bytes, BytesMut}; +use lazy_static::lazy_static; +use tokio::task_local; +use tracing_subscriber::fmt::MakeWriter; /// In-memory buffer for logging output. Sends output to global static `LOG_BUFFER` in the pact_matching /// crate. If there is a task local ID found, will accumulate against that ID, otherwise will @@ -31,3 +35,38 @@ impl <'a> MakeWriter<'a> for InMemBuffer { *self } } + +lazy_static! { + /// Memory buffer for the buffer logger. This is needed here because there is no + /// way to get the logger sync from the Dispatch struct. The buffer will be emptied + /// when the contents is fetched via an FFI call. + /// + /// Accumulates the log entries against a task local ID. If the ID is not set, accumulates against + /// the "global" ID. + /// cbindgen:ignore + static ref LOG_BUFFER: Mutex> = Mutex::new(HashMap::new()); +} + +task_local! { + /// Log ID to accumulate logs against + #[allow(missing_docs)] + pub static LOG_ID: String; +} + +/// Fetches the contents from the id scoped in-memory buffer and empties the buffer. +pub fn fetch_buffer_contents(id: &str) -> Bytes { + let mut inner = LOG_BUFFER.lock().unwrap(); + let buffer = inner.entry(id.to_string()) + .or_insert_with(|| BytesMut::with_capacity(256)); + buffer.split().freeze() +} + +/// Writes the provided bytes to the task local ID scoped in-memory buffer. If there is no +/// task local ID set, will write to the "global" buffer. +pub fn write_to_log_buffer(buf: &[u8]) { + let id = LOG_ID.try_with(|id| id.clone()).unwrap_or_else(|_| "global".into()); + let mut inner = LOG_BUFFER.lock().unwrap(); + let buffer = inner.entry(id) + .or_insert_with(|| BytesMut::with_capacity(256)); + buffer.put(buf); +} From edc6a23e278a269009c345171cfd19aad8c49aa2 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 4 Sep 2024 15:53:01 +1000 Subject: [PATCH 46/53] chore: Copy the in-mem logging functions to the FFI crate --- rust/pact_ffi/src/log/inmem_buffer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/pact_ffi/src/log/inmem_buffer.rs b/rust/pact_ffi/src/log/inmem_buffer.rs index bbf978718..45f61374d 100644 --- a/rust/pact_ffi/src/log/inmem_buffer.rs +++ b/rust/pact_ffi/src/log/inmem_buffer.rs @@ -18,7 +18,7 @@ pub(crate) struct InMemBuffer { } impl Write for InMemBuffer { fn write(&mut self, buf: &[u8]) -> io::Result { - write_to_log_buffer(buf); + pact_matching::logging::write_to_log_buffer(buf); Ok(buf.len()) } From 16861857f98b10e292c3c30df4df90d0d3d62eb8 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Wed, 4 Sep 2024 16:04:50 +1000 Subject: [PATCH 47/53] chore: Replicate setting the LOG_ID in the FFI verify functions --- rust/pact_ffi/src/verifier/handle.rs | 6 +++--- rust/pact_ffi/src/verifier/verifier.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rust/pact_ffi/src/verifier/handle.rs b/rust/pact_ffi/src/verifier/handle.rs index a6679c1d1..8b3dca3cb 100644 --- a/rust/pact_ffi/src/verifier/handle.rs +++ b/rust/pact_ffi/src/verifier/handle.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use itertools::Itertools; use serde_json::Value; use tracing::{debug, error}; - +use pact_matching::logging::LOG_ID; use pact_models::prelude::HttpAuth; use pact_verifier::{ConsumerVersionSelector, FilterInfo, NullRequestFilterExecutor, PactSource, ProviderInfo, ProviderTransport, PublishOptions, VerificationOptions, verify_provider_async}; use pact_verifier::callback_executors::HttpRequestProviderStateExecutor; @@ -286,7 +286,7 @@ impl VerifierHandle { let (calling_app_name, calling_app_version) = self.calling_app.clone().unwrap_or_else(|| { ("pact_ffi".to_string(), env!("CARGO_PKG_VERSION").to_string()) }); - match RUNTIME.block_on(async { + match RUNTIME.block_on(LOG_ID.scope(format!("verify:{}", self.provider.name), async { verify_provider_async( self.provider.clone(), self.sources.clone(), @@ -301,7 +301,7 @@ impl VerifierHandle { app_version: calling_app_version.clone() }) ).await - }) { + })) { Ok(result) => { self.verifier_output = result.clone(); if result.result { 0 } else { 1 } diff --git a/rust/pact_ffi/src/verifier/verifier.rs b/rust/pact_ffi/src/verifier/verifier.rs index a20951cb3..527cc2643 100644 --- a/rust/pact_ffi/src/verifier/verifier.rs +++ b/rust/pact_ffi/src/verifier/verifier.rs @@ -13,7 +13,7 @@ use pact_models::PactSpecification; use tracing::{debug, error, warn}; use tracing_core::LevelFilter; use tracing_subscriber::FmtSubscriber; - +use pact_matching::logging::LOG_ID; use pact_verifier::*; use pact_verifier::callback_executors::HttpRequestProviderStateExecutor; use pact_verifier::metrics::VerificationMetrics; @@ -247,7 +247,7 @@ async fn handle_matches(matches: &clap::ArgMatches<'_>) -> Result<(), i32> { debug!("Pact source to verify = {}", s); }; - verify_provider_async( + LOG_ID.scope(format!("verify:{}", provider.name), verify_provider_async( provider, source, filter, @@ -260,7 +260,7 @@ async fn handle_matches(matches: &clap::ArgMatches<'_>) -> Result<(), i32> { app_name: "unknown".to_string(), app_version: "unknown".to_string() }) - ).await + )).await .map_err(|err| { error!("Verification failed with error: {}", err); 2 From 9d3610dd11360f0bfab9969044213d0b1f508a49 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Thu, 5 Sep 2024 10:03:30 +1000 Subject: [PATCH 48/53] chore: Use the pact_matcing LOG_ID in the FFI inmem logging functions --- rust/pact_ffi/src/log/inmem_buffer.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/rust/pact_ffi/src/log/inmem_buffer.rs b/rust/pact_ffi/src/log/inmem_buffer.rs index 45f61374d..07e12bd66 100644 --- a/rust/pact_ffi/src/log/inmem_buffer.rs +++ b/rust/pact_ffi/src/log/inmem_buffer.rs @@ -7,7 +7,6 @@ use std::sync::Mutex; use bytes::{BufMut, Bytes, BytesMut}; use lazy_static::lazy_static; -use tokio::task_local; use tracing_subscriber::fmt::MakeWriter; /// In-memory buffer for logging output. Sends output to global static `LOG_BUFFER` in the pact_matching @@ -47,11 +46,13 @@ lazy_static! { static ref LOG_BUFFER: Mutex> = Mutex::new(HashMap::new()); } -task_local! { - /// Log ID to accumulate logs against - #[allow(missing_docs)] - pub static LOG_ID: String; -} +// TODO: This needs to be moved from pact_matching, but at the moment the mock server crate +// relies on it +// task_local! { +// /// Log ID to accumulate logs against +// #[allow(missing_docs)] +// pub static LOG_ID: String; +// } /// Fetches the contents from the id scoped in-memory buffer and empties the buffer. pub fn fetch_buffer_contents(id: &str) -> Bytes { @@ -64,7 +65,9 @@ pub fn fetch_buffer_contents(id: &str) -> Bytes { /// Writes the provided bytes to the task local ID scoped in-memory buffer. If there is no /// task local ID set, will write to the "global" buffer. pub fn write_to_log_buffer(buf: &[u8]) { - let id = LOG_ID.try_with(|id| id.clone()).unwrap_or_else(|_| "global".into()); + let id = pact_matching::logging::LOG_ID + .try_with(|id| id.clone()) + .unwrap_or_else(|_| "global".into()); let mut inner = LOG_BUFFER.lock().unwrap(); let buffer = inner.entry(id) .or_insert_with(|| BytesMut::with_capacity(256)); From f5228c52b0880204c68e00f2997cd3d87acfeb4e Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Thu, 5 Sep 2024 10:14:50 +1000 Subject: [PATCH 49/53] chore: Use the inmem logging functions in the FFI crate --- rust/pact_ffi/src/log/ffi.rs | 3 +-- rust/pact_ffi/src/log/inmem_buffer.rs | 2 +- rust/pact_ffi/src/log/mod.rs | 4 ++++ rust/pact_ffi/src/mock_server/mod.rs | 2 +- rust/pact_ffi/src/verifier/mod.rs | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/rust/pact_ffi/src/log/ffi.rs b/rust/pact_ffi/src/log/ffi.rs index 3bd3bbfe2..5f1bb40a3 100644 --- a/rust/pact_ffi/src/log/ffi.rs +++ b/rust/pact_ffi/src/log/ffi.rs @@ -8,9 +8,8 @@ use std::str::from_utf8; use libc::{c_char, c_int}; use log::{error, LevelFilter as LogLevelFilter}; -use pact_matching::logging::fetch_buffer_contents; - use crate::error::set_error_msg; +use crate::log::inmem_buffer::fetch_buffer_contents; use crate::log::level_filter::LevelFilter; use crate::log::logger::{add_sink, apply_logger, init_logger}; use crate::log::sink::Sink; diff --git a/rust/pact_ffi/src/log/inmem_buffer.rs b/rust/pact_ffi/src/log/inmem_buffer.rs index 07e12bd66..4df8ab0cb 100644 --- a/rust/pact_ffi/src/log/inmem_buffer.rs +++ b/rust/pact_ffi/src/log/inmem_buffer.rs @@ -17,7 +17,7 @@ pub(crate) struct InMemBuffer { } impl Write for InMemBuffer { fn write(&mut self, buf: &[u8]) -> io::Result { - pact_matching::logging::write_to_log_buffer(buf); + write_to_log_buffer(buf); Ok(buf.len()) } diff --git a/rust/pact_ffi/src/log/mod.rs b/rust/pact_ffi/src/log/mod.rs index b61b19983..b5df13c5b 100644 --- a/rust/pact_ffi/src/log/mod.rs +++ b/rust/pact_ffi/src/log/mod.rs @@ -17,3 +17,7 @@ pub use crate::log::ffi::{ pactffi_log_to_file, pactffi_log_to_buffer }; +pub use crate::log::inmem_buffer::{ + fetch_buffer_contents, + write_to_log_buffer +}; diff --git a/rust/pact_ffi/src/mock_server/mod.rs b/rust/pact_ffi/src/mock_server/mod.rs index 5377bb1be..2fd59b57f 100644 --- a/rust/pact_ffi/src/mock_server/mod.rs +++ b/rust/pact_ffi/src/mock_server/mod.rs @@ -63,7 +63,6 @@ use tokio_rustls::rustls::ServerConfig; use tracing::{error, warn}; use uuid::Uuid; -use pact_matching::logging::fetch_buffer_contents; use pact_matching::metrics::{MetricEvent, send_metrics}; use pact_mock_server::{MANAGER, mock_server_mismatches, MockServerError, tls::TlsConfigBuilder, WritePactFileErr}; use pact_mock_server::mock_server::MockServerConfig; @@ -72,6 +71,7 @@ use pact_models::generators::GeneratorCategory; use pact_models::matchingrules::{Category, MatchingRuleCategory}; use crate::{convert_cstr, ffi_fn, safe_str}; +use crate::log::fetch_buffer_contents; use crate::mock_server::handles::{PactHandle, path_from_dir}; use crate::string::optional_str; diff --git a/rust/pact_ffi/src/verifier/mod.rs b/rust/pact_ffi/src/verifier/mod.rs index dd2834e87..38ed1fa87 100644 --- a/rust/pact_ffi/src/verifier/mod.rs +++ b/rust/pact_ffi/src/verifier/mod.rs @@ -16,10 +16,10 @@ use pact_models::prelude::HttpAuth; use regex::Regex; use serde::{Deserialize, Serialize}; -use pact_matching::logging::fetch_buffer_contents; use pact_verifier::selectors::{consumer_tags_to_selectors, json_to_selectors}; use crate::{as_mut, as_ref, ffi_fn, RUNTIME, safe_str}; +use crate::log::fetch_buffer_contents; use crate::ptr; use crate::util::string::{if_null, optional_str}; From effa4c76526ec049a11cc62540a338d425a03592 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Thu, 5 Sep 2024 10:30:12 +1000 Subject: [PATCH 50/53] chore: Update deprecation message on in-mem support loggin functions in pact_matching crate --- rust/pact_matching/src/logging.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/pact_matching/src/logging.rs b/rust/pact_matching/src/logging.rs index 818b72ff5..eb0e6f690 100644 --- a/rust/pact_matching/src/logging.rs +++ b/rust/pact_matching/src/logging.rs @@ -17,7 +17,7 @@ lazy_static! { /// Accumulates the log entries against a task local ID. If the ID is not set, accumulates against /// the "global" ID. /// cbindgen:ignore - #[deprecated(note = "This must be moved to the FFI crate")] + #[deprecated(note = "Do not use this, it has been moved to the FFI crate")] static ref LOG_BUFFER: Mutex> = Mutex::new(HashMap::new()); } @@ -29,7 +29,7 @@ task_local! { } /// Fetches the contents from the id scoped in-memory buffer and empties the buffer. -#[deprecated(note = "This must be moved to the FFI crate")] +#[deprecated(note = "Do not use this function, it has been moved to the FFI crate")] pub fn fetch_buffer_contents(id: &str) -> Bytes { let mut inner = LOG_BUFFER.lock().unwrap(); let buffer = inner.entry(id.to_string()) @@ -39,7 +39,7 @@ pub fn fetch_buffer_contents(id: &str) -> Bytes { /// Writes the provided bytes to the task local ID scoped in-memory buffer. If there is no /// task local ID set, will write to the "global" buffer. -#[deprecated(note = "This must be moved to the FFI crate")] +#[deprecated(note = "Do not use this function, it has been moved to the FFI crate")] pub fn write_to_log_buffer(buf: &[u8]) { let id = LOG_ID.try_with(|id| id.clone()).unwrap_or_else(|_| "global".into()); let mut inner = LOG_BUFFER.lock().unwrap(); From fe07b87874b8d8c24346b33159a4e1a1581de0a2 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Fri, 6 Sep 2024 12:25:40 +0100 Subject: [PATCH 51/53] docs: add pact_ffi compat docs [skip ci] closes #416 --- rust/pact_ffi/README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/rust/pact_ffi/README.md b/rust/pact_ffi/README.md index 153f34f2c..3cfedb14b 100644 --- a/rust/pact_ffi/README.md +++ b/rust/pact_ffi/README.md @@ -86,3 +86,22 @@ $ cmake --build . You can read about the architecture and design choices of this crate in [ARCHITECTURE.md](https://github.com/pact-foundation/pact-reference/blob/master/rust/pact_ffi/ARCHITECTURE.md). + +## Compatibility + +
Supported Platforms + +| OS | Architecture | Supported | Pact FFI Version | +| ------- | ------------ | --------- | ---------------- | +| OSX | x86_64 | ✅ | All | +| Linux | x86_64 | ✅ | All | +| Windows | x86_64 | ✅ | All | +| OSX | arm64 | ✅ | [>=0.0.1](https://github.com/pact-foundation/pact-reference/releases/tag/libpact_ffi-v0.4.14) | +| Linux | arm64 | ✅ | [>=0.3.6](https://github.com/pact-foundation/pact-reference/releases/tag/libpact_ffi-v0.3.6) | | +| Windows | arm64 | ✅ | [>=0.4.14](https://github.com/pact-foundation/pact-reference/releases/tag/libpact_ffi-v0.4.14) | +| Alpine | x86_64 | ✅ | static - [>=0.2.4](https://github.com/pact-foundation/pact-reference/releases/tag/libpact_ffi-v0.2.4)| +| Alpine | arm64 | ✅ | static - [>=0.4.15](https://github.com/pact-foundation/pact-reference/releases/tag/libpact_ffi-v0.4.15)| +| Alpine | x86_64 | ✅ | dynamic - [>=0.4.17](https://github.com/pact-foundation/pact-reference/releases/tag/libpact_ffi-v0.4.17)| +| Alpine | arm64 | ✅ | dynamic - [>=0.4.17](https://github.com/pact-foundation/pact-reference/releases/tag/libpact_ffi-v0.4.17)| + +
From 303073cf63aeb8f3fea365a180b2324eb937a3b4 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Fri, 6 Sep 2024 13:01:21 +0100 Subject: [PATCH 52/53] docs: update obsolete links [ci skip] --- rust/pact_matching/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/pact_matching/src/lib.rs b/rust/pact_matching/src/lib.rs index 0f0752814..297e88aa8 100644 --- a/rust/pact_matching/src/lib.rs +++ b/rust/pact_matching/src/lib.rs @@ -31,7 +31,7 @@ //! //! V3 specification matching is supported for both JSON and XML bodies, headers, query strings and request paths. //! -//! To understand the basic rules of matching, see [Matching Gotchas](https://github.com/realestate-com-au/pact/wiki/Matching-gotchas). +//! To understand the basic rules of matching, see [Matching Gotchas](https://docs.pact.io/getting_started/matching/gotchas). //! For example test cases for matching, see the [Pact Specification Project, version 3](https://github.com/bethesque/pact-specification/tree/version-3). //! //! By default, Pact will use string equality matching following Postel's Law. This means From f5ddf3d353149ae0fb539a1616eeb8544509fdfc Mon Sep 17 00:00:00 2001 From: "tien.xuan.vo" Date: Thu, 26 Sep 2024 14:51:14 +0700 Subject: [PATCH 53/53] docs: Update safety comments --- rust/pact_ffi/src/mock_server/handles.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/pact_ffi/src/mock_server/handles.rs b/rust/pact_ffi/src/mock_server/handles.rs index 56da1796a..3453b59ca 100644 --- a/rust/pact_ffi/src/mock_server/handles.rs +++ b/rust/pact_ffi/src/mock_server/handles.rs @@ -2523,7 +2523,8 @@ ffi_fn!{ /// /// # Safety /// - /// The comments parameter must be a valid pointer to a NULL terminated UTF-8, + /// The key parameter must be a valid pointer to a NULL terminated UTF-8. + /// The value parameter must be a valid pointer to a NULL terminated UTF-8, /// or NULL if the comment is to be cleared. fn pactffi_set_comment(interaction: InteractionHandle, key: *const c_char, value: *const c_char) -> bool { let key = match convert_cstr("key", key) { @@ -2578,8 +2579,7 @@ ffi_fn!{ /// /// # Safety /// - /// The comments parameter must be a valid pointer to a NULL terminated UTF-8, - /// or NULL if the comment is to be cleared. + /// The comment parameter must be a valid pointer to a NULL terminated UTF-8. fn pactffi_add_text_comment(interaction: InteractionHandle, comment: *const c_char) -> bool { let comment = match convert_cstr("comment", comment) { Some(comment) => comment,