Skip to content

Commit 5a84453

Browse files
committed
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 <[email protected]>
1 parent 9eb34a9 commit 5a84453

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/test_41_response.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4+
import datetime
5+
import mock
6+
47
from contextlib import closing
58

69
from saml2 import config
@@ -16,7 +19,7 @@
1619

1720
FALSE_ASSERT_SIGNED = full_path("saml_false_signed.xml")
1821

19-
TIMESLACK = 62000000 # Roughly +- 24 month
22+
TIMESLACK = 60*5
2023

2124

2225
def _eq(l1, l2):
@@ -93,7 +96,10 @@ def test_2(self):
9396
assert isinstance(resp, StatusResponse)
9497
assert isinstance(resp, AuthnResponse)
9598

96-
def test_false_sign(self):
99+
@mock.patch('saml2.time_util.datetime')
100+
def test_false_sign(self, mock_datetime):
101+
mock_datetime.utcnow = mock.Mock(
102+
return_value=datetime.datetime(2016, 9, 4, 9, 59, 39))
97103
with open(FALSE_ASSERT_SIGNED) as fp:
98104
xml_response = fp.read()
99105
resp = response_factory(

0 commit comments

Comments
 (0)