pact-provider-verifier 1.34.0 → 1.36.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: 97f4e0f7b4b4f8daf7cb3960ce80e52a23119f2409abde541f51b64c653ae93a
4
- data.tar.gz: 6126a5247e221ca0fc05e2e4dd829023f75c8c3682e4a20ed497a629b24d4651
3
+ metadata.gz: 8a78bbf0bd6a02f5ae8601da7624b20ad1721c68ab63f8522519861eeeb43b4b
4
+ data.tar.gz: 8d7cba4856e310898b110697d9835f6787ce4f9900047d8318f1fb87bff3e431
5
5
  SHA512:
6
- metadata.gz: 7640a18b5a9d83766ca30138172d43521e543c8509325c2566867aab51afeccccdad472b8cafef12d701b0f28f16950fddaf7d697b664d6742a024b307d137a2
7
- data.tar.gz: 762afb591b585af8a3a178f277e2084676df0a2b9336d39bd4ba89d078527d50b9d1134e0df41af212c8425dff1761aa0d4d26e72b0434c6fd89c0ae8296fa05
6
+ metadata.gz: 9bf7bd254fe9003ce19a89222757c4f8b890e97dadd9044391a0431b0d6e92163b607d66306abe1f7540fba3101b2e3e4dfaecb61f6db793b356e0474d319160
7
+ data.tar.gz: 505923346b53a1f8331db747bc43d8a6f7819263829a57eb38878d486e1ef3bb9e0829a32b56d843fd6d3abae139ea05795b1f82edacc4a939fb4ce8a19f3965
data/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ <a name="v1.36.0"></a>
2
+ ### v1.36.0 (2021-09-09)
3
+
4
+ #### Features
5
+
6
+ * add support for specifying the provider version branch ([7f53206](/../../commit/7f53206))
7
+
8
+ <a name="v1.35.2"></a>
9
+ ### v1.35.2 (2021-09-09)
10
+
11
+ #### Bug Fixes
12
+
13
+ * lock pact gem to compatible version ([b4db21e](/../../commit/b4db21e))
14
+
15
+ <a name="v1.35.1"></a>
16
+ ### v1.35.1 (2021-07-01)
17
+
18
+ #### Bug Fixes
19
+
20
+ * exit with correct exit code on failure ([a8a2144](/../../commit/a8a2144))
21
+
22
+ <a name="v1.35.0"></a>
23
+ ### v1.35.0 (2021-03-20)
24
+
25
+ #### Features
26
+
27
+ * Optionally fail when no pacts are found ([772e8fb](/../../commit/772e8fb))
28
+
1
29
  <a name="v1.34.0"></a>
2
30
  ### v1.34.0 (2021-02-01)
3
31
 
data/README.md CHANGED
@@ -10,7 +10,7 @@ binary-like CLI tool.
10
10
 
11
11
  * Verify Pacts against Pacts published to an http endpoint, such as a [Pact Broker](https://github.com/pact-foundation/pact_broker)
12
12
  * Verify local `*.json` Pacts on the file system
13
- * Works with Pact [provider states](https://docs.pact.io/documentation/provider_states.html) should you need them
13
+ * Works with Pact [provider states](https://docs.pact.io/getting_started/provider_states) should you need them
14
14
  * Publishes the verification results back to the pact broker if the pact was retrieved from a broker.
15
15
 
16
16
  ## Installation
@@ -97,6 +97,8 @@ Options:
97
97
  # The log level
98
98
 
99
99
  # Default: debug
100
+ [--fail-if-no-pacts-found]
101
+ # If specified, will fail when no pacts are found
100
102
 
101
103
  Description:
102
104
  The parameters used when fetching pacts dynamically from a Pact Broker are:
@@ -108,9 +110,9 @@ Description:
108
110
  --enable-pending
109
111
  --include-wip-pacts-since
110
112
 
111
- To fetch a pact from a known URL (eg. when a
112
- verification is triggered by a 'contract content changed' webhook), pass in the pact URL(s) as
113
- the first argument(s) to the command.
113
+ To verify a pact at a known URL (eg. when a verification is triggered by a 'contract content changed'
114
+ webhook), pass in the pact URL(s) as the first argument(s) to the command, and do NOT set any of the
115
+ other parameters apart from the base URL and credentials.
114
116
 
115
117
  To publish verification results for either of the above scenarios, set:
116
118
 
@@ -159,7 +161,7 @@ Modification of the request headers is sometimes necessary, but be aware that an
159
161
 
160
162
  ### API with Provider States
161
163
 
162
- Read the [Provider States section on docs.pact.io](https://docs.pact.io/documentation/provider_states.html) for an introduction to provider states.
164
+ Read the [Provider States section on docs.pact.io](https://docs.pact.io/getting_started/provider_states) for an introduction to provider states.
163
165
 
164
166
  To allow the correct data to be set up before each interaction is replayed, you will need to create a dev/test only HTTP endpoint that accepts a JSON document that looks like:
165
167
 
@@ -6,15 +6,16 @@ module Pact
6
6
  module ProviderVerifier
7
7
  class AggregatePactConfigs
8
8
 
9
- def self.call(pact_urls, provider_name, consumer_version_tags, consumer_version_selectors, provider_version_tags, pact_broker_base_url, http_client_options, options)
10
- new(pact_urls, provider_name, consumer_version_tags, consumer_version_selectors, provider_version_tags, pact_broker_base_url, http_client_options, options).call
9
+ def self.call(pact_urls, provider_name, consumer_version_tags, consumer_version_selectors, provider_version_branch, provider_version_tags, pact_broker_base_url, http_client_options, options)
10
+ new(pact_urls, provider_name, consumer_version_tags, consumer_version_selectors, provider_version_branch, provider_version_tags, pact_broker_base_url, http_client_options, options).call
11
11
  end
12
12
 
13
- def initialize(pact_urls, provider_name, consumer_version_tags, consumer_version_selectors, provider_version_tags, pact_broker_base_url, http_client_options, options)
13
+ def initialize(pact_urls, provider_name, consumer_version_tags, consumer_version_selectors, provider_version_branch, provider_version_tags, pact_broker_base_url, http_client_options, options)
14
14
  @pact_urls = pact_urls
15
15
  @provider_name = provider_name
16
16
  @consumer_version_tags = consumer_version_tags
17
17
  @consumer_version_selectors = consumer_version_selectors
18
+ @provider_version_branch = provider_version_branch
18
19
  @provider_version_tags = provider_version_tags
19
20
  @pact_broker_base_url = pact_broker_base_url
20
21
  @http_client_options = http_client_options
@@ -27,7 +28,7 @@ module Pact
27
28
 
28
29
  private
29
30
 
30
- attr_reader :pact_urls, :provider_name, :consumer_version_tags, :consumer_version_selectors, :provider_version_tags, :pact_broker_base_url, :http_client_options, :options
31
+ attr_reader :pact_urls, :provider_name, :consumer_version_tags, :consumer_version_selectors, :provider_version_branch, :provider_version_tags, :pact_broker_base_url, :http_client_options, :options
31
32
 
32
33
  def specified_pact_uris
33
34
  pact_urls.collect{ | url | Pact::PactBroker.build_pact_uri(url, http_client_options) }
@@ -45,6 +46,7 @@ module Pact
45
46
  @pacts_for_verification ||= Pact::PactBroker.fetch_pact_uris_for_verification(
46
47
  provider_name,
47
48
  aggregated_consumer_version_selectors,
49
+ provider_version_branch,
48
50
  provider_version_tags,
49
51
  pact_broker_base_url,
50
52
  http_client_options,
@@ -19,13 +19,14 @@ module Pact
19
19
 
20
20
  PROXY_PACT_HELPER = File.expand_path(File.join(File.dirname(__FILE__), "pact_helper.rb"))
21
21
  EMPTY_ARRAY = [].freeze
22
- attr_reader :pact_urls, :options, :consumer_version_tags, :provider_version_tags, :consumer_version_selectors, :publish_verification_results
22
+ attr_reader :pact_urls, :options, :consumer_version_tags, :provider_version_branch, :provider_version_tags, :consumer_version_selectors, :publish_verification_results
23
23
 
24
24
  def initialize pact_urls, options = {}
25
25
  @pact_urls = pact_urls
26
26
  @options = options
27
27
  @consumer_version_tags = options.consumer_version_tag || EMPTY_ARRAY
28
28
  @provider_version_tags = merge_provider_version_tags(options)
29
+ @provider_version_branch = options.provider_version_branch
29
30
  @consumer_version_selectors = parse_consumer_version_selectors(options.consumer_version_selector || EMPTY_ARRAY)
30
31
  @publish_verification_results = options.publish_verification_results || ENV['PACT_BROKER_PUBLISH_VERIFICATION_RESULTS'] == 'true'
31
32
  end
@@ -36,18 +37,23 @@ module Pact
36
37
 
37
38
  def call
38
39
  setup
39
-
40
- pact_urls = all_pact_urls
40
+ warn_empty_pact_set
41
41
  wait_until_provider_available
42
- exit_statuses = pact_urls.collect do |pact_uri|
42
+ pacts_pass_verification?
43
+ end
44
+
45
+ private
46
+
47
+ def pacts_pass_verification?
48
+ return false if all_pact_urls.empty? && options.fail_if_no_pacts_found
49
+
50
+ exit_statuses = all_pact_urls.collect do |pact_uri|
43
51
  verify_pact pact_uri
44
52
  end
45
53
 
46
54
  exit_statuses.all?{ | status | status == 0 }
47
55
  end
48
56
 
49
- private
50
-
51
57
 
52
58
  def setup
53
59
  configure_output
@@ -187,25 +193,35 @@ module Pact
187
193
  end
188
194
 
189
195
  def all_pact_urls
190
- http_client_options = {
191
- username: options.broker_username || ENV['PACT_BROKER_USERNAME'],
192
- password: options.broker_password || ENV['PACT_BROKER_PASSWORD'],
193
- token: options.broker_token || ENV['PACT_BROKER_TOKEN'],
194
- verbose: verbose?
195
- }
196
- opts = {
197
- enable_pending: options.enable_pending,
198
- include_wip_pacts_since: options.include_wip_pacts_since
199
- }
200
- AggregatePactConfigs.call(
201
- pact_urls,
202
- options.provider,
203
- consumer_version_tags,
204
- consumer_version_selectors,
205
- provider_version_tags,
206
- options.pact_broker_base_url || ENV['PACT_BROKER_BASE_URL'],
207
- http_client_options,
208
- opts)
196
+ @all_pact_urls ||= begin
197
+ http_client_options = {
198
+ username: options.broker_username || ENV['PACT_BROKER_USERNAME'],
199
+ password: options.broker_password || ENV['PACT_BROKER_PASSWORD'],
200
+ token: options.broker_token || ENV['PACT_BROKER_TOKEN'],
201
+ verbose: verbose?
202
+ }
203
+ opts = {
204
+ enable_pending: options.enable_pending,
205
+ include_wip_pacts_since: options.include_wip_pacts_since
206
+ }
207
+ AggregatePactConfigs.call(
208
+ pact_urls,
209
+ options.provider,
210
+ consumer_version_tags,
211
+ consumer_version_selectors,
212
+ provider_version_branch,
213
+ provider_version_tags,
214
+ options.pact_broker_base_url || ENV['PACT_BROKER_BASE_URL'],
215
+ http_client_options,
216
+ opts)
217
+ end
218
+ end
219
+
220
+ def warn_empty_pact_set
221
+ if all_pact_urls.empty?
222
+ level = options.fail_if_no_pacts_found ? "ERROR" : "WARN"
223
+ $stderr.puts "#{level}: No pacts were found for the consumer versions selected"
224
+ end
209
225
  end
210
226
 
211
227
  def require_pact_project_pact_helper
@@ -7,7 +7,7 @@ The parameters used when fetching pacts dynamically from a Pact Broker are:
7
7
  --enable-pending
8
8
  --include-wip-pacts-since
9
9
 
10
- To fetch a pact from a known URL (eg. when a verification is triggered by a 'contract content changed' webhook), pass in the pact URL(s) as the first argument(s) to the command.
10
+ To verify a pact at a known URL (eg. when a verification is triggered by a 'contract content changed' webhook), pass in the pact URL(s) as the first argument(s) to the command, and do NOT set any of the other parameters apart from the base URL and credentials.
11
11
 
12
12
  To publish verification results for either of the above scenarios, set:
13
13
 
@@ -21,6 +21,7 @@ module Pact
21
21
  method_option :consumer_version_tag, type: :array, banner: "TAG", desc: "Retrieve the latest pacts with this consumer version tag. Used in conjunction with --provider. May be specified multiple times.", :required => false
22
22
  method_option :consumer_version_selector, hide: true, type: :array, banner: "SELECTOR", desc: "JSON string specifying a selector that identifies which pacts to verify. May be specified multiple times. See below for further documentation.", :required => false
23
23
  method_option :provider_version_tag, type: :array, banner: "TAG", desc: "Tag to apply to the provider application version. May be specified multiple times.", :required => false
24
+ method_option :provider_version_branch, banner: "BRANCH", desc: "The name of the branch the provider version belongs to.", :required => false
24
25
  method_option :tag_with_git_branch, aliases: "-g", type: :boolean, default: false, required: false, desc: "Tag provider version with the name of the current git branch. Default: false"
25
26
  method_option :provider_app_version, aliases: "-a", desc: "Provider application version, required when publishing verification results", :required => false
26
27
  method_option :publish_verification_results, aliases: "-r", desc: "Publish verification results to the broker. This can also be enabled by setting the environment variable PACT_BROKER_PUBLISH_VERIFICATION_RESULTS=true", required: false, type: :boolean, default: false
@@ -38,6 +39,7 @@ module Pact
38
39
  method_option :wait, banner: "SECONDS", required: false, type: :numeric, desc: "The number of seconds to poll for the provider to become available before running the verification", default: 0
39
40
  method_option :log_dir, desc: "The directory for the pact.log file"
40
41
  method_option :log_level, desc: "The log level", default: "debug"
42
+ method_option :fail_if_no_pacts_found, desc: "If specified, will fail when no pacts are found", required: false, type: :boolean, default: false
41
43
 
42
44
  def verify(*pact_urls)
43
45
  require 'pact/provider_verifier/app'
@@ -124,7 +126,7 @@ module Pact
124
126
  exit 1
125
127
  end
126
128
 
127
- def exit_on_failure?
129
+ def self.exit_on_failure?
128
130
  true
129
131
  end
130
132
  end
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module ProviderVerifier
3
- VERSION = "1.34.0"
3
+ VERSION = "1.36.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pact-provider-verifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.34.0
4
+ version: 1.36.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Fellows
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-02-01 00:00:00.000000000 Z
12
+ date: 2021-09-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '1.55'
34
+ version: '1.59'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '1.55'
41
+ version: '1.59'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: pact-message
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -342,7 +342,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
342
342
  - !ruby/object:Gem::Version
343
343
  version: '0'
344
344
  requirements: []
345
- rubygems_version: 3.2.7
345
+ rubygems_version: 3.2.27
346
346
  signing_key:
347
347
  specification_version: 4
348
348
  summary: Provides a Pact verification service for use with Pact