diff options
author | Giuseppe <giuseppe.demarco@unical.it> | 2020-09-06 22:47:48 +0200 |
---|---|---|
committer | Giuseppe <giuseppe.demarco@unical.it> | 2020-09-06 22:49:25 +0200 |
commit | eb4100e8d2865be01877367a5ab03755d71375b5 (patch) | |
tree | 4bcc1dedf3bb6ee62faa0fc2ef7ccc4c8fa5226c | |
parent | 1aeae3ae565e02f863a26b2893354d048a7abff8 (diff) | |
download | pysaml2-eb4100e8d2865be01877367a5ab03755d71375b5.tar.gz |
first deletion of assertion
-rw-r--r-- | src/saml2/__init__.py | 4 | ||||
-rw-r--r-- | src/saml2/sigver.py | 9 | ||||
-rw-r--r-- | src/saml2/time_util.py | 3 |
3 files changed, 9 insertions, 7 deletions
diff --git a/src/saml2/__init__.py b/src/saml2/__init__.py index 5fa769f9..0fa9e49c 100644 --- a/src/saml2/__init__.py +++ b/src/saml2/__init__.py @@ -822,9 +822,7 @@ class SamlBase(ExtensionContainer): self.text = None def __eq__(self, other): - try: - assert isinstance(other, SamlBase) - except AssertionError: + if not isinstance(other, SamlBase): return False self.clear_text() diff --git a/src/saml2/sigver.py b/src/saml2/sigver.py index 94666b8d..3979d63a 100644 --- a/src/saml2/sigver.py +++ b/src/saml2/sigver.py @@ -356,7 +356,8 @@ M2_TIME_FORMAT = '%b %d %H:%M:%S %Y' def to_time(_time): - assert _time.endswith(' GMT') + if not _time.endswith(' GMT'): + raise Exception('Time does not end with GMT') _time = _time[:-4] return mktime(str_to_time(_time, M2_TIME_FORMAT)) @@ -372,8 +373,10 @@ def active_cert(key): try: cert_str = pem_format(key) cert = crypto.load_certificate(crypto.FILETYPE_PEM, cert_str) - assert cert.has_expired() == 0 - assert not OpenSSLWrapper().certificate_not_valid_yet(cert) + if not cert.has_expired() == 0: + raise Exception('Cert is expired.') + if OpenSSLWrapper().certificate_not_valid_yet(cert): + raise Exception('Certificate not valid yet.') return True except AssertionError: return False diff --git a/src/saml2/time_util.py b/src/saml2/time_util.py index fa4b48e1..b7f1f1cc 100644 --- a/src/saml2/time_util.py +++ b/src/saml2/time_util.py @@ -67,7 +67,8 @@ def parse_duration(duration): index += 1 else: sign = '+' - assert duration[index] == "P" + if duration[index] != "P": + raise Exception('Parse Duration is not valid.') index += 1 dic = dict([(typ, 0) for (code, typ) in D_FORMAT if typ]) |