Skip to content

Commit

Permalink
Fixed return code check for 403 in task
Browse files Browse the repository at this point in the history
  • Loading branch information
Dympna Laverty committed Nov 7, 2023
1 parent a647a65 commit 22612f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plugins/duo_admin/komand_duo_admin/util/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def make_request(self, method: str, path: str, params: dict = {}) -> requests.Re
self.logger.info(f"Request to {path} returned 403 unauthorized. Not raising exception as may be authorized to hit other endpoint(s)")
self.logger.info(f"403 Response data returned for reference: {response.json()}")
return {}
self._handle_exceptions(response, path)
self._handle_exceptions(response)
if 200 <= response.status_code < 300:
return response
raise PluginException(preset=PluginException.Preset.UNKNOWN, data=response.text)
Expand Down
6 changes: 4 additions & 2 deletions plugins/duo_admin/unit_test/test_monitor_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
return_value=datetime.strptime("2023-05-01T08:34:46", "%Y-%m-%dT%H:%M:%S").replace(tzinfo=timezone.utc),
)
@patch("requests.request", side_effect=Util.mock_request)
@patch("komand_duo_admin.util.api.isinstance", return_value=True)
@patch("komand_duo_admin.util.api.DuoAdminAPI.get_headers", return_value={})
class TestMonitorLogs(TestCase):
@classmethod
def setUpClass(cls) -> None:
Expand Down Expand Up @@ -51,9 +53,9 @@ def setUpClass(cls) -> None:
],
]
)
def test_monitor_logs(self, mock_request, mock_get_time, test_name, current_state, expected):
actual, actual_state, has_more_pages, status_code, _ = self.action.run(state=current_state)
def test_monitor_logs(self, mock_request, mock_request_instance, mock_get_headers, mock_get_time, test_name, current_state, expected):

actual, actual_state, has_more_pages, status_code, _ = self.action.run(state=current_state)
self.assertEqual(actual, expected.get("logs"))
self.assertEqual(actual_state, expected.get("state"))
self.assertEqual(status_code, expected.get("status_code"))

0 comments on commit 22612f0

Please sign in to comment.