summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/saml2/__init__.py4
-rw-r--r--src/saml2/sigver.py9
-rw-r--r--src/saml2/time_util.py3
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])