pact-provider-verifier 1.15.0 → 1.16.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: 68a5df8078a6d2408f6afadb8f956365f673ceed3736cdfbceb33bbebf1e89e9
4
- data.tar.gz: e992a96f7b210b0b7cef7020e2c6fa5b31d7247f4ad45e932cd4489f2b7537fe
3
+ metadata.gz: 6aaa2449696ee3831573ec483077f0b8262e54c24a8d98dc2bf9333ff32d916e
4
+ data.tar.gz: c5c723af674ded08ccc2577828c19c3156574d3521d5022d0de87deb738e5297
5
5
  SHA512:
6
- metadata.gz: f6526309c0ad113f6c5c6c80d086143387a45b36e3fe77a96bf2da0b2494120b3c7cae13a7fdbf07a70a0794d62b7eceee506932333f9fb248f38697fee923de
7
- data.tar.gz: 5d6ec539e538572eebd3648a64f83beed3325d823214ac4d26b69ce0b879030119198a2b2a91fd43e7fa8e633b3200b9dff1d92be0b09ec5e23847795abe36a2
6
+ metadata.gz: 037c6cefcc939635ab745c594ea1512aaca1683986a2f75d80b984f0b6f19d294b42d6a6a29b9f8566457f0ab256d0dce0822208f05870227761233ca5ab36b9
7
+ data.tar.gz: 38f4a53c8a6013026b8f1b108e326f536ed05cda4e919a8cdd7fdc0950345d0ca1b0ed93e5cd07961eaca45fca8106e30ee36a60e39e2b47a1d4a7411d779043
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ <a name="v1.16.0-1"></a>
2
+ ### v1.16.0-1 (2018-07-24)
3
+
4
+
5
+ #### Features
6
+
7
+ * allow pacts to be fetched from a Pact Broker by provider name, including WIP pacts. ([0b80528](/../../commit/0b80528))
8
+ * correct debug message regarding provider state URL ([d134ba6](/../../commit/d134ba6))
9
+
10
+
1
11
  <a name="v1.15.0-1"></a>
2
12
  ### v1.15.0-1 (2018-07-13)
3
13
 
@@ -0,0 +1,50 @@
1
+ require 'pact/pact_broker'
2
+ require 'ostruct'
3
+
4
+ module Pact
5
+ module ProviderVerifier
6
+ class AggregatePactConfigs
7
+
8
+ def self.call(pact_urls, provider_name, consumer_version_tags, pact_broker_base_url, http_client_options)
9
+ new(pact_urls, provider_name, consumer_version_tags, pact_broker_base_url, http_client_options).call
10
+ end
11
+
12
+ def initialize(pact_urls, provider_name, consumer_version_tags, pact_broker_base_url, http_client_options)
13
+ @pact_urls = pact_urls
14
+ @provider_name = provider_name
15
+ @consumer_version_tags = consumer_version_tags
16
+ @pact_broker_base_url = pact_broker_base_url
17
+ @http_client_options = http_client_options
18
+ end
19
+
20
+ def call
21
+ pacts_urls_from_broker + pact_urls.collect{ |uri| OpenStruct.new(uri: uri) }
22
+ end
23
+
24
+ private
25
+
26
+ attr_reader :pact_urls, :provider_name, :consumer_version_tags, :pact_broker_base_url, :http_client_options
27
+
28
+ def pacts_urls_from_broker
29
+ if pact_broker_base_url && provider_name
30
+ net_wip_pact_uris.collect{ | uri| OpenStruct.new(uri: uri, wip: true) } +
31
+ non_wip_pact_uris.collect{ | uri| OpenStruct.new(uri: uri) }
32
+ else
33
+ []
34
+ end
35
+ end
36
+
37
+ def non_wip_pact_uris
38
+ @non_wip_pact_uris ||= Pact::PactBroker.fetch_pact_uris(provider_name, consumer_version_tags, pact_broker_base_url, http_client_options)
39
+ end
40
+
41
+ def wip_pact_uris
42
+ @wip_pact_uris ||= Pact::PactBroker.fetch_wip_pact_uris(provider_name, pact_broker_base_url, http_client_options)
43
+ end
44
+
45
+ def net_wip_pact_uris
46
+ wip_pact_uris - non_wip_pact_uris
47
+ end
48
+ end
49
+ end
50
+ end
@@ -2,13 +2,13 @@ require 'pact/provider_verifier/add_header_middlware'
2
2
  require 'pact/provider/rspec'
3
3
  require 'pact/message'
4
4
  require 'pact/cli/run_pact_verification'
5
+ require 'pact/provider_verifier/aggregate_pact_configs'
5
6
  require 'rack/reverse_proxy'
6
7
  require 'faraday_middleware'
7
8
  require 'json'
8
9
 
9
10
  module Pact
10
11
  module ProviderVerifier
11
-
12
12
  class App
13
13
 
14
14
  PROXY_PACT_HELPER = File.expand_path(File.join(File.dirname(__FILE__), "pact_helper.rb"))
@@ -16,6 +16,7 @@ module Pact
16
16
  def initialize pact_urls, options = {}
17
17
  @pact_urls = pact_urls
18
18
  @options = options
19
+ @consumer_version_tags = options[:consumer_version_tag] || []
19
20
  end
20
21
 
21
22
  def self.call pact_urls, options
@@ -25,17 +26,16 @@ module Pact
25
26
  def call
26
27
  setup
27
28
 
28
- exit_statuses = pact_urls.collect do |pact_url|
29
+ exit_statuses = all_pact_urls.collect do |pact_url|
29
30
  verify_pact pact_url
30
31
  end
31
32
 
32
- # Return non-zero exit code if failures - increment for each Pact
33
- exit exit_statuses.count{ | status | status != 0 }
33
+ exit_statuses.all?{ | status | status == 0 }
34
34
  end
35
35
 
36
36
  private
37
37
 
38
- attr_reader :pact_urls, :options
38
+ attr_reader :pact_urls, :options, :consumer_version_tags
39
39
 
40
40
  def setup
41
41
  print_deprecation_note
@@ -92,16 +92,17 @@ module Pact
92
92
  end
93
93
  end
94
94
 
95
- def verify_pact pact_url
95
+ def verify_pact config
96
96
  begin
97
97
  verify_options = {
98
98
  pact_helper: PROXY_PACT_HELPER,
99
- pact_uri: pact_url,
99
+ pact_uri: config.uri,
100
100
  backtrace: ENV['BACKTRACE'] == 'true',
101
101
  pact_broker_username: options.broker_username,
102
102
  pact_broker_password: options.broker_password,
103
103
  format: options.format,
104
- out: options.out
104
+ out: options.out,
105
+ wip: config.wip
105
106
  }
106
107
  verify_options[:description] = ENV['PACT_DESCRIPTION'] if ENV['PACT_DESCRIPTION']
107
108
  verify_options[:provider_state] = ENV['PACT_PROVIDER_STATE'] if ENV['PACT_PROVIDER_STATE']
@@ -124,6 +125,11 @@ module Pact
124
125
  configure_service_provider
125
126
  end
126
127
 
128
+ def all_pact_urls
129
+ http_client_options = { username: options.broker_username, password: options.broker_password }
130
+ AggregatePactConfigs.call(pact_urls, options.provider, consumer_version_tags, options.pact_broker_base_url, http_client_options)
131
+ end
132
+
127
133
  def require_pact_project_pact_helper
128
134
  require ENV['PACT_PROJECT_PACT_HELPER'] if ENV.fetch('PACT_PROJECT_PACT_HELPER','') != ''
129
135
  end
@@ -7,24 +7,33 @@ module Pact
7
7
  module ProviderVerifier
8
8
  module CLI
9
9
  class Verify < CustomThor
10
+
11
+ class InvalidArgumentsError < ::Thor::Error; end
12
+
10
13
  desc 'PACT_URL ...', "Verify pact(s) against a provider. Supports local and networked (http-based) files."
11
14
  method_option :provider_base_url, aliases: "-h", desc: "Provider host URL", :required => true
12
15
  method_option :provider_states_setup_url, aliases: "-c", desc: "Base URL to setup the provider states at", :required => false
13
- method_option :provider_app_version, aliases: "-a", desc: "Provider application version, required when publishing verification results", :required => false
14
- method_option :publish_verification_results, aliases: "-r", desc: "Publish verification results to the broker", required: false
16
+ method_option :pact_broker_base_url, desc: "Base URL of the Pact Broker from which to retrieve the pacts.", :required => false
15
17
  method_option :broker_username, aliases: "-n", desc: "Pact Broker basic auth username", :required => false
16
18
  method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password", :required => false
19
+ method_option :provider, required: false
20
+ method_option :consumer_version_tag, type: :array, desc: "Retrieve the latest pacts with this consumer version tag. Used in conjuction with --provider.", :required => false
21
+ method_option :provider_app_version, aliases: "-a", desc: "Provider application version, required when publishing verification results", :required => false
22
+ method_option :publish_verification_results, aliases: "-r", desc: "Publish verification results to the broker", required: false
17
23
  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
18
24
  method_option :monkeypatch, hide: true, type: :array, :required => false
19
25
  method_option :verbose, aliases: "-v", desc: "Verbose output", :required => false
20
26
  method_option :provider_states_url, aliases: "-s", :required => false, hide: true
21
27
  method_option :format, banner: "FORMATTER", aliases: "-f", desc: "RSpec formatter. Defaults to custom Pact formatter. Other options are json and RspecJunitFormatter (which outputs xml)."
22
28
  method_option :out, aliases: "-o", banner: "FILE", desc: "Write output to a file instead of $stdout."
29
+ method_option :wip, type: :boolean, default: false, desc: "If WIP, process will always exit with exit code 0", hide: true
23
30
  method_option :pact_urls, aliases: "-u", hide: true, :required => false
24
31
 
25
32
  def verify(*pact_urls)
33
+ validate_verify
26
34
  print_deprecation_warnings
27
- Pact::ProviderVerifier::App.call(merged_urls(pact_urls), options)
35
+ success = Pact::ProviderVerifier::App.call(merged_urls(pact_urls), options)
36
+ exit_with_non_zero_status if !success && !options.wip
28
37
  end
29
38
 
30
39
  default_task :verify
@@ -46,6 +55,20 @@ module Pact
46
55
  $stderr.puts "WARN: The --pact-urls option is deprecated. Please pass in a space separated list of URLs as the first arguments to the pact-provider-verifier command."
47
56
  end
48
57
  end
58
+
59
+ def validate_verify
60
+ if options.pact_broker_base_url && (options.provider.nil? || options.provider == "")
61
+ raise InvalidArgumentsError, "No value provided for required option '--provider'"
62
+ end
63
+ end
64
+
65
+ def exit_with_non_zero_status
66
+ exit 1
67
+ end
68
+
69
+ def exit_on_failure?
70
+ true
71
+ end
49
72
  end
50
73
  end
51
74
  end
@@ -92,7 +92,7 @@ module Pact
92
92
 
93
93
  def log_request
94
94
  if verbose?
95
- $stdout.puts "DEBUG: Setting up provider state '#{provider_state}' for consumer '#{consumer}' using provider state server at #{provider_states_setup_url}"
95
+ $stdout.puts "DEBUG: Setting up provider state '#{provider_state}' for consumer '#{consumer}' using provider state set up URL #{provider_states_setup_url}"
96
96
  end
97
97
  end
98
98
 
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module ProviderVerifier
3
- VERSION = "1.15.0"
3
+ VERSION = "1.16.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.15.0
4
+ version: 1.16.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: 2018-07-12 00:00:00.000000000 Z
12
+ date: 2018-09-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -31,14 +31,20 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '1.17'
34
+ version: '1.33'
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: 1.33.1
35
38
  type: :runtime
36
39
  prerelease: false
37
40
  version_requirements: !ruby/object:Gem::Requirement
38
41
  requirements:
39
42
  - - "~>"
40
43
  - !ruby/object:Gem::Version
41
- version: '1.17'
44
+ version: '1.33'
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.33.1
42
48
  - !ruby/object:Gem::Dependency
43
49
  name: pact-message
44
50
  requirement: !ruby/object:Gem::Requirement
@@ -299,6 +305,7 @@ files:
299
305
  - bin/pact-provider-verifier
300
306
  - lib/pact/provider_verifier.rb
301
307
  - lib/pact/provider_verifier/add_header_middlware.rb
308
+ - lib/pact/provider_verifier/aggregate_pact_configs.rb
302
309
  - lib/pact/provider_verifier/app.rb
303
310
  - lib/pact/provider_verifier/cli/custom_thor.rb
304
311
  - lib/pact/provider_verifier/cli/verify.rb