summaryrefslogtreecommitdiffstats
path: root/roles/openshift_certificate_expiry
diff options
context:
space:
mode:
authorTim Bielawa <tbielawa@redhat.com>2017-02-21 11:00:00 -0800
committerTim Bielawa <tbielawa@redhat.com>2017-02-21 11:00:00 -0800
commit003bc8d5b9233e61c7a2a5f0a27b66ac1babc1a0 (patch)
tree19d34acf9e16b8221e4a0faaa9cea167723a9025 /roles/openshift_certificate_expiry
parent288e304643a6a02e6d90ed5c1b4e7f6b349ad929 (diff)
downloadopenshift-003bc8d5b9233e61c7a2a5f0a27b66ac1babc1a0.tar.gz
openshift-003bc8d5b9233e61c7a2a5f0a27b66ac1babc1a0.tar.bz2
openshift-003bc8d5b9233e61c7a2a5f0a27b66ac1babc1a0.tar.xz
openshift-003bc8d5b9233e61c7a2a5f0a27b66ac1babc1a0.zip
Address cert expiry parsing review comments
Diffstat (limited to 'roles/openshift_certificate_expiry')
-rw-r--r--roles/openshift_certificate_expiry/library/openshift_cert_expiry.py9
-rw-r--r--roles/openshift_certificate_expiry/test/test_fakeopensslclasses.py6
2 files changed, 7 insertions, 8 deletions
diff --git a/roles/openshift_certificate_expiry/library/openshift_cert_expiry.py b/roles/openshift_certificate_expiry/library/openshift_cert_expiry.py
index 33930c0c1..b093d84fe 100644
--- a/roles/openshift_certificate_expiry/library/openshift_cert_expiry.py
+++ b/roles/openshift_certificate_expiry/library/openshift_cert_expiry.py
@@ -242,6 +242,8 @@ will be returned
# pylint: disable=too-many-locals,too-many-branches
+#
+# TODO: Break this function down into smaller chunks
def load_and_handle_cert(cert_string, now, base64decode=False, ans_module=None):
"""Load a certificate, split off the good parts, and return some
useful data
@@ -254,8 +256,8 @@ Params:
- `ans_module` (AnsibleModule) - The AnsibleModule object for this module (so we can raise errors)
Returns:
-A 3-tuple of the form: (certificate_common_name, certificate_expiry_date, certificate_time_remaining)
-
+A tuple of the form:
+ (cert_subject, cert_expiry_date, time_remaining, cert_serial_number)
"""
if base64decode:
_cert_string = cert_string.decode('base-64')
@@ -287,8 +289,9 @@ A 3-tuple of the form: (certificate_common_name, certificate_expiry_date, certif
ans_module.fail_json(msg="Error: The 'OpenSSL' python library and CLI command were not found on the target host. Unable to parse any certificates. This host will not be included in generated reports.")
else:
openssl_decoded = openssl_decoded.communicate()[0]
- os.remove(path)
cert_loaded = FakeOpenSSLCertificate(openssl_decoded)
+ finally:
+ os.remove(path)
######################################################################
# Read all possible names from the cert
diff --git a/roles/openshift_certificate_expiry/test/test_fakeopensslclasses.py b/roles/openshift_certificate_expiry/test/test_fakeopensslclasses.py
index e98d6ac64..2e245191f 100644
--- a/roles/openshift_certificate_expiry/test/test_fakeopensslclasses.py
+++ b/roles/openshift_certificate_expiry/test/test_fakeopensslclasses.py
@@ -11,7 +11,7 @@ import pytest
# Disable import-error b/c our libraries aren't loaded in jenkins
# pylint: disable=import-error,wrong-import-position
# place class in our python path
-module_path = os.path.join('/'.join(os.path.realpath(__file__).split('/')[:-1]), 'library')
+module_path = os.path.join('/'.join(os.path.realpath(__file__).split(os.path.sep)[:-1]), 'library')
sys.path.insert(0, module_path)
openshift_cert_expiry = pytest.importorskip("openshift_cert_expiry")
@@ -77,10 +77,6 @@ class TestFakeOpenSSLClasses(unittest.TestCase):
self.assertEqual('CN=172.30.0.1', ', '.join(subjects))
- def tearDown(self):
- '''TearDown method'''
- pass
-
if __name__ == "__main__":
unittest.main()