Skip to content

Commit

Permalink
Okta Error Code Mapping Changes for develop Branch
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SharmilaMS-Hcl committed Apr 20, 2023
1 parent 8602293 commit f0c3a7e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions stix_shifter_modules/okta/stix_transmission/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand All @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions stix_shifter_modules/okta/test/stix_transmission/test_okta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand Down

0 comments on commit f0c3a7e

Please sign in to comment.