pact 1.57.0 → 1.66.1
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 +138 -0
- data/lib/pact/cli/run_pact_verification.rb +0 -1
- data/lib/pact/consumer/consumer_contract_builder.rb +1 -1
- data/lib/pact/hal/entity.rb +4 -0
- data/lib/pact/hal/http_client.rb +35 -1
- data/lib/pact/hash_refinements.rb +17 -0
- data/lib/pact/pact_broker/fetch_pact_uris_for_verification.rb +31 -15
- data/lib/pact/pact_broker/pact_selection_description.rb +47 -4
- data/lib/pact/provider/configuration/message_provider_dsl.rb +5 -1
- data/lib/pact/provider/configuration/pact_verification_from_broker.rb +11 -3
- data/lib/pact/provider/configuration/service_provider_config.rb +4 -1
- data/lib/pact/provider/configuration/service_provider_dsl.rb +19 -5
- data/lib/pact/provider/help/console_text.rb +4 -8
- data/lib/pact/provider/help/prompt_text.rb +2 -4
- data/lib/pact/provider/matchers/messages.rb +3 -5
- data/lib/pact/provider/pact_spec_runner.rb +3 -0
- data/lib/pact/provider/pact_uri.rb +7 -3
- data/lib/pact/provider/print_missing_provider_states.rb +3 -5
- data/lib/pact/provider/request.rb +12 -5
- data/lib/pact/provider/rspec/formatter_rspec_2.rb +1 -3
- data/lib/pact/provider/rspec/formatter_rspec_3.rb +1 -3
- data/lib/pact/provider/rspec/pact_broker_formatter.rb +2 -2
- data/lib/pact/provider/rspec.rb +5 -3
- data/lib/pact/provider/state/provider_state.rb +5 -5
- data/lib/pact/provider/test_methods.rb +9 -3
- data/lib/pact/provider/verification_results/create.rb +7 -1
- data/lib/pact/provider/verification_results/publish.rb +27 -1
- data/lib/pact/provider/verification_results/verification_result.rb +4 -2
- data/lib/pact/utils/metrics.rb +100 -0
- data/lib/pact/version.rb +1 -1
- data/lib/tasks/pact.rake +2 -2
- data/pact.gemspec +11 -8
- metadata +77 -24
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 26cc958a02d05dd977adaee8c952de9392fcb06188c75564e4f9d261821ae6d8
|
|
4
|
+
data.tar.gz: f73fef0a466d12221bee83f0695ecf9f2cfbdbcb92c83f2706449025b78d9408
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e7ed964f7532f0baa701aead43ac24fa10e40b4503b8da7b637ce8e41ffdc263141689a042d01bd37a20cd0d6ca703c9bee1d645fd76424583b63c151b35e644
|
|
7
|
+
data.tar.gz: d8decbbd6cc63282600dc90f07c79e83db40f6d79181c2afd03bcc325567daad0213b6f36817ae3248876a9e25a04da14d8ee7f1b3a82240f19a9146f91d6df9
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,141 @@
|
|
|
1
|
+
<a name="v1.66.1"></a>
|
|
2
|
+
### v1.66.1 (2025-01-20)
|
|
3
|
+
|
|
4
|
+
#### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* HTTP_HOST headers for sinatra 4.x ([173bfb7](/../../commit/173bfb7))
|
|
7
|
+
|
|
8
|
+
<a name="v1.66.0"></a>
|
|
9
|
+
### v1.66.0 (2024-11-29)
|
|
10
|
+
|
|
11
|
+
#### Features
|
|
12
|
+
|
|
13
|
+
* **generators**
|
|
14
|
+
* Add more generators as per spec ([f55adf1](/../../commit/f55adf1))
|
|
15
|
+
* Pass context and add ProviderState generator ([7a1cf3b](/../../commit/7a1cf3b))
|
|
16
|
+
|
|
17
|
+
#### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* add HTTPS_HOST header if invoking a Sinatra app ([ed44189](/../../commit/ed44189))
|
|
20
|
+
* example/animal-service/Gemfile to reduce vulnerabilities ([981ebee](/../../commit/981ebee))
|
|
21
|
+
|
|
22
|
+
<a name="v1.65.3"></a>
|
|
23
|
+
### v1.65.3 (2024-10-23)
|
|
24
|
+
|
|
25
|
+
#### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* **test**
|
|
28
|
+
* explicitly require ostruct as non stdlib in ruby 3.5.x ([c9a8525](/../../commit/c9a8525))
|
|
29
|
+
|
|
30
|
+
<a name="v1.65.2"></a>
|
|
31
|
+
### v1.65.2 (2024-09-26)
|
|
32
|
+
|
|
33
|
+
<a name="v1.65.1"></a>
|
|
34
|
+
### v1.65.1 (2024-08-08)
|
|
35
|
+
|
|
36
|
+
#### Bug Fixes
|
|
37
|
+
|
|
38
|
+
* set color codes even on dumb terms (prev behaviour) ([4f01bc9](/../../commit/4f01bc9))
|
|
39
|
+
* use .empty? in handling_no_pacts_found ([43bce74](/../../commit/43bce74))
|
|
40
|
+
|
|
41
|
+
<a name="v1.65.0"></a>
|
|
42
|
+
### v1.65.0 (2024-08-06)
|
|
43
|
+
|
|
44
|
+
#### Features
|
|
45
|
+
|
|
46
|
+
* support app_version_branch in MessageProviderDSL ([1653128](/../../commit/1653128))
|
|
47
|
+
* allow setting fail_if_no_pacts_found in honours_pacts_from_pact_broker ([f0f142e](/../../commit/f0f142e))
|
|
48
|
+
|
|
49
|
+
#### Bug Fixes
|
|
50
|
+
|
|
51
|
+
* handle case in no_pacts_found - undefined method empty? for nil ([0145d2d](/../../commit/0145d2d))
|
|
52
|
+
* remove unused ConsumerContractBuilder contract_details accessor ([fb5488e](/../../commit/fb5488e))
|
|
53
|
+
* example/animal-service/Gemfile to reduce vulnerabilities ([2bbefe2](/../../commit/2bbefe2))
|
|
54
|
+
* example/zoo-app/Gemfile to reduce vulnerabilities ([e10f914](/../../commit/e10f914))
|
|
55
|
+
* example/animal-service/Gemfile to reduce vulnerabilities ([7560918](/../../commit/7560918))
|
|
56
|
+
* example/zoo-app/Gemfile to reduce vulnerabilities ([b4cbe85](/../../commit/b4cbe85))
|
|
57
|
+
* example/animal-service/Gemfile to reduce vulnerabilities ([4028087](/../../commit/4028087))
|
|
58
|
+
* ConsumerContractBuilder exposing incorrect field ([c805c3e](/../../commit/c805c3e))
|
|
59
|
+
|
|
60
|
+
* **test**
|
|
61
|
+
* alias Rack/Rackup WEBrick handler in x509 test for backwards compat ([cc77498](/../../commit/cc77498))
|
|
62
|
+
|
|
63
|
+
<a name="v1.64.0"></a>
|
|
64
|
+
### v1.64.0 (2023-11-09)
|
|
65
|
+
|
|
66
|
+
#### Features
|
|
67
|
+
|
|
68
|
+
* support x509 certs in HTTP Client (#298) ([3ed5680](/../../commit/3ed5680))
|
|
69
|
+
|
|
70
|
+
* **CI**
|
|
71
|
+
* use setup-ruby's bundle installer and cache (#275) ([f5621b6](/../../commit/f5621b6))
|
|
72
|
+
|
|
73
|
+
#### Bug Fixes
|
|
74
|
+
|
|
75
|
+
* assert provider retrieved successfully before using link ([0af0691](/../../commit/0af0691))
|
|
76
|
+
* update call to Rack::Builder.parse_file for rack 3 ([652047c](/../../commit/652047c))
|
|
77
|
+
* example/zoo-app/Gemfile to reduce vulnerabilities ([b4ca8cb](/../../commit/b4ca8cb))
|
|
78
|
+
* example/animal-service/Gemfile to reduce vulnerabilities ([7ad2073](/../../commit/7ad2073))
|
|
79
|
+
* example/zoo-app/Gemfile to reduce vulnerabilities ([dd417fd](/../../commit/dd417fd))
|
|
80
|
+
* example/animal-service/Gemfile to reduce vulnerabilities (#281) ([4ea07cd](/../../commit/4ea07cd))
|
|
81
|
+
|
|
82
|
+
<a name="v1.63.0"></a>
|
|
83
|
+
### v1.63.0 (2022-09-28)
|
|
84
|
+
|
|
85
|
+
#### Features
|
|
86
|
+
|
|
87
|
+
* relax rack-test dependency to allow version 2 (#270) ([a619deb](/../../commit/a619deb))
|
|
88
|
+
* only print metrics warning once per thread ([91da38f](/../../commit/91da38f))
|
|
89
|
+
* provide configuration for build url to be published in verification results (#252) ([ce1c9bc](/../../commit/ce1c9bc))
|
|
90
|
+
|
|
91
|
+
#### Bug Fixes
|
|
92
|
+
|
|
93
|
+
* example/animal-service/Gemfile to reduce vulnerabilities (#263) ([8f3b732](/../../commit/8f3b732))
|
|
94
|
+
* Fixup ruby warnings (#262) ([3640593](/../../commit/3640593))
|
|
95
|
+
|
|
96
|
+
<a name="v1.62.0"></a>
|
|
97
|
+
### v1.62.0 (2022-02-21)
|
|
98
|
+
|
|
99
|
+
#### Features
|
|
100
|
+
|
|
101
|
+
* add telemetry (#256) ([4497ee9](/../../commit/4497ee9))
|
|
102
|
+
|
|
103
|
+
<a name="v1.61.0"></a>
|
|
104
|
+
### v1.61.0 (2021-12-16)
|
|
105
|
+
|
|
106
|
+
#### Features
|
|
107
|
+
|
|
108
|
+
* support description of matching_branch and matching_tag consumer version selectors ([8e8bb22](/../../commit/8e8bb22))
|
|
109
|
+
|
|
110
|
+
#### Bug Fixes
|
|
111
|
+
|
|
112
|
+
* pass through includePendingStatus to the 'pacts for verification' API when it is false ([f0e37a4](/../../commit/f0e37a4))
|
|
113
|
+
|
|
114
|
+
<a name="v1.60.0"></a>
|
|
115
|
+
### v1.60.0 (2021-10-01)
|
|
116
|
+
|
|
117
|
+
#### Features
|
|
118
|
+
|
|
119
|
+
* allow SSL verification to be disabled in the HAL client by setting the environment variable PACT_DISABLE_SSL_VERIFICATION=true ([ce07d32](/../../commit/ce07d32))
|
|
120
|
+
|
|
121
|
+
<a name="v1.59.0"></a>
|
|
122
|
+
### v1.59.0 (2021-09-07)
|
|
123
|
+
|
|
124
|
+
#### Features
|
|
125
|
+
|
|
126
|
+
* update descriptions for new consumer version selectors ([0471397](/../../commit/0471397))
|
|
127
|
+
|
|
128
|
+
<a name="v1.58.0"></a>
|
|
129
|
+
### v1.58.0 (2021-09-01)
|
|
130
|
+
|
|
131
|
+
#### Features
|
|
132
|
+
|
|
133
|
+
* support publishing verification results with a version branch ([da2facf](/../../commit/da2facf))
|
|
134
|
+
|
|
135
|
+
#### Bug Fixes
|
|
136
|
+
|
|
137
|
+
* gracefully handle display of username that causes InvalidComponentError to be raised when composing a URI ([cecb98f](/../../commit/cecb98f))
|
|
138
|
+
|
|
1
139
|
<a name="v1.57.0"></a>
|
|
2
140
|
### v1.57.0 (2021-01-27)
|
|
3
141
|
|
data/lib/pact/hal/entity.rb
CHANGED
data/lib/pact/hal/http_client.rb
CHANGED
|
@@ -2,6 +2,7 @@ require 'pact/retry'
|
|
|
2
2
|
require 'pact/hal/authorization_header_redactor'
|
|
3
3
|
require 'net/http'
|
|
4
4
|
require 'rack'
|
|
5
|
+
require 'openssl'
|
|
5
6
|
|
|
6
7
|
module Pact
|
|
7
8
|
module Hal
|
|
@@ -48,10 +49,22 @@ module Pact
|
|
|
48
49
|
def perform_request request, uri
|
|
49
50
|
response = Retry.until_true do
|
|
50
51
|
http = Net::HTTP.new(uri.host, uri.port, :ENV)
|
|
51
|
-
http.set_debug_output(output_stream) if verbose
|
|
52
|
+
http.set_debug_output(output_stream) if verbose?
|
|
52
53
|
http.use_ssl = (uri.scheme == 'https')
|
|
53
54
|
http.ca_file = ENV['SSL_CERT_FILE'] if ENV['SSL_CERT_FILE'] && ENV['SSL_CERT_FILE'] != ''
|
|
54
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
|
+
|
|
62
|
+
if disable_ssl_verification?
|
|
63
|
+
if verbose?
|
|
64
|
+
Pact.configuration.output_stream.puts("SSL verification is disabled")
|
|
65
|
+
end
|
|
66
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
67
|
+
end
|
|
55
68
|
http.start do |http|
|
|
56
69
|
http.request request
|
|
57
70
|
end
|
|
@@ -63,6 +76,27 @@ module Pact
|
|
|
63
76
|
AuthorizationHeaderRedactor.new(Pact.configuration.output_stream)
|
|
64
77
|
end
|
|
65
78
|
|
|
79
|
+
def verbose?
|
|
80
|
+
verbose || ENV['VERBOSE'] == 'true'
|
|
81
|
+
end
|
|
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
|
+
|
|
96
|
+
def disable_ssl_verification?
|
|
97
|
+
ENV['PACT_DISABLE_SSL_VERIFICATION'] == 'true' || ENV['PACT_BROKER_DISABLE_SSL_VERIFICATION'] == 'true'
|
|
98
|
+
end
|
|
99
|
+
|
|
66
100
|
class Response < SimpleDelegator
|
|
67
101
|
def body
|
|
68
102
|
bod = raw_body
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Pact
|
|
2
|
+
module HashRefinements
|
|
3
|
+
refine Hash do
|
|
4
|
+
def compact
|
|
5
|
+
h = {}
|
|
6
|
+
each do |key, value|
|
|
7
|
+
h[key] = value unless value == nil
|
|
8
|
+
end
|
|
9
|
+
h
|
|
10
|
+
end unless Hash.method_defined? :compact
|
|
11
|
+
|
|
12
|
+
def compact!
|
|
13
|
+
reject! {|_key, value| value == nil}
|
|
14
|
+
end unless Hash.method_defined? :compact!
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -5,12 +5,15 @@ require 'pact/errors'
|
|
|
5
5
|
require 'pact/pact_broker/fetch_pacts'
|
|
6
6
|
require 'pact/pact_broker/notices'
|
|
7
7
|
require 'pact/pact_broker/pact_selection_description'
|
|
8
|
+
require "pact/hash_refinements"
|
|
8
9
|
|
|
9
10
|
module Pact
|
|
10
11
|
module PactBroker
|
|
11
12
|
class FetchPactURIsForVerification
|
|
13
|
+
using Pact::HashRefinements
|
|
14
|
+
|
|
12
15
|
include PactSelectionDescription
|
|
13
|
-
attr_reader :provider, :consumer_version_selectors, :provider_version_tags, :broker_base_url, :http_client_options, :http_client, :options
|
|
16
|
+
attr_reader :provider, :consumer_version_selectors, :provider_version_branch, :provider_version_tags, :broker_base_url, :http_client_options, :http_client, :options
|
|
14
17
|
|
|
15
18
|
PACTS_FOR_VERIFICATION_RELATION = 'pb:provider-pacts-for-verification'.freeze
|
|
16
19
|
PACTS_FOR_VERIFICATION_RELATION_BETA = 'beta:provider-pacts-for-verification'.freeze
|
|
@@ -20,9 +23,10 @@ module Pact
|
|
|
20
23
|
SELF = 'self'.freeze
|
|
21
24
|
EMBEDDED = '_embedded'.freeze
|
|
22
25
|
|
|
23
|
-
def initialize(provider, consumer_version_selectors, provider_version_tags, broker_base_url, http_client_options, options = {})
|
|
26
|
+
def initialize(provider, consumer_version_selectors, provider_version_branch, provider_version_tags, broker_base_url, http_client_options, options = {})
|
|
24
27
|
@provider = provider
|
|
25
28
|
@consumer_version_selectors = consumer_version_selectors || []
|
|
29
|
+
@provider_version_branch = provider_version_branch
|
|
26
30
|
@provider_version_tags = [*provider_version_tags]
|
|
27
31
|
@http_client_options = http_client_options
|
|
28
32
|
@broker_base_url = broker_base_url
|
|
@@ -30,20 +34,22 @@ module Pact
|
|
|
30
34
|
@options = options
|
|
31
35
|
end
|
|
32
36
|
|
|
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
|
|
37
|
+
def self.call(provider, consumer_version_selectors, provider_version_branch, provider_version_tags, broker_base_url, http_client_options, options = {})
|
|
38
|
+
new(provider, consumer_version_selectors, provider_version_branch, provider_version_tags, broker_base_url, http_client_options, options).call
|
|
35
39
|
end
|
|
36
40
|
|
|
37
41
|
def call
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
handling_no_pacts_found do
|
|
43
|
+
if index.can?(PACTS_FOR_VERIFICATION_RELATION) || index.can?(PACTS_FOR_VERIFICATION_RELATION_BETA)
|
|
44
|
+
log_message
|
|
45
|
+
pacts_for_verification
|
|
46
|
+
else
|
|
47
|
+
old_selectors = consumer_version_selectors.collect do | selector |
|
|
48
|
+
{ name: selector[:tag], all: !selector[:latest], fallback: selector[:fallbackTag]}
|
|
49
|
+
end
|
|
50
|
+
# Fall back to old method of fetching pacts
|
|
51
|
+
FetchPacts.call(provider, old_selectors, broker_base_url, http_client_options)
|
|
44
52
|
end
|
|
45
|
-
# Fall back to old method of fetching pacts
|
|
46
|
-
FetchPacts.call(provider, old_selectors, broker_base_url, http_client_options)
|
|
47
53
|
end
|
|
48
54
|
end
|
|
49
55
|
|
|
@@ -73,11 +79,12 @@ module Pact
|
|
|
73
79
|
|
|
74
80
|
def query
|
|
75
81
|
q = {}
|
|
76
|
-
q["includePendingStatus"] =
|
|
82
|
+
q["includePendingStatus"] = options[:include_pending_status]
|
|
77
83
|
q["consumerVersionSelectors"] = consumer_version_selectors if consumer_version_selectors.any?
|
|
78
84
|
q["providerVersionTags"] = provider_version_tags if provider_version_tags.any?
|
|
79
|
-
q["
|
|
80
|
-
q
|
|
85
|
+
q["providerVersionBranch"] = provider_version_branch
|
|
86
|
+
q["includeWipPactsSince"] = options[:include_wip_pacts_since]
|
|
87
|
+
q.compact
|
|
81
88
|
end
|
|
82
89
|
|
|
83
90
|
def extract_notices(pact)
|
|
@@ -91,6 +98,15 @@ module Pact
|
|
|
91
98
|
def log_message
|
|
92
99
|
Pact.configuration.output_stream.puts "INFO: #{pact_selection_description(provider, consumer_version_selectors, options, broker_base_url)}"
|
|
93
100
|
end
|
|
101
|
+
|
|
102
|
+
def handling_no_pacts_found
|
|
103
|
+
pacts_found = yield
|
|
104
|
+
raise "No pacts found to verify" if pacts_found.empty? && options[:fail_if_no_pacts_found] != false
|
|
105
|
+
if pacts_found.empty? && options[:fail_if_no_pacts_found] == false
|
|
106
|
+
Pact.configuration.output_stream.puts "WARN: No pacts found to verify & fail_if_no_pacts_found is set to false."
|
|
107
|
+
end
|
|
108
|
+
pacts_found
|
|
109
|
+
end
|
|
94
110
|
end
|
|
95
111
|
end
|
|
96
112
|
end
|
|
@@ -5,11 +5,54 @@ module Pact
|
|
|
5
5
|
message = "Fetching pacts for #{provider} from #{broker_base_url} with the selection criteria: "
|
|
6
6
|
if consumer_version_selectors.any?
|
|
7
7
|
desc = consumer_version_selectors.collect do |selector|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
desc = nil
|
|
9
|
+
if selector[:tag]
|
|
10
|
+
desc = !selector[:latest] ? "all for tag #{selector[:tag]}" : "latest for tag #{selector[:tag]}"
|
|
11
|
+
desc = "#{desc} of #{selector[:consumer]}" if selector[:consumer]
|
|
12
|
+
elsif selector[:branch]
|
|
13
|
+
desc = "latest from branch #{selector[:branch]}"
|
|
14
|
+
desc = "#{desc} of #{selector[:consumer]}" if selector[:consumer]
|
|
15
|
+
elsif selector[:mainBranch]
|
|
16
|
+
desc = "latest from main branch"
|
|
17
|
+
desc = "#{desc} of #{selector[:consumer]}" if selector[:consumer]
|
|
18
|
+
elsif selector[:deployed]
|
|
19
|
+
if selector[:environment]
|
|
20
|
+
desc = "currently deployed to #{selector[:environment]}"
|
|
21
|
+
else
|
|
22
|
+
desc = "currently deployed"
|
|
23
|
+
end
|
|
24
|
+
desc = "#{selector[:consumer]} #{desc}" if selector[:consumer]
|
|
25
|
+
elsif selector[:released]
|
|
26
|
+
if selector[:environment]
|
|
27
|
+
desc = "currently released to #{selector[:environment]}"
|
|
28
|
+
else
|
|
29
|
+
desc = "currently released"
|
|
30
|
+
end
|
|
31
|
+
desc = "#{selector[:consumer]} #{desc}" if selector[:consumer]
|
|
32
|
+
elsif selector[:deployedOrReleased]
|
|
33
|
+
if selector[:environment]
|
|
34
|
+
desc = "currently deployed or released to #{selector[:environment]}"
|
|
35
|
+
else
|
|
36
|
+
desc = "currently deployed or released"
|
|
37
|
+
end
|
|
38
|
+
desc = "#{selector[:consumer]} #{desc}" if selector[:consumer]
|
|
39
|
+
elsif selector[:environment]
|
|
40
|
+
desc = "currently in #{selector[:environment]}"
|
|
41
|
+
desc = "#{selector[:consumer]} #{desc}" if selector[:consumer]
|
|
42
|
+
elsif selector[:matchingBranch]
|
|
43
|
+
desc = "matching current branch"
|
|
44
|
+
desc = "#{desc} for #{selector[:consumer]}" if selector[:consumer]
|
|
45
|
+
elsif selector[:matchingTag]
|
|
46
|
+
desc = "matching tag"
|
|
47
|
+
desc = "#{desc} for #{selector[:consumer]}" if selector[:consumer]
|
|
48
|
+
else
|
|
49
|
+
desc = selector.to_s
|
|
50
|
+
end
|
|
51
|
+
|
|
10
52
|
fallback = selector[:fallback] || selector[:fallbackTag]
|
|
11
|
-
|
|
12
|
-
|
|
53
|
+
desc = "#{desc} (or #{fallback} if not found)" if fallback
|
|
54
|
+
|
|
55
|
+
desc
|
|
13
56
|
end.join(", ")
|
|
14
57
|
if options[:include_wip_pacts_since]
|
|
15
58
|
desc = "#{desc}, work in progress pacts created after #{options[:include_wip_pacts_since]}"
|
|
@@ -34,6 +34,10 @@ module Pact
|
|
|
34
34
|
self.tags = tags
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
def app_version_branch branch
|
|
38
|
+
self.branch = branch
|
|
39
|
+
end
|
|
40
|
+
|
|
37
41
|
def publish_verification_results publish_verification_results
|
|
38
42
|
self.publish_verification_results = publish_verification_results
|
|
39
43
|
Pact::RSpec.with_rspec_2 do
|
|
@@ -46,7 +50,7 @@ module Pact
|
|
|
46
50
|
end
|
|
47
51
|
|
|
48
52
|
def honours_pacts_from_pact_broker &block
|
|
49
|
-
create_pact_verification_from_broker
|
|
53
|
+
create_pact_verification_from_broker(&block)
|
|
50
54
|
end
|
|
51
55
|
|
|
52
56
|
def builder &block
|
|
@@ -15,16 +15,18 @@ 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, :_fail_if_no_pacts_found
|
|
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 = []
|
|
25
26
|
@_enable_pending = false
|
|
26
27
|
@_include_wip_pacts_since = nil
|
|
27
28
|
@_verbose = false
|
|
29
|
+
@_fail_if_no_pacts_found = true # CLI defaults to false, unfortunately for consistency
|
|
28
30
|
end
|
|
29
31
|
|
|
30
32
|
dsl do
|
|
@@ -45,6 +47,11 @@ module Pact
|
|
|
45
47
|
self._enable_pending = enable_pending
|
|
46
48
|
end
|
|
47
49
|
|
|
50
|
+
# Underlying code defaults to true if not specified
|
|
51
|
+
def fail_if_no_pacts_found fail_if_no_pacts_found
|
|
52
|
+
self._fail_if_no_pacts_found = fail_if_no_pacts_found
|
|
53
|
+
end
|
|
54
|
+
|
|
48
55
|
def include_wip_pacts_since since
|
|
49
56
|
self._include_wip_pacts_since = if since.respond_to?(:xmlschema)
|
|
50
57
|
since.xmlschema
|
|
@@ -69,10 +76,11 @@ module Pact
|
|
|
69
76
|
fetch_pacts = Pact::PactBroker::FetchPactURIsForVerification.new(
|
|
70
77
|
_provider_name,
|
|
71
78
|
consumer_version_selectors,
|
|
79
|
+
_provider_version_branch,
|
|
72
80
|
_provider_version_tags,
|
|
73
81
|
_pact_broker_base_url,
|
|
74
82
|
_basic_auth_options.merge(verbose: _verbose),
|
|
75
|
-
{ include_pending_status: _enable_pending, include_wip_pacts_since: _include_wip_pacts_since }
|
|
83
|
+
{ include_pending_status: _enable_pending, include_wip_pacts_since: _include_wip_pacts_since, fail_if_no_pacts_found: _fail_if_no_pacts_found }
|
|
76
84
|
)
|
|
77
85
|
|
|
78
86
|
Pact.provider_world.add_pact_uri_source fetch_pacts
|
|
@@ -4,12 +4,15 @@ module Pact
|
|
|
4
4
|
class ServiceProviderConfig
|
|
5
5
|
|
|
6
6
|
attr_accessor :application_version
|
|
7
|
+
attr_reader :branch, :build_url
|
|
7
8
|
|
|
8
|
-
def initialize application_version, tags, publish_verification_results, &app_block
|
|
9
|
+
def initialize application_version, branch, tags, publish_verification_results, build_url, &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
|
+
@build_url = build_url
|
|
13
16
|
end
|
|
14
17
|
|
|
15
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, :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)
|
|
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
|
|
@@ -44,6 +50,14 @@ module Pact
|
|
|
44
50
|
self.tags = tags
|
|
45
51
|
end
|
|
46
52
|
|
|
53
|
+
def app_version_branch branch
|
|
54
|
+
self.branch = branch
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def build_url build_url
|
|
58
|
+
self.build_url = build_url
|
|
59
|
+
end
|
|
60
|
+
|
|
47
61
|
def publish_verification_results publish_verification_results
|
|
48
62
|
self.publish_verification_results = publish_verification_results
|
|
49
63
|
Pact::RSpec.with_rspec_2 do
|
|
@@ -56,7 +70,7 @@ module Pact
|
|
|
56
70
|
end
|
|
57
71
|
|
|
58
72
|
def honours_pacts_from_pact_broker &block
|
|
59
|
-
create_pact_verification_from_broker
|
|
73
|
+
create_pact_verification_from_broker(&block)
|
|
60
74
|
end
|
|
61
75
|
end
|
|
62
76
|
|
|
@@ -65,7 +79,7 @@ module Pact
|
|
|
65
79
|
end
|
|
66
80
|
|
|
67
81
|
def create_pact_verification_from_broker(&block)
|
|
68
|
-
PactVerificationFromBroker.build(name, tags, &block)
|
|
82
|
+
PactVerificationFromBroker.build(name, branch, tags, &block)
|
|
69
83
|
end
|
|
70
84
|
|
|
71
85
|
def finalize
|
|
@@ -85,7 +99,7 @@ module Pact
|
|
|
85
99
|
end
|
|
86
100
|
|
|
87
101
|
def create_service_provider
|
|
88
|
-
Pact.configuration.provider = ServiceProviderConfig.new(application_version, tags, publish_verification_results, &@app_block)
|
|
102
|
+
Pact.configuration.provider = ServiceProviderConfig.new(application_version, branch, tags, publish_verification_results, build_url, &@app_block)
|
|
89
103
|
end
|
|
90
104
|
end
|
|
91
105
|
end
|
|
@@ -2,15 +2,13 @@ require 'pact/provider/help/content'
|
|
|
2
2
|
require 'fileutils'
|
|
3
3
|
require 'pact/consumer/configuration'
|
|
4
4
|
require 'pact/provider/help/write'
|
|
5
|
-
require '
|
|
5
|
+
require 'rainbow'
|
|
6
6
|
|
|
7
7
|
module Pact
|
|
8
8
|
module Provider
|
|
9
9
|
module Help
|
|
10
10
|
class ConsoleText
|
|
11
11
|
|
|
12
|
-
C = ::Term::ANSIColor
|
|
13
|
-
|
|
14
12
|
def self.call reports_dir = Pact.configuration.reports_dir, options = {color: true}
|
|
15
13
|
new(reports_dir || Pact.configuration.reports_dir, options).call
|
|
16
14
|
end
|
|
@@ -46,13 +44,11 @@ module Pact
|
|
|
46
44
|
end
|
|
47
45
|
|
|
48
46
|
def error_text_coloured
|
|
49
|
-
|
|
47
|
+
Rainbow(error_text_plain).red
|
|
50
48
|
end
|
|
51
49
|
|
|
52
50
|
class ColorizeMarkdown
|
|
53
51
|
|
|
54
|
-
C = ::Term::ANSIColor
|
|
55
|
-
|
|
56
52
|
def self.call markdown
|
|
57
53
|
markdown.split("\n").collect do | line |
|
|
58
54
|
if line.start_with?("# ")
|
|
@@ -66,11 +62,11 @@ module Pact
|
|
|
66
62
|
end
|
|
67
63
|
|
|
68
64
|
def self.yellow_underling string
|
|
69
|
-
|
|
65
|
+
Rainbow(string).yellow.underline
|
|
70
66
|
end
|
|
71
67
|
|
|
72
68
|
def self.green string
|
|
73
|
-
|
|
69
|
+
Rainbow(string).green
|
|
74
70
|
end
|
|
75
71
|
|
|
76
72
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require 'pact/consumer/configuration'
|
|
2
|
-
require '
|
|
2
|
+
require 'rainbow'
|
|
3
3
|
require 'pathname'
|
|
4
4
|
|
|
5
5
|
module Pact
|
|
@@ -7,8 +7,6 @@ module Pact
|
|
|
7
7
|
module Help
|
|
8
8
|
class PromptText
|
|
9
9
|
|
|
10
|
-
C = ::Term::ANSIColor
|
|
11
|
-
|
|
12
10
|
def self.call reports_dir = Pact.configuration.reports_dir, options = {color: Pact.configuration.color_enabled}
|
|
13
11
|
new(reports_dir, options).call
|
|
14
12
|
end
|
|
@@ -31,7 +29,7 @@ module Pact
|
|
|
31
29
|
end
|
|
32
30
|
|
|
33
31
|
def prompt_text_colored
|
|
34
|
-
|
|
32
|
+
Rainbow(prompt_text_plain).yellow
|
|
35
33
|
end
|
|
36
34
|
|
|
37
35
|
def rake_args
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'rainbow'
|
|
2
2
|
require 'pact/term'
|
|
3
3
|
|
|
4
4
|
module Pact
|
|
5
5
|
module Matchers
|
|
6
6
|
module Messages
|
|
7
7
|
|
|
8
|
-
C = ::Term::ANSIColor
|
|
9
|
-
|
|
10
8
|
def match_term_failure_message diff, actual, diff_formatter, color_enabled
|
|
11
9
|
actual_string = String === actual ? actual : actual.to_json
|
|
12
|
-
maybe_coloured_string = color_enabled ?
|
|
10
|
+
maybe_coloured_string = color_enabled ? Rainbow(actual_string).white : actual_string
|
|
13
11
|
message = "Actual: #{maybe_coloured_string}\n\n"
|
|
14
12
|
formatted_diff = diff_formatter.call(diff)
|
|
15
13
|
message + colorize_if_enabled(formatted_diff, color_enabled)
|
|
@@ -40,7 +38,7 @@ module Pact
|
|
|
40
38
|
# RSpec wraps each line in the failure message with failure_color, turning it red.
|
|
41
39
|
# To ensure the lines in the diff that should be white, stay white, put an
|
|
42
40
|
# ANSI reset at the start of each line.
|
|
43
|
-
formatted_diff.split("\n").collect{ |line|
|
|
41
|
+
formatted_diff.split("\n").collect{ |line|"\e[0m#{line}" }.join("\n")
|
|
44
42
|
else
|
|
45
43
|
formatted_diff
|
|
46
44
|
end
|