diff options
author | Roland Hedberg <roland.hedberg@adm.umu.se> | 2015-02-03 10:24:47 +0100 |
---|---|---|
committer | Roland Hedberg <roland.hedberg@adm.umu.se> | 2015-02-03 10:24:47 +0100 |
commit | 7b025c619ffd187ededb102143eaf6a6c87ee918 (patch) | |
tree | e030d7a58ca2e5d21be24008ce3ec959eb758979 /tests/test_88_nsprefix.py | |
parent | 3bc41c2d71447e9404bf439cb9c05eb913fd21e9 (diff) | |
download | pysaml2-7b025c619ffd187ededb102143eaf6a6c87ee918.tar.gz |
Allow setting namespace prefixes.2.3.0
Diffstat (limited to 'tests/test_88_nsprefix.py')
-rw-r--r-- | tests/test_88_nsprefix.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/test_88_nsprefix.py b/tests/test_88_nsprefix.py new file mode 100644 index 00000000..4f652a54 --- /dev/null +++ b/tests/test_88_nsprefix.py @@ -0,0 +1,45 @@ +from saml2.saml import NAMEID_FORMAT_TRANSIENT +from saml2.client import Saml2Client +from saml2 import config, BINDING_HTTP_POST +from saml2 import saml +from saml2 import samlp + +__author__ = 'roland' + + +def test_nsprefix(): + status_message = samlp.StatusMessage() + status_message.text = "OK" + + txt = "%s" % status_message + + assert "ns0:StatusMessage" in txt + + status_message.register_prefix({"saml2": saml.NAMESPACE, + "saml2p": samlp.NAMESPACE}) + + txt = "%s" % status_message + + assert "saml2p:StatusMessage" in txt + + +def test_nsprefix2(): + conf = config.SPConfig() + conf.load_file("servera_conf") + client = Saml2Client(conf) + + selected_idp = "urn:mace:example.com:saml:roland:idp" + + destination = client._sso_location(selected_idp, BINDING_HTTP_POST) + + reqid, req = client.create_authn_request( + destination, nameid_format=NAMEID_FORMAT_TRANSIENT, + nsprefix={"saml2": saml.NAMESPACE, "saml2p": samlp.NAMESPACE}) + + txt = "%s" % req + + assert "saml2p:AuthnRequest" in txt + assert "saml2:Issuer" in txt + +if __name__ == "__main__": + test_nsprefix2()
\ No newline at end of file |