pact 1.55.6 → 1.58.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +32 -0
- data/lib/pact/cli/run_pact_verification.rb +1 -0
- data/lib/pact/cli.rb +1 -0
- data/lib/pact/hal/http_client.rb +1 -1
- data/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb +6 -4
- data/lib/pact/pact_broker/pact_selection_description.rb +2 -2
- data/lib/pact/provider/configuration/pact_verification_from_broker.rb +4 -2
- data/lib/pact/provider/configuration/service_provider_config.rb +3 -1
- data/lib/pact/provider/configuration/service_provider_dsl.rb +7 -3
- data/lib/pact/provider/help/write.rb +2 -0
- data/lib/pact/provider/pact_spec_runner.rb +1 -0
- data/lib/pact/provider/pact_uri.rb +6 -2
- data/lib/pact/provider/rspec/pact_broker_formatter.rb +1 -1
- data/lib/pact/provider/rspec.rb +1 -1
- data/lib/pact/provider/verification_results/publish.rb +31 -5
- data/lib/pact/provider/verification_results/publish_all.rb +6 -5
- data/lib/pact/provider/world.rb +1 -1
- data/lib/pact/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0eccb0bdb60c799b434febc79b825448330f476eb1fd9041d85067b73afa12f
|
4
|
+
data.tar.gz: 552f9f3e11377b6bc4ebb0cb5a30ee5f95f5689ac7dcf0b74a59ec7688eaafac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef8d1d0f38c7370d36c1643592b82f45415e18065fb1ae3cc07f63f6eb20c082c80376995e3c0388b1bd85e432ada99bc13b4c2024d66ea1f1d2a511a6efa298
|
7
|
+
data.tar.gz: bb42f0d27a63304df146884e152f60f8628c673db09d52c6ff979a2c1508973522cf4f09bb7cb87dea0c2139ca500c745038a0f4702b1f38e67cae6838a68292
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,35 @@
|
|
1
|
+
<a name="v1.58.0"></a>
|
2
|
+
### v1.58.0 (2021-09-01)
|
3
|
+
|
4
|
+
#### Features
|
5
|
+
|
6
|
+
* support publishing verification results with a version branch ([da2facf](/../../commit/da2facf))
|
7
|
+
|
8
|
+
#### Bug Fixes
|
9
|
+
|
10
|
+
* gracefully handle display of username that causes InvalidComponentError to be raised when composing a URI ([cecb98f](/../../commit/cecb98f))
|
11
|
+
|
12
|
+
<a name="v1.57.0"></a>
|
13
|
+
### v1.57.0 (2021-01-27)
|
14
|
+
|
15
|
+
#### Features
|
16
|
+
|
17
|
+
* allow verbose flag to be set when publishing verifications ([9238e4c](/../../commit/9238e4c))
|
18
|
+
|
19
|
+
<a name="v1.56.0"></a>
|
20
|
+
### v1.56.0 (2021-01-22)
|
21
|
+
|
22
|
+
#### Features
|
23
|
+
|
24
|
+
* catch and log error during help text generation ([182a7cd](/../../commit/182a7cd))
|
25
|
+
|
26
|
+
<a name="v1.55.7"></a>
|
27
|
+
### v1.55.7 (2020-11-25)
|
28
|
+
|
29
|
+
#### Bug Fixes
|
30
|
+
|
31
|
+
* add consumer name to the selection description (#229) ([5127036](/../../commit/5127036))
|
32
|
+
|
1
33
|
<a name="v1.55.6"></a>
|
2
34
|
### v1.55.6 (2020-11-06)
|
3
35
|
|
data/lib/pact/cli.rb
CHANGED
@@ -16,6 +16,7 @@ module Pact
|
|
16
16
|
method_option :pact_broker_password, aliases: "-w", desc: "Pact broker password"
|
17
17
|
method_option :pact_broker_token, aliases: "-k", desc: "Pact broker token"
|
18
18
|
method_option :backtrace, aliases: "-b", desc: "Show full backtrace", :default => false, :type => :boolean
|
19
|
+
method_option :verbose, aliases: "-v", desc: "Show verbose HTTP logging", :default => false, :type => :boolean
|
19
20
|
method_option :interactions_replay_order, aliases: "-o",
|
20
21
|
desc: "Interactions replay order: randomised or recorded (default)",
|
21
22
|
default: Pact.configuration.interactions_replay_order
|
data/lib/pact/hal/http_client.rb
CHANGED
@@ -48,7 +48,7 @@ module Pact
|
|
48
48
|
def perform_request request, uri
|
49
49
|
response = Retry.until_true do
|
50
50
|
http = Net::HTTP.new(uri.host, uri.port, :ENV)
|
51
|
-
http.set_debug_output(output_stream) if verbose
|
51
|
+
http.set_debug_output(output_stream) if verbose || ENV['VERBOSE'] == 'true'
|
52
52
|
http.use_ssl = (uri.scheme == 'https')
|
53
53
|
http.ca_file = ENV['SSL_CERT_FILE'] if ENV['SSL_CERT_FILE'] && ENV['SSL_CERT_FILE'] != ''
|
54
54
|
http.ca_path = ENV['SSL_CERT_DIR'] if ENV['SSL_CERT_DIR'] && ENV['SSL_CERT_DIR'] != ''
|
@@ -10,7 +10,7 @@ module Pact
|
|
10
10
|
module PactBroker
|
11
11
|
class FetchPactURIsForVerification
|
12
12
|
include PactSelectionDescription
|
13
|
-
attr_reader :provider, :consumer_version_selectors, :provider_version_tags, :broker_base_url, :http_client_options, :http_client, :options
|
13
|
+
attr_reader :provider, :consumer_version_selectors, :provider_version_branch, :provider_version_tags, :broker_base_url, :http_client_options, :http_client, :options
|
14
14
|
|
15
15
|
PACTS_FOR_VERIFICATION_RELATION = 'pb:provider-pacts-for-verification'.freeze
|
16
16
|
PACTS_FOR_VERIFICATION_RELATION_BETA = 'beta:provider-pacts-for-verification'.freeze
|
@@ -20,9 +20,10 @@ module Pact
|
|
20
20
|
SELF = 'self'.freeze
|
21
21
|
EMBEDDED = '_embedded'.freeze
|
22
22
|
|
23
|
-
def initialize(provider, consumer_version_selectors, provider_version_tags, broker_base_url, http_client_options, options = {})
|
23
|
+
def initialize(provider, consumer_version_selectors, provider_version_branch, provider_version_tags, broker_base_url, http_client_options, options = {})
|
24
24
|
@provider = provider
|
25
25
|
@consumer_version_selectors = consumer_version_selectors || []
|
26
|
+
@provider_version_branch = provider_version_branch
|
26
27
|
@provider_version_tags = [*provider_version_tags]
|
27
28
|
@http_client_options = http_client_options
|
28
29
|
@broker_base_url = broker_base_url
|
@@ -30,8 +31,8 @@ module Pact
|
|
30
31
|
@options = options
|
31
32
|
end
|
32
33
|
|
33
|
-
def self.call(provider, consumer_version_selectors, provider_version_tags, broker_base_url, http_client_options, options = {})
|
34
|
-
new(provider, consumer_version_selectors, provider_version_tags, broker_base_url, http_client_options, options).call
|
34
|
+
def self.call(provider, consumer_version_selectors, provider_version_branch, provider_version_tags, broker_base_url, http_client_options, options = {})
|
35
|
+
new(provider, consumer_version_selectors, provider_version_branch, provider_version_tags, broker_base_url, http_client_options, options).call
|
35
36
|
end
|
36
37
|
|
37
38
|
def call
|
@@ -76,6 +77,7 @@ module Pact
|
|
76
77
|
q["includePendingStatus"] = true if options[:include_pending_status]
|
77
78
|
q["consumerVersionSelectors"] = consumer_version_selectors if consumer_version_selectors.any?
|
78
79
|
q["providerVersionTags"] = provider_version_tags if provider_version_tags.any?
|
80
|
+
q["providerVersionBranch"] = provider_version_branch if provider_version_branch
|
79
81
|
q["includeWipPactsSince"] = options[:include_wip_pacts_since] if options[:include_wip_pacts_since]
|
80
82
|
q
|
81
83
|
end
|
@@ -2,14 +2,14 @@ module Pact
|
|
2
2
|
module PactBroker
|
3
3
|
module PactSelectionDescription
|
4
4
|
def pact_selection_description(provider, consumer_version_selectors, options, broker_base_url)
|
5
|
-
latest = consumer_version_selectors.any? ? "" : "latest "
|
6
5
|
message = "Fetching pacts for #{provider} from #{broker_base_url} with the selection criteria: "
|
7
6
|
if consumer_version_selectors.any?
|
8
7
|
desc = consumer_version_selectors.collect do |selector|
|
9
8
|
all_or_latest = !selector[:latest] ? "all for tag" : "latest for tag"
|
9
|
+
consumer = selector[:consumer] ? "of consumer #{selector[:consumer]}" : nil
|
10
10
|
fallback = selector[:fallback] || selector[:fallbackTag]
|
11
11
|
name = fallback ? "#{selector[:tag]} (or #{fallback} if not found)" : selector[:tag]
|
12
|
-
|
12
|
+
[all_or_latest, name, consumer].compact.join(" ")
|
13
13
|
end.join(", ")
|
14
14
|
if options[:include_wip_pacts_since]
|
15
15
|
desc = "#{desc}, work in progress pacts created after #{options[:include_wip_pacts_since]}"
|
@@ -15,10 +15,11 @@ module Pact
|
|
15
15
|
# in parent scope, it will clash with these ones,
|
16
16
|
# so put an underscore in front of the name to be safer.
|
17
17
|
|
18
|
-
attr_accessor :_provider_name, :_pact_broker_base_url, :_consumer_version_tags, :_provider_version_tags, :_basic_auth_options, :_enable_pending, :_include_wip_pacts_since, :_verbose, :_consumer_version_selectors
|
18
|
+
attr_accessor :_provider_name, :_pact_broker_base_url, :_consumer_version_tags, :_provider_version_branch, :_provider_version_tags, :_basic_auth_options, :_enable_pending, :_include_wip_pacts_since, :_verbose, :_consumer_version_selectors
|
19
19
|
|
20
|
-
def initialize(provider_name, provider_version_tags)
|
20
|
+
def initialize(provider_name, provider_version_branch, provider_version_tags)
|
21
21
|
@_provider_name = provider_name
|
22
|
+
@_provider_version_branch = provider_version_branch
|
22
23
|
@_provider_version_tags = provider_version_tags
|
23
24
|
@_consumer_version_tags = []
|
24
25
|
@_consumer_version_selectors = []
|
@@ -69,6 +70,7 @@ module Pact
|
|
69
70
|
fetch_pacts = Pact::PactBroker::FetchPactURIsForVerification.new(
|
70
71
|
_provider_name,
|
71
72
|
consumer_version_selectors,
|
73
|
+
_provider_version_branch,
|
72
74
|
_provider_version_tags,
|
73
75
|
_pact_broker_base_url,
|
74
76
|
_basic_auth_options.merge(verbose: _verbose),
|
@@ -4,9 +4,11 @@ module Pact
|
|
4
4
|
class ServiceProviderConfig
|
5
5
|
|
6
6
|
attr_accessor :application_version
|
7
|
+
attr_reader :branch
|
7
8
|
|
8
|
-
def initialize application_version, tags, publish_verification_results, &app_block
|
9
|
+
def initialize application_version, branch, tags, publish_verification_results, &app_block
|
9
10
|
@application_version = application_version
|
11
|
+
@branch = branch
|
10
12
|
@tags = [*tags]
|
11
13
|
@publish_verification_results = publish_verification_results
|
12
14
|
@app_block = app_block
|
@@ -15,7 +15,7 @@ module Pact
|
|
15
15
|
|
16
16
|
extend Pact::DSL
|
17
17
|
|
18
|
-
attr_accessor :name, :app_block, :application_version, :tags, :publish_verification_results
|
18
|
+
attr_accessor :name, :app_block, :application_version, :branch, :tags, :publish_verification_results
|
19
19
|
|
20
20
|
CONFIG_RU_APP = lambda {
|
21
21
|
unless File.exist? Pact.configuration.config_ru_path
|
@@ -44,6 +44,10 @@ module Pact
|
|
44
44
|
self.tags = tags
|
45
45
|
end
|
46
46
|
|
47
|
+
def app_version_branch branch
|
48
|
+
self.branch = branch
|
49
|
+
end
|
50
|
+
|
47
51
|
def publish_verification_results publish_verification_results
|
48
52
|
self.publish_verification_results = publish_verification_results
|
49
53
|
Pact::RSpec.with_rspec_2 do
|
@@ -65,7 +69,7 @@ module Pact
|
|
65
69
|
end
|
66
70
|
|
67
71
|
def create_pact_verification_from_broker(&block)
|
68
|
-
PactVerificationFromBroker.build(name, tags, &block)
|
72
|
+
PactVerificationFromBroker.build(name, branch, tags, &block)
|
69
73
|
end
|
70
74
|
|
71
75
|
def finalize
|
@@ -85,7 +89,7 @@ module Pact
|
|
85
89
|
end
|
86
90
|
|
87
91
|
def create_service_provider
|
88
|
-
Pact.configuration.provider = ServiceProviderConfig.new(application_version, tags, publish_verification_results, &@app_block)
|
92
|
+
Pact.configuration.provider = ServiceProviderConfig.new(application_version, branch, tags, publish_verification_results, &@app_block)
|
89
93
|
end
|
90
94
|
end
|
91
95
|
end
|
@@ -30,7 +30,11 @@ module Pact
|
|
30
30
|
|
31
31
|
def to_s
|
32
32
|
if basic_auth? && http_or_https_uri?
|
33
|
-
|
33
|
+
begin
|
34
|
+
URI(@uri).tap { |x| x.userinfo="#{username}:*****"}.to_s
|
35
|
+
rescue URI::InvalidComponentError
|
36
|
+
URI(@uri).tap { |x| x.userinfo="*****:*****"}.to_s
|
37
|
+
end
|
34
38
|
elsif personal_access_token? && http_or_https_uri?
|
35
39
|
URI(@uri).tap { |x| x.userinfo="*****"}.to_s
|
36
40
|
else
|
@@ -45,7 +49,7 @@ module Pact
|
|
45
49
|
private def http_or_https_uri?
|
46
50
|
uri.start_with?('http://', 'https://')
|
47
51
|
end
|
48
|
-
|
52
|
+
|
49
53
|
end
|
50
54
|
end
|
51
55
|
end
|
@@ -25,7 +25,7 @@ module Pact
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def close(_notification)
|
28
|
-
Pact::Provider::VerificationResults::PublishAll.call(Pact.provider_world.pact_sources, output_hash)
|
28
|
+
Pact::Provider::VerificationResults::PublishAll.call(Pact.provider_world.pact_sources, output_hash, { verbose: Pact.provider_world.verbose })
|
29
29
|
end
|
30
30
|
|
31
31
|
private
|
data/lib/pact/provider/rspec.rb
CHANGED
@@ -16,21 +16,23 @@ module Pact
|
|
16
16
|
PUBLISH_RELATION = 'pb:publish-verification-results'.freeze
|
17
17
|
PROVIDER_RELATION = 'pb:provider'.freeze
|
18
18
|
VERSION_TAG_RELATION = 'pb:version-tag'.freeze
|
19
|
+
BRANCH_VERSION_RELATION = 'pb:branch-version'.freeze
|
19
20
|
|
20
|
-
def self.call pact_source, verification_result
|
21
|
-
new(pact_source, verification_result).call
|
21
|
+
def self.call pact_source, verification_result, options = {}
|
22
|
+
new(pact_source, verification_result, options).call
|
22
23
|
end
|
23
24
|
|
24
|
-
def initialize pact_source, verification_result
|
25
|
+
def initialize pact_source, verification_result, options = {}
|
25
26
|
@pact_source = pact_source
|
26
27
|
@verification_result = verification_result
|
27
28
|
http_client_options = pact_source.uri.options.reject{ |k, v| ![:username, :password, :token].include?(k) }
|
28
|
-
@http_client = Pact::Hal::HttpClient.new(http_client_options)
|
29
|
+
@http_client = Pact::Hal::HttpClient.new(http_client_options.merge(verbose: options[:verbose]))
|
29
30
|
@pact_entity = Pact::Hal::Entity.new(pact_source.uri, pact_source.pact_hash, http_client)
|
30
31
|
end
|
31
32
|
|
32
33
|
def call
|
33
34
|
if can_publish_verification_results?
|
35
|
+
create_branch_version_if_configured
|
34
36
|
tag_versions_if_configured
|
35
37
|
publish_verification_results
|
36
38
|
true
|
@@ -72,8 +74,28 @@ module Pact
|
|
72
74
|
end
|
73
75
|
end
|
74
76
|
|
77
|
+
def create_branch_version_if_configured
|
78
|
+
if Pact.configuration.provider.branch
|
79
|
+
branch_version_link = provider_entity._link(BRANCH_VERSION_RELATION)
|
80
|
+
if branch_version_link
|
81
|
+
version_number = Pact.configuration.provider.application_version
|
82
|
+
branch = Pact.configuration.provider.branch
|
83
|
+
|
84
|
+
Pact.configuration.output_stream.puts "INFO: Creating #{provider_name} version #{version_number} with branch \"#{branch}\""
|
85
|
+
branch_entity = branch_version_link.expand(
|
86
|
+
version: version_number,
|
87
|
+
branch: branch
|
88
|
+
).put
|
89
|
+
unless branch_entity.success?
|
90
|
+
raise PublicationError.new("Error returned from tagging request: status=#{branch_entity.response.code} body=#{branch_entity.response.body}")
|
91
|
+
end
|
92
|
+
else
|
93
|
+
raise PublicationError.new("This version of the Pact Broker does not support version branches. Please update to version 2.58.0 or later.")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
75
98
|
def tag_versions
|
76
|
-
provider_entity = pact_entity.get(PROVIDER_RELATION)
|
77
99
|
tag_link = provider_entity._link(VERSION_TAG_RELATION) || hacky_tag_url(provider_entity)
|
78
100
|
provider_application_version = Pact.configuration.provider.application_version
|
79
101
|
|
@@ -111,6 +133,10 @@ module Pact
|
|
111
133
|
def provider_name
|
112
134
|
pact_source.pact_hash['provider']['name']
|
113
135
|
end
|
136
|
+
|
137
|
+
def provider_entity
|
138
|
+
@provider_entity ||= pact_entity.get(PROVIDER_RELATION)
|
139
|
+
end
|
114
140
|
end
|
115
141
|
end
|
116
142
|
end
|
@@ -6,20 +6,21 @@ module Pact
|
|
6
6
|
module VerificationResults
|
7
7
|
class PublishAll
|
8
8
|
|
9
|
-
def self.call pact_sources, test_results_hash
|
10
|
-
new(pact_sources, test_results_hash).call
|
9
|
+
def self.call pact_sources, test_results_hash, options = {}
|
10
|
+
new(pact_sources, test_results_hash, options).call
|
11
11
|
end
|
12
12
|
|
13
|
-
def initialize pact_sources, test_results_hash
|
13
|
+
def initialize pact_sources, test_results_hash, options = {}
|
14
14
|
@pact_sources = pact_sources
|
15
15
|
@test_results_hash = test_results_hash
|
16
|
+
@options = options
|
16
17
|
end
|
17
18
|
|
18
19
|
def call
|
19
20
|
verification_results.collect do | (pact_source, verification_result) |
|
20
21
|
published = false
|
21
22
|
begin
|
22
|
-
published = Publish.call(pact_source, verification_result)
|
23
|
+
published = Publish.call(pact_source, verification_result, { verbose: options[:verbose] })
|
23
24
|
ensure
|
24
25
|
print_after_verification_notices(pact_source, verification_result, published)
|
25
26
|
end
|
@@ -42,7 +43,7 @@ module Pact
|
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
45
|
-
attr_reader :pact_sources, :test_results_hash
|
46
|
+
attr_reader :pact_sources, :test_results_hash, :options
|
46
47
|
end
|
47
48
|
end
|
48
49
|
end
|
data/lib/pact/provider/world.rb
CHANGED
data/lib/pact/version.rb
CHANGED
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.
|
4
|
+
version: 1.58.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:
|
15
|
+
date: 2021-09-07 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rspec
|
@@ -405,7 +405,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
405
405
|
- !ruby/object:Gem::Version
|
406
406
|
version: '0'
|
407
407
|
requirements: []
|
408
|
-
rubygems_version: 3.
|
408
|
+
rubygems_version: 3.2.27
|
409
409
|
signing_key:
|
410
410
|
specification_version: 4
|
411
411
|
summary: Enables consumer driven contract testing, providing a mock service and DSL
|