|
32 | 32 | from saml2.sigver import verify_redirect_signature
|
33 | 33 | from saml2.s_utils import do_attribute_statement
|
34 | 34 | from saml2.s_utils import factory
|
35 |
| -from saml2.time_util import in_a_while |
| 35 | +from saml2.time_util import in_a_while, a_while_ago |
36 | 36 |
|
37 | 37 | from fakeIDP import FakeIDP
|
38 | 38 | from fakeIDP import unpack_form
|
@@ -1265,6 +1265,36 @@ def test_do_logout_post(self):
|
1265 | 1265 | BINDING_HTTP_POST)
|
1266 | 1266 | assert b'<ns0:SessionIndex>_foo</ns0:SessionIndex>' in res.xmlstr
|
1267 | 1267 |
|
| 1268 | + def test_do_logout_session_expired(self): |
| 1269 | + # information about the user from an IdP |
| 1270 | + session_info = { |
| 1271 | + "name_id": nid, |
| 1272 | + "issuer": "urn:mace:example.com:saml:roland:idp", |
| 1273 | + "not_on_or_after": a_while_ago(minutes=15), |
| 1274 | + "ava": { |
| 1275 | + "givenName": "Anders", |
| 1276 | + "surName": "Andersson", |
| 1277 | + |
| 1278 | + }, |
| 1279 | + "session_index": SessionIndex("_foo") |
| 1280 | + } |
| 1281 | + self.client.users.add_information_about_person(session_info) |
| 1282 | + entity_ids = self.client.users.issuers_of_info(nid) |
| 1283 | + assert entity_ids == ["urn:mace:example.com:saml:roland:idp"] |
| 1284 | + resp = self.client.do_logout(nid, entity_ids, "Tired", |
| 1285 | + in_a_while(minutes=5), sign=True, |
| 1286 | + expected_binding=BINDING_HTTP_POST) |
| 1287 | + assert resp |
| 1288 | + assert len(resp) == 1 |
| 1289 | + assert list(resp.keys()) == entity_ids |
| 1290 | + binding, info = resp[entity_ids[0]] |
| 1291 | + assert binding == BINDING_HTTP_POST |
| 1292 | + |
| 1293 | + _dic = unpack_form(info["data"][3]) |
| 1294 | + res = self.server.parse_logout_request(_dic["SAMLRequest"], |
| 1295 | + BINDING_HTTP_POST) |
| 1296 | + assert b'<ns0:SessionIndex>_foo</ns0:SessionIndex>' in res.xmlstr |
| 1297 | + |
1268 | 1298 |
|
1269 | 1299 | # Below can only be done with dummy Server
|
1270 | 1300 | IDP = "urn:mace:example.com:saml:roland:idp"
|
|
0 commit comments