|
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 | | -from saml2.saml import AUTHN_PASSWORD_PROTECTED, AuthnContextClassRef |
11 | | -from saml2.samlp import RequestedAuthnContext |
| 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 |
12 | 15 | from saml2 import logger |
13 | 16 |
|
14 | 17 | from pathutils import dotname, full_path |
15 | 18 | from saml2.sigver import security_context, CryptoBackendXMLSecurity |
16 | 19 |
|
| 20 | + |
17 | 21 | sp1 = { |
18 | 22 | "entityid": "urn:mace:umu.se:saml:roland:sp", |
19 | 23 | "service": { |
|
29 | 33 | {'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect': |
30 | 34 | 'http://localhost:8088/sso/'}}, |
31 | 35 | }, |
32 | | - "requested_authn_context": RequestedAuthnContext( |
33 | | - authn_context_class_ref=[ |
34 | | - AuthnContextClassRef(AUTHN_PASSWORD_PROTECTED), |
35 | | - ], |
36 | | - comparison="exact", |
37 | | - ), |
| 36 | + "requested_authn_context": { |
| 37 | + "authn_context_class_ref": [ |
| 38 | + AUTHN_PASSWORD_PROTECTED, |
| 39 | + AUTHN_TIME_SYNC_TOKEN, |
| 40 | + ], |
| 41 | + "comparison": "exact", |
| 42 | + }, |
38 | 43 | } |
39 | 44 | }, |
40 | 45 | "key_file": full_path("test.key"), |
@@ -218,13 +223,23 @@ def test_1(): |
218 | 223 |
|
219 | 224 | assert len(c._sp_idp) == 1 |
220 | 225 | assert list(c._sp_idp.keys()) == ["urn:mace:example.com:saml:roland:idp"] |
221 | | - assert list(c._sp_idp.values()) == [{'single_sign_on_service': |
222 | | - { |
223 | | - 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect': |
224 | | - '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 | + ] |
225 | 235 |
|
226 | 236 | assert c.only_use_keys_in_metadata |
227 | | - assert 'PasswordProtectedTransport' in c._sp_requested_authn_context.to_string().decode() |
| 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" |
228 | 243 |
|
229 | 244 |
|
230 | 245 | def test_2(): |
|
0 commit comments