| 
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,61 @@ 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):  # check unsigned requests over SOAP to fail  | 
 | 2257 | +                req = idp.parse_logout_request(saml_soap)  | 
 | 2258 | + | 
 | 2259 | +            idp.ident.close()  | 
 | 2260 | + | 
 | 2261 | +    def test_slo_soap_signed(self):  | 
 | 2262 | +        soon = time_util.in_a_while(days=1)  | 
 | 2263 | +        sinfo = {  | 
 | 2264 | +            "name_id": nid,  | 
 | 2265 | +            "issuer": "urn:mace:example.com:saml:roland:idp",  | 
 | 2266 | +            "not_on_or_after": soon,  | 
 | 2267 | +            "user": {  | 
 | 2268 | +                "givenName": "Leo",  | 
 | 2269 | +                "sn": "Laport",  | 
 | 2270 | +            }  | 
 | 2271 | +        }  | 
 | 2272 | + | 
 | 2273 | +        sp = client.Saml2Client(config_file="server_conf")  | 
 | 2274 | +        sp.users.add_information_about_person(sinfo)  | 
 | 2275 | + | 
 | 2276 | +        req_id, logout_request = sp.create_logout_request(  | 
 | 2277 | +            name_id=nid, destination="http://localhost:8088/slo",  | 
 | 2278 | +            issuer_entity_id="urn:mace:example.com:saml:roland:idp",  | 
 | 2279 | +            reason="I'm tired of this", sign=True, sign_alg=ds.SIG_RSA_SHA512,  | 
 | 2280 | +            digest_alg=ds.DIGEST_SHA512,  | 
 | 2281 | +        )  | 
 | 2282 | + | 
 | 2283 | +        saml_soap = sp.apply_binding(BINDING_SOAP, logout_request, sign=False)["data"]  | 
 | 2284 | +        self.server.ident.close()  | 
 | 2285 | + | 
 | 2286 | +        with closing(Server("idp_soap_conf")) as idp:  | 
 | 2287 | +            idp.config.setattr("idp", "want_authn_requests_signed", True)  | 
 | 2288 | +            assert idp.config.getattr( "want_authn_requests_signed", "idp")  | 
 | 2289 | + | 
 | 2290 | +            with raises(IncorrectlySigned):  # idp_soap_conf has invalid certificate for sp  | 
 | 2291 | +                request = idp.parse_logout_request(saml_soap)  | 
 | 2292 | +                assert request  | 
 | 2293 | + | 
 | 2294 | +            idp.ident.close()  | 
 | 2295 | + | 
 | 2296 | +        with closing(Server("idp_conf_verify_cert")) as idp:  | 
 | 2297 | +            idp.config.setattr("idp", "want_authn_requests_signed", True)  | 
 | 2298 | +            assert idp.config.getattr( "want_authn_requests_signed", "idp")  | 
 | 2299 | + | 
2248 | 2300 |             request = idp.parse_logout_request(saml_soap)  | 
2249 | 2301 |             idp.ident.close()  | 
2250 | 2302 |             assert request  | 
2251 | 2303 | 
 
  | 
 | 2304 | + | 
2252 | 2305 | # ------------------------------------------------------------------------  | 
2253 | 2306 | 
 
  | 
2254 | 2307 | 
 
  | 
 | 
0 commit comments