Skip to content

Commit 640fad3

Browse files
committed
Adding test case for signed SOAP LogoutRequests
1 parent 2055450 commit 640fad3

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

tests/test_50_server.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from saml2.sigver import make_temp, DecryptError, EncryptError, CertificateError
1313
from saml2.assertion import Policy
1414
from saml2.authn_context import INTERNETPROTOCOLPASSWORD
15+
from saml2.response import IncorrectlySigned
1516
from saml2.saml import NameID, NAMEID_FORMAT_TRANSIENT
1617
from saml2.samlp import response_from_string
1718

@@ -32,6 +33,7 @@
3233
from saml2.soap import make_soap_enveloped_saml_thingy
3334
from saml2 import BINDING_HTTP_POST
3435
from saml2 import BINDING_HTTP_REDIRECT
36+
from saml2 import BINDING_SOAP
3537
from saml2.time_util import instant
3638

3739
from pytest import raises
@@ -2245,10 +2247,61 @@ def test_slo_soap(self):
22452247
self.server.ident.close()
22462248

22472249
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+
22482300
request = idp.parse_logout_request(saml_soap)
22492301
idp.ident.close()
22502302
assert request
22512303

2304+
22522305
# ------------------------------------------------------------------------
22532306

22542307

0 commit comments

Comments
 (0)