Skip to content

Commit 75ca851

Browse files
committed
Added test file for tests around authentication requests
Added a file for holding tests around authentication requests and added a first test to test that the IdP code can pick the correct location from SAML metadata using the AssertionConsumerServiceIndex from an authentication request.
1 parent 634ae8c commit 75ca851

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/test_71_authn_request.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from contextlib import closing
2+
from saml2.client import Saml2Client
3+
from saml2.server import Server
4+
5+
6+
def test_authn_request_with_acs_by_index():
7+
# ACS index and location from SP metadata in servera.xml.
8+
ACS_INDEX = '4'
9+
ACS_LOCATION = 'http://lingon.catalogix.se:8087/another/path'
10+
11+
# Create SP using the configuration found in servera_conf.py.
12+
sp = Saml2Client(config_file="servera_conf")
13+
14+
# Generate an authn request object that uses AssertionConsumerServiceIndex
15+
# instead of AssertionConsumerServiceURL. The index with label ACS_INDEX
16+
# exists in the SP metadata in servera.xml.
17+
request_id, authn_request = sp.create_authn_request(
18+
sp.config.entityid,
19+
assertion_consumer_service_index=ACS_INDEX)
20+
21+
# Make sure the authn_request contains AssertionConsumerServiceIndex.
22+
acs_index = getattr(authn_request,
23+
'assertion_consumer_service_index', None)
24+
25+
assert acs_index == ACS_INDEX
26+
27+
# Create IdP.
28+
with closing(Server(config_file="idp_all_conf")) as idp:
29+
30+
# Ask the IdP to pick out the binding and destination from the
31+
# authn_request.
32+
binding, destination = idp.pick_binding("assertion_consumer_service",
33+
request=authn_request)
34+
35+
# Make sure the IdP pick_binding method picks the correct location
36+
# or destination based on the ACS index in the authn request.
37+
assert destination == ACS_LOCATION

0 commit comments

Comments
 (0)