Skip to content
Snippets Groups Projects
Commit a4ebece6 authored by Robert Latta's avatar Robert Latta
Browse files

switched default for verify_ssl to False

parent cffc51ed
No related branches found
No related tags found
No related merge requests found
......@@ -200,7 +200,7 @@ class IMS(object):
reconnect_attempts = 0
def __init__(self, base_url, username, password, bearer_token=None,
verify_ssl=True):
verify_ssl=False):
IMS.base_url = base_url
self.username = username
self.password = password
......@@ -208,7 +208,7 @@ class IMS(object):
IMS.bearer_token = bearer_token
@classmethod
def _init_bearer_token(cls, username, password, verify_ssl=True):
def _init_bearer_token(cls, username, password, verify_ssl=False):
re_init_time = time.time()
if not cls.bearer_token or \
re_init_time - cls.bearer_token_init_time \
......@@ -230,7 +230,8 @@ class IMS(object):
def clear_dynamic_context_cache(self):
if not IMS.bearer_token:
IMS._init_bearer_token(self.username, self.password)
IMS._init_bearer_token(
self.username, self.password, self.verify_ssl)
while True:
logger.info('Clearing Dynamic Context Cache')
response = requests.put(
......@@ -238,7 +239,8 @@ class IMS(object):
headers={'Authorization': f'Bearer {self.bearer_token}'},
verify=self.verify_ssl)
if response.status_code == 401:
IMS._init_bearer_token(self.username, self.password)
IMS._init_bearer_token(
self.username, self.password, self.verify_ssl)
continue
response.raise_for_status()
break
......@@ -267,7 +269,8 @@ class IMS(object):
return entity
if not IMS.bearer_token:
IMS._init_bearer_token(self.username, self.password)
IMS._init_bearer_token(
self.username, self.password, self.verify_ssl)
def _is_invalid_login_state(response_):
if response_.status_code == requests.codes.unauthorized:
......@@ -315,7 +318,8 @@ class IMS(object):
headers={'Authorization': f'Bearer {self.bearer_token}'},
params=params, verify=self.verify_ssl)
if _is_invalid_login_state(response):
IMS._init_bearer_token(self.username, self.password)
IMS._init_bearer_token(
self.username, self.password, self.verify_ssl)
else:
response.raise_for_status()
orig = response.json()
......
......@@ -764,7 +764,7 @@ def extract_ims_data():
ims_api_url=c['api'],
ims_username=c['username'],
ims_password=c['password'],
verify_ssl=c.get('verify-ssl', True)
verify_ssl=c.get('verify-ssl', False)
)
......
......@@ -27,11 +27,12 @@ def test_ims_class_login(mocker):
'dummy_base', 'dummy_username', 'dummy_password')
ds.get_entity_by_id('Node', 1234)
mock_post.assert_called_once_with(
'dummy_base/login', auth=('dummy_username', 'dummy_password'), verify=True)
'dummy_base/login',
auth=('dummy_username', 'dummy_password'), verify=False)
mock_get.assert_called_once_with(
'dummy_base/ims/Node/1234',
headers={'Authorization': 'Bearer my_bearer_token'},
params=None, verify=True)
params=None, verify=False)
def test_ims_failed_response(mocker):
......@@ -60,7 +61,7 @@ def test_ims_class_entity_by_id(mocker):
mock_get.assert_called_once_with(
'dummy_base/ims/Node/1234',
headers={'Authorization': 'Bearer dummy_bt'},
params=None, verify=True)
params=None, verify=False)
def test_ims_class_entity_by_name(mocker):
......@@ -72,7 +73,7 @@ def test_ims_class_entity_by_name(mocker):
mock_get.assert_called_once_with(
'dummy_base/ims/Node/byname/"dummy_name"',
headers={'Authorization': 'Bearer dummy_bt'},
params=None, verify=True)
params=None, verify=False)
def test_ims_class_filtered_entities(mocker):
......@@ -88,7 +89,7 @@ def test_ims_class_filtered_entities(mocker):
params={
'paginatorStartElement': 0,
'paginatorNumberOfElements': 50
}, verify=True)
}, verify=False)
def side_effect(*args, **kargs):
if kargs['params']['paginatorStartElement'] == 0:
......@@ -106,14 +107,14 @@ def test_ims_class_filtered_entities(mocker):
params={
'paginatorStartElement': 0,
'paginatorNumberOfElements': 2
}, verify=True)
}, verify=False)
mock_multi_get.assert_any_call(
'dummy_base/ims/Node/filtered/dummy_param=dummy value',
headers={'Authorization': 'Bearer dummy_bt'},
params={
'paginatorStartElement': 2,
'paginatorNumberOfElements': 2
}, verify=True)
}, verify=False)
assert mock_multi_get.call_count == 2
assert res == [1, 2, 3]
......@@ -144,7 +145,7 @@ def test_ims_class_get_all_entities(mocker):
params={
'paginatorStartElement': 0,
'paginatorNumberOfElements': 10
}, verify=True)
}, verify=False)
def test_ims_class_navigation_properties(mocker):
......@@ -156,7 +157,7 @@ def test_ims_class_navigation_properties(mocker):
mock_get.assert_called_with(
'dummy_base/ims/Node/1234',
headers={'Authorization': 'Bearer dummy_bt'},
params={'navigationproperty': 6}, verify=True)
params={'navigationproperty': 6}, verify=False)
def test_ims_class_cache(mocker):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment