|
28 | 28 | from saml2.authn_context import INTERNETPROTOCOLPASSWORD
|
29 | 29 | from saml2.client import Saml2Client
|
30 | 30 | from saml2.pack import parse_soap_enveloped_saml
|
31 |
| -from saml2.response import LogoutResponse, StatusInvalidNameidPolicy |
| 31 | +from saml2.response import LogoutResponse, StatusInvalidNameidPolicy, StatusError |
32 | 32 | from saml2.saml import NAMEID_FORMAT_PERSISTENT, EncryptedAssertion, Advice
|
33 | 33 | from saml2.saml import NAMEID_FORMAT_TRANSIENT
|
34 | 34 | from saml2.saml import NameID
|
@@ -2325,6 +2325,37 @@ def test_response_error_status(self):
|
2325 | 2325 | resp_str, BINDING_HTTP_POST,
|
2326 | 2326 | {"id1": "http://foo.example.com/service"})
|
2327 | 2327 |
|
| 2328 | + def test_response_error_status_non_standard_status_code(self): |
| 2329 | + """ Test that the SP client can parse an authentication response |
| 2330 | + from an IdP that contains an error status.""" |
| 2331 | + |
| 2332 | + conf = config.SPConfig() |
| 2333 | + conf.load_file("server_conf") |
| 2334 | + client = Saml2Client(conf) |
| 2335 | + |
| 2336 | + resp = self.server.create_error_response( |
| 2337 | + in_response_to="id1", |
| 2338 | + destination="http://lingon.catalogix.se:8087/", |
| 2339 | + info=('http://example.com/status/1.0/cancel', None), |
| 2340 | + ) |
| 2341 | + |
| 2342 | + # Cast the response to a string and encode it to mock up the payload |
| 2343 | + # the SP client is expected to receive via HTTP POST binding. |
| 2344 | + if six.PY2: |
| 2345 | + resp_str = encode_fn(str(resp)) |
| 2346 | + else: |
| 2347 | + resp_str = encode_fn(bytes(str(resp), 'utf-8')) |
| 2348 | + |
| 2349 | + # We do not need the client to verify a signature for this test. |
| 2350 | + client.want_assertions_signed = False |
| 2351 | + client.want_response_signed = False |
| 2352 | + |
| 2353 | + # Parse the authentication error response |
| 2354 | + with raises(StatusError): |
| 2355 | + client.parse_authn_request_response( |
| 2356 | + resp_str, BINDING_HTTP_POST, |
| 2357 | + {"id1": "http://foo.example.com/service"}) |
| 2358 | + |
2328 | 2359 | def setup_verify_authn_response(self):
|
2329 | 2360 | idp = "urn:mace:example.com:saml:roland:idp"
|
2330 | 2361 | ava = {"givenName": ["Dave"], "sn": ["Concepción"],
|
|
0 commit comments