pact 1.65.3 → 1.66.0

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: d5f4cb5a83116a65cd755ec7d8e8ab48a07bbd9084854eafe8479ce619258d87
4
+ data.tar.gz: 453b876959da6e040739f461d53d342c5c76650720480f484694f4f40a67b3f5
5
5
  SHA512:
6
- metadata.gz: 48ae099d0e39dfe40ed0928cc6f33dcfe297154fae7c00c61bffa12b67e0b84c80ea8df198afc6a602c66aad1a9527aad188d5ff7d1bcf04c7fdd2a85ccc9c44
7
- data.tar.gz: b62f9883ca3b7336cb93acb76b88963c6361970d14aac3604ddc43480bb4a56d97fd05afa1c35a7c6d2a834e3ad8e5b6f940042ea6789020508e0e256fcdcaa6
6
+ metadata.gz: d4de1c45268fdd6c77c7dddb4ea15235a8cc12604670acb8f64b95569dcbb64de4f1a81e8333e5ec640dcf0da6f90ed8463d34c9203f5c1260d689d16cf1ff81
7
+ data.tar.gz: 7d5c9e3124136d5604b821566a22f7967f1b2e3fb160ab6a15547462c25a28562b467ee029d6740f42047933d1d55c20c53b4b880f8ea0a86af46e3af1cfbe16
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ <a name="v1.66.0"></a>
2
+ ### v1.66.0 (2024-11-29)
3
+
4
+ #### Features
5
+
6
+ * **generators**
7
+ * Add more generators as per spec ([f55adf1](/../../commit/f55adf1))
8
+ * Pass context and add ProviderState generator ([7a1cf3b](/../../commit/7a1cf3b))
9
+
10
+ #### Bug Fixes
11
+
12
+ * add HTTPS_HOST header if invoking a Sinatra app ([ed44189](/../../commit/ed44189))
13
+ * example/animal-service/Gemfile to reduce vulnerabilities ([981ebee](/../../commit/981ebee))
14
+
1
15
  <a name="v1.65.3"></a>
2
16
  ### v1.65.3 (2024-10-23)
3
17
 
@@ -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,21 @@ 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
+ request_headers.merge!('HTTP_HOST' => 'localhost') if defined?(Sinatra)
36
39
  return request_headers if expected_request.headers.is_a?(Pact::NullExpectation)
40
+
37
41
  expected_request.headers.each do |key, value|
38
- request_headers[rack_request_header_for(key)] = Pact::Reification.from_term(value)
42
+ request_headers[key] = Pact::Reification.from_term(value)
39
43
  end
40
- request_headers
44
+
45
+ request_headers = Pact::Generators.apply_generators(expected_request, "header", request_headers, @state_params)
46
+ request_headers.map{ |key,value| [rack_request_header_for(key), value]}.to_h
41
47
  end
42
48
 
43
49
  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.0"
4
4
  end
data/pact.gemspec CHANGED
@@ -30,8 +30,10 @@ 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.19', '>= 1.19.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'
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Fraser
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2024-10-23 00:00:00.000000000 Z
15
+ date: 2024-11-29 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rspec
@@ -82,26 +82,54 @@ dependencies:
82
82
  - - "~>"
83
83
  - !ruby/object:Gem::Version
84
84
  version: '3.1'
85
+ - !ruby/object:Gem::Dependency
86
+ name: string_pattern
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '2.0'
92
+ type: :runtime
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - "~>"
97
+ - !ruby/object:Gem::Version
98
+ version: '2.0'
99
+ - !ruby/object:Gem::Dependency
100
+ name: jsonpath
101
+ requirement: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - "~>"
104
+ - !ruby/object:Gem::Version
105
+ version: '1.0'
106
+ type: :runtime
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - "~>"
111
+ - !ruby/object:Gem::Version
112
+ version: '1.0'
85
113
  - !ruby/object:Gem::Dependency
86
114
  name: pact-support
87
115
  requirement: !ruby/object:Gem::Requirement
88
116
  requirements:
89
117
  - - "~>"
90
118
  - !ruby/object:Gem::Version
91
- version: '1.16'
119
+ version: '1.19'
92
120
  - - ">="
93
121
  - !ruby/object:Gem::Version
94
- version: 1.16.9
122
+ version: 1.19.0
95
123
  type: :runtime
96
124
  prerelease: false
97
125
  version_requirements: !ruby/object:Gem::Requirement
98
126
  requirements:
99
127
  - - "~>"
100
128
  - !ruby/object:Gem::Version
101
- version: '1.16'
129
+ version: '1.19'
102
130
  - - ">="
103
131
  - !ruby/object:Gem::Version
104
- version: 1.16.9
132
+ version: 1.19.0
105
133
  - !ruby/object:Gem::Dependency
106
134
  name: pact-mock_service
107
135
  requirement: !ruby/object:Gem::Requirement
@@ -433,7 +461,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
433
461
  - !ruby/object:Gem::Version
434
462
  version: '0'
435
463
  requirements: []
436
- rubygems_version: 3.5.22
464
+ rubygems_version: 3.5.23
437
465
  signing_key:
438
466
  specification_version: 4
439
467
  summary: Enables consumer driven contract testing, providing a mock service and DSL