pact 2.0.2 → 2.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7025748777b864b3e23efaf7ac0cbdd79f41e52300737651a2dc6f20023c44b
4
- data.tar.gz: 27e691b749816d4cf746279bcb68f6fca740c1718b8213fa7d134ed8c9882e8c
3
+ metadata.gz: 9fedd79fe261a6e6b2a21eba15e1adfddd50ae8a39c947894284eaa693c2a7c0
4
+ data.tar.gz: 9f07589709bc8423566ca1eb7621240bd3e8cca1e4ebc31c1e018c0f7aa70890
5
5
  SHA512:
6
- metadata.gz: 572d6976b61a36b63c46433bee409d0f45bb1fdb44139c1440f15b77d5c0ed7c6e15fd348d5ca392a1e1cf0dd0f0919d16bf54e129878e4a07bcd0dcee6fc517
7
- data.tar.gz: ee765594f4b73945b8a9d2bbd1dfa199b6ac73863bd1aa066d1e795e71f87d5152c26ba057788e5c1bec2520345205137e03f8930767a570b6dc20a0c46dee45
6
+ metadata.gz: 876698c72508446aecad3723893eb3b68e789042801b39c4da3f661c6e5c22bb1bdc7f06de2b7fe93a1ff9b69a01468efefe4acba3c77288784ab40bfd2aca67
7
+ data.tar.gz: 0d4342358605a35a9da2a1e441e5b25f82957211627c2cf7bea5f6fea2bf556083d329c976ff18e9a32821f66b6da2e52d07deb376db661d930e935a87de1d89
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ <a name="v2.0.3"></a>
2
+ ### v2.0.3 (2026-09-12)
3
+
4
+ #### Bug Fixes
5
+
6
+ * #417 patch webrick for bodyless put/patch/post ([6c7c3d7](/../../commit/6c7c3d7))
7
+ * support rack-proxy 1+2 ([1b80200](/../../commit/1b80200))
8
+ * support https pact_uri ([88d884a](/../../commit/88d884a))
9
+
1
10
  <a name="v2.0.2"></a>
2
11
  ### v2.0.2 (2026-08-12)
3
12
 
@@ -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 == '200' && PACT_FILE_REQUEST_PATH_REGEX.match?(path)
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 body if parsed_body['consumer'].blank? || parsed_body['provider'].blank?
54
- return body if parsed_body['interactions'].blank?
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
@@ -1,4 +1,4 @@
1
1
  # Remember to bump pact-provider-proxy when this changes major version
2
2
  module Pact
3
- VERSION = "2.0.2"
3
+ VERSION = "2.0.3"
4
4
  end
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.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Fraser
@@ -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.18
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