Fixed a couple of tests

This commit is contained in:
Roland Hedberg
2014-10-20 10:29:31 +02:00
parent 9af755597d
commit 6a85250075
4 changed files with 67 additions and 59 deletions

View File

@@ -215,7 +215,7 @@ class TestSAMLBase:
attr = Attribute() attr = Attribute()
saml2.make_vals(ava, AttributeValue, attr, prop="attribute_value") 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 assert len(attr.attribute_value) == 4
def test_to_string_nspair(self): def test_to_string_nspair(self):
@@ -1211,3 +1211,7 @@ class TestAssertion:
"""Test assertion_from_string() using test data""" """Test assertion_from_string() using test data"""
# TODO # TODO
pass pass
if __name__ == "__main__":
t = TestSAMLBase()
t.test_make_vals_multi_dict()

View File

@@ -137,10 +137,10 @@ def test_attribute_statement():
assert statement.keyswv() == ["attribute"] assert statement.keyswv() == ["attribute"]
assert len(statement.attribute) == 2 assert len(statement.attribute) == 2
attr0 = statement.attribute[0] 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 assert len(attr0.attribute_value) == 1
attr1 = statement.attribute[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 assert len(attr1.attribute_value) == 1
if attr0.name == "givenName": if attr0.name == "givenName":
assert attr0.attribute_value[0].text == "Derek" assert attr0.attribute_value[0].text == "Derek"
@@ -222,7 +222,8 @@ def test_value_4():
saml.AttributeValue, text="Derek")], saml.AttributeValue, text="Derek")],
friendly_name="givenName") 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 attribute.friendly_name == "givenName"
assert len(attribute.attribute_value) == 1 assert len(attribute.attribute_value) == 1
assert attribute.attribute_value[0].text == "Derek" assert attribute.attribute_value[0].text == "Derek"
@@ -234,7 +235,7 @@ def test_do_attribute_statement_0():
assert statement.keyswv() == ["attribute"] assert statement.keyswv() == ["attribute"]
assert len(statement.attribute) == 1 assert len(statement.attribute) == 1
attr0 = statement.attribute[0] 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 attr0.name == "vo_attr"
assert len(attr0.attribute_value) == 1 assert len(attr0.attribute_value) == 1
assert attr0.attribute_value[0].text == "foobar" assert attr0.attribute_value[0].text == "foobar"
@@ -248,9 +249,9 @@ def test_do_attribute_statement():
assert statement.keyswv() == ["attribute"] assert statement.keyswv() == ["attribute"]
assert len(statement.attribute) == 2 assert len(statement.attribute) == 2
attr0 = statement.attribute[0] attr0 = statement.attribute[0]
assert _eq(attr0.keyswv(), ["name", "attribute_value"]) assert _eq(attr0.keyswv(), ["name", "attribute_value", "name_format"])
attr1 = statement.attribute[1] attr1 = statement.attribute[1]
assert _eq(attr1.keyswv(), ["name", "attribute_value"]) assert _eq(attr1.keyswv(), ["name", "attribute_value", "name_format"])
if attr0.name == "givenName": if attr0.name == "givenName":
assert len(attr0.attribute_value) == 2 assert len(attr0.attribute_value) == 2
assert _eq([av.text for av in attr0.attribute_value], assert _eq([av.text for av in attr0.attribute_value],

View File

@@ -150,8 +150,11 @@ class TestAC():
# assert result == {'givenName': [], 'sn': [], 'title': []} # assert result == {'givenName': [], 'sn': [], 'title': []}
def test_to_local_name_from_basic(self): def test_to_local_name_from_basic(self):
attr = [saml.Attribute( attr = [
name="urn:mace:dir:attribute-def:eduPersonPrimaryOrgUnitDN")] 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] lan = [attribute_converter.to_local_name(self.acs, a) for a in attr]
@@ -222,7 +225,7 @@ def test_schac():
if __name__ == "__main__": if __name__ == "__main__":
# t = TestAC() t = TestAC()
# t.setup_class() t.setup_class()
# t.test_mixed_attributes_1() t.test_to_local_name_from_basic()
test_schac() #test_schac()

View File

@@ -26,7 +26,8 @@ ENV1 = {'SERVER_SOFTWARE': 'CherryPy/3.1.2 WSGI Server',
'HTTP_HOST': '127.0.0.1:8087', 'HTTP_HOST': '127.0.0.1:8087',
'wsgi.multithread': True, 'wsgi.multithread': True,
'HTTP_ACCEPT': 'HTTP_ACCEPT':
'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', '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.version': (1, 0),
'wsgi.run_once': False, 'wsgi.run_once': False,
'wsgi.multiprocess': False, 'wsgi.multiprocess': False,
@@ -51,7 +52,6 @@ class TestSP():
assert self.sp assert self.sp
def test_identify(self): def test_identify(self):
# Create a SAMLResponse # Create a SAMLResponse
ava = {"givenName": ["Derek"], "surName": ["Jeter"], ava = {"givenName": ["Derek"], "surName": ["Jeter"],
"mail": ["derek@nyy.mlb.com"], "title": ["The man"]} "mail": ["derek@nyy.mlb.com"], "title": ["The man"]}
@@ -63,8 +63,8 @@ class TestSP():
resp_str = base64.encodestring(resp_str) resp_str = base64.encodestring(resp_str)
self.sp.outstanding_queries = {"id1": "http://www.example.com/service"} self.sp.outstanding_queries = {"id1": "http://www.example.com/service"}
session_info = self.sp._eval_authn_response({}, session_info = self.sp._eval_authn_response(
{"SAMLResponse": resp_str}) {}, {"SAMLResponse": [resp_str]})
assert len(session_info) > 1 assert len(session_info) > 1
assert session_info["came_from"] == 'http://www.example.com/service' assert session_info["came_from"] == 'http://www.example.com/service'