workable-pact-provider-verifier 1.24.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +296 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +22 -0
- data/README.md +143 -0
- data/bin/pact-provider-verifier +3 -0
- data/lib/pact/provider_verifier.rb +2 -0
- data/lib/pact/provider_verifier/add_header_middlware.rb +34 -0
- data/lib/pact/provider_verifier/aggregate_pact_configs.rb +51 -0
- data/lib/pact/provider_verifier/app.rb +229 -0
- data/lib/pact/provider_verifier/cli/custom_thor.rb +71 -0
- data/lib/pact/provider_verifier/cli/verify.rb +80 -0
- data/lib/pact/provider_verifier/custom_middleware.rb +33 -0
- data/lib/pact/provider_verifier/pact_helper.rb +25 -0
- data/lib/pact/provider_verifier/provider_states/add_provider_states_header.rb +36 -0
- data/lib/pact/provider_verifier/provider_states/remove_provider_states_header_middleware.rb +19 -0
- data/lib/pact/provider_verifier/rspec_json_formatter_monkeypatch.rb +34 -0
- data/lib/pact/provider_verifier/set_up_provider_state.rb +112 -0
- data/lib/pact/provider_verifier/underscored_headers_monkeypatch.rb +96 -0
- data/lib/pact/provider_verifier/version.rb +5 -0
- data/lib/pact/wait_until_server_available.rb +24 -0
- metadata +324 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 99e33e7f43f9d975a4e2c725684e7e0134e391d9cd4869a587617916bc3ae10c
|
4
|
+
data.tar.gz: 1c53e57eb4de4101c925304f307276638da99ed8e26c0e11d70f9c63a2fce719
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6565535cdd4c3a097fdb35a3768b348b0f95452671bb9e83f4bfac2bfc08eeba62f383c53807f4b8f19aa275c43c442a44673a49599986008e8cf33ef3940806
|
7
|
+
data.tar.gz: '096493954612183631b334d4364f13c35faeebe00d56abb449aa175fa98189c089901f92449b7787891050ebb5049a2d93c56714319040ea399949529b028a98'
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,296 @@
|
|
1
|
+
<a name="v1.24.0-1"></a>
|
2
|
+
### v1.24.0-1 (2019-09-26)
|
3
|
+
|
4
|
+
|
5
|
+
#### Features
|
6
|
+
|
7
|
+
* update pact version dependency to 1.42.0 ([828deff](/../../commit/828deff))
|
8
|
+
* use new 'pacts for verification' endpoint when PACT_BROKER_PACTS_FOR_VERIFICATION_ENABLED is set to 'true' ([6e6f45b](/../../commit/6e6f45b))
|
9
|
+
* allow --provider-version-tag to be specified, which will be applied to the provider version when the verification results are published ([bf4bc93](/../../commit/bf4bc93))
|
10
|
+
|
11
|
+
|
12
|
+
<a name="v1.23.1-1"></a>
|
13
|
+
### v1.23.1-1 (2019-05-22)
|
14
|
+
|
15
|
+
|
16
|
+
#### Bug Fixes
|
17
|
+
|
18
|
+
* honour the --broker-token CLI param ([36bc88c](/../../commit/36bc88c))
|
19
|
+
|
20
|
+
|
21
|
+
<a name="v1.23.0-1"></a>
|
22
|
+
### v1.23.0-1 (2019-04-28)
|
23
|
+
|
24
|
+
|
25
|
+
#### Features
|
26
|
+
|
27
|
+
* allow a wait time to be specified to allow the provider to become available ([cec8d56](/../../commit/cec8d56))
|
28
|
+
|
29
|
+
|
30
|
+
<a name="v1.22.0-1"></a>
|
31
|
+
### v1.22.0-1 (2019-02-21)
|
32
|
+
|
33
|
+
|
34
|
+
#### Features
|
35
|
+
|
36
|
+
* add support for bearer token ([3a102c4](/../../commit/3a102c4))
|
37
|
+
* add support for bearer token ([bc37817](/../../commit/bc37817))
|
38
|
+
|
39
|
+
|
40
|
+
<a name="v1.21.0-1"></a>
|
41
|
+
### v1.21.0-1 (2018-11-15)
|
42
|
+
|
43
|
+
|
44
|
+
#### Features
|
45
|
+
|
46
|
+
* pass verbose flag through to HAL client when fetching pacts ([d3acd1a](/../../commit/d3acd1a))
|
47
|
+
|
48
|
+
|
49
|
+
<a name="v1.20.0-1"></a>
|
50
|
+
### v1.20.0-1 (2018-10-04)
|
51
|
+
|
52
|
+
|
53
|
+
#### Features
|
54
|
+
|
55
|
+
* **pact specification v3**
|
56
|
+
* add support for multiple provider states and params ([556b957](/../../commit/556b957))
|
57
|
+
|
58
|
+
|
59
|
+
<a name="v1.18.0-1"></a>
|
60
|
+
### v1.18.0-1 (2018-09-11)
|
61
|
+
|
62
|
+
|
63
|
+
#### Features
|
64
|
+
|
65
|
+
* **pending pacts**
|
66
|
+
* allow pending pacts to be feature toggled ([5e8e15f](/../../commit/5e8e15f))
|
67
|
+
|
68
|
+
* allow custom rack middleware to be specified ([ef857d4](/../../commit/ef857d4))
|
69
|
+
|
70
|
+
* **custom-middleware**
|
71
|
+
* allow custom middleware to be configured via the command line ([217136d](/../../commit/217136d))
|
72
|
+
|
73
|
+
|
74
|
+
<a name="v1.17.0-1"></a>
|
75
|
+
### v1.17.0-1 (2018-09-06)
|
76
|
+
|
77
|
+
|
78
|
+
#### Features
|
79
|
+
|
80
|
+
* rename wip in CLI to ignore-failures and wip pacts to pending pacts ([bf9ed81](/../../commit/bf9ed81))
|
81
|
+
|
82
|
+
|
83
|
+
<a name="v1.16.1-1"></a>
|
84
|
+
### v1.16.1-1 (2018-09-05)
|
85
|
+
|
86
|
+
|
87
|
+
#### Features
|
88
|
+
|
89
|
+
* **cli**
|
90
|
+
* update help text ([740dc4b](/../../commit/740dc4b))
|
91
|
+
|
92
|
+
|
93
|
+
<a name="v1.16.0-1"></a>
|
94
|
+
### v1.16.0-1 (2018-07-24)
|
95
|
+
|
96
|
+
|
97
|
+
#### Features
|
98
|
+
|
99
|
+
* allow pacts to be fetched from a Pact Broker by provider name, including WIP pacts. ([0b80528](/../../commit/0b80528))
|
100
|
+
* correct debug message regarding provider state URL ([d134ba6](/../../commit/d134ba6))
|
101
|
+
|
102
|
+
|
103
|
+
<a name="v1.15.0-1"></a>
|
104
|
+
### v1.15.0-1 (2018-07-13)
|
105
|
+
|
106
|
+
|
107
|
+
#### Features
|
108
|
+
|
109
|
+
* print a new line between JSON documents when using --format json ([dc90d8e](/../../commit/dc90d8e))
|
110
|
+
|
111
|
+
|
112
|
+
<a name="v1.14.4-1"></a>
|
113
|
+
### v1.14.4-1 (2018-07-10)
|
114
|
+
|
115
|
+
|
116
|
+
#### Bug Fixes
|
117
|
+
|
118
|
+
* ensure all json results are sent to stdout when multiple pacts are verified ([7662df0](/../../commit/7662df0))
|
119
|
+
|
120
|
+
|
121
|
+
<a name="v1.14.1-1"></a>
|
122
|
+
### v1.14.1-1 (2018-05-08)
|
123
|
+
|
124
|
+
|
125
|
+
#### Bug Fixes
|
126
|
+
|
127
|
+
* ensure headers with underscores are correctly replayed ([abb4b4a](/../../commit/abb4b4a))
|
128
|
+
|
129
|
+
|
130
|
+
<a name="v1.14.0-1"></a>
|
131
|
+
### v1.14.0-1 (2018-04-16)
|
132
|
+
|
133
|
+
|
134
|
+
#### Features
|
135
|
+
|
136
|
+
* add --out option to CLI to allow test results to be written to a file ([8be3367](/../../commit/8be3367))
|
137
|
+
|
138
|
+
|
139
|
+
<a name="v1.13.0-1"></a>
|
140
|
+
### v1.13.0-1 (2018-04-05)
|
141
|
+
|
142
|
+
|
143
|
+
#### Bug Fixes
|
144
|
+
|
145
|
+
* ensure v3 message matching rules are loaded correctly ([48f29a1](/../../commit/48f29a1))
|
146
|
+
|
147
|
+
|
148
|
+
<a name="v1.12.0-1"></a>
|
149
|
+
### v1.12.0-1 (2018-03-24)
|
150
|
+
|
151
|
+
|
152
|
+
#### Features
|
153
|
+
|
154
|
+
* add message pact verification support - alpha release only ([69cd7e9](/../../commit/69cd7e9))
|
155
|
+
|
156
|
+
|
157
|
+
<a name="v1.11.0-1"></a>
|
158
|
+
### v1.11.0-1 (2017-12-07)
|
159
|
+
|
160
|
+
|
161
|
+
#### Features
|
162
|
+
|
163
|
+
* maintain path portion of specified provider base URL ([b765b00](/../../commit/b765b00))
|
164
|
+
|
165
|
+
|
166
|
+
<a name="v1.10.0-1"></a>
|
167
|
+
### v1.10.0-1 (2017-11-11)
|
168
|
+
|
169
|
+
|
170
|
+
#### Features
|
171
|
+
|
172
|
+
* add support for --format RspecJunitFormatter ([2ba6439](/../../commit/2ba6439))
|
173
|
+
|
174
|
+
|
175
|
+
<a name="v1.9.0-1"></a>
|
176
|
+
### v1.9.0-1 (2017-11-07)
|
177
|
+
|
178
|
+
|
179
|
+
#### Features
|
180
|
+
|
181
|
+
* **monkeypatch**
|
182
|
+
* allow a ruby file to be loaded in order to perform at monkeypatch ([96bb549](/../../commit/96bb549))
|
183
|
+
|
184
|
+
|
185
|
+
<a name="v1.8.0-1"></a>
|
186
|
+
### v1.8.0-1 (2017-10-27)
|
187
|
+
|
188
|
+
#### Features
|
189
|
+
|
190
|
+
* **cli**
|
191
|
+
* allow --format json to be used to output spec results in json format to stdout ([aa7359a](/../../commit/aa7359a))
|
192
|
+
|
193
|
+
<a name="v1.7.0-1"></a>
|
194
|
+
### v1.7.0-1 (2017-10-18)
|
195
|
+
|
196
|
+
#### Features
|
197
|
+
|
198
|
+
* allow backtrace toggle to be configured via an environment variable ([298d791](/../../commit/298d791))
|
199
|
+
|
200
|
+
<a name="v1.6.0-1"></a>
|
201
|
+
### v1.6.0-1 (2017-10-01)
|
202
|
+
|
203
|
+
#### Features
|
204
|
+
|
205
|
+
* **cli**
|
206
|
+
* allow multiple --custom-provider-header to be specified ([6a8573a](/../../commit/6a8573a))
|
207
|
+
|
208
|
+
<a name="v1.5.0-1"></a>
|
209
|
+
### v1.5.0-1 (2017-10-01)
|
210
|
+
|
211
|
+
#### Features
|
212
|
+
|
213
|
+
* **cli**
|
214
|
+
* specify pact urls as the arguments to pact-provider-verifier instead of using --pact-urls option ([df78617](/../../commit/df78617))
|
215
|
+
|
216
|
+
<a name="v1.4.1-1"></a>
|
217
|
+
### v1.4.1-1 (2017-08-27)
|
218
|
+
|
219
|
+
#### Bug Fixes
|
220
|
+
|
221
|
+
* ensure Host header is correctly set ([9048744](/../../commit/9048744))
|
222
|
+
|
223
|
+
<a name="v1.4.0-1"></a>
|
224
|
+
### v1.4.0-1 (2017-08-11)
|
225
|
+
|
226
|
+
#### Features
|
227
|
+
|
228
|
+
* **run single interaction**
|
229
|
+
* allow env vars to be set to run a single interaction ([3e39517](/../../commit/3e39517))
|
230
|
+
|
231
|
+
#### Bug Fixes
|
232
|
+
|
233
|
+
* Turn off SSL verification for provider states setup call. ([744add2](/../../commit/744add2))
|
234
|
+
|
235
|
+
<a name="v1.3.1"></a>
|
236
|
+
### v1.3.1 (2017-08-08)
|
237
|
+
|
238
|
+
#### Bug Fixes
|
239
|
+
|
240
|
+
* **windows**
|
241
|
+
* Add retries for flakiness demonstrated on windows builds for pact-go ([198efef](/../../commit/198efef))
|
242
|
+
|
243
|
+
<a name="v1.3.0-1"></a>
|
244
|
+
# v1.3.0 (2017-08-08)
|
245
|
+
|
246
|
+
#### Features
|
247
|
+
|
248
|
+
* **custom provider header**
|
249
|
+
* Allow a --custom-provider-header to be specified ([e3ea6fa](/../../commit/e3ea6fa))
|
250
|
+
|
251
|
+
<a name="1.2.0"></a>
|
252
|
+
# 1.2.0 (2017-08-05)
|
253
|
+
|
254
|
+
* chore(gems): Change json version to allow >1.8 ([b91391a](https://github.com/pact-foundation/pact-provider-verifier/commit/b91391a))
|
255
|
+
|
256
|
+
# 1.1.3 (02 June 2017)
|
257
|
+
* 066fa60 - Add states list to state setup JSON body, to prepare for v3 pact spec which allows multiple provider states (Beth Skurrie, Fri Jun 2 15:01:28 2017 +1000)
|
258
|
+
|
259
|
+
# 1.1.2 (02 June 2017)
|
260
|
+
* da958c0 - Only set up state if a provider-states-setup-url is provided. Add tests for SetUpProviderState. (Beth Skurrie, Fri Jun 2 14:31:27 2017 +1000)
|
261
|
+
* 36ef2eb - Remove .java, .class, .gitignore and .travis.yml files from package (Beth Skurrie, Fri Jun 2 10:32:55 2017 +1000)
|
262
|
+
* 7902674 - Add rake tasks to generate and upload release notes. (Beth Skurrie, Fri Jun 2 10:12:17 2017 +1000)
|
263
|
+
* 01e811e - Add integration specs for command (Beth Skurrie, Fri Jun 2 05:51:30 2017 +1000)
|
264
|
+
|
265
|
+
# 1.1.0 (01 June 2017)
|
266
|
+
* 7106832 - chore(docs): update docs for provider states URL (Matt Fellows, Fri May 26 22:45:09 2017 +1000)
|
267
|
+
* 8f787e6 - Add deprecation warning for --provider-states-url (Beth Skurrie, Fri May 26 20:51:48 2017 +1000)
|
268
|
+
* 982ba7c - Remove need for provider-states-url by dynamically calling the set up code during test execution (Beth Skurrie, Fri May 26 16:30:14 2017 +1000)
|
269
|
+
* f055375 - Turn silent mode on for zip task in rake package (Beth Skurrie, Tue May 23 09:34:51 2017 +1000)
|
270
|
+
|
271
|
+
# 1.0.2 (23 May 2017)
|
272
|
+
* 33f0811 - Upgrade rspec version to ~>3.5 to fix #11 (Beth Skurrie, Tue May 23 09:01:07 2017 +1000)
|
273
|
+
|
274
|
+
# 1.0.1 (9 May 2017)
|
275
|
+
* 94597a0 - Updated pact gem to allow use of https for publishing verifications (Beth Skurrie, Tue May 9 14:27:19 2017 +1000)
|
276
|
+
|
277
|
+
# 1.0.0 (9 May 2017)
|
278
|
+
|
279
|
+
# 0.0.4 (15 May 2016)
|
280
|
+
|
281
|
+
* c5dc292 - Added basic authentication support for Pact Broker URLs (Matt Fellows, Sun May 15 19:08:22 2016 +1000)
|
282
|
+
|
283
|
+
# 0.0.3 (15 May 2016)
|
284
|
+
|
285
|
+
* d36ae19 - Release v0.0.3 (Matt Fellows, Sun May 15 11:22:41 2016 +1000)
|
286
|
+
|
287
|
+
# 0.0.2 (12 May 2016)
|
288
|
+
|
289
|
+
* 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)
|
290
|
+
* 9feb60e - Verifier properly runs all Pacts provided and handles Pact CLI exit call (Matt Fellows, Sun May 15 11:22:12 2016 +1000)
|
291
|
+
* a85903d - Release template (Matt Fellows, Thu May 12 21:53:22 2016 +1000)
|
292
|
+
* 059b488 - Setting execute perms on wrapper script during package (Matt Fellows, Thu May 12 22:30:22 2016 +1000)
|
293
|
+
|
294
|
+
# 0.0.1 (8 May 2016)
|
295
|
+
|
296
|
+
* 39e75f3 - Pact provider verifier cross-platform CLI tool (Matt Fellows, Thu May 12 07:30:47 2016 +1000)
|
data/Gemfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
gem "pact-message", git: "https://github.com/ang3lkar/pact-message-ruby"
|
6
|
+
|
7
|
+
if ENV['X_PACT_DEVELOPMENT']
|
8
|
+
gem "pact", path: '../pact'
|
9
|
+
gem "pact-message", path: '../pact-message-ruby'
|
10
|
+
gem "pact-support", path: '../pact-support'
|
11
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 Matt Fellows
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
# Pact Provider Verification
|
2
|
+
|
3
|
+
This setup simplifies Pact Provider [verification](https://docs.pact.io/documentation/verifying_pacts.html)
|
4
|
+
process in any language, wrapping the Ruby implementation into a cross-platform,
|
5
|
+
binary-like CLI tool.
|
6
|
+
|
7
|
+
[![Build Status](https://travis-ci.org/pact-foundation/pact-provider-verifier.svg?branch=master)](https://travis-ci.org/pact-foundation/pact-provider-verifier)
|
8
|
+
|
9
|
+
**Features**:
|
10
|
+
|
11
|
+
* Verify Pacts against Pacts published to an http endpoint, such as a [Pact Broker](https://github.com/pact-foundation/pact_broker)
|
12
|
+
* Verify local `*.json` Pacts on the file system
|
13
|
+
* Works with Pact [provider states](https://docs.pact.io/documentation/provider_states.html) should you need them
|
14
|
+
* Publishes the verification results back to the pact broker if the pact was retrieved from a broker.
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
### Docker
|
19
|
+
|
20
|
+
Take a look at https://github.com/DiUS/pact-provider-verifier-docker.
|
21
|
+
|
22
|
+
### Native Installation
|
23
|
+
|
24
|
+
Download the appropriate [release](https://github.com/pact-foundation/pact-ruby-standalone/releases)
|
25
|
+
for your OS and put somewhere on your `PATH`.
|
26
|
+
|
27
|
+
### With Ruby on Mac OSX and Linux
|
28
|
+
|
29
|
+
```
|
30
|
+
gem install pact-provider-verifier
|
31
|
+
pact-provider-verifier <args>
|
32
|
+
```
|
33
|
+
|
34
|
+
Run `pact-provider-verifier help` for command line options.
|
35
|
+
|
36
|
+
## Usage
|
37
|
+
|
38
|
+
```
|
39
|
+
Usage:
|
40
|
+
pact-provider-verifier PACT_URL ... -h, --provider-base-url=PROVIDER_BASE_URL
|
41
|
+
|
42
|
+
Options:
|
43
|
+
-h, --provider-base-url=PROVIDER_BASE_URL # Provider host URL
|
44
|
+
-c, [--provider-states-setup-url=PROVIDER_STATES_SETUP_URL] # Base URL to setup the provider states at
|
45
|
+
[--pact-broker-base-url=PACT_BROKER_BASE_URL] # Base URL of the Pact Broker from which to retrieve the pacts.
|
46
|
+
-n, [--broker-username=BROKER_USERNAME] # Pact Broker basic auth username
|
47
|
+
-p, [--broker-password=BROKER_PASSWORD] # Pact Broker basic auth password
|
48
|
+
-k, [--broker-token=BROKER_TOKEN] # Pact Broker bearer token
|
49
|
+
[--provider=PROVIDER]
|
50
|
+
[--consumer-version-tag=TAG] # Retrieve the latest pacts with this consumer version tag. Used in conjunction with --provider. May be specified multiple times.
|
51
|
+
[--provider-version-tag=TAG] # Tag to apply to the provider application version. May be specified multiple times.
|
52
|
+
-a, [--provider-app-version=PROVIDER_APP_VERSION] # Provider application version, required when publishing verification results
|
53
|
+
-r, [--publish-verification-results], [--no-publish-verification-results] # Publish verification results to the broker
|
54
|
+
[--custom-provider-header=CUSTOM_PROVIDER_HEADER] # Header to add to provider state set up and pact verification requests. eg 'Authorization: Basic cGFjdDpwYWN0'. May be specified multiple times.
|
55
|
+
[--custom-middleware=FILE] # Ruby file containing a class implementing Pact::ProviderVerifier::CustomMiddleware. This allows the response to be modified before replaying. Use with caution!
|
56
|
+
-v, [--verbose=VERBOSE] # Verbose output
|
57
|
+
-f, [--format=FORMATTER] # RSpec formatter. Defaults to custom Pact formatter. Other options are json and RspecJunitFormatter (which outputs xml).
|
58
|
+
-o, [--out=FILE] # Write output to a file instead of $stdout.
|
59
|
+
[--wait=SECONDS] # The number of seconds to poll for the provider to become available before running the verification
|
60
|
+
# Default: 0
|
61
|
+
```
|
62
|
+
|
63
|
+
## Examples
|
64
|
+
|
65
|
+
See the [example](examples) for a demonstration with a [Sinatra](http://www.sinatrarb.com/) API:
|
66
|
+
|
67
|
+
```
|
68
|
+
cd examples
|
69
|
+
bundle install
|
70
|
+
./test.sh
|
71
|
+
```
|
72
|
+
|
73
|
+
### Simple API
|
74
|
+
|
75
|
+
*Steps*:
|
76
|
+
|
77
|
+
1. Create an API and a corresponding Docker image for it
|
78
|
+
1. Publish Pacts to the Pact broker (or create local ones)
|
79
|
+
1. Run the CLI tool for your OS, passing the appropriate arguments:
|
80
|
+
* a space delimited list of local Pact file URLs or Pact Broker URLs.
|
81
|
+
* `--provider-base-url` - the base url of the provider (i.e. your API)
|
82
|
+
|
83
|
+
eg.
|
84
|
+
|
85
|
+
```
|
86
|
+
pact-provider-verifier foo-bar.json --provider-base-url http://localhost:9292
|
87
|
+
```
|
88
|
+
|
89
|
+
### Setting a custom Authentication header
|
90
|
+
|
91
|
+
If you need to set a valid Authentication header for your replayed requests and provider state setup calls, specify `--custom-provider-header "Authentication: Type VALUE"` in the command line options.
|
92
|
+
|
93
|
+
Modification of the request headers is sometimes necessary, but be aware that any modification of the request before it is replayed lessens your confidence that the consumer and provider will work correctly in real life, so do it with caution.
|
94
|
+
|
95
|
+
### API with Provider States
|
96
|
+
|
97
|
+
Read the [Provider States section on docs.pact.io](https://docs.pact.io/documentation/provider_states.html) for an introduction to provider states.
|
98
|
+
|
99
|
+
To allow the correct data to be set up before each interaction is replayed, you will need to create a dev/test only HTTP endpoint that accepts a JSON document that looks like:
|
100
|
+
|
101
|
+
```json
|
102
|
+
{
|
103
|
+
"consumer": "CONSUMER_NAME",
|
104
|
+
"state": "PROVIDER_STATE"
|
105
|
+
}
|
106
|
+
```
|
107
|
+
|
108
|
+
The endpoint should set up the given provider state for the given consumer synchronously, and return an error if the provider state is not recognised. Namespacing your provider states within each consumer will avoid clashes if more than one consumer defines the same provider state with different data.
|
109
|
+
|
110
|
+
The following flag is required when running the CLI:
|
111
|
+
|
112
|
+
* `--provider-states-setup-url` - the full url of the endpoint which sets the active consumer and provider state.
|
113
|
+
|
114
|
+
Rather than tearing down the specific test data created after each interaction, you should clear all the existing data at the start of each set up call. This is a more reliable method of ensuring that your test data does not leak from one test to another.
|
115
|
+
|
116
|
+
Note that the HTTP endpoint does not have to actually be within your application - it just has to have access to the same data store. So if you cannot add "test only" endpoints during your verification, consider making a separate app which shares credentials to your app's datastore. It is highly recommended that you run your verifications against a locally running provider, rather than a deployed one, as this will make it much easier to stub any downstream calls, debug issues, and it will make your tests run as fast as possible.
|
117
|
+
|
118
|
+
Ignore the `states` array that you will see if you happen to print out the live provider state set up request body - that was an attempt to make the set up call forwards compatible with the v3 pact specification, which allows multiple provider states. Unfortunately, this forwards compatibilty attempt failed, because the v3 provider states support a map of params, not just a name, so it should have been `{ "state": { "name": "PROVIDER_STATE, "params": {...} } }`. See the next section for the actual v3 support.
|
119
|
+
|
120
|
+
#### Pact specification v3 provider state support
|
121
|
+
|
122
|
+
The v3 Pact specification adds support for multiple provider states, and provider state params. If you are verifying a pact with multiple provider states, then set up URL will be invoked once for each state. The `params` hash from the pact will also be passed through in the JSON document with the key name `params`.
|
123
|
+
|
124
|
+
### Using the Pact Broker with Basic authentication
|
125
|
+
|
126
|
+
The following flags are required to use basic authentication with a Pact Broker:
|
127
|
+
|
128
|
+
* `--broker-user` - the Username for Pact Broker basic authentication.
|
129
|
+
* `--broker-password` - the Password for Pact Broker basic authentication.
|
130
|
+
|
131
|
+
NOTE: the `http://user:password@host` format for basic HTTP auth is not supported.
|
132
|
+
|
133
|
+
## Contributing
|
134
|
+
|
135
|
+
See [CONTRIBUTING.md](/CONTRIBUTING.md)
|
136
|
+
|
137
|
+
[pact]: https://github.com/realestate-com-au/pact
|
138
|
+
[releases]: https://github.com/bethesque/pact-mock_service/releases
|
139
|
+
[javascript]: https://github.com/DiUS/pact-consumer-js-dsl
|
140
|
+
[pact-dev]: https://groups.google.com/forum/#!forum/pact-dev
|
141
|
+
[windows]: https://github.com/bethesque/pact-mock_service/wiki/Building-a-Windows-standalone-executable
|
142
|
+
[install-windows]: https://github.com/bethesque/pact-mock_service/wiki/Installing-the-pact-mock_service-gem-on-Windows
|
143
|
+
[why-generated]: https://github.com/realestate-com-au/pact/wiki/FAQ#why-are-the-pacts-generated-and-not-static
|