From f0c3a7e7ec9622628aaa02a95469be06633ecd61 Mon Sep 17 00:00:00 2001 From: sharmilaMS-Hcl Date: Thu, 20 Apr 2023 17:07:14 +0530 Subject: [PATCH] Okta Error Code Mapping Changes for develop Branch 1.Modified the error mapper with TRANSMISSION_AUTH_CREDENTIALS for invalid Api token (401 error code) and added the timeout parameter in api_client.py file. 2.Updated unit test cases for the same. --- stix_shifter_modules/okta/stix_transmission/api_client.py | 5 +++-- stix_shifter_modules/okta/stix_transmission/error_mapper.py | 2 +- .../okta/test/stix_transmission/test_okta.py | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/stix_shifter_modules/okta/stix_transmission/api_client.py b/stix_shifter_modules/okta/stix_transmission/api_client.py index 0370d9f63..b683c9ab0 100644 --- a/stix_shifter_modules/okta/stix_transmission/api_client.py +++ b/stix_shifter_modules/okta/stix_transmission/api_client.py @@ -19,7 +19,8 @@ async def ping_data_source(self): Ping the Data Source :return: Response object """ - return await self.client.call_api(self.PING_ENDPOINT, 'GET', headers=self.headers, data={}) + return await self.client.call_api(self.PING_ENDPOINT, 'GET', headers=self.headers, data={}, + timeout=self.timeout) async def get_search_results(self, query, after_number): """ @@ -32,4 +33,4 @@ async def get_search_results(self, query, after_number): if after_number != '0': query = query + '&' + after_number - return await self.client.call_api(query, 'GET', headers=self.headers, data={}) + return await self.client.call_api(query, 'GET', headers=self.headers, data={}, timeout=self.timeout) diff --git a/stix_shifter_modules/okta/stix_transmission/error_mapper.py b/stix_shifter_modules/okta/stix_transmission/error_mapper.py index 991a4ca3d..bb951c1a0 100644 --- a/stix_shifter_modules/okta/stix_transmission/error_mapper.py +++ b/stix_shifter_modules/okta/stix_transmission/error_mapper.py @@ -8,7 +8,7 @@ 408: ErrorCode.TRANSMISSION_CONNECT, 503: ErrorCode.TRANSMISSION_CONNECT, 400: ErrorCode.TRANSMISSION_QUERY_PARSING_ERROR, - 401: ErrorCode.TRANSMISSION_INVALID_PARAMETER, + 401: ErrorCode.TRANSMISSION_AUTH_CREDENTIALS, 403: ErrorCode.TRANSMISSION_FORBIDDEN, 404: ErrorCode.TRANSMISSION_SEARCH_DOES_NOT_EXISTS, 410: ErrorCode.TRANSMISSION_REMOTE_SYSTEM_IS_UNAVAILABLE, diff --git a/stix_shifter_modules/okta/test/stix_transmission/test_okta.py b/stix_shifter_modules/okta/test/stix_transmission/test_okta.py index 9b700ee02..3850af97e 100644 --- a/stix_shifter_modules/okta/test/stix_transmission/test_okta.py +++ b/stix_shifter_modules/okta/test/stix_transmission/test_okta.py @@ -538,7 +538,7 @@ def test_ping_invalid_auth(self, mock_results_response): ping_response = transmission.ping() assert ping_response is not None assert ping_response['success'] is False - assert ping_response['code'] == "invalid_parameter" + assert ping_response['code'] == "authentication_fail" assert "Invalid session" in ping_response['error'] @patch('stix_shifter_utils.stix_transmission.utils.RestApiClientAsync.RestApiClientAsync.call_api') @@ -554,7 +554,7 @@ def test_results_invalid_auth(self, mock_results_response): result_response = transmission.results(query, offset, length) assert result_response is not None assert result_response['success'] is False - assert result_response['code'] == "invalid_parameter" + assert result_response['code'] == "authentication_fail" assert 'Invalid session' in result_response['error'] @patch('stix_shifter_utils.stix_transmission.utils.RestApiClientAsync.RestApiClientAsync.call_api')