Fixed a couple of tests
This commit is contained in:
@@ -215,7 +215,7 @@ class TestSAMLBase:
|
||||
|
||||
attr = Attribute()
|
||||
saml2.make_vals(ava, AttributeValue, attr, prop="attribute_value")
|
||||
assert attr.keyswv() == ["attribute_value"]
|
||||
assert attr.keyswv() == ["name_format", "attribute_value"]
|
||||
assert len(attr.attribute_value) == 4
|
||||
|
||||
def test_to_string_nspair(self):
|
||||
@@ -1211,3 +1211,7 @@ class TestAssertion:
|
||||
"""Test assertion_from_string() using test data"""
|
||||
# TODO
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
t = TestSAMLBase()
|
||||
t.test_make_vals_multi_dict()
|
@@ -137,10 +137,10 @@ def test_attribute_statement():
|
||||
assert statement.keyswv() == ["attribute"]
|
||||
assert len(statement.attribute) == 2
|
||||
attr0 = statement.attribute[0]
|
||||
assert _eq(attr0.keyswv(), ["name", "attribute_value"])
|
||||
assert _eq(attr0.keyswv(), ["name", "attribute_value", "name_format"])
|
||||
assert len(attr0.attribute_value) == 1
|
||||
attr1 = statement.attribute[1]
|
||||
assert _eq(attr1.keyswv(), ["name", "attribute_value"])
|
||||
assert _eq(attr1.keyswv(), ["name", "attribute_value", "name_format"])
|
||||
assert len(attr1.attribute_value) == 1
|
||||
if attr0.name == "givenName":
|
||||
assert attr0.attribute_value[0].text == "Derek"
|
||||
@@ -222,7 +222,8 @@ def test_value_4():
|
||||
saml.AttributeValue, text="Derek")],
|
||||
friendly_name="givenName")
|
||||
|
||||
assert _eq(attribute.keyswv(), ["friendly_name", "attribute_value"])
|
||||
assert _eq(attribute.keyswv(), ["friendly_name", "attribute_value",
|
||||
"name_format"])
|
||||
assert attribute.friendly_name == "givenName"
|
||||
assert len(attribute.attribute_value) == 1
|
||||
assert attribute.attribute_value[0].text == "Derek"
|
||||
@@ -234,7 +235,7 @@ def test_do_attribute_statement_0():
|
||||
assert statement.keyswv() == ["attribute"]
|
||||
assert len(statement.attribute) == 1
|
||||
attr0 = statement.attribute[0]
|
||||
assert _eq(attr0.keyswv(), ["name", "attribute_value"])
|
||||
assert _eq(attr0.keyswv(), ["name", "attribute_value", "name_format"])
|
||||
assert attr0.name == "vo_attr"
|
||||
assert len(attr0.attribute_value) == 1
|
||||
assert attr0.attribute_value[0].text == "foobar"
|
||||
@@ -248,9 +249,9 @@ def test_do_attribute_statement():
|
||||
assert statement.keyswv() == ["attribute"]
|
||||
assert len(statement.attribute) == 2
|
||||
attr0 = statement.attribute[0]
|
||||
assert _eq(attr0.keyswv(), ["name", "attribute_value"])
|
||||
assert _eq(attr0.keyswv(), ["name", "attribute_value", "name_format"])
|
||||
attr1 = statement.attribute[1]
|
||||
assert _eq(attr1.keyswv(), ["name", "attribute_value"])
|
||||
assert _eq(attr1.keyswv(), ["name", "attribute_value", "name_format"])
|
||||
if attr0.name == "givenName":
|
||||
assert len(attr0.attribute_value) == 2
|
||||
assert _eq([av.text for av in attr0.attribute_value],
|
||||
|
@@ -26,7 +26,7 @@ def test_default():
|
||||
class TestAC():
|
||||
def setup_class(self):
|
||||
self.acs = attribute_converter.ac_factory(full_path("attributemaps"))
|
||||
|
||||
|
||||
def test_setup(self):
|
||||
print self.acs
|
||||
assert len(self.acs) == 3
|
||||
@@ -67,9 +67,9 @@ class TestAC():
|
||||
|
||||
def test_to_attrstat_1(self):
|
||||
ava = { "givenName": "Roland", "sn": "Hedberg" }
|
||||
|
||||
|
||||
statement = attribute_converter.from_local(self.acs, ava, BASIC_NF)
|
||||
|
||||
|
||||
assert statement is not None
|
||||
assert len(statement) == 2
|
||||
a0 = statement[0]
|
||||
@@ -88,12 +88,12 @@ class TestAC():
|
||||
assert a1.name_format == BASIC_NF
|
||||
else:
|
||||
assert False
|
||||
|
||||
|
||||
def test_to_attrstat_2(self):
|
||||
ava = { "givenName": "Roland", "surname": "Hedberg" }
|
||||
|
||||
|
||||
statement = attribute_converter.from_local(self.acs, ava, URI_NF)
|
||||
|
||||
|
||||
assert len(statement) == 2
|
||||
a0 = statement[0]
|
||||
a1 = statement[1]
|
||||
@@ -111,9 +111,9 @@ class TestAC():
|
||||
assert a1.name_format == URI_NF
|
||||
else:
|
||||
assert False
|
||||
|
||||
|
||||
def test_to_local_name(self):
|
||||
|
||||
|
||||
attr = [
|
||||
saml.Attribute(
|
||||
friendly_name="surName",
|
||||
@@ -127,9 +127,9 @@ class TestAC():
|
||||
friendly_name="titel",
|
||||
name="urn:oid:2.5.4.12",
|
||||
name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:uri")]
|
||||
|
||||
|
||||
lan = [attribute_converter.to_local_name(self.acs, a) for a in attr]
|
||||
|
||||
|
||||
assert _eq(lan, ['sn', 'givenName', 'title'])
|
||||
|
||||
# def test_ava_fro_1(self):
|
||||
@@ -150,8 +150,11 @@ class TestAC():
|
||||
# assert result == {'givenName': [], 'sn': [], 'title': []}
|
||||
|
||||
def test_to_local_name_from_basic(self):
|
||||
attr = [saml.Attribute(
|
||||
name="urn:mace:dir:attribute-def:eduPersonPrimaryOrgUnitDN")]
|
||||
attr = [
|
||||
saml.Attribute(
|
||||
name="urn:mace:dir:attribute-def:eduPersonPrimaryOrgUnitDN",
|
||||
name_format="urn:oasis:names:tc:SAML:2.0:attrname-format:basic")
|
||||
]
|
||||
|
||||
lan = [attribute_converter.to_local_name(self.acs, a) for a in attr]
|
||||
|
||||
@@ -222,7 +225,7 @@ def test_schac():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# t = TestAC()
|
||||
# t.setup_class()
|
||||
# t.test_mixed_attributes_1()
|
||||
test_schac()
|
||||
t = TestAC()
|
||||
t.setup_class()
|
||||
t.test_to_local_name_from_basic()
|
||||
#test_schac()
|
||||
|
@@ -8,30 +8,31 @@ from saml2.samlp import NameIDPolicy
|
||||
from s2repoze.plugins.sp import make_plugin
|
||||
from saml2.server import Server
|
||||
|
||||
ENV1 = {'SERVER_SOFTWARE': 'CherryPy/3.1.2 WSGI Server',
|
||||
'SCRIPT_NAME': '',
|
||||
'ACTUAL_SERVER_PROTOCOL': 'HTTP/1.1',
|
||||
'REQUEST_METHOD': 'GET',
|
||||
'PATH_INFO': '/krissms',
|
||||
'SERVER_PROTOCOL': 'HTTP/1.1',
|
||||
'QUERY_STRING': '',
|
||||
'REMOTE_ADDR': '127.0.0.1',
|
||||
'HTTP_USER_AGENT':
|
||||
'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; en-us) ',
|
||||
'HTTP_CONNECTION': 'keep-alive',
|
||||
'SERVER_NAME': 'lingon-catalogix-se-2.local',
|
||||
'REMOTE_PORT': '57309',
|
||||
'wsgi.url_scheme': 'http',
|
||||
'SERVER_PORT': '8087',
|
||||
'HTTP_HOST': '127.0.0.1:8087',
|
||||
'wsgi.multithread': True,
|
||||
'HTTP_ACCEPT':
|
||||
'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
|
||||
'wsgi.version': (1, 0),
|
||||
'wsgi.run_once': False,
|
||||
'wsgi.multiprocess': False,
|
||||
'HTTP_ACCEPT_LANGUAGE': 'en-us',
|
||||
'HTTP_ACCEPT_ENCODING': 'gzip, deflate'}
|
||||
ENV1 = {'SERVER_SOFTWARE': 'CherryPy/3.1.2 WSGI Server',
|
||||
'SCRIPT_NAME': '',
|
||||
'ACTUAL_SERVER_PROTOCOL': 'HTTP/1.1',
|
||||
'REQUEST_METHOD': 'GET',
|
||||
'PATH_INFO': '/krissms',
|
||||
'SERVER_PROTOCOL': 'HTTP/1.1',
|
||||
'QUERY_STRING': '',
|
||||
'REMOTE_ADDR': '127.0.0.1',
|
||||
'HTTP_USER_AGENT':
|
||||
'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; en-us) ',
|
||||
'HTTP_CONNECTION': 'keep-alive',
|
||||
'SERVER_NAME': 'lingon-catalogix-se-2.local',
|
||||
'REMOTE_PORT': '57309',
|
||||
'wsgi.url_scheme': 'http',
|
||||
'SERVER_PORT': '8087',
|
||||
'HTTP_HOST': '127.0.0.1:8087',
|
||||
'wsgi.multithread': True,
|
||||
'HTTP_ACCEPT':
|
||||
'application/xml,application/xhtml+xml,text/html;q=0.9,'
|
||||
'text/plain;q=0.8,image/png,*/*;q=0.5',
|
||||
'wsgi.version': (1, 0),
|
||||
'wsgi.run_once': False,
|
||||
'wsgi.multiprocess': False,
|
||||
'HTTP_ACCEPT_LANGUAGE': 'en-us',
|
||||
'HTTP_ACCEPT_ENCODING': 'gzip, deflate'}
|
||||
|
||||
trans_name_policy = NameIDPolicy(format=NAMEID_FORMAT_TRANSIENT,
|
||||
allow_create="true")
|
||||
@@ -49,12 +50,11 @@ class TestSP():
|
||||
|
||||
def test_setup(self):
|
||||
assert self.sp
|
||||
|
||||
def test_identify(self):
|
||||
|
||||
def test_identify(self):
|
||||
# Create a SAMLResponse
|
||||
ava = { "givenName": ["Derek"], "surName": ["Jeter"],
|
||||
"mail": ["derek@nyy.mlb.com"], "title":["The man"]}
|
||||
ava = {"givenName": ["Derek"], "surName": ["Jeter"],
|
||||
"mail": ["derek@nyy.mlb.com"], "title": ["The man"]}
|
||||
|
||||
resp_str = "%s" % self.server.create_authn_response(
|
||||
ava, "id1", "http://lingon.catalogix.se:8087/",
|
||||
@@ -62,16 +62,16 @@ class TestSP():
|
||||
"foba0001@example.com", authn=AUTHN)
|
||||
|
||||
resp_str = base64.encodestring(resp_str)
|
||||
self.sp.outstanding_queries = {"id1":"http://www.example.com/service"}
|
||||
session_info = self.sp._eval_authn_response({},
|
||||
{"SAMLResponse": resp_str})
|
||||
|
||||
self.sp.outstanding_queries = {"id1": "http://www.example.com/service"}
|
||||
session_info = self.sp._eval_authn_response(
|
||||
{}, {"SAMLResponse": [resp_str]})
|
||||
|
||||
assert len(session_info) > 1
|
||||
assert session_info["came_from"] == 'http://www.example.com/service'
|
||||
assert session_info["ava"] == {'givenName': ['Derek'],
|
||||
'mail': ['derek@nyy.mlb.com'],
|
||||
'sn': ['Jeter'],
|
||||
'title': ['The man']}
|
||||
assert session_info["ava"] == {'givenName': ['Derek'],
|
||||
'mail': ['derek@nyy.mlb.com'],
|
||||
'sn': ['Jeter'],
|
||||
'title': ['The man']}
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Reference in New Issue
Block a user