summaryrefslogtreecommitdiff
path: root/tests/fakeIDP.py
diff options
context:
space:
mode:
authorRoland Hedberg <roland.hedberg@adm.umu.se>2013-04-28 16:59:48 +0200
committerRoland Hedberg <roland.hedberg@adm.umu.se>2013-04-28 16:59:48 +0200
commit872a26633330b84fce49426ea0961dde399f01dc (patch)
tree9d24e6e4493685f0a956d0e5314baa4113d5faad /tests/fakeIDP.py
parentee42c42b13f913a37f18b6c106d61ce63f73e503 (diff)
downloadpysaml2-872a26633330b84fce49426ea0961dde399f01dc.tar.gz
Updated tests to follow the changed way of handling authentication context.
Diffstat (limited to 'tests/fakeIDP.py')
-rw-r--r--tests/fakeIDP.py53
1 files changed, 31 insertions, 22 deletions
diff --git a/tests/fakeIDP.py b/tests/fakeIDP.py
index 971281cd..3114704b 100644
--- a/tests/fakeIDP.py
+++ b/tests/fakeIDP.py
@@ -1,5 +1,5 @@
from urlparse import parse_qs
-from saml2.saml import AUTHN_PASSWORD
+from saml2.authn_context import INTERNETPROTOCOLPASSWORD
from saml2.samlp import attribute_query_from_string, logout_request_from_string
from saml2 import BINDING_HTTP_REDIRECT, pack
from saml2 import BINDING_HTTP_POST
@@ -16,6 +16,13 @@ TYP = {
"POST": [BINDING_HTTP_POST, BINDING_SOAP]
}
+
+AUTHN = {
+ "class_ref": INTERNETPROTOCOLPASSWORD,
+ "authn_auth": "http://www.example.com/login"
+}
+
+
def unpack_form(_str, ver="SAMLRequest"):
SR_STR = "name=\"%s\" value=\"" % ver
RS_STR = 'name="RelayState" value="'
@@ -32,7 +39,8 @@ def unpack_form(_str, ver="SAMLRequest"):
rs = _str[k:l]
- return {ver:sr, "RelayState":rs}
+ return {ver: sr, "RelayState": rs}
+
class DummyResponse(object):
def __init__(self, code, data, headers=None):
@@ -40,6 +48,7 @@ class DummyResponse(object):
self.text = data
self.headers = headers or []
+
class FakeIDP(Server):
def __init__(self, config_file=""):
Server.__init__(self, config_file)
@@ -106,21 +115,20 @@ class FakeIDP(Server):
except Exception:
raise
- identity = { "surName":"Hedberg", "givenName": "Roland",
- "title": "supertramp", "mail": "roland@example.com"}
+ identity = {"surName": "Hedberg", "givenName": "Roland",
+ "title": "supertramp", "mail": "roland@example.com"}
userid = "Pavill"
authn_resp = self.create_authn_response(identity,
- userid=userid,
- authn=(AUTHN_PASSWORD,
- "http://www.example.com/login"),
- **resp_args)
+ userid=userid,
+ authn=AUTHN,
+ **resp_args)
response = "%s" % authn_resp
_dict = pack.factory(_binding, response,
- resp_args["destination"], relay_state,
- "SAMLResponse")
+ resp_args["destination"], relay_state,
+ "SAMLResponse")
return DummyResponse(200, **_dict)
def attribute_query_endpoint(self, xml_str, binding):
@@ -131,26 +139,27 @@ class FakeIDP(Server):
aquery = attribute_query_from_string(_str)
extra = {"eduPersonAffiliation": "faculty"}
- userid = "Pavill"
+ #userid = "Pavill"
name_id = aquery.subject.name_id
attr_resp = self.create_attribute_response(extra, aquery.id,
- None,
- sp_entity_id=aquery.issuer.text,
- name_id=name_id,
- attributes=aquery.attribute)
+ None,
+ sp_entity_id=aquery.issuer
+ .text,
+ name_id=name_id,
+ attributes=aquery.attribute)
if binding == BINDING_SOAP:
# SOAP packing
#headers = {"content-type": "application/soap+xml"}
soap_message = make_soap_enveloped_saml_thingy(attr_resp)
-# if self.sign and self.sec:
-# _signed = self.sec.sign_statement_using_xmlsec(soap_message,
-# class_name(attr_resp),
-# nodeid=attr_resp.id)
-# soap_message = _signed
+ # if self.sign and self.sec:
+ # _signed = self.sec.sign_statement_using_xmlsec(soap_message,
+ # class_name(attr_resp),
+ # nodeid=attr_resp.id)
+ # soap_message = _signed
response = "%s" % soap_message
- else: # Just POST
+ else: # Just POST
response = "%s" % attr_resp
return DummyResponse(200, response)
@@ -178,4 +187,4 @@ class FakeIDP(Server):
else: # Just POST
response = "%s" % _resp
- return DummyResponse(200, response)
+ return DummyResponse(200, response) \ No newline at end of file