summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxime Besson <maxime.besson@worteks.com>2020-09-28 18:44:56 +0200
committerIvan Kanakarakis <ivan.kanak@gmail.com>2020-10-27 22:07:55 +0200
commit524b70d3ef4523b40b999ee2cd0008f41a31c437 (patch)
treedcb1cd76865d513d4fba2ba671560388c1790921
parent0edfb57b8863d39a776b9a1c0e288c8f95d845bb (diff)
downloadpysaml2-524b70d3ef4523b40b999ee2cd0008f41a31c437.tar.gz
Add unit test for #720
making sure that ResponseLocation behaves properly when present and that Location is used in its place when missing
-rw-r--r--tests/sp_slo_redirect.xml2
-rw-r--r--tests/test_50_server.py21
2 files changed, 21 insertions, 2 deletions
diff --git a/tests/sp_slo_redirect.xml b/tests/sp_slo_redirect.xml
index 7db2c837..b0c484ec 100644
--- a/tests/sp_slo_redirect.xml
+++ b/tests/sp_slo_redirect.xml
@@ -14,4 +14,4 @@ mDY9MAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAJSrKOEzHO7TL5cy6
h3qh+3+JAk8HbGBW+cbX6KBCAw/mzU8flK25vnWwXS3dv2FF3Aod0/S7AWNfKib5
U/SA9nJaz/mWeF9S0farz9AQFc8/NSzAzaVq7YbM4F6f6N2FRl7GikdXRCed45j6
mrPzGzk3ECbupFnqyREH3+ZPSdk=
-</ns1:X509Certificate></ns1:X509Data></ns1:KeyInfo></ns0:KeyDescriptor><ns0:SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" Location="http://lingon.catalogix.se:8087/slo" /><ns0:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="http://lingon.catalogix.se:8087/" index="1" /><ns0:AttributeConsumingService index="1"><ns0:ServiceName xml:lang="en">urn:mace:example.com:saml:roland:sp</ns0:ServiceName><ns0:ServiceDescription xml:lang="en">My own SP</ns0:ServiceDescription><ns0:RequestedAttribute Name="surName" isRequired="true" /><ns0:RequestedAttribute FriendlyName="givenName" Name="urn:oid:2.5.4.42" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" isRequired="true" /><ns0:RequestedAttribute FriendlyName="mail" Name="urn:oid:0.9.2342.19200300.100.1.3" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" isRequired="true" /><ns0:RequestedAttribute FriendlyName="title" Name="urn:oid:2.5.4.12" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" isRequired="false" /></ns0:AttributeConsumingService></ns0:SPSSODescriptor><ns0:Organization><ns0:OrganizationName xml:lang="se">AB Exempel</ns0:OrganizationName><ns0:OrganizationDisplayName xml:lang="se">AB Exempel</ns0:OrganizationDisplayName><ns0:OrganizationURL xml:lang="en">http://www.example.org</ns0:OrganizationURL></ns0:Organization><ns0:ContactPerson contactType="technical"><ns0:GivenName>Roland</ns0:GivenName><ns0:SurName>Hedberg</ns0:SurName><ns0:EmailAddress>tech@eample.com</ns0:EmailAddress><ns0:EmailAddress>tech@example.org</ns0:EmailAddress><ns0:TelephoneNumber>+46 70 100 0000</ns0:TelephoneNumber></ns0:ContactPerson></ns0:EntityDescriptor></ns0:EntitiesDescriptor>
+</ns1:X509Certificate></ns1:X509Data></ns1:KeyInfo></ns0:KeyDescriptor><ns0:SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" Location="http://lingon.catalogix.se:8087/sloreq" ResponseLocation="http://lingon.catalogix.se:8087/sloresp" /><ns0:SingleLogoutService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="http://lingon.catalogix.se:8087/slo"/><ns0:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="http://lingon.catalogix.se:8087/" index="1" /><ns0:AttributeConsumingService index="1"><ns0:ServiceName xml:lang="en">urn:mace:example.com:saml:roland:sp</ns0:ServiceName><ns0:ServiceDescription xml:lang="en">My own SP</ns0:ServiceDescription><ns0:RequestedAttribute Name="surName" isRequired="true" /><ns0:RequestedAttribute FriendlyName="givenName" Name="urn:oid:2.5.4.42" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" isRequired="true" /><ns0:RequestedAttribute FriendlyName="mail" Name="urn:oid:0.9.2342.19200300.100.1.3" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" isRequired="true" /><ns0:RequestedAttribute FriendlyName="title" Name="urn:oid:2.5.4.12" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri" isRequired="false" /></ns0:AttributeConsumingService></ns0:SPSSODescriptor><ns0:Organization><ns0:OrganizationName xml:lang="se">AB Exempel</ns0:OrganizationName><ns0:OrganizationDisplayName xml:lang="se">AB Exempel</ns0:OrganizationDisplayName><ns0:OrganizationURL xml:lang="en">http://www.example.org</ns0:OrganizationURL></ns0:Organization><ns0:ContactPerson contactType="technical"><ns0:GivenName>Roland</ns0:GivenName><ns0:SurName>Hedberg</ns0:SurName><ns0:EmailAddress>tech@eample.com</ns0:EmailAddress><ns0:EmailAddress>tech@example.org</ns0:EmailAddress><ns0:TelephoneNumber>+46 70 100 0000</ns0:TelephoneNumber></ns0:ContactPerson></ns0:EntityDescriptor></ns0:EntitiesDescriptor>
diff --git a/tests/test_50_server.py b/tests/test_50_server.py
index 589890cc..93fbc6c6 100644
--- a/tests/test_50_server.py
+++ b/tests/test_50_server.py
@@ -2297,6 +2297,7 @@ def _logout_request(conf_file):
class TestServerLogout():
+
def test_1(self):
with closing(Server("idp_slo_redirect_conf")) as server:
req_id, request = _logout_request("sp_slo_redirect_conf")
@@ -2305,7 +2306,7 @@ class TestServerLogout():
response = server.create_logout_response(request, bindings)
binding, destination = server.pick_binding("single_logout_service",
bindings, "spsso",
- request)
+ request, response=True)
http_args = server.apply_binding(binding, "%s" % response, destination,
"relay_state", response=True)
@@ -2313,7 +2314,25 @@ class TestServerLogout():
assert len(http_args) == 4
assert http_args["headers"][0][0] == "Location"
assert http_args["data"] == []
+ assert http_args['url'] == 'http://lingon.catalogix.se:8087/sloresp'
+
+ def test_2(self):
+ with closing(Server("idp_slo_redirect_conf")) as server:
+ req_id, request = _logout_request("sp_slo_redirect_conf")
+ print(request)
+ bindings = [BINDING_HTTP_POST]
+ response = server.create_logout_response(request, bindings)
+ binding, destination = server.pick_binding("single_logout_service",
+ bindings, "spsso",
+ request, response=True)
+
+ http_args = server.apply_binding(binding, "%s" % response, destination,
+ "relay_state", response=True)
+ assert len(http_args) == 4
+ assert len(http_args["data"]) > 0
+ assert http_args["method"] == "POST"
+ assert http_args['url'] == 'http://lingon.catalogix.se:8087/slo'
if __name__ == "__main__":
ts = TestServer1()