From 547f08a6adb2b805069a322cff937c4a0da945b8 Mon Sep 17 00:00:00 2001 From: telday Date: Fri, 12 Feb 2021 10:15:04 -0500 Subject: [PATCH] Added extra authenticators for auth status test --- test/python/test_status_api.py | 56 ++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/test/python/test_status_api.py b/test/python/test_status_api.py index cefd7c9a..f095ec79 100644 --- a/test/python/test_status_api.py +++ b/test/python/test_status_api.py @@ -1,6 +1,7 @@ from __future__ import absolute_import import unittest +from unittest.mock import patch import openapi_client @@ -69,10 +70,7 @@ def test_who_am_i_401(self): self.assertEqual(context.exception.status, 401) def test_authenticator_service_status_200(self): - """Test case for authenticator_service_status 200 return code - - We currently do not test this, see https://github.com/cyberark/conjur-openapi-spec/issues/84 - """ + """Test case for authenticator_service_status 200 return code""" api_config.setup_oidc_webservice() resp, status, _ = self.api.authenticator_service_status_with_http_info( 'oidc', @@ -82,6 +80,28 @@ def test_authenticator_service_status_200(self): self.assertEqual(resp.status, 'ok') self.assertEqual(status, 200) + with patch.object(openapi_client.api_client.ApiClient, 'call_api', return_value=None) \ + as mock: + self.api.authenticator_service_status('azure', 'test', self.account) + + mock.assert_called_once_with( + '/authn-{authenticator}/{service_id}/{account}/status', + 'GET', + {'account': self.account, 'authenticator': 'azure', 'service_id': 'test'}, + [], + {'Accept': 'application/json'}, + body=None, + files={}, + post_params=[], + response_type='AuthenticatorStatus', + auth_settings=['conjurAuth'], + async_req=None, + _return_http_data_only=True, + _preload_content=True, + _request_timeout=None, + collection_formats={} + ) + def test_authenticator_service_status_403(self): """Test case for authenticator_service_status 403 return code""" alice_client = api_config.get_api_client(username='alice') @@ -113,13 +133,29 @@ def test_authenticator_service_status_501(self): self.assertEqual(context.exception.status, 501) - @unittest.expectedFailure def test_authenticator_status_200(self): - """Test case for authenticator_status 200 return code - We currently do not test this, see https://github.com/cyberark/conjur-openapi-spec/issues/84 - """ - resp = self.api.authenticator_status('azure', self.account) - self.assertEqual(resp['status'], 'ok') + """Test case for authenticator_status 200 return code""" + with patch.object(openapi_client.api_client.ApiClient, 'call_api', return_value=None) \ + as mock: + self.api.authenticator_status('gcp', self.account) + + mock.assert_called_once_with( + '/authn-{authenticator}/{account}/status', + 'GET', + {'account': self.account, 'authenticator': 'gcp'}, + [], + {'Accept': 'application/json'}, + body=None, + files={}, + post_params=[], + response_type='AuthenticatorStatus', + auth_settings=['conjurAuth'], + async_req=None, + _return_http_data_only=True, + _preload_content=True, + _request_timeout=None, + collection_formats={} + ) def test_authenticator_status_403(self): """Test case for authenticator_status 403 return code"""