From ce62588d3dc3a0748d0c6ce39e62817fb2d14661 Mon Sep 17 00:00:00 2001 From: Elliott Murray Date: Mon, 24 Aug 2020 16:03:44 +0100 Subject: [PATCH] feat: added env vars for broker verify --- pact/cli/verify.py | 2 ++ tests/cli/test_verify.py | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pact/cli/verify.py b/pact/cli/verify.py index f529d8228..64bb61843 100644 --- a/pact/cli/verify.py +++ b/pact/cli/verify.py @@ -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', diff --git a/tests/cli/test_verify.py b/tests/cli/test_verify.py index 3f765bc08..8545dba8b 100644 --- a/tests/cli/test_verify.py +++ b/tests/cli/test_verify.py @@ -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) @@ -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)