pact-provider-verifier 0.0.3 → 0.0.6
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 +15 -0
- data/README.md +14 -6
- data/lib/pact/provider_verifier/app.rb +9 -2
- data/lib/pact/provider_verifier/cli.rb +2 -0
- data/lib/pact/provider_verifier/pact_helper.rb +3 -0
- data/lib/pact/provider_verifier/version.rb +1 -1
- metadata +3 -4
- data/lib/pact/provider_verifier/Rakefile +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49b9a6fc39315154ac39e62ad0d33d41316dc2ba
|
4
|
+
data.tar.gz: bd0241d66bddf289531c83fe45a89ec0ffcd599f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28d2625326161d771639a58c83ee50f1160ee69a385cff037d19da2c07d6aad685ca1d50a26c241b79d2c021cd4a00cf5cebbfc37fa9fabd472ea2b898ccdd6a
|
7
|
+
data.tar.gz: 44f0046ee789322a1e1330a87b356e9736c1cc16f2734519b45a4d049bda8c6a1445a2aa6a7351b0122b07753df9d90af7e04e82e0e56b669a6b4921fe5db2e0
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,21 @@ Do this to generate your change history
|
|
2
2
|
|
3
3
|
git log --pretty=format:' * %h - %s (%an, %ad)' vX.Y.Z..HEAD
|
4
4
|
|
5
|
+
### 0.0.4 (15 May 2016)
|
6
|
+
|
7
|
+
* c5dc292 - Added basic authentication support for Pact Broker URLs (Matt Fellows, Sun May 15 19:08:22 2016 +1000)
|
8
|
+
|
9
|
+
### 0.0.3 (15 May 2016)
|
10
|
+
|
11
|
+
* d36ae19 - Release v0.0.3 (Matt Fellows, Sun May 15 11:22:41 2016 +1000)
|
12
|
+
|
13
|
+
### 0.0.2 (12 May 2016)
|
14
|
+
|
15
|
+
* 0aca507 - Refactored to not use the Pact rake tasks. Traveling Ruby does not like shelling out to a Ruby process (where's my Gems?) (Matt Fellows, Thu May 12 21:55:29 2016 +1000)
|
16
|
+
* 9feb60e - Verifier properly runs all Pacts provided and handles Pact CLI exit call (Matt Fellows, Sun May 15 11:22:12 2016 +1000)
|
17
|
+
* a85903d - Release template (Matt Fellows, Thu May 12 21:53:22 2016 +1000)
|
18
|
+
* 059b488 - Setting execute perms on wrapper script during package (Matt Fellows, Thu May 12 22:30:22 2016 +1000)
|
19
|
+
|
5
20
|
### 0.0.1 (8 May 2016)
|
6
21
|
|
7
22
|
* 39e75f3 - Pact provider verifier cross-platform CLI tool (Matt Fellows, Thu May 12 07:30:47 2016 +1000)
|
data/README.md
CHANGED
@@ -42,7 +42,7 @@ cd examples
|
|
42
42
|
1. Create an API and a corresponding Docker image for it
|
43
43
|
1. Publish Pacts to the Pact broker (or create local ones)
|
44
44
|
1. Run the CLI tool for your OS, passing the appropriate flags:
|
45
|
-
* `--pact_urls` - a comma delimited list of
|
45
|
+
* `--pact_urls` - a comma delimited list of local Pact file urls or Pact Broker URLs.
|
46
46
|
* `--provider_base_url` - the base url of the pact provider (i.e. your API)
|
47
47
|
1.
|
48
48
|
|
@@ -63,13 +63,21 @@ Execute pact provider verification against a provider which implements the follo
|
|
63
63
|
|
64
64
|
consumer=web&state=customer%20is%20logged%20in
|
65
65
|
|
66
|
-
The following
|
66
|
+
The following flags are required:
|
67
67
|
|
68
|
-
* `
|
69
|
-
* `
|
70
|
-
* `
|
71
|
-
* `
|
68
|
+
* `--pact-urls` - a comma delimited list of pact file urls
|
69
|
+
* `--provider-base-url` - the base url of the pact provider
|
70
|
+
* `--provider-states-url` - the full url of the endpoint which returns provider states by consumer
|
71
|
+
* `--provider-states-setup-url` - the full url of the endpoint which sets the active pact consumer and provider state
|
72
72
|
|
73
|
+
### Using the Pact Broker with Basic authentication
|
74
|
+
|
75
|
+
The following flags are required to use basic authentication with a Pact Broker:
|
76
|
+
|
77
|
+
* `--broker-user` - the Username for Pact Broker basic authentication.
|
78
|
+
* `--broker-password` - the Password for Pact Broker basic authentication.
|
79
|
+
|
80
|
+
NOTE: the `http://user:password@host` format for basic HTTP auth is not supported.
|
73
81
|
|
74
82
|
## Contributing
|
75
83
|
|
@@ -37,6 +37,8 @@ module Pact
|
|
37
37
|
proxy_pact_helper = File.expand_path(File.join(File.dirname(__FILE__), "pact_helper.rb"))
|
38
38
|
ENV['provider_states_url'] = @options.provider_states_url
|
39
39
|
ENV['provider_states_setup_url'] = @options.provider_states_setup_url
|
40
|
+
ENV['PACT_BROKER_USERNAME'] = @options.broker_username if @options.broker_username
|
41
|
+
ENV['PACT_BROKER_PASSWORD'] = @options.broker_password if @options.broker_password
|
40
42
|
provider_base_url = @options.provider_base_url
|
41
43
|
|
42
44
|
Pact.service_provider "Running Provider Application" do
|
@@ -56,7 +58,9 @@ module Pact
|
|
56
58
|
options = {
|
57
59
|
:pact_helper => proxy_pact_helper,
|
58
60
|
:pact_uri => pact_url,
|
59
|
-
:backtrace => false
|
61
|
+
:backtrace => false,
|
62
|
+
:pact_broker_username => @options.broker_username,
|
63
|
+
:pact_broker_password => @options.broker_password
|
60
64
|
}
|
61
65
|
Cli::RunPactVerification.call(options)
|
62
66
|
rescue SystemExit => e
|
@@ -66,7 +70,7 @@ module Pact
|
|
66
70
|
end
|
67
71
|
|
68
72
|
# Return non-zero exit code if failures - increment for each Pact
|
69
|
-
exit_statuses.count{ | status | status != 0 }
|
73
|
+
exit exit_statuses.count{ | status | status != 0 }
|
70
74
|
end
|
71
75
|
end
|
72
76
|
end
|
@@ -84,6 +88,9 @@ end
|
|
84
88
|
def get_json_from_server(path)
|
85
89
|
url = URI.parse(path)
|
86
90
|
conn = Faraday.new("http://#{url.host}:#{url.port}") do |c|
|
91
|
+
if ENV['PACT_BROKER_USERNAME'] && ENV['PACT_BROKER_PASSWORD']
|
92
|
+
c.use Faraday::Request::BasicAuthentication, ENV['PACT_BROKER_USERNAME'], ENV['PACT_BROKER_PASSWORD']
|
93
|
+
end
|
87
94
|
c.use FaradayMiddleware::ParseJson
|
88
95
|
c.use Faraday::Adapter::NetHttp
|
89
96
|
end
|
@@ -10,6 +10,8 @@ module Pact
|
|
10
10
|
method_option :provider_base_url, aliases: "-h", desc: "Provide host URL", :required => true
|
11
11
|
method_option :provider_states_url, aliases: "-s", desc: "Base URL to retrieve the provider states from", :required => false
|
12
12
|
method_option :provider_states_setup_url, aliases: "-c", desc: "Base URL to setup the provider states at", :required => false
|
13
|
+
method_option :broker_username, aliases: "-n", desc: "Pact Broker username", :required => false
|
14
|
+
method_option :broker_password, aliases: "-p", desc: "Pact Broker password", :required => false
|
13
15
|
|
14
16
|
def verify
|
15
17
|
app = Pact::ProviderVerifier::App.new(options)
|
@@ -10,6 +10,9 @@ if ENV['provider_states_url']
|
|
10
10
|
puts "Setting up provider state '#{provider_state}' for consumer '#{ENV['pact_consumer']}' using provider state server at #{ENV['provider_states_setup_url']}"
|
11
11
|
|
12
12
|
conn = Faraday.new(:url => ENV['provider_states_setup_url']) do |faraday|
|
13
|
+
if ENV['PACT_BROKER_USERNAME'] && ENV['PACT_BROKER_PASSWORD']
|
14
|
+
faraday.use Faraday::Request::BasicAuthentication, ENV['PACT_BROKER_USERNAME'], ENV['PACT_BROKER_PASSWORD']
|
15
|
+
end
|
13
16
|
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
14
17
|
end
|
15
18
|
conn.post do |req|
|
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: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Fellows
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -134,7 +134,6 @@ files:
|
|
134
134
|
- README.md
|
135
135
|
- bin/pact-provider-verifier
|
136
136
|
- lib/pact/provider_verifier.rb
|
137
|
-
- lib/pact/provider_verifier/Rakefile
|
138
137
|
- lib/pact/provider_verifier/app.rb
|
139
138
|
- lib/pact/provider_verifier/cli.rb
|
140
139
|
- lib/pact/provider_verifier/pact_helper.rb
|
@@ -159,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
158
|
version: '0'
|
160
159
|
requirements: []
|
161
160
|
rubyforge_project:
|
162
|
-
rubygems_version: 2.4.
|
161
|
+
rubygems_version: 2.4.6
|
163
162
|
signing_key:
|
164
163
|
specification_version: 4
|
165
164
|
summary: Provides a Pact verification service for use with Pact
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'pact/provider/proxy/tasks'
|
2
|
-
require 'pact/provider_verifier/json_helper'
|
3
|
-
|
4
|
-
# make sure that the required environment variables are sets
|
5
|
-
required_environment_variables = ['pact_urls', 'provider_base_url']
|
6
|
-
missing_environment_variables = required_environment_variables.select { |ev| ENV[ev].to_s == '' }
|
7
|
-
if missing_environment_variables.count > 0 then
|
8
|
-
raise("ERROR: the following environment variables have not been specified: '#{missing_environment_variables}'")
|
9
|
-
end
|
10
|
-
|
11
|
-
# Non-mandatory, but probably useful environment variables
|
12
|
-
other_environment_variables = ['provider_states_url', 'provider_states_setup_url']
|
13
|
-
missing_environment_variables = other_environment_variables.select { |ev| ENV[ev].to_s == '' }
|
14
|
-
if missing_environment_variables.count > 0 then
|
15
|
-
warn("WARN: the following non-mandatory environment variables have not been specified: '#{missing_environment_variables}'")
|
16
|
-
end
|
17
|
-
|
18
|
-
pacts = ENV['pact_urls'].split(',')
|
19
|
-
# if you have duplicates in the pact_urls you will see more iterations than expected,
|
20
|
-
# but that shouldn't be the case except when you're trying stuff out in dev
|
21
|
-
|
22
|
-
def get_pact_consumer_name pact_url
|
23
|
-
json = get_json(pact_url)
|
24
|
-
json['consumer']['name']
|
25
|
-
end
|
26
|
-
|
27
|
-
task :verify_pacts do
|
28
|
-
pacts.each do |pact_url|
|
29
|
-
Pact::ProxyVerificationTask.new :"#{pact_url}" do | task |
|
30
|
-
ENV['pact_consumer'] = get_pact_consumer_name(pact_url)
|
31
|
-
task.pact_url pact_url, :pact_helper => './pact_helper'
|
32
|
-
task.provider_base_url ENV['provider_base_url']
|
33
|
-
end
|
34
|
-
task_name = "pact:verify:#{pact_url}"
|
35
|
-
Rake::Task[task_name].invoke
|
36
|
-
Rake::Task[task_name].reenable
|
37
|
-
end
|
38
|
-
end
|