diff options
author | Scott Koranda <skoranda@gmail.com> | 2019-08-26 14:20:06 -0500 |
---|---|---|
committer | Scott Koranda <skoranda@gmail.com> | 2019-08-26 14:20:06 -0500 |
commit | 75ca851ba910d10fe30eb9a662529239395d5fd7 (patch) | |
tree | 90c55afbf15a90e7e0bbade52bd7287c3fa9f106 | |
parent | 634ae8c7193abb037a06b978bba220094540151b (diff) | |
download | pysaml2-75ca851ba910d10fe30eb9a662529239395d5fd7.tar.gz |
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.
-rw-r--r-- | tests/test_71_authn_request.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/test_71_authn_request.py b/tests/test_71_authn_request.py new file mode 100644 index 00000000..ee970923 --- /dev/null +++ b/tests/test_71_authn_request.py @@ -0,0 +1,37 @@ +from contextlib import closing +from saml2.client import Saml2Client +from saml2.server import Server + + +def test_authn_request_with_acs_by_index(): + # ACS index and location from SP metadata in servera.xml. + ACS_INDEX = '4' + ACS_LOCATION = 'http://lingon.catalogix.se:8087/another/path' + + # Create SP using the configuration found in servera_conf.py. + sp = Saml2Client(config_file="servera_conf") + + # Generate an authn request object that uses AssertionConsumerServiceIndex + # instead of AssertionConsumerServiceURL. The index with label ACS_INDEX + # exists in the SP metadata in servera.xml. + request_id, authn_request = sp.create_authn_request( + sp.config.entityid, + assertion_consumer_service_index=ACS_INDEX) + + # Make sure the authn_request contains AssertionConsumerServiceIndex. + acs_index = getattr(authn_request, + 'assertion_consumer_service_index', None) + + assert acs_index == ACS_INDEX + + # Create IdP. + with closing(Server(config_file="idp_all_conf")) as idp: + + # Ask the IdP to pick out the binding and destination from the + # authn_request. + binding, destination = idp.pick_binding("assertion_consumer_service", + request=authn_request) + + # Make sure the IdP pick_binding method picks the correct location + # or destination based on the ACS index in the authn request. + assert destination == ACS_LOCATION |