Skip to content

Commit 2016c45

Browse files
author
Rebecka Gulliksson
committed
Mock all dates for hardcoded encrypted test assertion.
1 parent 1acc752 commit 2016c45

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tests/satosa/backends/test_saml2.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import re
66
from base64 import urlsafe_b64encode
77
from collections import Counter
8+
from datetime import datetime
89
from unittest.mock import Mock, patch
910
from urllib.parse import urlparse, parse_qs, parse_qsl
1011

@@ -207,8 +208,11 @@ def test_authn_response_with_encrypted_assertion(self, sp_conf, context):
207208
samlbackend.encryption_keys = [encryption_key_file.read()]
208209

209210
assertion_issued_at = 1479315212
210-
with patch('saml2.validate.time_util.utc_now') as time_mock:
211-
time_mock.return_value = assertion_issued_at + 1
211+
with patch('saml2.validate.time_util.shift_time') as mock_shift_time, \
212+
patch('saml2.validate.time_util.utc_now') as mock_utc_now:
213+
mock_utc_now.return_value = assertion_issued_at + 1
214+
mock_shift_time.side_effect = [datetime.utcfromtimestamp(assertion_issued_at + 1),
215+
datetime.utcfromtimestamp(assertion_issued_at - 1)]
212216
samlbackend.authn_response(context, response_binding)
213217

214218
context, internal_resp = samlbackend.auth_callback_func.call_args[0]

0 commit comments

Comments
 (0)