Fixed all tests.
Shelve don't allow unicode strings as keys.
This commit is contained in:
@@ -67,6 +67,9 @@ class IdentDB(object):
|
|||||||
return _id
|
return _id
|
||||||
|
|
||||||
def store(self, ident, name_id):
|
def store(self, ident, name_id):
|
||||||
|
if isinstance(ident, unicode):
|
||||||
|
ident = ident.encode("utf-8")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
val = self.db[ident].split(" ")
|
val = self.db[ident].split(" ")
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -90,6 +93,9 @@ class IdentDB(object):
|
|||||||
del self.db[_cn]
|
del self.db[_cn]
|
||||||
|
|
||||||
def remove_local(self, id):
|
def remove_local(self, id):
|
||||||
|
if isinstance(id, unicode):
|
||||||
|
id = id.encode("utf-8")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for val in self.db[id].split(" "):
|
for val in self.db[id].split(" "):
|
||||||
try:
|
try:
|
||||||
|
@@ -134,10 +134,10 @@ class FakeIDP(Server):
|
|||||||
userid = "Pavill"
|
userid = "Pavill"
|
||||||
|
|
||||||
name_id = aquery.subject.name_id
|
name_id = aquery.subject.name_id
|
||||||
attr_resp = self.create_aa_response(aquery.id,
|
attr_resp = self.create_attribute_response(extra, aquery.id,
|
||||||
None,
|
None,
|
||||||
sp_entity_id=aquery.issuer.text,
|
sp_entity_id=aquery.issuer.text,
|
||||||
identity=extra, name_id=name_id,
|
name_id=name_id,
|
||||||
attributes=aquery.attribute)
|
attributes=aquery.attribute)
|
||||||
|
|
||||||
if binding == BINDING_SOAP:
|
if binding == BINDING_SOAP:
|
||||||
|
@@ -198,7 +198,7 @@ class TestClient:
|
|||||||
ar_str = "%s" % self.client.create_authn_request(
|
ar_str = "%s" % self.client.create_authn_request(
|
||||||
"http://www.example.com/sso",
|
"http://www.example.com/sso",
|
||||||
"urn:mace:example.com:it:tek", # vo
|
"urn:mace:example.com:it:tek", # vo
|
||||||
format=NAMEID_FORMAT_PERSISTENT,
|
nameid_format=NAMEID_FORMAT_PERSISTENT,
|
||||||
id="666")
|
id="666")
|
||||||
|
|
||||||
ar = samlp.authn_request_from_string(ar_str)
|
ar = samlp.authn_request_from_string(ar_str)
|
||||||
|
@@ -2,21 +2,20 @@ from saml2.saml import AUTHN_PASSWORD
|
|||||||
from saml2.httpbase import set_list2dict
|
from saml2.httpbase import set_list2dict
|
||||||
from saml2.profile.ecp import RelayState
|
from saml2.profile.ecp import RelayState
|
||||||
from saml2.profile.paos import Request
|
from saml2.profile.paos import Request
|
||||||
from saml2.request import AuthnRequest
|
|
||||||
from saml2.server import Server
|
from saml2.server import Server
|
||||||
from saml2.samlp import Response, STATUS_SUCCESS
|
from saml2.samlp import Response
|
||||||
|
from saml2.samlp import STATUS_SUCCESS
|
||||||
|
from saml2.samlp import AuthnRequest
|
||||||
|
from saml2 import ecp_client
|
||||||
|
from saml2 import BINDING_SOAP
|
||||||
|
from saml2 import BINDING_PAOS
|
||||||
|
from saml2 import create_class_from_xml_string
|
||||||
|
|
||||||
|
from saml2.profile import ecp as ecp_prof
|
||||||
|
from saml2.client import Saml2Client
|
||||||
|
|
||||||
__author__ = 'rolandh'
|
__author__ = 'rolandh'
|
||||||
|
|
||||||
from saml2 import soap, ecp_client, BINDING_SOAP, BINDING_PAOS, \
|
|
||||||
create_class_from_xml_string
|
|
||||||
from saml2 import samlp
|
|
||||||
from saml2 import config
|
|
||||||
from saml2 import ecp
|
|
||||||
|
|
||||||
from saml2.profile import ecp as ecp_prof
|
|
||||||
from saml2.profile import paos
|
|
||||||
from saml2.client import Saml2Client
|
|
||||||
|
|
||||||
def _eq(l1, l2):
|
def _eq(l1, l2):
|
||||||
if len(l1) == len(l2):
|
if len(l1) == len(l2):
|
||||||
@@ -24,58 +23,6 @@ def _eq(l1, l2):
|
|||||||
else:
|
else:
|
||||||
return len(l1) == len(l2)
|
return len(l1) == len(l2)
|
||||||
|
|
||||||
def test_multiple_soap_headers():
|
|
||||||
xml_str = open("ecp_soap.xml").read()
|
|
||||||
res = soap.class_instances_from_soap_enveloped_saml_thingies(xml_str,
|
|
||||||
[ecp_prof,
|
|
||||||
paos,
|
|
||||||
samlp])
|
|
||||||
|
|
||||||
assert res["body"].c_tag == "AuthnRequest"
|
|
||||||
|
|
||||||
assert len(res["header"]) == 3
|
|
||||||
headers = ["{%s}%s" % (i.c_namespace, i.c_tag) for i in res["header"]]
|
|
||||||
print headers
|
|
||||||
assert _eq(headers,['{urn:liberty:paos:2003-08}Request',
|
|
||||||
'{urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp}Request',
|
|
||||||
'{urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp}RelayState'])
|
|
||||||
|
|
||||||
_relay_state = None
|
|
||||||
|
|
||||||
for item in res["header"]:
|
|
||||||
if item.c_tag == "RelayState" and item.c_namespace == ecp_prof.NAMESPACE:
|
|
||||||
_relay_state = item
|
|
||||||
|
|
||||||
assert _relay_state
|
|
||||||
assert _relay_state.actor == "http://schemas.xmlsoap.org/soap/actor/next"
|
|
||||||
|
|
||||||
class TestECPClient(object):
|
|
||||||
def setup_class(self):
|
|
||||||
conf = config.SPConfig()
|
|
||||||
conf.load_file("server_conf")
|
|
||||||
self.client = Saml2Client(conf)
|
|
||||||
|
|
||||||
def test_ecp_authn(self):
|
|
||||||
ssid, soap_req = ecp.ecp_auth_request(self.client,
|
|
||||||
"urn:mace:example.com:saml:roland:idp",
|
|
||||||
"id1")
|
|
||||||
print soap_req
|
|
||||||
response = soap.class_instances_from_soap_enveloped_saml_thingies(
|
|
||||||
soap_req,
|
|
||||||
[paos,
|
|
||||||
ecp_prof,
|
|
||||||
samlp])
|
|
||||||
print response
|
|
||||||
assert len(response["header"]) == 2
|
|
||||||
assert response["body"].c_tag == "AuthnRequest"
|
|
||||||
assert response["body"].c_namespace == samlp.NAMESPACE
|
|
||||||
headers = ["{%s}%s" % (i.c_namespace,
|
|
||||||
i.c_tag) for i in response["header"]]
|
|
||||||
print headers
|
|
||||||
assert _eq(headers,['{urn:liberty:paos:2003-08}Request',
|
|
||||||
#'{urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp}Request',
|
|
||||||
'{urn:oasis:names:tc:SAML:2.0:profiles:SSO:ecp}RelayState'])
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from saml2.sigver import get_xmlsec_binary
|
from saml2.sigver import get_xmlsec_binary
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@@ -67,7 +67,7 @@ def test_flow():
|
|||||||
|
|
||||||
# ---------- @SP ---------------
|
# ---------- @SP ---------------
|
||||||
|
|
||||||
_response = sp.parse_manage_name_id_response(respargs["data"], binding)
|
_response = sp.parse_manage_name_id_request_response(respargs["data"], binding)
|
||||||
|
|
||||||
print _response.response
|
print _response.response
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user