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

Update method for checking endpoint protocol #769

Merged
merged 4 commits into from
May 4, 2023
Merged
Changes from 1 commit
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
26 changes: 24 additions & 2 deletions tests/contrib/hahelpers/test_cluster_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,11 @@ def test_https_cert_key_in_config(self):
]
self.assertTrue(cluster_utils.https())

def test_https_cert_key_in_identity_relation(self):
@patch('charmhelpers.contrib.openstack.cert_utils')
def test_https_cert_key_in_identity_relation(self, cert_utils):
'''It determines https is available if cert in identity-service'''
cert_utils.get_certificate_request.return_value = False
cert_utils.get_requests_for_local_unit.return_value = {}
self.config_get.return_value = False
self.relation_ids.return_value = 'identity-service:0'
self.relation_list.return_value = 'keystone/0'
Expand All @@ -244,8 +247,27 @@ def test_https_cert_key_in_identity_relation(self):
]
self.assertTrue(cluster_utils.https())

def test_https_cert_key_incomplete_identity_relation(self):
@patch('charmhelpers.contrib.openstack.cert_utils')
def test_https_cert_req_pending(self, cert_utils):
'''It determines https is available if cert in identity-service'''
cert_utils.get_certificate_request.return_value = True
cert_utils.get_requests_for_local_unit.return_value = {}
self.config_get.return_value = False
self.relation_ids.return_value = 'identity-service:0'
self.relation_list.return_value = 'keystone/0'
self.relation_get.side_effect = [
'yes', # relation_get('https_keystone')
'cert', # relation_get('ssl_cert')
'key', # relation_get('ssl_key')
'ca_cert', # relation_get('ca_cert')
]
self.assertTrue(cluster_utils.https())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be assertFalse as the request for local unit is {} and that it will return False from https().


@patch('charmhelpers.contrib.openstack.cert_utils')
def test_https_cert_key_incomplete_identity_relation(self, cert_utils):
'''It determines https unavailable if cert not in identity-service'''
cert_utils.get_certificate_request.return_value = False
cert_utils.get_requests_for_local_unit.return_value = {}
self.config_get.return_value = False
self.relation_ids.return_value = 'identity-service:0'
self.relation_list.return_value = 'keystone/0'
Expand Down