pact-provider-verifier 1.4.1 → 1.5.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 +8 -0
- data/bin/pact-provider-verifier +2 -2
- data/lib/pact/provider_verifier/app.rb +23 -23
- data/lib/pact/provider_verifier/cli/custom_thor.rb +71 -0
- data/lib/pact/provider_verifier/cli/verify.rb +50 -0
- data/lib/pact/provider_verifier/version.rb +1 -1
- metadata +5 -4
- data/lib/pact/provider_verifier/cli.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ce3798b8ee40da180087db72750ff3e72d66055
|
4
|
+
data.tar.gz: ec328a826124163d927bb41c25e9fa3246e667a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26ec3b274333503bed29de0549abd432416e9829a939e4fe09237ee3d2f4177ea1c89d6f2499827a3b288a81ca73937d032fd449346608668dd1d271efd4ff11
|
7
|
+
data.tar.gz: 4d044730f12f63c9771b49a04d5b251ac1d47471e62dc27ad387d67e490ea174de426dabaef0c596af12899c5ca0d58f34fd5735d71aa43c8090a6c7c3d4a5e6
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
<a name="v1.5.0-1"></a>
|
2
|
+
### v1.5.0-1 (2017-10-01)
|
3
|
+
|
4
|
+
#### Features
|
5
|
+
|
6
|
+
* **cli**
|
7
|
+
* specify pact urls as the arguments to pact-provider-verifier instead of using --pact-urls option ([df78617](/../../commit/df78617))
|
8
|
+
|
1
9
|
<a name="v1.4.1-1"></a>
|
2
10
|
### v1.4.1-1 (2017-08-27)
|
3
11
|
|
data/bin/pact-provider-verifier
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'pact/provider_verifier/cli'
|
3
|
-
Pact::ProviderVerifier::CLI.start
|
2
|
+
require 'pact/provider_verifier/cli/verify'
|
3
|
+
Pact::ProviderVerifier::CLI::Verify.start
|
@@ -12,12 +12,13 @@ module Pact
|
|
12
12
|
|
13
13
|
PROXY_PACT_HELPER = File.expand_path(File.join(File.dirname(__FILE__), "pact_helper.rb"))
|
14
14
|
|
15
|
-
def initialize options = {}
|
15
|
+
def initialize pact_urls, options = {}
|
16
|
+
@pact_urls = pact_urls
|
16
17
|
@options = options
|
17
18
|
end
|
18
19
|
|
19
|
-
def self.call options
|
20
|
-
new(options).call
|
20
|
+
def self.call pact_urls, options
|
21
|
+
new(pact_urls, options).call
|
21
22
|
end
|
22
23
|
|
23
24
|
def call
|
@@ -31,6 +32,10 @@ module Pact
|
|
31
32
|
exit exit_statuses.count{ | status | status != 0 }
|
32
33
|
end
|
33
34
|
|
35
|
+
private
|
36
|
+
|
37
|
+
attr_reader :pact_urls, :options
|
38
|
+
|
34
39
|
def setup
|
35
40
|
print_deprecation_note
|
36
41
|
set_environment_variables
|
@@ -39,9 +44,9 @@ module Pact
|
|
39
44
|
end
|
40
45
|
|
41
46
|
def set_environment_variables
|
42
|
-
ENV['PROVIDER_STATES_SETUP_URL'] =
|
43
|
-
ENV['VERBOSE_LOGGING'] =
|
44
|
-
ENV['CUSTOM_PROVIDER_HEADER'] =
|
47
|
+
ENV['PROVIDER_STATES_SETUP_URL'] = options.provider_states_setup_url
|
48
|
+
ENV['VERBOSE_LOGGING'] = options.verbose if options.verbose
|
49
|
+
ENV['CUSTOM_PROVIDER_HEADER'] = options.custom_provider_header if options.custom_provider_header
|
45
50
|
end
|
46
51
|
|
47
52
|
def configure_service_provider
|
@@ -49,8 +54,8 @@ module Pact
|
|
49
54
|
rack_reverse_proxy = configure_reverse_proxy
|
50
55
|
rack_reverse_proxy = configure_custom_header_middlware(rack_reverse_proxy)
|
51
56
|
|
52
|
-
provider_application_version =
|
53
|
-
publish_results =
|
57
|
+
provider_application_version = options.provider_app_version
|
58
|
+
publish_results = options.publish_verification_results
|
54
59
|
|
55
60
|
Pact.service_provider "Running Provider Application" do
|
56
61
|
app do
|
@@ -66,7 +71,7 @@ module Pact
|
|
66
71
|
end
|
67
72
|
|
68
73
|
def configure_reverse_proxy
|
69
|
-
provider_base_url =
|
74
|
+
provider_base_url = options.provider_base_url
|
70
75
|
Rack::ReverseProxy.new do
|
71
76
|
reverse_proxy_options(
|
72
77
|
verify_mode: OpenSSL::SSL::VERIFY_NONE,
|
@@ -78,32 +83,27 @@ module Pact
|
|
78
83
|
end
|
79
84
|
|
80
85
|
def configure_custom_header_middlware rack_reverse_proxy
|
81
|
-
if
|
86
|
+
if options.custom_provider_header
|
82
87
|
Pact::ProviderVerifier::AddHeaderMiddlware.new(rack_reverse_proxy, parse_header)
|
83
88
|
else
|
84
89
|
rack_reverse_proxy
|
85
90
|
end
|
86
91
|
end
|
87
92
|
|
88
|
-
def pact_urls
|
89
|
-
@options.pact_urls.split(',')
|
90
|
-
end
|
91
|
-
|
92
93
|
def verify_pact pact_url
|
93
94
|
begin
|
94
|
-
|
95
|
+
verify_options = {
|
95
96
|
:pact_helper => PROXY_PACT_HELPER,
|
96
97
|
:pact_uri => pact_url,
|
97
98
|
:backtrace => false,
|
98
|
-
:pact_broker_username =>
|
99
|
-
:pact_broker_password =>
|
99
|
+
:pact_broker_username => options.broker_username,
|
100
|
+
:pact_broker_password => options.broker_password
|
100
101
|
}
|
101
|
-
|
102
|
-
|
102
|
+
verify_options[:description] = ENV['PACT_DESCRIPTION'] if ENV['PACT_DESCRIPTION']
|
103
|
+
verify_options[:provider_state] = ENV['PACT_PROVIDER_STATE'] if ENV['PACT_PROVIDER_STATE']
|
103
104
|
|
104
|
-
Cli::RunPactVerification.call(
|
105
|
+
Cli::RunPactVerification.call(verify_options)
|
105
106
|
rescue SystemExit => e
|
106
|
-
puts ""
|
107
107
|
e.status
|
108
108
|
end
|
109
109
|
end
|
@@ -113,12 +113,12 @@ module Pact
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def parse_header
|
116
|
-
header_name, header_value =
|
116
|
+
header_name, header_value = options.custom_provider_header.split(":", 2).collect(&:strip)
|
117
117
|
{header_name => header_value}
|
118
118
|
end
|
119
119
|
|
120
120
|
def print_deprecation_note
|
121
|
-
if
|
121
|
+
if options.provider_states_url
|
122
122
|
$stderr.puts "WARN: The --provider-states-url option is deprecated and the URL endpoint can be removed from the application"
|
123
123
|
end
|
124
124
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module Pact
|
4
|
+
module ProviderVerifier
|
5
|
+
module CLI
|
6
|
+
##
|
7
|
+
# Custom Thor task allows the following:
|
8
|
+
#
|
9
|
+
# `script arg1 arg2` to be interpreted as `script <default_task> arg1 arg2`
|
10
|
+
# `--option 1 --option 2` to be interpreted as `--option 1 2` (the standard Thor format for multiple value options)
|
11
|
+
# `script --help` to display the help for the default task instead of the command list
|
12
|
+
#
|
13
|
+
class CustomThor < ::Thor
|
14
|
+
|
15
|
+
no_commands do
|
16
|
+
def self.start given_args = ARGV, config = {}
|
17
|
+
super(massage_args(given_args))
|
18
|
+
end
|
19
|
+
|
20
|
+
def help *args
|
21
|
+
if args.empty?
|
22
|
+
super(self.class.default_task)
|
23
|
+
else
|
24
|
+
super
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.massage_args argv
|
29
|
+
prepend_default_task_name(turn_muliple_tag_options_into_array(argv))
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.prepend_default_task_name argv
|
33
|
+
if known_first_arguments.include?(argv[0])
|
34
|
+
argv
|
35
|
+
else
|
36
|
+
[default_command] + argv
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# other task names, help, and the help shortcuts
|
41
|
+
def self.known_first_arguments
|
42
|
+
@known_first_arguments ||= tasks.keys + ::Thor::HELP_MAPPINGS + ['help']
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.turn_muliple_tag_options_into_array argv
|
46
|
+
new_argv = []
|
47
|
+
opt_name = nil
|
48
|
+
argv.each_with_index do | arg, i |
|
49
|
+
if arg.start_with?('-')
|
50
|
+
opt_name = arg
|
51
|
+
existing = new_argv.find { | a | a.first == opt_name }
|
52
|
+
if !existing
|
53
|
+
new_argv << [arg]
|
54
|
+
end
|
55
|
+
else
|
56
|
+
if opt_name
|
57
|
+
existing = new_argv.find { | a | a.first == opt_name }
|
58
|
+
existing << arg
|
59
|
+
opt_name = nil
|
60
|
+
else
|
61
|
+
new_argv << [arg]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
new_argv.flatten
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'socket'
|
3
|
+
require 'pact/provider_verifier/app'
|
4
|
+
require 'pact/provider_verifier/cli/custom_thor'
|
5
|
+
|
6
|
+
module Pact
|
7
|
+
module ProviderVerifier
|
8
|
+
module CLI
|
9
|
+
class Verify < CustomThor
|
10
|
+
desc 'PACT_URL ...', "Verify pact(s) against a provider. Supports local and networked (http-based) files."
|
11
|
+
method_option :provider_base_url, aliases: "-h", desc: "Provider host URL", :required => true
|
12
|
+
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
|
15
|
+
method_option :broker_username, aliases: "-n", desc: "Pact Broker basic auth username", :required => false
|
16
|
+
method_option :broker_password, aliases: "-p", desc: "Pact Broker basic auth password", :required => false
|
17
|
+
method_option :custom_provider_header, desc: "Header to add to provider state set up and pact requests. eg 'Authorization: Basic cGFjdDpwYWN0'", :required => false
|
18
|
+
method_option :provider_states_url, aliases: "-s", desc: "DEPRECATED", :required => false
|
19
|
+
method_option :verbose, aliases: "-v", desc: "Verbose output", :required => false
|
20
|
+
method_option :pact_urls, aliases: "-u", desc: "DEPRECATED. Please provide as space separated arguments.", :required => false
|
21
|
+
|
22
|
+
def verify(*pact_urls)
|
23
|
+
print_deprecation_warnings
|
24
|
+
Pact::ProviderVerifier::App.call(merged_urls(pact_urls), options)
|
25
|
+
end
|
26
|
+
|
27
|
+
default_task :verify
|
28
|
+
|
29
|
+
desc 'version', 'Show the pact-provider-verifier gem version'
|
30
|
+
def version
|
31
|
+
require 'pact/provider_verifier/version'
|
32
|
+
puts Pact::ProviderVerifier::VERSION
|
33
|
+
end
|
34
|
+
|
35
|
+
no_commands do
|
36
|
+
def merged_urls pact_urls_from_args
|
37
|
+
from_opts = options.pact_urls ? options.pact_urls.split(',') : []
|
38
|
+
from_opts + pact_urls_from_args
|
39
|
+
end
|
40
|
+
|
41
|
+
def print_deprecation_warnings
|
42
|
+
if options.pact_urls
|
43
|
+
$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."
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Fellows
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -250,7 +250,8 @@ files:
|
|
250
250
|
- lib/pact/provider_verifier.rb
|
251
251
|
- lib/pact/provider_verifier/add_header_middlware.rb
|
252
252
|
- lib/pact/provider_verifier/app.rb
|
253
|
-
- lib/pact/provider_verifier/cli.rb
|
253
|
+
- lib/pact/provider_verifier/cli/custom_thor.rb
|
254
|
+
- lib/pact/provider_verifier/cli/verify.rb
|
254
255
|
- lib/pact/provider_verifier/pact_helper.rb
|
255
256
|
- lib/pact/provider_verifier/set_up_provider_state.rb
|
256
257
|
- lib/pact/provider_verifier/version.rb
|
@@ -274,7 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
274
275
|
version: '0'
|
275
276
|
requirements: []
|
276
277
|
rubyforge_project:
|
277
|
-
rubygems_version: 2.
|
278
|
+
rubygems_version: 2.6.13
|
278
279
|
signing_key:
|
279
280
|
specification_version: 4
|
280
281
|
summary: Provides a Pact verification service for use with Pact
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'socket'
|
3
|
-
require 'pact/provider_verifier/app'
|
4
|
-
|
5
|
-
module Pact
|
6
|
-
module ProviderVerifier
|
7
|
-
class CLI < Thor
|
8
|
-
desc 'verify', "Runs the Pact verification process"
|
9
|
-
method_option :pact_urls, aliases: "-u", desc: "Comma-separated list of Pact file URIs. Supports local and networked (http-based) files", :required => true
|
10
|
-
method_option :provider_base_url, aliases: "-h", desc: "Provide host URL", :required => true
|
11
|
-
method_option :provider_states_setup_url, aliases: "-c", desc: "Base URL to setup the provider states at", :required => false
|
12
|
-
method_option :provider_app_version, aliases: "-a", desc: "The provider application version, required for publishing verification results", :required => false
|
13
|
-
method_option :publish_verification_results, aliases: "-r", desc: "Publish verification results to the broker", required: false
|
14
|
-
method_option :broker_username, aliases: "-n", desc: "Pact Broker username", :required => false
|
15
|
-
method_option :broker_password, aliases: "-p", desc: "Pact Broker password", :required => false
|
16
|
-
method_option :verbose, aliases: "-v", desc: "Verbose output", :required => false
|
17
|
-
method_option :custom_provider_header, desc: "Header to add to provider state set up and pact requests. eg 'Authorization: Basic cGFjdDpwYWN0'", :required => false
|
18
|
-
method_option :provider_states_url, aliases: "-s", desc: "DEPRECATED", :required => false
|
19
|
-
|
20
|
-
def verify
|
21
|
-
Pact::ProviderVerifier::App.call(options)
|
22
|
-
end
|
23
|
-
|
24
|
-
default_task :verify
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|