From 44d9dc1e801fa10f2131f849b2912b8f5854f599 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Fri, 29 Nov 2024 15:48:40 +1100 Subject: [PATCH] fix(plugins): Upgrade pact-plugin-driver to 0.7.2, fixes #473 --- rust/Cargo.lock | 413 ++++++++++-------- rust/pact_consumer/Cargo.toml | 3 +- .../src/builders/message_builder.rs | 28 +- rust/pact_consumer/tests/tests.rs | 181 +++++++- rust/pact_ffi/Cargo.toml | 2 +- rust/pact_ffi/src/plugins/mod.rs | 15 +- rust/pact_matching/Cargo.toml | 2 +- rust/pact_verifier/Cargo.toml | 2 +- 8 files changed, 442 insertions(+), 204 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 89e403ed8..ee073654a 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -137,9 +137,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.17" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cb8f1d480b0ea3783ab015936d2a55c87e219676f0c0b7dec61494043f21857" +checksum = "df895a515f70646414f4b45c0b79082783b80552b373a68283012928df56f522" dependencies = [ "flate2", "futures-core", @@ -165,9 +165,9 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -176,9 +176,9 @@ version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -210,16 +210,16 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edf3ee19dbc0a46d740f6f0926bde8c50f02bdbc7b536842da28f6ac56513a8b" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] name = "axum" -version = "0.7.7" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504e3947307ac8326a5437504c517c4b56716c9d98fac0028c2acc7ca47d70ae" +checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" dependencies = [ "async-trait", "axum-core", @@ -236,7 +236,7 @@ dependencies = [ "pin-project-lite", "rustversion", "serde", - "sync_wrapper 1.0.1", + "sync_wrapper 1.0.2", "tower 0.5.1", "tower-layer", "tower-service", @@ -257,7 +257,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper 1.0.1", + "sync_wrapper 1.0.2", "tower-layer", "tower-service", ] @@ -330,9 +330,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" dependencies = [ "serde", ] @@ -360,9 +360,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aeb932158bd710538c73702db6945cb68a8fb08c519e6e12706b94263b36db8" +checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" dependencies = [ "jobserver", "libc", @@ -477,18 +477,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.20" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.20" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" +checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" dependencies = [ "anstream", "anstyle", @@ -498,9 +498,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" [[package]] name = "colorchoice" @@ -546,6 +546,16 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -554,9 +564,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" +checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" dependencies = [ "libc", ] @@ -638,10 +648,10 @@ checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" dependencies = [ "fnv", "ident_case", - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", "strsim 0.11.1", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -652,7 +662,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -677,7 +687,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a2c35ab6e03642397cdda1dd58abbc05d418aef8e36297f336d5aba060fe8df" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", "syn 1.0.109", ] @@ -688,9 +698,9 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -722,9 +732,9 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -795,12 +805,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -838,9 +848,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", "miniz_oxide", @@ -925,9 +935,9 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -992,8 +1002,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] @@ -1038,9 +1050,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" +checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e" dependencies = [ "atomic-waker", "bytes", @@ -1073,9 +1085,9 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.15.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "hashers" @@ -1241,14 +1253,14 @@ dependencies = [ [[package]] name = "hyper" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" +checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f" dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.6", + "h2 0.4.7", "http 1.1.0", "http-body 1.0.1", "httparse", @@ -1284,11 +1296,11 @@ checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http 1.1.0", - "hyper 1.5.0", + "hyper 1.5.1", "hyper-util", "log", - "rustls 0.23.16", - "rustls-native-certs 0.8.0", + "rustls 0.23.19", + "rustls-native-certs 0.8.1", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -1302,7 +1314,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" dependencies = [ - "hyper 1.5.0", + "hyper 1.5.1", "hyper-util", "pin-project-lite", "tokio", @@ -1320,7 +1332,7 @@ dependencies = [ "futures-util", "http 1.1.0", "http-body 1.0.1", - "hyper 1.5.0", + "hyper 1.5.1", "pin-project-lite", "socket2", "tokio", @@ -1464,9 +1476,9 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -1514,7 +1526,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.15.1", + "hashbrown 0.15.2", "serde", ] @@ -1535,11 +1547,11 @@ checksum = "477e2e7ec7379407656293ff74902caea786a1dda427ca1f84b923c4fdeb7659" dependencies = [ "either", "itertools", - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", "strum", - "syn 2.0.87", - "thiserror", + "syn 2.0.89", + "thiserror 1.0.69", ] [[package]] @@ -1596,9 +1608,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "jobserver" @@ -1667,9 +1679,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.162" +version = "0.2.166" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" +checksum = "c2ccc108bbc0b1331bd061864e7cd823c0cab660bbe6970e66e2c0614decde36" [[package]] name = "libredox" @@ -1690,9 +1702,9 @@ checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "litemap" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" [[package]] name = "lock_api" @@ -1734,10 +1746,10 @@ dependencies = [ "beef", "fnv", "lazy_static", - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", "regex-syntax 0.8.5", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -1914,7 +1926,7 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16d0d3f2a488592e5368ebbe996e7f1d44aa13156efad201f5b4d84e150eaa93" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", "syn 1.0.109", ] @@ -1926,7 +1938,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcc7c92f190c97f79b4a332f5e81dcf68c8420af2045c936c9be0bc9de6f63b5" dependencies = [ "proc-macro-crate", - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", "syn 1.0.109", ] @@ -2099,9 +2111,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "pact-plugin-driver" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d522f37b56bea8d219fde70740a7cfe1c6c5f2f81ad03cab49121da6bf0d2477" +checksum = "764d105f3df62feb17ecfa2891616f310334530e84867580a99bf106dc0dad95" dependencies = [ "anyhow", "async-trait", @@ -2163,6 +2175,7 @@ dependencies = [ "reqwest", "serde", "serde_json", + "tempfile", "termsize", "test-log", "tokio", @@ -2217,7 +2230,7 @@ dependencies = [ "sxd-document", "tempfile", "test-log", - "thiserror", + "thiserror 1.0.69", "tokio", "tokio-rustls 0.24.1", "tracing", @@ -2297,7 +2310,7 @@ dependencies = [ "rustls-pemfile 1.0.4", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", "tokio", "tokio-rustls 0.24.1", "tracing", @@ -2316,7 +2329,7 @@ dependencies = [ "bytes", "futures", "http-body-util", - "hyper 1.5.0", + "hyper 1.5.1", "hyper-rustls 0.27.3", "hyper-util", "itertools", @@ -2326,12 +2339,12 @@ dependencies = [ "pact_matching", "pact_models", "rcgen", - "rustls 0.23.16", + "rustls 0.23.19", "rustls-pemfile 2.2.0", "rustls-webpki 0.102.8", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", "tokio", "tokio-rustls 0.26.0", "tracing", @@ -2419,7 +2432,7 @@ dependencies = [ "serde_json", "serde_with", "test-log", - "thiserror", + "thiserror 1.0.69", "tokio", "tracing", "tracing-core", @@ -2434,7 +2447,7 @@ version = "1.1.5" dependencies = [ "ansi_term", "anyhow", - "clap 4.5.20", + "clap 4.5.21", "env_logger 0.11.5", "expectest", "junit-report", @@ -2590,9 +2603,9 @@ version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -2615,9 +2628,9 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "portable-atomic" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" +checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" [[package]] name = "powerfmt" @@ -2650,8 +2663,8 @@ version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ - "proc-macro2 1.0.89", - "syn 2.0.87", + "proc-macro2 1.0.92", + "syn 2.0.89", ] [[package]] @@ -2674,9 +2687,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -2708,7 +2721,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.87", + "syn 2.0.89", "tempfile", ] @@ -2720,9 +2733,9 @@ checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" dependencies = [ "anyhow", "itertools", - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -2756,37 +2769,40 @@ dependencies = [ [[package]] name = "quinn" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" +checksum = "62e96808277ec6f97351a2380e6c25114bc9e67037775464979f3037c92d05ef" dependencies = [ "bytes", "pin-project-lite", "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.16", + "rustls 0.23.19", "socket2", - "thiserror", + "thiserror 2.0.3", "tokio", "tracing", ] [[package]] name = "quinn-proto" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" +checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d" dependencies = [ "bytes", + "getrandom", "rand", "ring", "rustc-hash", - "rustls 0.23.16", + "rustls 0.23.19", + "rustls-pki-types", "slab", - "thiserror", + "thiserror 2.0.3", "tinyvec", "tracing", + "web-time", ] [[package]] @@ -2818,7 +2834,7 @@ version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", ] [[package]] @@ -2978,7 +2994,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.0", + "hyper 1.5.1", "hyper-rustls 0.27.3", "hyper-util", "ipnet", @@ -2989,14 +3005,14 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.16", - "rustls-native-certs 0.8.0", + "rustls 0.23.19", + "rustls-native-certs 0.8.1", "rustls-pemfile 2.2.0", "rustls-pki-types", "serde", "serde_json", "serde_urlencoded", - "sync_wrapper 1.0.1", + "sync_wrapper 1.0.2", "tokio", "tokio-rustls 0.26.0", "tokio-util", @@ -3057,12 +3073,12 @@ dependencies = [ "cfg-if", "glob", "proc-macro-crate", - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", "regex", "relative-path", "rustc_version", - "syn 2.0.87", + "syn 2.0.89", "unicode-ident", ] @@ -3075,12 +3091,12 @@ dependencies = [ "cfg-if", "glob", "proc-macro-crate", - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", "regex", "relative-path", "rustc_version", - "syn 2.0.87", + "syn 2.0.89", "unicode-ident", ] @@ -3107,9 +3123,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.40" +version = "0.38.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0" +checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" dependencies = [ "bitflags 2.6.0", "errno", @@ -3132,9 +3148,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.16" +version = "0.23.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" +checksum = "934b404430bb06b3fae2cba809eb45a1ab1aecd64491213d7c3301b88393f8d1" dependencies = [ "log", "once_cell", @@ -3154,20 +3170,19 @@ dependencies = [ "openssl-probe", "rustls-pemfile 1.0.4", "schannel", - "security-framework", + "security-framework 2.11.1", ] [[package]] name = "rustls-native-certs" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcaf18a4f2be7326cd874a5fa579fae794320a0f388d365dca7e480e55f83f8a" +checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3" dependencies = [ "openssl-probe", - "rustls-pemfile 2.2.0", "rustls-pki-types", "schannel", - "security-framework", + "security-framework 3.0.1", ] [[package]] @@ -3193,6 +3208,9 @@ name = "rustls-pki-types" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" +dependencies = [ + "web-time", +] [[package]] name = "rustls-webpki" @@ -3238,9 +3256,9 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" dependencies = [ "windows-sys 0.59.0", ] @@ -3268,7 +3286,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ "bitflags 2.6.0", - "core-foundation", + "core-foundation 0.9.4", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1415a607e92bec364ea2cf9264646dcce0f91e6d65281bd6f2819cca3bf39c8" +dependencies = [ + "bitflags 2.6.0", + "core-foundation 0.10.0", "core-foundation-sys", "libc", "security-framework-sys", @@ -3305,16 +3336,16 @@ version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] name = "serde_json" -version = "1.0.132" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "itoa", "memchr", @@ -3368,9 +3399,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" dependencies = [ "darling", - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -3485,9 +3516,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" dependencies = [ "libc", "windows-sys 0.52.0", @@ -3554,10 +3585,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ "heck", - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", "rustversion", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -3593,18 +3624,18 @@ version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", "unicode-ident", ] [[package]] name = "syn" -version = "2.0.87" +version = "2.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", "unicode-ident", ] @@ -3617,9 +3648,9 @@ checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] name = "sync_wrapper" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" dependencies = [ "futures-core", ] @@ -3630,9 +3661,9 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -3701,9 +3732,9 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5999e24eaa32083191ba4e425deb75cdf25efefabe5aaccb7446dd0d4122a3f5" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -3721,7 +3752,16 @@ version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl", + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" +dependencies = [ + "thiserror-impl 2.0.3", ] [[package]] @@ -3730,9 +3770,20 @@ version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" +dependencies = [ + "proc-macro2 1.0.92", + "quote 1.0.37", + "syn 2.0.89", ] [[package]] @@ -3825,9 +3876,9 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -3846,7 +3897,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.16", + "rustls 0.23.19", "rustls-pki-types", "tokio", ] @@ -3933,11 +3984,11 @@ dependencies = [ "axum", "base64 0.22.1", "bytes", - "h2 0.4.6", + "h2 0.4.7", "http 1.1.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.0", + "hyper 1.5.1", "hyper-timeout", "hyper-util", "percent-encoding", @@ -3959,11 +4010,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9557ce109ea773b399c9b9e5dca39294110b74f1f342cb347a80d1fce8c26a11" dependencies = [ "prettyplease", - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "prost-build", "prost-types", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -4028,9 +4079,9 @@ name = "tracing-attributes" 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.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -4143,9 +4194,9 @@ checksum = "7e51b68083f157f853b6379db119d1c1be0e6e4dec98101079dec41f6f5cf6df" [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "unicode-width" @@ -4173,9 +4224,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.3" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", "idna", @@ -4249,7 +4300,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e369bee1b05d510a7b4ed645f5faa90619e05437111783ea5848f28d97d3c2e" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", ] @@ -4307,9 +4358,9 @@ dependencies = [ "bumpalo", "log", "once_cell", - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", "wasm-bindgen-shared", ] @@ -4341,9 +4392,9 @@ version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4389,9 +4440,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.6" +version = "0.26.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958" +checksum = "5d642ff16b7e79272ae451b7322067cdc17cadf68c23264be9d94a32319efe7e" dependencies = [ "rustls-pki-types", ] @@ -4607,9 +4658,9 @@ dependencies = [ [[package]] name = "yoke" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" dependencies = [ "serde", "stable_deref_trait", @@ -4619,13 +4670,13 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", "synstructure", ] @@ -4645,29 +4696,29 @@ version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] name = "zerofrom" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" dependencies = [ "zerofrom-derive", ] [[package]] name = "zerofrom-derive" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", "synstructure", ] @@ -4686,9 +4737,9 @@ version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -4708,16 +4759,16 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ - "proc-macro2 1.0.89", + "proc-macro2 1.0.92", "quote 1.0.37", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] name = "zip" -version = "2.2.0" +version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc5e4288ea4057ae23afc69a4472434a87a2495cafce6632fd1c4ec9f5cf3494" +checksum = "99d52293fc86ea7cf13971b3bb81eb21683636e7ae24c729cdaf1b7c4157a352" dependencies = [ "aes", "arbitrary", @@ -4735,7 +4786,7 @@ dependencies = [ "pbkdf2", "rand", "sha1", - "thiserror", + "thiserror 2.0.3", "time", "zeroize", "zopfli", diff --git a/rust/pact_consumer/Cargo.toml b/rust/pact_consumer/Cargo.toml index 3532fb0b6..9f3049b7e 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.2", default-features = false } pact_models = { version = "~1.2.5", default-features = false } -pact-plugin-driver = { version = "~0.7.1", optional = true, default-features = false } +pact-plugin-driver = { version = "~0.7.2", optional = true, default-features = false } regex = "1.10.6" serde_json = "1.0.127" termsize = "0.1.9" @@ -51,6 +51,7 @@ expectest = "0.12.0" 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" +tempfile = "3.14.0" tokio-test = "0.4.4" test-log = { version = "0.2.16", features = ["trace"] } tracing-subscriber = { version = "0.3.18", features = ["env-filter", "tracing-log", "fmt"] } diff --git a/rust/pact_consumer/src/builders/message_builder.rs b/rust/pact_consumer/src/builders/message_builder.rs index af1ec8cf0..8106ca4ee 100644 --- a/rust/pact_consumer/src/builders/message_builder.rs +++ b/rust/pact_consumer/src/builders/message_builder.rs @@ -87,12 +87,18 @@ impl InteractionContents { #[cfg(feature = "plugins")] /// Create a new struct from a plugin specific one pub fn from(contents: &pact_plugin_driver::content::InteractionContents) -> Self { + let metadata = contents.metadata.as_ref() + .map(|md| { + md.iter() + .map(|(k, v)| (k.clone(), v.clone())) + .collect() + }); InteractionContents { part_name: contents.part_name.clone(), body: contents.body.clone(), rules: contents.rules.clone(), generators: contents.generators.clone(), - metadata: contents.metadata.clone(), + metadata, metadata_rules: contents.metadata_rules.clone(), plugin_config: PluginConfiguration::from(&contents.plugin_config), interaction_markup: contents.interaction_markup.clone(), @@ -226,6 +232,9 @@ impl MessageInteractionBuilder { }; } + let metadata = self.message_contents.metadata.as_ref() + .map(|md| md.iter().map(|(k, v)| (k.clone(), v.clone())).collect()) + .unwrap_or_default(); AsynchronousMessage { id: None, key: self.key.clone(), @@ -233,7 +242,7 @@ impl MessageInteractionBuilder { provider_states: self.provider_states.clone(), contents: MessageContents { contents: self.message_contents.body.clone(), - metadata: self.message_contents.metadata.as_ref().cloned().unwrap_or_default(), + metadata, matching_rules: rules, generators: self.message_contents.generators.as_ref().cloned().unwrap_or_default() }, @@ -256,15 +265,18 @@ impl MessageInteractionBuilder { rules.add_category("body") .add_rules(self.message_contents.rules.as_ref().cloned().unwrap_or_default()); - Message { + let metadata = self.message_contents.metadata.as_ref() + .map(|md| md.iter().map(|(k, v)| (k.clone(), v.clone())).collect()) + .unwrap_or_default(); + Message { id: None, description: self.description.clone(), provider_states: self.provider_states.clone(), contents: self.message_contents.body.clone(), - metadata: self.message_contents.metadata.as_ref().cloned().unwrap_or_default(), - matching_rules: rules, - generators: self.message_contents.generators.as_ref().cloned().unwrap_or_default() - } + metadata, + matching_rules: rules, + generators: self.message_contents.generators.as_ref().cloned().unwrap_or_default() + } } /// Configure the interaction contents from a map @@ -427,7 +439,7 @@ impl MessageInteractionBuilder { } /// Specify the message payload and content type - pub fn body>(&mut self, body: B, content_type: Option) -> &mut Self { + pub fn body>(&mut self, body: B, content_type: Option) -> &mut Self { let message_body = OptionalBody::Present( body.into(), content_type.as_ref().map(|ct| ct.into()), diff --git a/rust/pact_consumer/tests/tests.rs b/rust/pact_consumer/tests/tests.rs index 3d865a0c3..7c9ea635a 100644 --- a/rust/pact_consumer/tests/tests.rs +++ b/rust/pact_consumer/tests/tests.rs @@ -3,26 +3,30 @@ use std::{ fs, path::Path }; +use std::io::Write; use std::path::PathBuf; use bytes::Bytes; use expectest::prelude::*; use maplit::hashmap; -use pact_models::content_types::ContentType; -use pact_models::pact::{read_pact, ReadWritePact}; -use pact_models::prelude::OptionalBody; -use pact_models::provider_states::ProviderState; -use pact_models::sync_pact::RequestResponsePact; -use pact_models::v4::http_parts::{HttpRequest, HttpResponse}; -use pact_models::v4::synch_http::SynchronousHttp; +use pretty_assertions::assert_eq; use rand::prelude::*; use reqwest::{Client, StatusCode}; use serde::{Deserialize, Serialize}; use serde_json::json; -use pact_consumer::{json_pattern, json_pattern_internal, like, object_matching, matching_regex}; +use pact_consumer::{json_pattern, json_pattern_internal, like, matching_regex, object_matching}; use pact_consumer::mock_server::StartMockServerAsync; use pact_consumer::prelude::*; +use pact_models::content_types::ContentType; +use pact_models::pact::{read_pact, ReadWritePact}; +use pact_models::pact::write_pact; +use pact_models::PactSpecification; +use pact_models::prelude::OptionalBody; +use pact_models::provider_states::ProviderState; +use pact_models::sync_pact::RequestResponsePact; +use pact_models::v4::http_parts::{HttpRequest, HttpResponse}; +use pact_models::v4::synch_http::SynchronousHttp; /// This is supposed to be a doctest in mod, but it's breaking there, so /// we have an executable copy here. @@ -386,3 +390,164 @@ fn each_key_matcher() { .unwrap(); expect!(response.status().is_server_error()).to(be_true()); } + +const PROTO: &str = " +syntax = \"proto3\"; + +package area_calculator; + +service Calculator { + rpc calculate (ShapeMessage) returns (AreaResponse) {} +} + +message ShapeMessage { + oneof shape { + Square square = 1; + Rectangle rectangle = 2; + Circle circle = 3; + Triangle triangle = 4; + Parallelogram parallelogram = 5; + } +} + +message Square { + float edge_length = 1; +} + +message Rectangle { + float length = 1; + float width = 2; +} + +message Circle { + float radius = 1; +} + +message Triangle { + float edge_a = 1; + float edge_b = 2; + float edge_c = 3; +} + +message Parallelogram { + float base_length = 1; + float height = 2; +} + +message AreaResponse { + float value = 1; +} +"; + +// Issue https://github.com/YOU54F/pact-ruby-ffi/issues/6 +// Note, this test requires the gRPC plugin to be installed +#[test_log::test(tokio::test(flavor = "multi_thread", worker_threads = 1))] +#[ignore = "test requires Protobuf plugin"] +async fn test_protobuf_plugin_contents_merge_with_existing_interaction() { + let tmp = tempfile::tempdir().unwrap(); + let proto_path = tmp.path().join("area-calculator.proto"); + let mut proto_file = fs::File::create(proto_path.clone()).unwrap(); + proto_file.write_all(PROTO.as_bytes()).unwrap(); + + // 1. create an existing pact with single plugin interaction + // 2. create a new plugin interaction that only differs by interaction description + // expected: 2 interactions are generated, identical bar interaction description + // actual: existing interaction is modified at response[0].contents, when merging 2nd interaction + + let pact_1_file_path = { + let proto_path_str = proto_path.to_string_lossy(); + let mut pact_builder = PactBuilderAsync::new_v4("PluginMergeConsumer", "PluginMergeProvider"); + let pact_1 = pact_builder + .using_plugin("protobuf", None).await + .synchronous_message_interaction("description 1", |mut i| async move { + i.contents_from(json!({ + "pact:proto": proto_path_str, + "pact:content-type": "application/protobuf", + "pact:proto-service": "Calculator/calculate", + + "request": { + "rectangle": { + "length": "matching(number, 3)", + "width": "matching(number, 4)" + } + }, + + "responseMetadata": { + "grpc-status": "UNIMPLEMENTED", + "grpc-message": "Not implemented" + } + })).await; + i + }) + .await + .build(); + let pact_file_name = pact_1.default_file_name(); + let path_file_path = tmp.path().join(pact_file_name); + write_pact(pact_1, &path_file_path, PactSpecification::V4, false).unwrap(); + path_file_path.clone() + }; + + let pact_file = fs::File::open(pact_1_file_path).unwrap(); + let json: serde_json::Value = serde_json::from_reader(&pact_file).unwrap(); + + let interaction_1_response_contents = &json["interactions"][0]["response"][0]["contents"]; + let expected_response_contents = json!({ + "content": "", + }); + assert_eq!( + &expected_response_contents, + interaction_1_response_contents + ); + + // Setup New interaction and write to existing pact file - validate .interactions[0].response[0].contents + let pact_2_file_path = { + let mut pact_builder_2 = PactBuilderAsync::new_v4("PluginMergeConsumer", "PluginMergeProvider"); + let pact_2 = pact_builder_2 + .using_plugin("protobuf", None).await + .synchronous_message_interaction("description 2", |mut i| async move { + i.contents_from(json!({ + "pact:proto": proto_path, + "pact:content-type": "application/protobuf", + "pact:proto-service": "Calculator/calculate", + + "request": { + "rectangle": { + "length": "matching(number, 3)", + "width": "matching(number, 4)" + } + }, + + "responseMetadata": { + "grpc-status": "UNIMPLEMENTED", + "grpc-message": "Not implemented" + } + })).await; + i + }) + .await + .build(); + let pact_file_name = pact_2.default_file_name(); + let path_file_path = tmp.path().join(pact_file_name); + write_pact(pact_2, &path_file_path, PactSpecification::V4, false).unwrap(); + path_file_path.clone() + }; + + let pact_file = fs::File::open(pact_2_file_path).unwrap(); + let json_2: serde_json::Value = serde_json::from_reader(pact_file).unwrap(); + + let interaction_2_description = &json_2["interactions"][0]["description"]; + let interaction_2_description_2 = &json_2["interactions"][1]["description"]; + let interaction_2_response_contents = &json_2["interactions"][0]["response"][0]["contents"]; + let interaction_2_response_contents_2 = &json_2["interactions"][1]["response"][0]["contents"]; + + assert_eq!("description 1", interaction_2_description.as_str().unwrap()); + assert_eq!("description 2", interaction_2_description_2.as_str().unwrap()); + assert_eq!( + &expected_response_contents, + interaction_2_response_contents_2 + ); + assert_eq!( + &expected_response_contents, + interaction_2_response_contents + ); +} diff --git a/rust/pact_ffi/Cargo.toml b/rust/pact_ffi/Cargo.toml index 997992858..4ed8fea44 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.10" } pact_models = { version = "~1.2.5" } -pact-plugin-driver = { version = "~0.7.1" } +pact-plugin-driver = { version = "~0.7.2" } pact_verifier = { version = "~1.2.4", path = "../pact_verifier" } panic-message = "0.3.0" rand = "0.8.5" diff --git a/rust/pact_ffi/src/plugins/mod.rs b/rust/pact_ffi/src/plugins/mod.rs index fd897b253..6fe387d71 100644 --- a/rust/pact_ffi/src/plugins/mod.rs +++ b/rust/pact_ffi/src/plugins/mod.rs @@ -207,7 +207,10 @@ pub extern fn pactffi_interaction_contents( let message = interaction.as_v4_async_message_mut().unwrap(); if let Some(contents) = contents.first() { message.contents.contents = contents.body.clone(); - message.contents.metadata = contents.metadata.clone().unwrap_or_default(); + let metadata = contents.metadata.as_ref() + .map(|md| md.iter().map(|(k, v)| (k.clone(), v.clone())).collect()) + .unwrap_or_default(); + message.contents.metadata = metadata; if let Some(rules) = &contents.rules { message.contents.matching_rules.add_rules("body", rules.clone()); } @@ -264,7 +267,10 @@ fn setup_sync_message_contents( if let Some(contents) = &contents.iter().find(|c| c.part_name == "request") { message.request.contents = contents.body.clone(); - message.request.metadata = contents.metadata.clone().unwrap_or_default(); + let metadata = contents.metadata.as_ref() + .map(|md| md.iter().map(|(k, v)| (k.clone(), v.clone())).collect()) + .unwrap_or_default(); + message.request.metadata = metadata; if let Some(rules) = &contents.rules { message.request.matching_rules.add_rules("body", rules.clone()); } @@ -293,9 +299,12 @@ fn setup_sync_message_contents( if let Some(g) = &c.generators { generators.add_generators(g.clone()); } + let metadata = c.metadata.as_ref() + .map(|md| md.iter().map(|(k, v)| (k.clone(), v.clone())).collect()) + .unwrap_or_default(); message.response.push(MessageContents { contents: c.body.clone(), - metadata: c.metadata.clone().unwrap_or_default(), + metadata, matching_rules, generators }); diff --git a/rust/pact_matching/Cargo.toml b/rust/pact_matching/Cargo.toml index 323ae134b..ee5b4654f 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.5", default-features = false } -pact-plugin-driver = { version = "~0.7.1", optional = true, default-features = false } +pact-plugin-driver = { version = "~0.7.2", 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 925a13858..7b827c467 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.5", default-features = false } -pact-plugin-driver = { version = "~0.7.1", optional = true, default-features = false } +pact-plugin-driver = { version = "~0.7.2", 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"