Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added extra authenticators for auth status test #142

Merged
merged 1 commit into from
Feb 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) \
telday marked this conversation as resolved.
Show resolved Hide resolved
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