pact 1.62.0 → 1.64.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: 7b4004f1a6eed7b4222d8f6f4bd72eb568c75fd198ab77ee663b6aab918ea907
4
- data.tar.gz: f6cc541f1416275a0cea5b0819d20f58e6b27d8ca10e8f708b0d44d382b88461
3
+ metadata.gz: 174a9376cd442f1edd545cd006e1b15f07804077bb91060678e224d1717c6a5b
4
+ data.tar.gz: 4b5d1a84949fbad2dedeb1233626ef649ac4352840a204ea20c6496d3c0c0493
5
5
  SHA512:
6
- metadata.gz: 31ce201c07203749e19cb6ca6d1088ef69f1119686119519ab5e15faddda38f80f2846b782efb2e7cb4c3e26bb9df529e45fcc1350df2be63819fbfde50c54e5
7
- data.tar.gz: 3fa2538f3f8472759eafcd12b8ef829141f343e5cdab8c83ba27bd4f4f1ca0eee1e960fb2467333b17da30a29c8bc849427178c5dc7566e2c94d948cd109a96e
6
+ metadata.gz: 957b95b85b59906f1a59bb23fe2b85674c1574171a0880a508df9c6413bc7fe3f2b54fc3fe766eab3fdd8f18e68eaabf4efda43da50df01c66ebe2e9a0f19111
7
+ data.tar.gz: 6a34522651d931773d8ee92565ffd5173fd3f2cd99ba1211d25985da499b62d993a5b62b87257afb11a759cf691aa7702efe9e1773d11165794980d1301138e1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,36 @@
1
+ <a name="v1.64.0"></a>
2
+ ### v1.64.0 (2023-11-09)
3
+
4
+ #### Features
5
+
6
+ * support x509 certs in HTTP Client (#298) ([3ed5680](/../../commit/3ed5680))
7
+
8
+ * **CI**
9
+ * use setup-ruby's bundle installer and cache (#275) ([f5621b6](/../../commit/f5621b6))
10
+
11
+ #### Bug Fixes
12
+
13
+ * assert provider retrieved successfully before using link ([0af0691](/../../commit/0af0691))
14
+ * update call to Rack::Builder.parse_file for rack 3 ([652047c](/../../commit/652047c))
15
+ * example/zoo-app/Gemfile to reduce vulnerabilities ([b4ca8cb](/../../commit/b4ca8cb))
16
+ * example/animal-service/Gemfile to reduce vulnerabilities ([7ad2073](/../../commit/7ad2073))
17
+ * example/zoo-app/Gemfile to reduce vulnerabilities ([dd417fd](/../../commit/dd417fd))
18
+ * example/animal-service/Gemfile to reduce vulnerabilities (#281) ([4ea07cd](/../../commit/4ea07cd))
19
+
20
+ <a name="v1.63.0"></a>
21
+ ### v1.63.0 (2022-09-28)
22
+
23
+ #### Features
24
+
25
+ * relax rack-test dependency to allow version 2 (#270) ([a619deb](/../../commit/a619deb))
26
+ * only print metrics warning once per thread ([91da38f](/../../commit/91da38f))
27
+ * provide configuration for build url to be published in verification results (#252) ([ce1c9bc](/../../commit/ce1c9bc))
28
+
29
+ #### Bug Fixes
30
+
31
+ * example/animal-service/Gemfile to reduce vulnerabilities (#263) ([8f3b732](/../../commit/8f3b732))
32
+ * Fixup ruby warnings (#262) ([3640593](/../../commit/3640593))
33
+
1
34
  <a name="v1.62.0"></a>
2
35
  ### v1.62.0 (2022-02-21)
3
36
 
@@ -23,6 +23,10 @@ module Pact
23
23
  _link(key).get(*args)
24
24
  end
25
25
 
26
+ def get!(key, *args)
27
+ _link(key).get!(*args)
28
+ end
29
+
26
30
  def post(key, *args)
27
31
  _link(key).post(*args)
28
32
  end
@@ -53,6 +53,12 @@ module Pact
53
53
  http.use_ssl = (uri.scheme == 'https')
54
54
  http.ca_file = ENV['SSL_CERT_FILE'] if ENV['SSL_CERT_FILE'] && ENV['SSL_CERT_FILE'] != ''
55
55
  http.ca_path = ENV['SSL_CERT_DIR'] if ENV['SSL_CERT_DIR'] && ENV['SSL_CERT_DIR'] != ''
56
+
57
+ if x509_certificate?
58
+ http.cert = OpenSSL::X509::Certificate.new(x509_client_cert_file)
59
+ http.key = OpenSSL::PKey::RSA.new(x509_client_key_file)
60
+ end
61
+
56
62
  if disable_ssl_verification?
57
63
  if verbose?
58
64
  Pact.configuration.output_stream.puts("SSL verification is disabled")
@@ -74,6 +80,19 @@ module Pact
74
80
  verbose || ENV['VERBOSE'] == 'true'
75
81
  end
76
82
 
83
+ def x509_certificate?
84
+ ENV['X509_CLIENT_CERT_FILE'] && ENV['X509_CLIENT_CERT_FILE'] != '' &&
85
+ ENV['X509_CLIENT_KEY_FILE'] && ENV['X509_CLIENT_KEY_FILE'] != ''
86
+ end
87
+
88
+ def x509_client_cert_file
89
+ File.read(ENV['X509_CLIENT_CERT_FILE'])
90
+ end
91
+
92
+ def x509_client_key_file
93
+ File.read(ENV['X509_CLIENT_KEY_FILE'])
94
+ end
95
+
77
96
  def disable_ssl_verification?
78
97
  ENV['PACT_DISABLE_SSL_VERIFICATION'] == 'true' || ENV['PACT_BROKER_DISABLE_SSL_VERIFICATION'] == 'true'
79
98
  end
@@ -46,7 +46,7 @@ module Pact
46
46
  end
47
47
 
48
48
  def honours_pacts_from_pact_broker &block
49
- create_pact_verification_from_broker &block
49
+ create_pact_verification_from_broker(&block)
50
50
  end
51
51
 
52
52
  def builder &block
@@ -4,14 +4,15 @@ module Pact
4
4
  class ServiceProviderConfig
5
5
 
6
6
  attr_accessor :application_version
7
- attr_reader :branch
7
+ attr_reader :branch, :build_url
8
8
 
9
- def initialize application_version, branch, tags, publish_verification_results, &app_block
9
+ def initialize application_version, branch, tags, publish_verification_results, build_url, &app_block
10
10
  @application_version = application_version
11
11
  @branch = branch
12
12
  @tags = [*tags]
13
13
  @publish_verification_results = publish_verification_results
14
14
  @app_block = app_block
15
+ @build_url = build_url
15
16
  end
16
17
 
17
18
  def app
@@ -15,13 +15,19 @@ module Pact
15
15
 
16
16
  extend Pact::DSL
17
17
 
18
- attr_accessor :name, :app_block, :application_version, :branch, :tags, :publish_verification_results
18
+ attr_accessor :name, :app_block, :application_version, :branch, :tags, :publish_verification_results, :build_url
19
19
 
20
20
  CONFIG_RU_APP = lambda {
21
21
  unless File.exist? Pact.configuration.config_ru_path
22
22
  raise "Could not find config.ru file at #{Pact.configuration.config_ru_path} Please configure the service provider app or create a config.ru file in the root directory of the project. See https://github.com/pact-foundation/pact-ruby/wiki/Verifying-pacts for more information."
23
23
  end
24
- Rack::Builder.parse_file(Pact.configuration.config_ru_path).first
24
+ result = Rack::Builder.parse_file(Pact.configuration.config_ru_path)
25
+
26
+ if result.respond_to?(:first) # rack 2
27
+ result.first
28
+ else # rack 3
29
+ result
30
+ end
25
31
  }
26
32
 
27
33
  def initialize name
@@ -48,6 +54,10 @@ module Pact
48
54
  self.branch = branch
49
55
  end
50
56
 
57
+ def build_url build_url
58
+ self.build_url = build_url
59
+ end
60
+
51
61
  def publish_verification_results publish_verification_results
52
62
  self.publish_verification_results = publish_verification_results
53
63
  Pact::RSpec.with_rspec_2 do
@@ -60,7 +70,7 @@ module Pact
60
70
  end
61
71
 
62
72
  def honours_pacts_from_pact_broker &block
63
- create_pact_verification_from_broker &block
73
+ create_pact_verification_from_broker(&block)
64
74
  end
65
75
  end
66
76
 
@@ -89,7 +99,7 @@ module Pact
89
99
  end
90
100
 
91
101
  def create_service_provider
92
- Pact.configuration.provider = ServiceProviderConfig.new(application_version, branch, tags, publish_verification_results, &@app_block)
102
+ Pact.configuration.provider = ServiceProviderConfig.new(application_version, branch, tags, publish_verification_results, build_url, &@app_block)
93
103
  end
94
104
  end
95
105
  end
@@ -3,7 +3,7 @@ module Pact
3
3
  class PactURI
4
4
  attr_reader :uri, :options, :metadata
5
5
 
6
- def initialize (uri, options = nil, metadata = nil)
6
+ def initialize(uri, options = nil, metadata = nil)
7
7
  @uri = uri
8
8
  @options = options || {}
9
9
  @metadata = metadata || {} # make sure it's not nil if nil is passed in
@@ -12,11 +12,11 @@ module Pact
12
12
  end
13
13
 
14
14
  def set_up &block
15
- ProviderStates.base_provider_state.register.register_set_up &block
15
+ ProviderStates.base_provider_state.register.register_set_up(&block)
16
16
  end
17
17
 
18
18
  def tear_down &block
19
- ProviderStates.base_provider_state.register_tear_down &block
19
+ ProviderStates.base_provider_state.register_tear_down(&block)
20
20
  end
21
21
 
22
22
  def provider_states_for name, &block
@@ -60,7 +60,7 @@ module Pact
60
60
  end
61
61
 
62
62
  def self.namespaced_name name, options = {}
63
- fullname = options[:for] ? "#{options[:for]}.#{name}" : name
63
+ options[:for] ? "#{options[:for]}.#{name}" : name
64
64
  end
65
65
  end
66
66
 
@@ -81,11 +81,11 @@ module Pact
81
81
 
82
82
  dsl do
83
83
  def set_up &block
84
- self.register_set_up &block
84
+ self.register_set_up(&block)
85
85
  end
86
86
 
87
87
  def tear_down &block
88
- self.register_tear_down &block
88
+ self.register_tear_down(&block)
89
89
  end
90
90
 
91
91
  def no_op
@@ -14,7 +14,13 @@ module Pact
14
14
  end
15
15
 
16
16
  def call
17
- VerificationResult.new(publishable?, !any_failures?, Pact.configuration.provider.application_version, test_results_hash_for_pact_uri)
17
+ VerificationResult.new(
18
+ publishable?,
19
+ !any_failures?,
20
+ Pact.configuration.provider.application_version,
21
+ test_results_hash_for_pact_uri,
22
+ Pact.configuration.provider.build_url
23
+ )
18
24
  end
19
25
 
20
26
  private
@@ -135,7 +135,7 @@ module Pact
135
135
  end
136
136
 
137
137
  def provider_entity
138
- @provider_entity ||= pact_entity.get(PROVIDER_RELATION)
138
+ @provider_entity ||= pact_entity.get!(PROVIDER_RELATION)
139
139
  end
140
140
  end
141
141
  end
@@ -6,11 +6,12 @@ module Pact
6
6
  class VerificationResult
7
7
  attr_reader :success, :provider_application_version, :test_results_hash
8
8
 
9
- def initialize publishable, success, provider_application_version, test_results_hash
9
+ def initialize publishable, success, provider_application_version, test_results_hash, build_url
10
10
  @publishable = publishable
11
11
  @success = success
12
12
  @provider_application_version = provider_application_version
13
13
  @test_results_hash = test_results_hash
14
+ @build_url = build_url
14
15
  end
15
16
 
16
17
  def publishable?
@@ -25,7 +26,8 @@ module Pact
25
26
  {
26
27
  success: success,
27
28
  providerApplicationVersion: provider_application_version,
28
- testResults: test_results_hash
29
+ testResults: test_results_hash,
30
+ buildUrl: @build_url
29
31
  }.to_json(options)
30
32
  end
31
33
 
@@ -9,13 +9,17 @@ module Pact
9
9
  class Metrics
10
10
 
11
11
  def self.report_metric(event, category, action, value = 1)
12
+ do_once_per_thread(:pact_metrics_message_shown) do
13
+ if track_events?
14
+ Pact.configuration.output_stream.puts "pact WARN: Please note: we are tracking events anonymously to gather important usage statistics like Pact-Ruby version
15
+ and operating system. To disable tracking, set the 'PACT_DO_NOT_TRACK' environment
16
+ variable to 'true'."
17
+ end
18
+ end
19
+
12
20
  in_thread do
13
21
  begin
14
22
  if track_events?
15
- Pact.configuration.output_stream.puts "WARN: Please note: we are tracking events anonymously to gather important usage statistics like Pact-Ruby version
16
- and operating system. To disable tracking, set the 'PACT_DO_NOT_TRACK' environment
17
- variable to 'true'."
18
-
19
23
  uri = URI('https://www.google-analytics.com/collect')
20
24
  req = Net::HTTP::Post.new(uri)
21
25
  req.set_form_data(create_tracking_event(event, category, action, value))
@@ -31,6 +35,7 @@ module Pact
31
35
  end
32
36
 
33
37
  private
38
+
34
39
  def self.handle_error e
35
40
  if ENV['PACT_METRICS_DEBUG'] == 'true'
36
41
  Pact.configuration.output_stream.puts("DEBUG: #{e.inspect}\n" + e.backtrace.join("\n"))
@@ -43,6 +48,16 @@ module Pact
43
48
  end
44
49
  end
45
50
 
51
+ # not super safe to use the thread, but it's good enough for this usecase
52
+ def self.do_once_per_thread(key)
53
+ result = nil
54
+ if !Thread.current[key]
55
+ result = yield
56
+ end
57
+ Thread.current[key] = true
58
+ result
59
+ end
60
+
46
61
  def self.create_tracking_event(event, category, action, value)
47
62
  {
48
63
  "v" => 1,
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.62.0"
3
+ VERSION = "1.64.0"
4
4
  end
data/pact.gemspec CHANGED
@@ -27,20 +27,20 @@ Gem::Specification.new do |gem|
27
27
  }
28
28
 
29
29
  gem.add_runtime_dependency 'rspec', '~> 3.0'
30
- gem.add_runtime_dependency 'rack-test', '>= 0.6.3', '< 2.0.0'
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
- gem.add_runtime_dependency 'webrick', '~> 1.3'
33
- gem.add_runtime_dependency 'term-ansicolor', '~> 1.0'
32
+ gem.add_runtime_dependency 'webrick', '~> 1.8'
33
+ gem.add_runtime_dependency 'term-ansicolor', '~> 1.7'
34
34
 
35
35
  gem.add_runtime_dependency 'pact-support', '~> 1.16', '>= 1.16.9'
36
36
  gem.add_runtime_dependency 'pact-mock_service', '~> 3.0', '>= 3.3.1'
37
37
 
38
38
  gem.add_development_dependency 'rake', '~> 13.0'
39
39
  gem.add_development_dependency 'webmock', '~> 3.0'
40
- gem.add_development_dependency 'fakefs', '0.5' # 0.6.0 blows up
41
- gem.add_development_dependency 'hashie', '~> 2.0'
42
- gem.add_development_dependency 'activesupport', '~> 5.2'
43
- gem.add_development_dependency 'faraday', '~> 0.13'
40
+ gem.add_development_dependency 'fakefs', '2.4' # 0.6.0 blows up
41
+ gem.add_development_dependency 'hashie', '~> 5.0'
42
+ gem.add_development_dependency 'faraday', '~>1.0', '<3.0'
43
+ gem.add_development_dependency 'faraday-multipart', '~> 1.0'
44
44
  gem.add_development_dependency 'conventional-changelog', '~> 1.3'
45
45
  gem.add_development_dependency 'bump', '~> 0.5'
46
46
  gem.add_development_dependency 'pact-message', '~> 0.8'
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.62.0
4
+ version: 1.64.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: 2022-02-21 00:00:00.000000000 Z
15
+ date: 2023-12-20 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rspec
@@ -37,7 +37,7 @@ dependencies:
37
37
  version: 0.6.3
38
38
  - - "<"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.0.0
40
+ version: 3.0.0
41
41
  type: :runtime
42
42
  prerelease: false
43
43
  version_requirements: !ruby/object:Gem::Requirement
@@ -47,7 +47,7 @@ dependencies:
47
47
  version: 0.6.3
48
48
  - - "<"
49
49
  - !ruby/object:Gem::Version
50
- version: 2.0.0
50
+ version: 3.0.0
51
51
  - !ruby/object:Gem::Dependency
52
52
  name: thor
53
53
  requirement: !ruby/object:Gem::Requirement
@@ -74,28 +74,28 @@ dependencies:
74
74
  requirements:
75
75
  - - "~>"
76
76
  - !ruby/object:Gem::Version
77
- version: '1.3'
77
+ version: '1.8'
78
78
  type: :runtime
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - "~>"
83
83
  - !ruby/object:Gem::Version
84
- version: '1.3'
84
+ version: '1.8'
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: term-ansicolor
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
89
  - - "~>"
90
90
  - !ruby/object:Gem::Version
91
- version: '1.0'
91
+ version: '1.7'
92
92
  type: :runtime
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - "~>"
97
97
  - !ruby/object:Gem::Version
98
- version: '1.0'
98
+ version: '1.7'
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: pact-support
101
101
  requirement: !ruby/object:Gem::Requirement
@@ -170,56 +170,62 @@ dependencies:
170
170
  requirements:
171
171
  - - '='
172
172
  - !ruby/object:Gem::Version
173
- version: '0.5'
173
+ version: '2.4'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - '='
179
179
  - !ruby/object:Gem::Version
180
- version: '0.5'
180
+ version: '2.4'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: hashie
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
185
  - - "~>"
186
186
  - !ruby/object:Gem::Version
187
- version: '2.0'
187
+ version: '5.0'
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
- version: '2.0'
194
+ version: '5.0'
195
195
  - !ruby/object:Gem::Dependency
196
- name: activesupport
196
+ name: faraday
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: '5.2'
201
+ version: '1.0'
202
+ - - "<"
203
+ - !ruby/object:Gem::Version
204
+ version: '3.0'
202
205
  type: :development
203
206
  prerelease: false
204
207
  version_requirements: !ruby/object:Gem::Requirement
205
208
  requirements:
206
209
  - - "~>"
207
210
  - !ruby/object:Gem::Version
208
- version: '5.2'
211
+ version: '1.0'
212
+ - - "<"
213
+ - !ruby/object:Gem::Version
214
+ version: '3.0'
209
215
  - !ruby/object:Gem::Dependency
210
- name: faraday
216
+ name: faraday-multipart
211
217
  requirement: !ruby/object:Gem::Requirement
212
218
  requirements:
213
219
  - - "~>"
214
220
  - !ruby/object:Gem::Version
215
- version: '0.13'
221
+ version: '1.0'
216
222
  type: :development
217
223
  prerelease: false
218
224
  version_requirements: !ruby/object:Gem::Requirement
219
225
  requirements:
220
226
  - - "~>"
221
227
  - !ruby/object:Gem::Version
222
- version: '0.13'
228
+ version: '1.0'
223
229
  - !ruby/object:Gem::Dependency
224
230
  name: conventional-changelog
225
231
  requirement: !ruby/object:Gem::Requirement
@@ -413,7 +419,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
413
419
  - !ruby/object:Gem::Version
414
420
  version: '0'
415
421
  requirements: []
416
- rubygems_version: 3.3.7
422
+ rubygems_version: 3.5.1
417
423
  signing_key:
418
424
  specification_version: 4
419
425
  summary: Enables consumer driven contract testing, providing a mock service and DSL