|
5 | 5 | import logging |
6 | 6 | from saml2.mdstore import MetadataStore, name |
7 | 7 |
|
8 | | -from saml2 import BINDING_HTTP_REDIRECT, BINDING_SOAP, BINDING_HTTP_POST |
9 | | -from saml2.config import SPConfig, IdPConfig, Config |
10 | | - |
| 8 | +from saml2 import BINDING_HTTP_REDIRECT |
| 9 | +from saml2 import BINDING_SOAP |
| 10 | +from saml2.config import Config |
| 11 | +from saml2.config import IdPConfig |
| 12 | +from saml2.config import SPConfig |
| 13 | +from saml2.authn_context import PASSWORDPROTECTEDTRANSPORT as AUTHN_PASSWORD_PROTECTED |
| 14 | +from saml2.authn_context import TIMESYNCTOKEN as AUTHN_TIME_SYNC_TOKEN |
11 | 15 | from saml2 import logger |
12 | 16 |
|
13 | 17 | from pathutils import dotname, full_path |
14 | 18 | from saml2.sigver import security_context, CryptoBackendXMLSecurity |
15 | 19 |
|
| 20 | + |
16 | 21 | sp1 = { |
17 | 22 | "entityid": "urn:mace:umu.se:saml:roland:sp", |
18 | 23 | "service": { |
|
26 | 31 | "urn:mace:example.com:saml:roland:idp": { |
27 | 32 | 'single_sign_on_service': |
28 | 33 | {'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect': |
29 | | - 'http://localhost:8088/sso/'}}, |
30 | | - } |
| 34 | + 'http://localhost:8088/sso/'}}, |
| 35 | + }, |
| 36 | + "requested_authn_context": { |
| 37 | + "authn_context_class_ref": [ |
| 38 | + AUTHN_PASSWORD_PROTECTED, |
| 39 | + AUTHN_TIME_SYNC_TOKEN, |
| 40 | + ], |
| 41 | + "comparison": "exact", |
| 42 | + }, |
31 | 43 | } |
32 | 44 | }, |
33 | 45 | "key_file": full_path("test.key"), |
@@ -211,12 +223,23 @@ def test_1(): |
211 | 223 |
|
212 | 224 | assert len(c._sp_idp) == 1 |
213 | 225 | assert list(c._sp_idp.keys()) == ["urn:mace:example.com:saml:roland:idp"] |
214 | | - assert list(c._sp_idp.values()) == [{'single_sign_on_service': |
215 | | - { |
216 | | - 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect': |
217 | | - 'http://localhost:8088/sso/'}}] |
| 226 | + assert list(c._sp_idp.values()) == [ |
| 227 | + { |
| 228 | + 'single_sign_on_service': { |
| 229 | + 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect': ( |
| 230 | + 'http://localhost:8088/sso/' |
| 231 | + ) |
| 232 | + } |
| 233 | + } |
| 234 | + ] |
218 | 235 |
|
219 | 236 | assert c.only_use_keys_in_metadata |
| 237 | + assert type(c.getattr("requested_authn_context")) is dict |
| 238 | + assert c.getattr("requested_authn_context").get("authn_context_class_ref") == [ |
| 239 | + AUTHN_PASSWORD_PROTECTED, |
| 240 | + AUTHN_TIME_SYNC_TOKEN, |
| 241 | + ] |
| 242 | + assert c.getattr("requested_authn_context").get("comparison") == "exact" |
220 | 243 |
|
221 | 244 |
|
222 | 245 | def test_2(): |
|
0 commit comments