Skip to content

Commit 731d01f

Browse files
committed
Minor test fixes
1 parent a0b2015 commit 731d01f

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/onelogin/saml2/errors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class OneLogin_Saml2_ValidationError(Exception):
109109
DUPLICATED_ATTRIBUTE_NAME_FOUND = 41
110110
INVALID_SIGNATURE = 42
111111
WRONG_NUMBER_OF_SIGNATURES = 43
112+
RESPONSE_EXPIRED = 44
112113

113114
def __init__(self, message, code=0, errors=None):
114115
"""

src/onelogin/saml2/logout_request.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,10 @@ def is_valid(self, request_data, raise_exceptions=False):
309309
if dom.get('NotOnOrAfter', None):
310310
na = OneLogin_Saml2_Utils.parse_SAML_to_time(dom.get('NotOnOrAfter'))
311311
if na <= OneLogin_Saml2_Utils.now():
312-
raise Exception('Could not validate timestamp: expired. Check system clock.')
312+
raise OneLogin_Saml2_ValidationError(
313+
'Could not validate timestamp: expired. Check system clock.',
314+
OneLogin_Saml2_ValidationError.RESPONSE_EXPIRED
315+
)
313316

314317
# Check destination
315318
if dom.get('Destination', None):
@@ -322,7 +325,8 @@ def is_valid(self, request_data, raise_exceptions=False):
322325
{
323326
'currentURL': current_url,
324327
'destination': destination,
325-
}
328+
},
329+
OneLogin_Saml2_ValidationError.WRONG_DESTINATION
326330
)
327331

328332
# Check issuer

tests/src/OneLogin/saml2_tests/response_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def testConstruct(self):
6161

6262
self.assertIsInstance(response_enc, OneLogin_Saml2_Response)
6363

64-
def test_get_xml_document(self):
64+
def testGetXMLDocument(self):
6565
"""
6666
Tests that we can retrieve the raw text of an encrypted XML response
6767
without going through intermediate steps

0 commit comments

Comments
 (0)