Skip to content

Commit b78ac6d

Browse files
committed
Merge branch 'master' into pyasi_add_matcher_regexes
2 parents 35dfa0d + 48f0f51 commit b78ac6d

File tree

4 files changed

+56
-21
lines changed

4 files changed

+56
-21
lines changed

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
### 0.22.0
2+
* d112a4a - Merge pull request #134 from elliottmurray/multiple-custom-provider-header (Elliott Murray, Mon May 11 16:32:49 2020 +0100)
3+
* 58f8e6b - Fix some style issues (Elliott Murray, Wed Apr 29 12:35:00 2020 +0100)
4+
* bf9bc2d - Added multiple click options for custom headers (Elliott Murray, Tue Apr 28 18:14:02 2020 +0100)
5+
* 254ffc5 - Merge pull request #130 from elliottmurray/examples (Elliott Murray, Sat May 9 18:02:46 2020 +0100)
6+
* 3898aee - Created examples folder (Elliott Murray, Thu Apr 2 14:03:17 2020 +0100)
7+
* b859443 - Merge pull request #129 from elliottmurray/docker (Elliott Murray, Sat May 9 17:54:01 2020 +0100)
8+
* 9b83da7 - Added bash to containers (Elliott Murray, Fri Apr 10 11:52:43 2020 +0100)
9+
* 73db8fc - Remove subprocess requirement (Elliott Murray, Fri Apr 10 11:32:38 2020 +0100)
10+
* f3315a1 - Added 38 and created build helper script (Elliott Murray, Wed Apr 1 17:11:06 2020 +0100)
11+
* e7743de - Some readme and python37 (Elliott Murray, Wed Apr 1 14:25:20 2020 +0100)
12+
* 515aeb2 - Tweaked the run script (Elliott Murray, Wed Apr 1 12:57:02 2020 +0100)
13+
* 5a6acaf - Merge pull request #131 from elliottmurray/python38 (Elliott Murray, Sat May 9 17:47:13 2020 +0100)
14+
* bb921eb - Updated to 3.8 (Elliott Murray, Sat Apr 4 16:39:18 2020 +0100)
15+
* 12108c4 - Merge pull request #132 from pyasi/pyasi_test_refactor (Elliott Murray, Sat May 9 17:33:59 2020 +0100)
16+
* 48ad173 - Merge pull request #135 from m-aciek/master (Elliott Murray, Sat May 9 17:21:52 2020 +0100)
17+
* 6948482 - Merge pull request #136 from pact-foundation/chore/upgrade-to-pact-ruby-standalone-1-84-0 (Elliott Murray, Sat May 9 15:13:07 2020 +0100)
18+
* 14603ac - feat: update standalone to 1.84.0 (Beth Skurrie, Sat May 2 09:43:30 2020 +1000)
19+
* 410caf1 - chore: add script to create a PR to update the pact-ruby-standalone version (Beth Skurrie, Sat May 2 09:42:55 2020 +1000)
20+
* b5af1fc - Fix missing normalization of consumer name while publishing pact (Maciej Olko, Thu Apr 30 08:50:17 2020 +0200)
21+
* 5785782 - Move tests to standard tests dir (Peter Yasi, Fri Apr 17 14:03:04 2020 -0400)
22+
* 88ea23d - docs: update RELEASING.md (Beth Skurrie, Tue Feb 18 10:46:11 2020 +1100)
23+
124
### 0.21.0
225
* 6352dda - feat: update to pact-ruby-standalone-1.79.0 (#127) (Beth Skurrie, Tue Feb 18 10:25:59 2020 +1100)
326
* 758d6ea - Converting to kwargs (Elliott Murray, Sat Feb 1 16:24:49 2020 +1100)

pact/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Pact version info."""
22

3-
__version__ = '0.21.0'
3+
__version__ = '0.22.0'

pact/verify.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@
7777
default='',
7878
help='Retrieve the latest pacts for this provider')
7979
@click.option(
80-
'header', '--custom-provider-header',
80+
'headers', '--custom-provider-header',
8181
envvar='CUSTOM_PROVIDER_HEADER',
82+
multiple=True,
8283
help='Header to add to provider state set up and '
8384
'pact verification requests. '
8485
'eg \'Authorization: Basic cGFjdDpwYWN0\'. '
@@ -105,7 +106,7 @@
105106
help='Toggle verbose logging, defaults to False.')
106107
def main(pacts, base_url, pact_url, pact_urls, states_url, states_setup_url,
107108
username, broker_base_url, consumer_version_tag, provider_version_tag,
108-
password, token, provider, header, timeout, provider_app_version,
109+
password, token, provider, headers, timeout, provider_app_version,
109110
publish_verification_results, verbose):
110111
"""
111112
Verify one or more contracts against a provider service.
@@ -150,30 +151,22 @@ def main(pacts, base_url, pact_url, pact_urls, states_url, states_setup_url,
150151
'--pact-broker-base-url': broker_base_url,
151152
'--provider': provider,
152153
'--broker-password': password,
153-
'--broker-token': token,
154-
'--custom-provider-header': header,
154+
'--broker-token': token
155155
}
156156

157157
command = [VERIFIER_PATH]
158158
command.extend(all_pact_urls)
159159
command.extend(['{}={}'.format(k, v) for k, v in options.items() if v])
160160

161161
for tag in consumer_version_tag:
162-
command.extend(['--consumer-version-tag', tag])
162+
command.extend(["--consumer-version-tag={}".format(tag)])
163163
for tag in provider_version_tag:
164-
command.extend(['--provider-version-tag', tag])
164+
command.extend(["--provider-version-tag={}".format(tag)])
165+
for header in headers:
166+
command.extend(["--custom-provider-header={}".format(header)])
165167

166168
if publish_verification_results:
167-
if not provider_app_version:
168-
click.echo(
169-
error
170-
+ 'Provider application version is required '
171-
+ 'to publish verification results to broker'
172-
)
173-
raise click.Abort()
174-
command.extend(["--provider-app-version",
175-
provider_app_version,
176-
"--publish-verification-results"])
169+
publish_results(error, provider_app_version, command)
177170

178171
if verbose:
179172
command.extend(['--verbose'])
@@ -188,6 +181,20 @@ def main(pacts, base_url, pact_url, pact_urls, states_url, states_setup_url,
188181
sys.exit(p.returncode)
189182

190183

184+
def publish_results(error, provider_app_version, command):
185+
"""Publish results to broker."""
186+
if not provider_app_version:
187+
click.echo(
188+
error
189+
+ 'Provider application version is required '
190+
+ 'to publish verification results to broker'
191+
)
192+
raise click.Abort()
193+
command.extend(["--provider-app-version",
194+
provider_app_version,
195+
"--publish-verification-results"])
196+
197+
191198
def broker_not_provided(broker_base_url, provider):
192199
"""Check if broker not provided."""
193200
return (broker_base_url == '' or provider == '')

tests/test_verify.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def setUp(self):
6060
def assertProcess(self, *expected):
6161
self.assertEqual(self.mock_Popen.call_count, 1)
6262
call = self.mock_Popen.mock_calls[0]
63+
6364
actual = call[1][0]
6465
self.assertEqual(actual[0], VERIFIER_PATH)
6566
self.assertEqual(len(actual), len(expected) + 1)
@@ -148,6 +149,8 @@ def test_all_url_options(self):
148149
'./pacts/consumer-provider2.json',
149150
'--pact-url=./pacts/consumer-provider3.json',
150151
'--pact-url=./pacts/consumer-provider4.json',
152+
'--custom-provider-header=Authorization: Basic cGFj',
153+
'--custom-provider-header=CustomHeader: somevalue',
151154
'--provider-states-setup-url=http://localhost/provider-states/set',
152155
'--pact-broker-username=user',
153156
'--pact-broker-password=pass',
@@ -168,6 +171,8 @@ def test_all_url_options(self):
168171
'./pacts/consumer-provider4.json',
169172
'./pacts/consumer-provider.json',
170173
'./pacts/consumer-provider2.json',
174+
'--custom-provider-header=Authorization: Basic cGFj',
175+
'--custom-provider-header=CustomHeader: somevalue',
171176
'--provider-base-url=http://localhost',
172177
'--provider-states-setup-url=http://localhost/provider-states/set',
173178
'--broker-username=user',
@@ -204,10 +209,10 @@ def test_all_broker_options(self):
204209
self.assertEqual(self.mock_Popen.call_count, 1)
205210
self.assertProcess(
206211
'--pact-broker-base-url=http://localhost/broker',
207-
'--consumer-version-tag', 'prod',
208-
'--consumer-version-tag', 'dev',
209-
'--provider-version-tag', 'dev',
210-
'--provider-version-tag', 'qa',
212+
'--consumer-version-tag=prod',
213+
'--consumer-version-tag=dev',
214+
'--provider-version-tag=dev',
215+
'--provider-version-tag=qa',
211216
'--provider=provider_app',
212217
'--provider-base-url=http://localhost',
213218
'--provider-states-setup-url=http://localhost/provider-states/set',

0 commit comments

Comments
 (0)