pact 1.65.3 → 1.66.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da6c6baee4f719b538106f31530a69992a3e1a5f26a43499bc232d3079182da2
4
- data.tar.gz: a42648b2f94c7e3df5cb687e38ef07ad52ae5d8c736c136f46645d7ca5f94e2e
3
+ metadata.gz: 26cc958a02d05dd977adaee8c952de9392fcb06188c75564e4f9d261821ae6d8
4
+ data.tar.gz: f73fef0a466d12221bee83f0695ecf9f2cfbdbcb92c83f2706449025b78d9408
5
5
  SHA512:
6
- metadata.gz: 48ae099d0e39dfe40ed0928cc6f33dcfe297154fae7c00c61bffa12b67e0b84c80ea8df198afc6a602c66aad1a9527aad188d5ff7d1bcf04c7fdd2a85ccc9c44
7
- data.tar.gz: b62f9883ca3b7336cb93acb76b88963c6361970d14aac3604ddc43480bb4a56d97fd05afa1c35a7c6d2a834e3ad8e5b6f940042ea6789020508e0e256fcdcaa6
6
+ metadata.gz: e7ed964f7532f0baa701aead43ac24fa10e40b4503b8da7b637ce8e41ffdc263141689a042d01bd37a20cd0d6ca703c9bee1d645fd76424583b63c151b35e644
7
+ data.tar.gz: d8decbbd6cc63282600dc90f07c79e83db40f6d79181c2afd03bcc325567daad0213b6f36817ae3248876a9e25a04da14d8ee7f1b3a82240f19a9146f91d6df9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ <a name="v1.66.1"></a>
2
+ ### v1.66.1 (2025-01-20)
3
+
4
+ #### Bug Fixes
5
+
6
+ * HTTP_HOST headers for sinatra 4.x ([173bfb7](/../../commit/173bfb7))
7
+
8
+ <a name="v1.66.0"></a>
9
+ ### v1.66.0 (2024-11-29)
10
+
11
+ #### Features
12
+
13
+ * **generators**
14
+ * Add more generators as per spec ([f55adf1](/../../commit/f55adf1))
15
+ * Pass context and add ProviderState generator ([7a1cf3b](/../../commit/7a1cf3b))
16
+
17
+ #### Bug Fixes
18
+
19
+ * add HTTPS_HOST header if invoking a Sinatra app ([ed44189](/../../commit/ed44189))
20
+ * example/animal-service/Gemfile to reduce vulnerabilities ([981ebee](/../../commit/981ebee))
21
+
1
22
  <a name="v1.65.3"></a>
2
23
  ### v1.65.3 (2024-10-23)
3
24
 
@@ -1,6 +1,7 @@
1
1
  require 'json'
2
2
  require 'pact/reification'
3
3
  require 'pact/shared/null_expectation'
4
+ require 'pact/generators'
4
5
 
5
6
  module Pact
6
7
  module Provider
@@ -10,8 +11,9 @@ module Pact
10
11
  # See https://github.com/rack/rack/blob/e7d741c6282ca4cf4e01506f5681e6e6b14c0b32/SPEC#L87-89
11
12
  NO_HTTP_PREFIX = ["CONTENT-TYPE", "CONTENT-LENGTH"]
12
13
 
13
- def initialize expected_request
14
+ def initialize expected_request, state_params = nil
14
15
  @expected_request = expected_request
16
+ @state_params = state_params
15
17
  end
16
18
 
17
19
  def method
@@ -19,7 +21,7 @@ module Pact
19
21
  end
20
22
 
21
23
  def path
22
- expected_request.full_path
24
+ Pact::Generators.apply_generators(expected_request, "path", expected_request.full_path, @state_params)
23
25
  end
24
26
 
25
27
  def body
@@ -27,17 +29,22 @@ module Pact
27
29
  when String then expected_request.body
28
30
  when NullExpectation then ''
29
31
  else
30
- reified_body
32
+ Pact::Generators.apply_generators(expected_request, "body", reified_body, @state_params)
31
33
  end
32
34
  end
33
35
 
34
36
  def headers
35
37
  request_headers = {}
38
+ # https://github.com/pact-foundation/pact-ruby/pull/327
39
+ request_headers.merge!('HOST' => 'localhost') if defined?(Sinatra)
36
40
  return request_headers if expected_request.headers.is_a?(Pact::NullExpectation)
41
+
37
42
  expected_request.headers.each do |key, value|
38
- request_headers[rack_request_header_for(key)] = Pact::Reification.from_term(value)
43
+ request_headers[key] = Pact::Reification.from_term(value)
39
44
  end
40
- request_headers
45
+
46
+ request_headers = Pact::Generators.apply_generators(expected_request, "header", request_headers, @state_params)
47
+ request_headers.map{ |key,value| [rack_request_header_for(key), value]}.to_h
41
48
  end
42
49
 
43
50
  private
@@ -25,6 +25,7 @@ module Pact
25
25
  pact_uri = pact_source.uri
26
26
  Pact.configuration.output_stream.puts "INFO: Reading pact at #{pact_uri}"
27
27
  consumer_contract = Pact::ConsumerContract.from_json(pact_json)
28
+
28
29
  suffix = pact_uri.metadata[:pending] ? " [PENDING]": ""
29
30
  example_group_description = "Verifying a pact between #{consumer_contract.consumer.name} and #{consumer_contract.provider.name}#{suffix}"
30
31
  example_group_metadata = { pactfile_uri: pact_uri, pact_criteria: options[:criteria] }
@@ -77,7 +78,6 @@ module Pact
77
78
  end
78
79
 
79
80
  def describe_interaction interaction, options
80
-
81
81
  # pact_uri and pact_interaction are used by
82
82
  # Pact::Provider::RSpec::PactBrokerFormatter
83
83
 
@@ -103,8 +103,9 @@ module Pact
103
103
  before do | example |
104
104
  interaction_context.run_once :before do
105
105
  Pact.configuration.logger.info "Running example '#{Pact::RSpec.full_description(example)}'"
106
- set_up_provider_states interaction.provider_states, options[:consumer]
107
- replay_interaction interaction, options[:request_customizer]
106
+ provider_states_result = set_up_provider_states interaction.provider_states, options[:consumer]
107
+ state_params = provider_states_result[interaction.provider_state];
108
+ replay_interaction interaction, options[:request_customizer], state_params
108
109
  interaction_context.last_response = last_response
109
110
  end
110
111
  end
@@ -129,6 +130,7 @@ module Pact
129
130
  include Pact::RSpec::Matchers
130
131
  extend Pact::Matchers::Messages
131
132
 
133
+
132
134
  let(:expected_contents) { expected_response.body[:contents].as_json }
133
135
  let(:response) { interaction_context.last_response }
134
136
  let(:differ) { Pact.configuration.body_differ_for_content_type diff_content_type }
@@ -14,8 +14,8 @@ module Pact
14
14
  include Pact::Logging
15
15
  include Rack::Test::Methods
16
16
 
17
- def replay_interaction interaction, request_customizer = nil
18
- request = Request::Replayable.new(interaction.request)
17
+ def replay_interaction interaction, request_customizer = nil, state_params = nil
18
+ request = Request::Replayable.new(interaction.request, state_params)
19
19
  request = request_customizer.call(request, interaction) if request_customizer
20
20
  args = [request.path, request.body, request.headers]
21
21
 
@@ -42,11 +42,17 @@ module Pact
42
42
  end
43
43
 
44
44
  def set_up_provider_states provider_states, consumer, options = {}
45
+ provider_states_result = {};
45
46
  # If there are no provider state, execute with an nil state to ensure global and base states are executed
46
47
  Pact.configuration.provider_state_set_up.call(nil, consumer, options) if provider_states.nil? || provider_states.empty?
47
48
  provider_states.each do | provider_state |
48
- Pact.configuration.provider_state_set_up.call(provider_state.name, consumer, options.merge(params: provider_state.params))
49
+ result = Pact.configuration.provider_state_set_up.call(provider_state.name, consumer, options.merge(params: provider_state.params))
50
+ if result.is_a?(Hash)
51
+ provider_states_result[provider_state.name] = result
52
+ end
49
53
  end
54
+
55
+ provider_states_result
50
56
  end
51
57
 
52
58
  def tear_down_provider_states provider_states, consumer, options = {}
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 = "1.65.3"
3
+ VERSION = "1.66.1"
4
4
  end
data/pact.gemspec CHANGED
@@ -30,15 +30,17 @@ Gem::Specification.new do |gem|
30
30
  gem.add_runtime_dependency 'rack-test', '>= 0.6.3', '< 3.0.0'
31
31
  gem.add_runtime_dependency 'thor', '>= 0.20', '< 2.0'
32
32
  gem.add_runtime_dependency "rainbow", '~> 3.1'
33
+ gem.add_runtime_dependency 'string_pattern', '~> 2.0'
34
+ gem.add_runtime_dependency 'jsonpath', '~> 1.0'
33
35
 
34
- gem.add_runtime_dependency 'pact-support', '~> 1.16', '>= 1.16.9'
36
+ gem.add_runtime_dependency 'pact-support', '~> 1.21', '>= 1.21.0'
35
37
  gem.add_runtime_dependency 'pact-mock_service', '~> 3.0', '>= 3.3.1'
36
38
 
37
39
  gem.add_development_dependency 'rake', '~> 13.0'
38
40
  gem.add_development_dependency 'webmock', '~> 3.0'
39
- gem.add_development_dependency 'fakefs', '2.4' # 0.6.0 blows up
41
+ gem.add_development_dependency 'fakefs', '2.4'
40
42
  gem.add_development_dependency 'hashie', '~> 5.0'
41
- gem.add_development_dependency 'faraday', '~>1.0', '<3.0'
43
+ gem.add_development_dependency 'faraday', '~>2.0', '<3.0'
42
44
  gem.add_development_dependency 'faraday-multipart', '~> 1.0'
43
45
  gem.add_development_dependency 'conventional-changelog', '~> 1.3'
44
46
  gem.add_development_dependency 'bump', '~> 0.5'
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: 1.65.3
4
+ version: 1.66.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Fraser
@@ -9,10 +9,9 @@ authors:
9
9
  - Brent Snook
10
10
  - Ronald Holshausen
11
11
  - Beth Skurrie
12
- autorequire:
13
12
  bindir: bin
14
13
  cert_chain: []
15
- date: 2024-10-23 00:00:00.000000000 Z
14
+ date: 2025-01-20 00:00:00.000000000 Z
16
15
  dependencies:
17
16
  - !ruby/object:Gem::Dependency
18
17
  name: rspec
@@ -82,26 +81,54 @@ dependencies:
82
81
  - - "~>"
83
82
  - !ruby/object:Gem::Version
84
83
  version: '3.1'
84
+ - !ruby/object:Gem::Dependency
85
+ name: string_pattern
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '2.0'
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '2.0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: jsonpath
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '1.0'
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '1.0'
85
112
  - !ruby/object:Gem::Dependency
86
113
  name: pact-support
87
114
  requirement: !ruby/object:Gem::Requirement
88
115
  requirements:
89
116
  - - "~>"
90
117
  - !ruby/object:Gem::Version
91
- version: '1.16'
118
+ version: '1.21'
92
119
  - - ">="
93
120
  - !ruby/object:Gem::Version
94
- version: 1.16.9
121
+ version: 1.21.0
95
122
  type: :runtime
96
123
  prerelease: false
97
124
  version_requirements: !ruby/object:Gem::Requirement
98
125
  requirements:
99
126
  - - "~>"
100
127
  - !ruby/object:Gem::Version
101
- version: '1.16'
128
+ version: '1.21'
102
129
  - - ">="
103
130
  - !ruby/object:Gem::Version
104
- version: 1.16.9
131
+ version: 1.21.0
105
132
  - !ruby/object:Gem::Dependency
106
133
  name: pact-mock_service
107
134
  requirement: !ruby/object:Gem::Requirement
@@ -184,7 +211,7 @@ dependencies:
184
211
  requirements:
185
212
  - - "~>"
186
213
  - !ruby/object:Gem::Version
187
- version: '1.0'
214
+ version: '2.0'
188
215
  - - "<"
189
216
  - !ruby/object:Gem::Version
190
217
  version: '3.0'
@@ -194,7 +221,7 @@ dependencies:
194
221
  requirements:
195
222
  - - "~>"
196
223
  - !ruby/object:Gem::Version
197
- version: '1.0'
224
+ version: '2.0'
198
225
  - - "<"
199
226
  - !ruby/object:Gem::Version
200
227
  version: '3.0'
@@ -418,7 +445,6 @@ metadata:
418
445
  source_code_uri: https://github.com/pact-foundation/pact-ruby
419
446
  bug_tracker_uri: https://github.com/pact-foundation/pact-ruby/issues
420
447
  documentation_uri: https://github.com/pact-foundation/pact-ruby/blob/master/README.md
421
- post_install_message:
422
448
  rdoc_options: []
423
449
  require_paths:
424
450
  - lib
@@ -433,8 +459,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
433
459
  - !ruby/object:Gem::Version
434
460
  version: '0'
435
461
  requirements: []
436
- rubygems_version: 3.5.22
437
- signing_key:
462
+ rubygems_version: 3.6.3
438
463
  specification_version: 4
439
464
  summary: Enables consumer driven contract testing, providing a mock service and DSL
440
465
  for the consumer project, and interaction playback and verification for the service