|
12 | 12 | from saml2.sigver import make_temp, DecryptError, EncryptError, CertificateError
|
13 | 13 | from saml2.assertion import Policy
|
14 | 14 | from saml2.authn_context import INTERNETPROTOCOLPASSWORD
|
| 15 | +from saml2.response import IncorrectlySigned |
15 | 16 | from saml2.saml import NameID, NAMEID_FORMAT_TRANSIENT
|
16 | 17 | from saml2.samlp import response_from_string
|
17 | 18 |
|
|
32 | 33 | from saml2.soap import make_soap_enveloped_saml_thingy
|
33 | 34 | from saml2 import BINDING_HTTP_POST
|
34 | 35 | from saml2 import BINDING_HTTP_REDIRECT
|
| 36 | +from saml2 import BINDING_SOAP |
35 | 37 | from saml2.time_util import instant
|
36 | 38 |
|
37 | 39 | from pytest import raises
|
@@ -2245,10 +2247,65 @@ def test_slo_soap(self):
|
2245 | 2247 | self.server.ident.close()
|
2246 | 2248 |
|
2247 | 2249 | with closing(Server("idp_soap_conf")) as idp:
|
| 2250 | + request = idp.parse_logout_request(saml_soap) |
| 2251 | + assert request |
| 2252 | + |
| 2253 | + idp.config.setattr("idp", "want_authn_requests_signed", True) |
| 2254 | + assert idp.config.getattr("want_authn_requests_signed", "idp") |
| 2255 | + |
| 2256 | + with raises(IncorrectlySigned): |
| 2257 | + # check unsigned requests over SOAP to fail |
| 2258 | + request = idp.parse_logout_request(saml_soap) |
| 2259 | + assert not request |
| 2260 | + |
| 2261 | + idp.ident.close() |
| 2262 | + |
| 2263 | + def test_slo_soap_signed(self): |
| 2264 | + soon = time_util.in_a_while(days=1) |
| 2265 | + sinfo = { |
| 2266 | + "name_id": nid, |
| 2267 | + "issuer": "urn:mace:example.com:saml:roland:idp", |
| 2268 | + "not_on_or_after": soon, |
| 2269 | + "user": { |
| 2270 | + "givenName": "Leo", |
| 2271 | + "sn": "Laport", |
| 2272 | + } |
| 2273 | + } |
| 2274 | + |
| 2275 | + sp = client.Saml2Client(config_file="server_conf") |
| 2276 | + sp.users.add_information_about_person(sinfo) |
| 2277 | + |
| 2278 | + req_id, logout_request = sp.create_logout_request( |
| 2279 | + name_id=nid, destination="http://localhost:8088/slo", |
| 2280 | + issuer_entity_id="urn:mace:example.com:saml:roland:idp", |
| 2281 | + reason="I'm tired of this", sign=True, sign_alg=ds.SIG_RSA_SHA512, |
| 2282 | + digest_alg=ds.DIGEST_SHA512, |
| 2283 | + ) |
| 2284 | + |
| 2285 | + saml_soap = sp.apply_binding(BINDING_SOAP, logout_request, sign=False) |
| 2286 | + saml_soap = saml_soap["data"] |
| 2287 | + self.server.ident.close() |
| 2288 | + |
| 2289 | + with closing(Server("idp_soap_conf")) as idp: |
| 2290 | + idp.config.setattr("idp", "want_authn_requests_signed", True) |
| 2291 | + assert idp.config.getattr("want_authn_requests_signed", "idp") |
| 2292 | + |
| 2293 | + with raises(IncorrectlySigned): |
| 2294 | + # idp_soap_conf has invalid certificate for sp |
| 2295 | + request = idp.parse_logout_request(saml_soap) |
| 2296 | + assert not request |
| 2297 | + |
| 2298 | + idp.ident.close() |
| 2299 | + |
| 2300 | + with closing(Server("idp_conf_verify_cert")) as idp: |
| 2301 | + idp.config.setattr("idp", "want_authn_requests_signed", True) |
| 2302 | + assert idp.config.getattr("want_authn_requests_signed", "idp") |
| 2303 | + |
2248 | 2304 | request = idp.parse_logout_request(saml_soap)
|
2249 | 2305 | idp.ident.close()
|
2250 | 2306 | assert request
|
2251 | 2307 |
|
| 2308 | + |
2252 | 2309 | # ------------------------------------------------------------------------
|
2253 | 2310 |
|
2254 | 2311 |
|
|
0 commit comments