summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2018-08-29 21:39:26 +0300
committerIvan Kanakarakis <ivan.kanak@gmail.com>2018-08-29 21:40:24 +0300
commit5a844536d7074b1c2fe111515beaa75557dbc577 (patch)
tree71dd21cf5af191059a3a47466e10abc0db8e825c /tests
parent9eb34a9b048b5897d41db730ab3d9ab777465554 (diff)
downloadpysaml2-5a844536d7074b1c2fe111515beaa75557dbc577.tar.gz
Fix test that depended on actual datetime
Mock utcnow call used by time_util module to return the same date as the IssueInstant date of the response. Signed-off-by: Ivan Kanakarakis <ivan.kanak@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_41_response.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/test_41_response.py b/tests/test_41_response.py
index c2b98ad7..6a531ecf 100644
--- a/tests/test_41_response.py
+++ b/tests/test_41_response.py
@@ -1,6 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
+import datetime
+import mock
+
from contextlib import closing
from saml2 import config
@@ -16,7 +19,7 @@ from pathutils import full_path
FALSE_ASSERT_SIGNED = full_path("saml_false_signed.xml")
-TIMESLACK = 62000000 # Roughly +- 24 month
+TIMESLACK = 60*5
def _eq(l1, l2):
@@ -93,7 +96,10 @@ class TestResponse:
assert isinstance(resp, StatusResponse)
assert isinstance(resp, AuthnResponse)
- def test_false_sign(self):
+ @mock.patch('saml2.time_util.datetime')
+ def test_false_sign(self, mock_datetime):
+ mock_datetime.utcnow = mock.Mock(
+ return_value=datetime.datetime(2016, 9, 4, 9, 59, 39))
with open(FALSE_ASSERT_SIGNED) as fp:
xml_response = fp.read()
resp = response_factory(