|
4 | 4 | # All rights reserved. |
5 | 5 |
|
6 | 6 | from base64 import b64decode |
| 7 | +from datetime import datetime |
| 8 | +from datetime import timedelta |
| 9 | +from freezegun import freeze_time |
7 | 10 | import json |
8 | 11 | from os.path import dirname, join, exists |
9 | 12 | import unittest |
@@ -1135,3 +1138,34 @@ def testIsValidSignWithEmptyReferenceURI(self): |
1135 | 1138 | xml = self.file_contents(join(self.data_path, 'responses', 'response_without_reference_uri.xml.base64')) |
1136 | 1139 | response = OneLogin_Saml2_Response(settings, xml) |
1137 | 1140 | self.assertTrue(response.is_valid(self.get_request_data())) |
| 1141 | + |
| 1142 | + def testIsValidWithoutInResponseTo(self): |
| 1143 | + """ |
| 1144 | + If assertion contains InResponseTo but not the Response tag, we should |
| 1145 | + not compare the assertion InResponseTo value to None. |
| 1146 | + """ |
| 1147 | + |
| 1148 | + # prepare strict settings |
| 1149 | + settings_info = self.loadSettingsJSON() |
| 1150 | + settings_info['strict'] = True |
| 1151 | + settings_info['idp']['entityId'] = 'https://pitbulk.no-ip.org/simplesaml/saml2/idp/metadata.php' |
| 1152 | + settings_info['sp']['entityId'] = 'https://pitbulk.no-ip.org/newonelogin/demo1/metadata.php' |
| 1153 | + |
| 1154 | + settings = OneLogin_Saml2_Settings(settings_info) |
| 1155 | + |
| 1156 | + xml = self.file_contents(join(self.data_path, 'responses', 'valid_response_without_inresponseto.xml.base64')) |
| 1157 | + response = OneLogin_Saml2_Response(settings, xml) |
| 1158 | + |
| 1159 | + |
| 1160 | + |
| 1161 | + not_on_or_after = datetime.strptime('2014-02-19T09:37:01Z', '%Y-%m-%dT%H:%M:%SZ') |
| 1162 | + not_on_or_after -= timedelta(seconds=150) |
| 1163 | + |
| 1164 | + with freeze_time(not_on_or_after): |
| 1165 | + self.assertTrue(response.is_valid({ |
| 1166 | + 'https': 'on', |
| 1167 | + 'http_host': 'pitbulk.no-ip.org', |
| 1168 | + 'script_name': 'newonelogin/demo1/index.php?acs' |
| 1169 | + })) |
| 1170 | + |
| 1171 | + |
0 commit comments