pact-provider-verifier 1.25.2 → 1.26.0
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 +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +49 -17
- data/lib/pact/provider_verifier/aggregate_pact_configs.rb +20 -7
- data/lib/pact/provider_verifier/app.rb +18 -3
- data/lib/pact/provider_verifier/cli/verify.rb +31 -1
- data/lib/pact/provider_verifier/version.rb +1 -1
- metadata +6 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2353417f47f75fbb238b3401c5ddbfa5dc98766f83ac1e78105a246420549636
|
|
4
|
+
data.tar.gz: abc6c780757ba1153318867cd8869883c6bbae1bee245a0504d3ed4b39708704
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b700edfe49387ab05780793f5fb9c515041633e6e345ee4bd30a8d4fbe0e9a64f1a0a55dd1c9daef12ad03fcd9d497c0eef4cabb16a7090d999bea6f996700fe
|
|
7
|
+
data.tar.gz: 4ac919f6e3f8fa1e6fa15719b67c5cb6406c7de62e2b26cb67f828afdc872dbe1c75f695b1b43885ebb2b08a66f72672041b4740ef21e4fb5f1acc8d863d91a0
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
<a name="v1.26.0-1"></a>
|
|
2
|
+
### v1.26.0-1 (2020-01-11)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
#### Features
|
|
6
|
+
|
|
7
|
+
* **cli**
|
|
8
|
+
* allow publishing of verification results to be enabled by setting the environment variable PACT_BROKER_PUBLISH_VERIFICATION_RESULTS=true ([14e37f0](/../../commit/14e37f0))
|
|
9
|
+
* add --enable-pending parameter to CLI ([0b32a1c](/../../commit/0b32a1c))
|
|
10
|
+
* add --consumer-version-selector parameter ([2526590](/../../commit/2526590))
|
|
11
|
+
* add long description ([905ab8d](/../../commit/905ab8d))
|
|
12
|
+
|
|
13
|
+
|
|
1
14
|
<a name="v1.25.1-1"></a>
|
|
2
15
|
### v1.25.1-1 (2019-11-10)
|
|
3
16
|
|
data/README.md
CHANGED
|
@@ -40,24 +40,56 @@ Usage:
|
|
|
40
40
|
pact-provider-verifier PACT_URL ... -h, --provider-base-url=PROVIDER_BASE_URL
|
|
41
41
|
|
|
42
42
|
Options:
|
|
43
|
-
-h, --provider-base-url=PROVIDER_BASE_URL
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
-h, --provider-base-url=PROVIDER_BASE_URL
|
|
44
|
+
# Provider host URL
|
|
45
|
+
-c, [--provider-states-setup-url=PROVIDER_STATES_SETUP_URL]
|
|
46
|
+
# Base URL to setup the provider states at
|
|
47
|
+
[--pact-broker-base-url=PACT_BROKER_BASE_URL]
|
|
48
|
+
# Base URL of the Pact Broker from which to retrieve the pacts.
|
|
49
|
+
-n, [--broker-username=BROKER_USERNAME]
|
|
50
|
+
# Pact Broker basic auth username
|
|
51
|
+
-p, [--broker-password=BROKER_PASSWORD]
|
|
52
|
+
# Pact Broker basic auth password
|
|
53
|
+
-k, [--broker-token=BROKER_TOKEN]
|
|
54
|
+
# Pact Broker bearer token
|
|
49
55
|
[--provider=PROVIDER]
|
|
50
|
-
[--consumer-version-tag=TAG]
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
[--
|
|
55
|
-
|
|
56
|
-
-
|
|
57
|
-
|
|
58
|
-
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
[--consumer-version-tag=TAG]
|
|
57
|
+
# Retrieve the latest pacts with this consumer version tag. Used in conjunction with --provider. May be specified multiple times.
|
|
58
|
+
[--consumer-version-selector=SELECTOR]
|
|
59
|
+
# JSON string specifying a selector that identifies which pacts to verify. May be specified multiple times. See below for further documentation.
|
|
60
|
+
[--provider-version-tag=TAG]
|
|
61
|
+
# Tag to apply to the provider application version. May be specified multiple times.
|
|
62
|
+
-a, [--provider-app-version=PROVIDER_APP_VERSION]
|
|
63
|
+
# Provider application version, required when publishing verification results
|
|
64
|
+
-r, [--publish-verification-results], [--no-publish-verification-results]
|
|
65
|
+
# Publish verification results to the broker. This can also be enabled by setting the environment variable PACT_BROKER_PUBLISH_VERIFICATION_RESULTS=true
|
|
66
|
+
[--enable-pending], [--no-enable-pending]
|
|
67
|
+
# Allow pacts which are in pending state to be verified without causing the overall task to fail. For more information, see https://pact.io/pending
|
|
68
|
+
[--custom-provider-header=CUSTOM_PROVIDER_HEADER]
|
|
69
|
+
# Header to add to provider state set up and pact verification requests. eg 'Authorization: Basic cGFjdDpwYWN0'. May be specified multiple times.
|
|
70
|
+
[--custom-middleware=FILE]
|
|
71
|
+
# Ruby file containing a class implementing Pact::ProviderVerifier::CustomMiddleware. This allows the response to be modified before replaying. Use with caution!
|
|
72
|
+
-v, [--verbose=VERBOSE]
|
|
73
|
+
# Verbose output
|
|
74
|
+
-f, [--format=FORMATTER]
|
|
75
|
+
# RSpec formatter. Defaults to custom Pact formatter. Other options are json and RspecJunitFormatter (which outputs xml).
|
|
76
|
+
-o, [--out=FILE]
|
|
77
|
+
# Write output to a file instead of $stdout.
|
|
78
|
+
[--wait=SECONDS]
|
|
79
|
+
# The number of seconds to poll for the provider to become available before running the verification
|
|
80
|
+
|
|
81
|
+
# Default: 0
|
|
82
|
+
|
|
83
|
+
Description:
|
|
84
|
+
To verify a pact from a known URL, specify one or more PACT_URL arguments. If the pact is
|
|
85
|
+
hosted in a Pact Broker that uses authentication, specify the relevant
|
|
86
|
+
--broker-username/--broker-password or --broker-token fields. To dynamically fetch pacts
|
|
87
|
+
from a Pact Broker based on the provider name, specify the --pact-broker-base-url,
|
|
88
|
+
--provider and relevant authentication fields.
|
|
89
|
+
|
|
90
|
+
Selectors: These are specified using JSON strings. The keys are 'tag' (the name of the consumer
|
|
91
|
+
version tag) and 'latest' (true|false). For example '{"tag": "master", "latest": true}'.
|
|
92
|
+
For a detailed explanation of selectors, see https://pact.io/selectors
|
|
61
93
|
```
|
|
62
94
|
|
|
63
95
|
## Examples
|
|
@@ -6,17 +6,19 @@ module Pact
|
|
|
6
6
|
module ProviderVerifier
|
|
7
7
|
class AggregatePactConfigs
|
|
8
8
|
|
|
9
|
-
def self.call(pact_urls, provider_name, consumer_version_tags, provider_version_tags, pact_broker_base_url, http_client_options)
|
|
10
|
-
new(pact_urls, provider_name, consumer_version_tags, provider_version_tags, pact_broker_base_url, http_client_options).call
|
|
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
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
def initialize(pact_urls, provider_name, consumer_version_tags, provider_version_tags, pact_broker_base_url, http_client_options)
|
|
13
|
+
def initialize(pact_urls, provider_name, consumer_version_tags, consumer_version_selectors, 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
|
+
@consumer_version_selectors = consumer_version_selectors
|
|
17
18
|
@provider_version_tags = provider_version_tags
|
|
18
19
|
@pact_broker_base_url = pact_broker_base_url
|
|
19
20
|
@http_client_options = http_client_options
|
|
21
|
+
@options = options
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
def call
|
|
@@ -25,7 +27,7 @@ module Pact
|
|
|
25
27
|
|
|
26
28
|
private
|
|
27
29
|
|
|
28
|
-
attr_reader :pact_urls, :provider_name, :consumer_version_tags, :provider_version_tags, :pact_broker_base_url, :http_client_options
|
|
30
|
+
attr_reader :pact_urls, :provider_name, :consumer_version_tags, :consumer_version_selectors, :provider_version_tags, :pact_broker_base_url, :http_client_options, :options
|
|
29
31
|
|
|
30
32
|
def specified_pact_uris
|
|
31
33
|
pact_urls.collect{ | url | Pact::PactBroker.build_pact_uri(url, http_client_options) }
|
|
@@ -40,11 +42,22 @@ module Pact
|
|
|
40
42
|
end
|
|
41
43
|
|
|
42
44
|
def pacts_for_verification
|
|
43
|
-
@pacts_for_verification ||= Pact::PactBroker.fetch_pact_uris_for_verification(
|
|
45
|
+
@pacts_for_verification ||= Pact::PactBroker.fetch_pact_uris_for_verification(
|
|
46
|
+
provider_name,
|
|
47
|
+
aggregated_consumer_version_selectors,
|
|
48
|
+
provider_version_tags,
|
|
49
|
+
pact_broker_base_url,
|
|
50
|
+
http_client_options,
|
|
51
|
+
pact_options
|
|
52
|
+
)
|
|
44
53
|
end
|
|
45
54
|
|
|
46
|
-
def
|
|
47
|
-
consumer_version_tags.collect{ |tag| { tag: tag, latest: true } }
|
|
55
|
+
def aggregated_consumer_version_selectors
|
|
56
|
+
consumer_version_selectors + consumer_version_tags.collect{ |tag| { tag: tag, latest: true } }
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def pact_options
|
|
60
|
+
{ include_pending_status: options[:enable_pending] }
|
|
48
61
|
end
|
|
49
62
|
end
|
|
50
63
|
end
|
|
@@ -17,13 +17,15 @@ module Pact
|
|
|
17
17
|
include Pact::WaitUntilServerAvailable
|
|
18
18
|
|
|
19
19
|
PROXY_PACT_HELPER = File.expand_path(File.join(File.dirname(__FILE__), "pact_helper.rb"))
|
|
20
|
-
attr_reader :pact_urls, :options, :consumer_version_tags, :provider_version_tags
|
|
20
|
+
attr_reader :pact_urls, :options, :consumer_version_tags, :provider_version_tags, :consumer_version_selectors, :publish_verification_results
|
|
21
21
|
|
|
22
22
|
def initialize pact_urls, options = {}
|
|
23
23
|
@pact_urls = pact_urls
|
|
24
24
|
@options = options
|
|
25
25
|
@consumer_version_tags = options[:consumer_version_tag] || []
|
|
26
26
|
@provider_version_tags = options[:provider_version_tag] || []
|
|
27
|
+
@consumer_version_selectors = parse_consumer_version_selectors(options[:consumer_version_selector] || [])
|
|
28
|
+
@publish_verification_results = options.publish_verification_results || ENV['PACT_BROKER_PUBLISH_VERIFICATION_RESULTS'] == 'true'
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
def self.call pact_urls, options
|
|
@@ -82,7 +84,7 @@ module Pact
|
|
|
82
84
|
app_version_tags this.provider_version_tags
|
|
83
85
|
end
|
|
84
86
|
|
|
85
|
-
publish_verification_results this.
|
|
87
|
+
publish_verification_results this.publish_verification_results
|
|
86
88
|
end
|
|
87
89
|
end
|
|
88
90
|
|
|
@@ -174,7 +176,16 @@ module Pact
|
|
|
174
176
|
|
|
175
177
|
def all_pact_urls
|
|
176
178
|
http_client_options = { username: options.broker_username, password: options.broker_password, token: options.broker_token, verbose: options.verbose }
|
|
177
|
-
AggregatePactConfigs.call(
|
|
179
|
+
AggregatePactConfigs.call(
|
|
180
|
+
pact_urls,
|
|
181
|
+
options.provider,
|
|
182
|
+
consumer_version_tags,
|
|
183
|
+
consumer_version_selectors,
|
|
184
|
+
provider_version_tags,
|
|
185
|
+
options.pact_broker_base_url,
|
|
186
|
+
http_client_options,
|
|
187
|
+
{ enable_pending: options.enable_pending }
|
|
188
|
+
)
|
|
178
189
|
end
|
|
179
190
|
|
|
180
191
|
def require_pact_project_pact_helper
|
|
@@ -200,6 +211,10 @@ module Pact
|
|
|
200
211
|
end
|
|
201
212
|
end
|
|
202
213
|
|
|
214
|
+
def parse_consumer_version_selectors consumer_version_selectors
|
|
215
|
+
consumer_version_selectors.collect{ | string | JSON.parse(string) }
|
|
216
|
+
end
|
|
217
|
+
|
|
203
218
|
def print_deprecation_note
|
|
204
219
|
if options.provider_states_url
|
|
205
220
|
$stderr.puts "WARN: The --provider-states-url option is deprecated and the URL endpoint can be removed from the application"
|
|
@@ -3,6 +3,12 @@ require 'socket'
|
|
|
3
3
|
require 'pact/provider_verifier/app'
|
|
4
4
|
require 'pact/provider_verifier/cli/custom_thor'
|
|
5
5
|
|
|
6
|
+
# verify --consumer-version-selector '{ all: true, tag: "feat-x", fallback: "master" }' --consumer-version-tag master
|
|
7
|
+
|
|
8
|
+
#
|
|
9
|
+
# tags "master", { all: true, tag: "feat-x", fallback: "master" }
|
|
10
|
+
#
|
|
11
|
+
|
|
6
12
|
module Pact
|
|
7
13
|
module ProviderVerifier
|
|
8
14
|
module CLI
|
|
@@ -10,7 +16,13 @@ module Pact
|
|
|
10
16
|
|
|
11
17
|
class InvalidArgumentsError < ::Thor::Error; end
|
|
12
18
|
|
|
19
|
+
SELECTOR_DOCS = "Selectors: These are specified using JSON strings. The keys are 'tag' (the name of the consumer version tag) and 'latest' (true|false). " +
|
|
20
|
+
"For example '{\"tag\": \"master\", \"latest\": true}'. For a detailed explanation of selectors, see https://pact.io/selectors"
|
|
21
|
+
|
|
13
22
|
desc 'PACT_URL ...', "Verify pact(s) against a provider. Supports local and networked (http-based) files."
|
|
23
|
+
long_desc "To verify a pact from a known URL, specify one or more PACT_URL arguments. If the pact is hosted in a Pact Broker that uses authentication, specify the relevant --broker-username/--broker-password or --broker-token fields. " +
|
|
24
|
+
"To dynamically fetch pacts from a Pact Broker based on the provider name, specify the --pact-broker-base-url, --provider and relevant authentication fields." +
|
|
25
|
+
"\n\n" + SELECTOR_DOCS
|
|
14
26
|
method_option :provider_base_url, aliases: "-h", desc: "Provider host URL", :required => true
|
|
15
27
|
method_option :provider_states_setup_url, aliases: "-c", desc: "Base URL to setup the provider states at", :required => false
|
|
16
28
|
method_option :pact_broker_base_url, desc: "Base URL of the Pact Broker from which to retrieve the pacts.", :required => false
|
|
@@ -19,9 +31,11 @@ module Pact
|
|
|
19
31
|
method_option :broker_token, aliases: "-k", desc: "Pact Broker bearer token", :required => false
|
|
20
32
|
method_option :provider, required: false
|
|
21
33
|
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
|
|
34
|
+
method_option :consumer_version_selector, 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
|
|
22
35
|
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
|
|
23
36
|
method_option :provider_app_version, aliases: "-a", desc: "Provider application version, required when publishing verification results", :required => false
|
|
24
|
-
method_option :publish_verification_results, aliases: "-r", desc: "Publish verification results to the broker", required: false, type: :boolean, default: false
|
|
37
|
+
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
|
+
method_option :enable_pending, desc: "Allow pacts which are in pending state to be verified without causing the overall task to fail. For more information, see https://pact.io/pending", required: false, type: :boolean, default: false
|
|
25
39
|
method_option :custom_provider_header, type: :array, banner: 'CUSTOM_PROVIDER_HEADER', desc: "Header to add to provider state set up and pact verification requests. eg 'Authorization: Basic cGFjdDpwYWN0'. May be specified multiple times.", :required => false
|
|
26
40
|
method_option :custom_middleware, type: :array, banner: 'FILE', desc: "Ruby file containing a class implementing Pact::ProviderVerifier::CustomMiddleware. This allows the response to be modified before replaying. Use with caution!", :required => false
|
|
27
41
|
method_option :monkeypatch, hide: true, type: :array, :required => false
|
|
@@ -64,6 +78,22 @@ module Pact
|
|
|
64
78
|
if options.pact_broker_base_url && (options.provider.nil? || options.provider == "")
|
|
65
79
|
raise InvalidArgumentsError, "No value provided for required option '--provider'"
|
|
66
80
|
end
|
|
81
|
+
validate_consumer_version_selectors
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def validate_consumer_version_selectors
|
|
85
|
+
error_messages = (options.consumer_version_selector || []).collect do | string |
|
|
86
|
+
begin
|
|
87
|
+
JSON.parse(string)
|
|
88
|
+
nil
|
|
89
|
+
rescue
|
|
90
|
+
"Invalid JSON string provided for --consumer-version-selector: #{string}"
|
|
91
|
+
end
|
|
92
|
+
end.compact
|
|
93
|
+
|
|
94
|
+
if error_messages.any?
|
|
95
|
+
raise InvalidArgumentsError, error_messages.join("\n")
|
|
96
|
+
end
|
|
67
97
|
end
|
|
68
98
|
|
|
69
99
|
def exit_with_non_zero_status
|
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.
|
|
4
|
+
version: 1.26.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:
|
|
12
|
+
date: 2020-01-11 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rspec
|
|
@@ -31,20 +31,14 @@ dependencies:
|
|
|
31
31
|
requirements:
|
|
32
32
|
- - "~>"
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
|
-
version: '1.
|
|
35
|
-
- - ">="
|
|
36
|
-
- !ruby/object:Gem::Version
|
|
37
|
-
version: 1.42.3
|
|
34
|
+
version: '1.43'
|
|
38
35
|
type: :runtime
|
|
39
36
|
prerelease: false
|
|
40
37
|
version_requirements: !ruby/object:Gem::Requirement
|
|
41
38
|
requirements:
|
|
42
39
|
- - "~>"
|
|
43
40
|
- !ruby/object:Gem::Version
|
|
44
|
-
version: '1.
|
|
45
|
-
- - ">="
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: 1.42.3
|
|
41
|
+
version: '1.43'
|
|
48
42
|
- !ruby/object:Gem::Dependency
|
|
49
43
|
name: pact-message
|
|
50
44
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -113,14 +107,14 @@ dependencies:
|
|
|
113
107
|
requirements:
|
|
114
108
|
- - "~>"
|
|
115
109
|
- !ruby/object:Gem::Version
|
|
116
|
-
version: '2.
|
|
110
|
+
version: '2.1'
|
|
117
111
|
type: :runtime
|
|
118
112
|
prerelease: false
|
|
119
113
|
version_requirements: !ruby/object:Gem::Requirement
|
|
120
114
|
requirements:
|
|
121
115
|
- - "~>"
|
|
122
116
|
- !ruby/object:Gem::Version
|
|
123
|
-
version: '2.
|
|
117
|
+
version: '2.1'
|
|
124
118
|
- !ruby/object:Gem::Dependency
|
|
125
119
|
name: rake
|
|
126
120
|
requirement: !ruby/object:Gem::Requirement
|