From 3878e8c9a29e66d2cdc0272f2fe02f7dbc049274 Mon Sep 17 00:00:00 2001 From: Ryan Deivert Date: Thu, 26 Oct 2017 18:32:49 -0700 Subject: [PATCH] [tests][apps] updating previous tests to use new `auth` property on config --- docs/source/app-development.rst | 6 +++--- tests/unit/app_integrations/test_apps/test_duo.py | 4 ++-- tests/unit/app_integrations/test_apps/test_onelogin.py | 6 +++--- tests/unit/app_integrations/test_config.py | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/source/app-development.rst b/docs/source/app-development.rst index 392991e4c..a3b1321c0 100644 --- a/docs/source/app-development.rst +++ b/docs/source/app-development.rst @@ -109,9 +109,9 @@ to outline what methods from the base ``AppIntegration`` class must be implement def _get_oauth(self): """This should return the oauth token for this request""" - secret_key = self._config['auth']['secret_key'] - client_id = self._config['auth']['client_id'] - token = self._config['auth']['token'] + secret_key = self._config.auth['secret_key'] + client_id = self._config.auth['client_id'] + token = self._config.auth['token'] # Do something to generate oauth return generated_oauth diff --git a/tests/unit/app_integrations/test_apps/test_duo.py b/tests/unit/app_integrations/test_apps/test_duo.py index 352b5e37e..228d325ba 100644 --- a/tests/unit/app_integrations/test_apps/test_duo.py +++ b/tests/unit/app_integrations/test_apps/test_duo.py @@ -46,7 +46,7 @@ def setup(self): @patch('logging.Logger.exception') def test_generate_auth_hmac_failure(self, log_mock): """DuoApp - Generate Auth, hmac Failure""" - self._app._config['auth']['secret_key'] = {'bad_secret'} + self._app._config.auth['secret_key'] = {'bad_secret'} assert_false(self._app._generate_auth('hostname', {})) log_mock.assert_called_with('Could not generate hmac signature') @@ -87,7 +87,7 @@ def _get_sample_logs(count, base_time): @patch('requests.get') def test_get_duo_logs_bad_headers(self, requests_mock): """DuoApp - Get Duo Logs, Bad Headers""" - self._app._config['auth']['secret_key'] = {'bad_secret'} + self._app._config.auth['secret_key'] = {'bad_secret'} assert_false(self._app._get_duo_logs('hostname', 'full_url')) requests_mock.assert_not_called() diff --git a/tests/unit/app_integrations/test_apps/test_onelogin.py b/tests/unit/app_integrations/test_apps/test_onelogin.py index 1045bcc98..75ee0cbfa 100644 --- a/tests/unit/app_integrations/test_apps/test_onelogin.py +++ b/tests/unit/app_integrations/test_apps/test_onelogin.py @@ -44,9 +44,9 @@ def setup(self): def set_config_values(self, region, client_id, client_secret): """Helper function to setup the auth values""" - self._app._config['auth']['region'] = region - self._app._config['auth']['client_id'] = client_id - self._app._config['auth']['client_secret'] = client_secret + self._app._config.auth['region'] = region + self._app._config.auth['client_id'] = client_id + self._app._config.auth['client_secret'] = client_secret @patch('requests.post') def test_generate_headers_bad_response(self, requests_mock): diff --git a/tests/unit/app_integrations/test_config.py b/tests/unit/app_integrations/test_config.py index 3b2223a39..202d368db 100644 --- a/tests/unit/app_integrations/test_config.py +++ b/tests/unit/app_integrations/test_config.py @@ -172,11 +172,11 @@ def test_is_success(self): def test_scrub_auth_info(self): """AppIntegrationConfig - Scrub Auth Info""" auth_key = '{}_auth'.format(FUNCTION_NAME) - param_dict = {auth_key: self._config['auth']} + param_dict = {auth_key: self._config.auth} scrubbed_config = self._config._scrub_auth_info(param_dict, auth_key) assert_equal(scrubbed_config[auth_key]['api_hostname'], - '*' * len(self._config['auth']['api_hostname'])) + '*' * len(self._config.auth['api_hostname'])) assert_equal(scrubbed_config[auth_key]['integration_key'], - '*' * len(self._config['auth']['integration_key'])) + '*' * len(self._config.auth['integration_key'])) assert_equal(scrubbed_config[auth_key]['secret_key'], - '*' * len(self._config['auth']['secret_key'])) + '*' * len(self._config.auth['secret_key']))