pact 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/lib/pact/consumer/grpc_interaction_builder.rb +13 -0
- data/lib/pact/consumer/http_interaction_builder.rb +13 -0
- data/lib/pact/consumer/message_interaction_builder.rb +13 -0
- data/lib/pact/consumer/plugin_async_message_interaction_builder.rb +13 -0
- data/lib/pact/consumer/plugin_http_interaction_builder.rb +14 -0
- data/lib/pact/consumer/plugin_sync_message_interaction_builder.rb +14 -0
- data/lib/pact/provider/base_verifier.rb +1 -1
- data/lib/pact/provider/http_server.rb +16 -0
- data/lib/pact/provider/pact_broker_proxy.rb +12 -3
- data/lib/pact/version.rb +1 -1
- data/pact.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5981192ff0284632e39d26660bf25cb35109ab17f8e6da065114b46a77e8bf77
|
|
4
|
+
data.tar.gz: 57c68d0b0217c0c51b55d5ef7d37a56b2fb2db1211de1693cd4020455614a3c2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5af0dcba077273ed185fd2793c4f2183d301d4ae826860cd2e57503d06970ef8dbb36d8c9a4fac266429f847feaee5706fb728e18293201ea4ea285561eb0602
|
|
7
|
+
data.tar.gz: 6c7cff40d5dac6a7c1ae2d7095486ed73455219b5b03e9fc70c0bc68cb44c7d71f04a6810855ac85586a66d0f52f7b7b9f5a5e2210d367e6902451e3dcbc3ec8
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
<a name="v2.1.0"></a>
|
|
2
|
+
### v2.1.0 (2026-09-14)
|
|
3
|
+
|
|
4
|
+
#### Features
|
|
5
|
+
|
|
6
|
+
* add interaction reference (#416) ([7953bca](/../../commit/7953bca))
|
|
7
|
+
|
|
8
|
+
<a name="v2.0.3"></a>
|
|
9
|
+
### v2.0.3 (2026-09-12)
|
|
10
|
+
|
|
11
|
+
#### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* #417 patch webrick for bodyless put/patch/post ([6c7c3d7](/../../commit/6c7c3d7))
|
|
14
|
+
* support rack-proxy 1+2 ([1b80200](/../../commit/1b80200))
|
|
15
|
+
* support https pact_uri ([88d884a](/../../commit/88d884a))
|
|
16
|
+
|
|
1
17
|
<a name="v2.0.2"></a>
|
|
2
18
|
### v2.0.2 (2026-08-12)
|
|
3
19
|
|
|
@@ -48,6 +48,7 @@ module Pact
|
|
|
48
48
|
@response = nil
|
|
49
49
|
@response_meta = nil
|
|
50
50
|
@provider_state_meta = nil
|
|
51
|
+
@references = []
|
|
51
52
|
end
|
|
52
53
|
|
|
53
54
|
def with_service(proto_path, method, include_dirs = [])
|
|
@@ -89,6 +90,14 @@ module Pact
|
|
|
89
90
|
self
|
|
90
91
|
end
|
|
91
92
|
|
|
93
|
+
def reference(group, name, value)
|
|
94
|
+
raise InteractionBuilderError.new("group is required") if group.blank?
|
|
95
|
+
raise InteractionBuilderError.new("name is required") if name.blank?
|
|
96
|
+
raise InteractionBuilderError.new("value is required") if value.blank?
|
|
97
|
+
@references << [group, name, value]
|
|
98
|
+
self
|
|
99
|
+
end
|
|
100
|
+
|
|
92
101
|
def will_respond_with(resp_hash)
|
|
93
102
|
@response = InteractionContents.plugin(resp_hash)
|
|
94
103
|
self
|
|
@@ -138,6 +147,10 @@ module Pact
|
|
|
138
147
|
end
|
|
139
148
|
end
|
|
140
149
|
|
|
150
|
+
@references.each do |group, name, value|
|
|
151
|
+
PactFfi.add_interaction_reference(pact_handle, group, name, value)
|
|
152
|
+
end
|
|
153
|
+
|
|
141
154
|
result = PactFfi::PluginConsumer.interaction_contents(message_pact, 0, GRPC_CONTENT_TYPE, interaction_json)
|
|
142
155
|
if CREATE_INTERACTION_ERRORS[result].present?
|
|
143
156
|
error = CREATE_INTERACTION_ERRORS[result]
|
|
@@ -34,6 +34,7 @@ module Pact
|
|
|
34
34
|
def initialize(pact_config, description: nil)
|
|
35
35
|
@pact_config = pact_config
|
|
36
36
|
@description = description || ""
|
|
37
|
+
@references = []
|
|
37
38
|
|
|
38
39
|
@pact_handle = pact_config.pact_handle ||= init_pact
|
|
39
40
|
@pact_interaction = PactFfi.new_interaction(pact_handle, @description)
|
|
@@ -88,6 +89,14 @@ module Pact
|
|
|
88
89
|
self
|
|
89
90
|
end
|
|
90
91
|
|
|
92
|
+
def reference(group, name, value)
|
|
93
|
+
raise InteractionBuilderError.new("group is required") if group.blank?
|
|
94
|
+
raise InteractionBuilderError.new("name is required") if name.blank?
|
|
95
|
+
raise InteractionBuilderError.new("value is required") if value.blank?
|
|
96
|
+
@references << [group, name, value]
|
|
97
|
+
self
|
|
98
|
+
end
|
|
99
|
+
|
|
91
100
|
def will_respond_with(status: nil, headers: {}, body: nil)
|
|
92
101
|
interaction_part = PactFfi::FfiInteractionPart["INTERACTION_PART_RESPONSE"]
|
|
93
102
|
PactFfi.response_status(pact_interaction, status)
|
|
@@ -106,6 +115,10 @@ module Pact
|
|
|
106
115
|
def execute(&block)
|
|
107
116
|
raise InteractionBuilderError.new("interaction is designed to be used one-time only") if defined?(@used)
|
|
108
117
|
|
|
118
|
+
@references.each do |group, name, value|
|
|
119
|
+
PactFfi.add_interaction_reference(pact_handle, group, name, value)
|
|
120
|
+
end
|
|
121
|
+
|
|
109
122
|
mock_server = MockServer.create_for_http!(
|
|
110
123
|
pact: pact_handle, host: pact_config.mock_host, port: pact_config.mock_port
|
|
111
124
|
)
|
|
@@ -58,6 +58,7 @@ module Pact
|
|
|
58
58
|
@meta = {}
|
|
59
59
|
@headers = {}
|
|
60
60
|
@provider_state_meta = nil
|
|
61
|
+
@references = []
|
|
61
62
|
end
|
|
62
63
|
|
|
63
64
|
def given(provider_state, metadata = {})
|
|
@@ -75,6 +76,14 @@ module Pact
|
|
|
75
76
|
self
|
|
76
77
|
end
|
|
77
78
|
|
|
79
|
+
def reference(group, name, value)
|
|
80
|
+
raise InteractionBuilderError.new("group is required") if group.blank?
|
|
81
|
+
raise InteractionBuilderError.new("name is required") if name.blank?
|
|
82
|
+
raise InteractionBuilderError.new("value is required") if value.blank?
|
|
83
|
+
@references << [group, name, value]
|
|
84
|
+
self
|
|
85
|
+
end
|
|
86
|
+
|
|
78
87
|
def with_proto_class(proto_path, message_class_name, include_dirs = [])
|
|
79
88
|
absolute_path = File.expand_path(proto_path)
|
|
80
89
|
raise InteractionBuilderError.new("proto file #{proto_path} does not exist") unless File.exist?(absolute_path)
|
|
@@ -131,6 +140,10 @@ module Pact
|
|
|
131
140
|
|
|
132
141
|
message_pact = PactFfi::MessageConsumer.new_message_interaction(pact_handle, @description)
|
|
133
142
|
|
|
143
|
+
@references.each do |group, name, value|
|
|
144
|
+
PactFfi.add_interaction_reference(pact_handle, group, name, value)
|
|
145
|
+
end
|
|
146
|
+
|
|
134
147
|
configure_interaction!(message_pact)
|
|
135
148
|
|
|
136
149
|
# strip out matchers and get raw payload/metadata
|
|
@@ -38,6 +38,7 @@ module Pact
|
|
|
38
38
|
@description = description || ""
|
|
39
39
|
@contents = nil
|
|
40
40
|
@provider_state_meta = nil
|
|
41
|
+
@references = []
|
|
41
42
|
end
|
|
42
43
|
|
|
43
44
|
def with_plugin(plugin_name, plugin_version)
|
|
@@ -79,6 +80,14 @@ module Pact
|
|
|
79
80
|
self
|
|
80
81
|
end
|
|
81
82
|
|
|
83
|
+
def reference(group, name, value)
|
|
84
|
+
raise InteractionBuilderError.new("group is required") if group.blank?
|
|
85
|
+
raise InteractionBuilderError.new("name is required") if name.blank?
|
|
86
|
+
raise InteractionBuilderError.new("value is required") if value.blank?
|
|
87
|
+
@references << [group, name, value]
|
|
88
|
+
self
|
|
89
|
+
end
|
|
90
|
+
|
|
82
91
|
def interaction_json
|
|
83
92
|
result = {
|
|
84
93
|
contents: @contents
|
|
@@ -101,6 +110,10 @@ module Pact
|
|
|
101
110
|
|
|
102
111
|
interaction = PactFfi::AsyncMessageConsumer.new(pact_handle, @description)
|
|
103
112
|
|
|
113
|
+
@references.each do |group, name, value|
|
|
114
|
+
PactFfi.add_interaction_reference(pact_handle, group, name, value)
|
|
115
|
+
end
|
|
116
|
+
|
|
104
117
|
@provider_state_meta&.each_pair do |provider_state, meta|
|
|
105
118
|
if meta.present?
|
|
106
119
|
meta.each_pair do |k, v|
|
|
@@ -38,6 +38,7 @@ module Pact
|
|
|
38
38
|
@description = description || ""
|
|
39
39
|
@contents = nil
|
|
40
40
|
@provider_state_meta = nil
|
|
41
|
+
@references = []
|
|
41
42
|
end
|
|
42
43
|
|
|
43
44
|
def with_plugin(plugin_name, plugin_version)
|
|
@@ -95,6 +96,14 @@ module Pact
|
|
|
95
96
|
self
|
|
96
97
|
end
|
|
97
98
|
|
|
99
|
+
def reference(group, name, value)
|
|
100
|
+
raise InteractionBuilderError.new("group is required") if group.blank?
|
|
101
|
+
raise InteractionBuilderError.new("name is required") if name.blank?
|
|
102
|
+
raise InteractionBuilderError.new("value is required") if value.blank?
|
|
103
|
+
@references << [group, name, value]
|
|
104
|
+
self
|
|
105
|
+
end
|
|
106
|
+
|
|
98
107
|
def interaction_json
|
|
99
108
|
result = {
|
|
100
109
|
request: @request,
|
|
@@ -118,6 +127,11 @@ module Pact
|
|
|
118
127
|
init_plugin!(pact_handle)
|
|
119
128
|
|
|
120
129
|
interaction = PactFfi.new_interaction(pact_handle, @description)
|
|
130
|
+
|
|
131
|
+
@references.each do |group, name, value|
|
|
132
|
+
PactFfi.add_interaction_reference(pact_handle, group, name, value)
|
|
133
|
+
end
|
|
134
|
+
|
|
121
135
|
@provider_state_meta&.each_pair do |provider_state, meta|
|
|
122
136
|
if meta.present?
|
|
123
137
|
meta.each_pair do |k, v|
|
|
@@ -40,6 +40,7 @@ module Pact
|
|
|
40
40
|
@response = nil
|
|
41
41
|
@response_meta = nil
|
|
42
42
|
@provider_state_meta = nil
|
|
43
|
+
@references = []
|
|
43
44
|
end
|
|
44
45
|
|
|
45
46
|
def with_plugin(plugin_name, plugin_version)
|
|
@@ -91,6 +92,14 @@ module Pact
|
|
|
91
92
|
self
|
|
92
93
|
end
|
|
93
94
|
|
|
95
|
+
def reference(group, name, value)
|
|
96
|
+
raise InteractionBuilderError.new("group is required") if group.blank?
|
|
97
|
+
raise InteractionBuilderError.new("name is required") if name.blank?
|
|
98
|
+
raise InteractionBuilderError.new("value is required") if value.blank?
|
|
99
|
+
@references << [group, name, value]
|
|
100
|
+
self
|
|
101
|
+
end
|
|
102
|
+
|
|
94
103
|
def interaction_json
|
|
95
104
|
result = {
|
|
96
105
|
request: @request
|
|
@@ -117,6 +126,11 @@ module Pact
|
|
|
117
126
|
init_plugin!(pact_handle)
|
|
118
127
|
|
|
119
128
|
message_pact = PactFfi::SyncMessageConsumer.new_interaction(pact_handle, @description)
|
|
129
|
+
|
|
130
|
+
@references.each do |group, name, value|
|
|
131
|
+
PactFfi.add_interaction_reference(pact_handle, group, name, value)
|
|
132
|
+
end
|
|
133
|
+
|
|
120
134
|
@provider_state_meta&.each_pair do |provider_state, meta|
|
|
121
135
|
if meta.present?
|
|
122
136
|
meta.each_pair { |k, v| PactFfi.given_with_param(message_pact, provider_state, k.to_s, v.to_s) }
|
|
@@ -206,7 +206,7 @@ module Pact
|
|
|
206
206
|
end
|
|
207
207
|
|
|
208
208
|
if @pact_config.pact_uri.present?
|
|
209
|
-
if @pact_config.pact_uri.start_with?('http')
|
|
209
|
+
if @pact_config.pact_uri.start_with?('http', 'https')
|
|
210
210
|
logger.info("[verifier] using pact uri #{@pact_config.pact_uri} as a verification source")
|
|
211
211
|
PactFfi::Verifier.url_source(handle, @pact_config.pact_uri, @pact_config.broker_username,
|
|
212
212
|
@pact_config.broker_password, @pact_config.broker_token)
|
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# https://github.com/pact-foundation/pact-ruby/issues/417
|
|
4
|
+
# workaround for bodyless put/patch/post.
|
|
5
|
+
# fix should be in pact-reference core
|
|
6
|
+
require "webrick"
|
|
7
|
+
|
|
8
|
+
PACT_WEBRICK_EMPTY_BODY_PATCH = Module.new do
|
|
9
|
+
def read_body(socket, block)
|
|
10
|
+
if self["content-length"].nil? && self["transfer-encoding"].nil? &&
|
|
11
|
+
WEBrick::HTTPRequest::BODY_CONTAINABLE_METHODS.include?(@request_method)
|
|
12
|
+
return @body
|
|
13
|
+
end
|
|
14
|
+
super
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
WEBrick::HTTPRequest.prepend(PACT_WEBRICK_EMPTY_BODY_PATCH)
|
|
18
|
+
|
|
3
19
|
module Pact
|
|
4
20
|
module Provider
|
|
5
21
|
# inspired by Gruf::Cli::Executor
|
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
require 'rack-proxy'
|
|
4
4
|
|
|
5
|
+
if Rack::Proxy.const_defined?(:RequestBodyStream, false)
|
|
6
|
+
Rack::Proxy.const_get(:RequestBodyStream).prepend(Module.new do
|
|
7
|
+
def read(length = nil, buffer = nil)
|
|
8
|
+
super(length || instance_variable_get(:@remaining), buffer)
|
|
9
|
+
end
|
|
10
|
+
end)
|
|
11
|
+
end
|
|
12
|
+
|
|
5
13
|
module Pact
|
|
6
14
|
module Provider
|
|
7
15
|
class PactBrokerProxy < Rack::Proxy
|
|
@@ -33,7 +41,7 @@ module Pact
|
|
|
33
41
|
def rewrite_response(triplet)
|
|
34
42
|
status, headers, body = triplet
|
|
35
43
|
|
|
36
|
-
if status ==
|
|
44
|
+
if status.to_i == 200 && PACT_FILE_REQUEST_PATH_REGEX.match?(path)
|
|
37
45
|
patched_body = patch_response(body.first)
|
|
38
46
|
|
|
39
47
|
# we need to recalculate content length
|
|
@@ -50,12 +58,13 @@ module Pact
|
|
|
50
58
|
def patch_response(raw_body)
|
|
51
59
|
parsed_body = JSON.parse(raw_body)
|
|
52
60
|
|
|
53
|
-
return
|
|
54
|
-
return
|
|
61
|
+
return raw_body if parsed_body['consumer'].blank? || parsed_body['provider'].blank?
|
|
62
|
+
return raw_body if parsed_body['interactions'].blank?
|
|
55
63
|
|
|
56
64
|
JSON.generate(parsed_body)
|
|
57
65
|
rescue JSON::ParserError => e
|
|
58
66
|
logger.error("cannot parse broker response: #{e.message}")
|
|
67
|
+
raw_body
|
|
59
68
|
end
|
|
60
69
|
end
|
|
61
70
|
end
|
data/lib/pact/version.rb
CHANGED
data/pact.gemspec
CHANGED
|
@@ -36,7 +36,7 @@ Gem::Specification.new do |gem|
|
|
|
36
36
|
# Core dependencies (code loading)
|
|
37
37
|
gem.add_dependency 'zeitwerk', '~> 2.3'
|
|
38
38
|
# For Pact support via Pact Rust Core
|
|
39
|
-
gem.add_dependency 'pact-ffi', '~> 0.
|
|
39
|
+
gem.add_dependency 'pact-ffi', '~> 0.5.8'
|
|
40
40
|
# For Provider Side Verification
|
|
41
41
|
gem.add_dependency 'rack'
|
|
42
42
|
gem.add_dependency 'rack-proxy'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pact
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- James Fraser
|
|
@@ -33,14 +33,14 @@ dependencies:
|
|
|
33
33
|
requirements:
|
|
34
34
|
- - "~>"
|
|
35
35
|
- !ruby/object:Gem::Version
|
|
36
|
-
version: 0.
|
|
36
|
+
version: 0.5.8
|
|
37
37
|
type: :runtime
|
|
38
38
|
prerelease: false
|
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
|
40
40
|
requirements:
|
|
41
41
|
- - "~>"
|
|
42
42
|
- !ruby/object:Gem::Version
|
|
43
|
-
version: 0.
|
|
43
|
+
version: 0.5.8
|
|
44
44
|
- !ruby/object:Gem::Dependency
|
|
45
45
|
name: rack
|
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -513,7 +513,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
513
513
|
- !ruby/object:Gem::Version
|
|
514
514
|
version: '0'
|
|
515
515
|
requirements: []
|
|
516
|
-
rubygems_version: 4.0.
|
|
516
|
+
rubygems_version: 4.0.20
|
|
517
517
|
specification_version: 4
|
|
518
518
|
summary: Enables consumer driven contract testing, providing a mock service and DSL
|
|
519
519
|
for the consumer project, and interaction playback and verification for the service
|