Skip to content

Commit

Permalink
Merge pull request #142 from cyberark/test-authenticators
Browse files Browse the repository at this point in the history
Added extra authenticators for auth status test
  • Loading branch information
john-odonnell authored Feb 22, 2021
2 parents 382cbcc + 547f08a commit a2c03eb
Showing 1 changed file with 46 additions and 10 deletions.
56 changes: 46 additions & 10 deletions test/python/test_status_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import absolute_import

import unittest
from unittest.mock import patch

import openapi_client

Expand Down Expand Up @@ -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',
Expand All @@ -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')
Expand Down Expand Up @@ -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"""
Expand Down

0 comments on commit a2c03eb

Please sign in to comment.