Skip to content

Commit

Permalink
Merge pull request #167 from pact-foundation/feat/add_env_vars_verify
Browse files Browse the repository at this point in the history
feat: added env vars for broker verify
  • Loading branch information
elliottmurray authored Aug 24, 2020
2 parents 880fff2 + ce62588 commit 2c52053
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pact/cli/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@
help='URL to send PUT requests to setup a given provider state.')
@click.option(
'username', '--pact-broker-username',
envvar='PACT_BROKER_USERNAME',
help='Username for Pact Broker basic authentication.')
@click.option(
'broker_base_url', '--pact-broker-url',
default='',
envvar='PACT_BROKER_BASE_URL',
help='Base URl for the Pact Broker instance to publish pacts to.')
@click.option(
'consumer_version_tag', '--consumer-version-tag',
Expand Down
8 changes: 6 additions & 2 deletions tests/cli/test_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,12 @@ def test_failed_verification(self, mock_isfile, mock_wrapper):
timeout=30,
verbose=False)

@patch.dict(os.environ, {'PACT_BROKER_PASSWORD': 'pwd'})
@patch.dict(os.environ, {'PACT_BROKER_PASSWORD': 'pwd',
'PACT_BROKER_USERNAME': 'broker_user',
'PACT_BROKER_BASE_URL': 'http://broker/'})
@patch("pact.verify_wrapper.VerifyWrapper.call_verify")
@patch("pact.verify_wrapper.isfile", return_value=True)
def test_password_from_env_var(self, mock_isfile, mock_wrapper):
def test_broker_creds_from_env_var(self, mock_isfile, mock_wrapper):
mock_wrapper.return_value = 0, None

result = self.runner.invoke(verify.main, self.simple_pact_opts)
Expand All @@ -197,6 +199,8 @@ def test_password_from_env_var(self, mock_isfile, mock_wrapper):
provider='provider',
provider_base_url='http://localhost',
broker_password='pwd',
broker_username='broker_user',
broker_url='http://broker/',
timeout=30,
verbose=False)

Expand Down

0 comments on commit 2c52053

Please sign in to comment.