Fixing py3 errors caused by views in assertions

Assertions code had some assumptions that dict method iterators would
return the actual type. Forcing a cast to list remedies that.
This commit is contained in:
Clint Byrum 2015-05-24 10:03:20 -07:00
parent f1305a3302
commit fb17c4f702
3 changed files with 8 additions and 8 deletions

View File

@ -229,7 +229,7 @@ def filter_attribute_value_assertions(ava, attribute_restrictions=None):
if not attribute_restrictions:
return ava
for attr, vals in ava.items():
for attr, vals in list(ava.items()):
_attr = attr.lower()
try:
_rests = attribute_restrictions[_attr]

View File

@ -31,7 +31,7 @@ class TestMongoDBCache():
#{u'issuer': u'', u'came from': u'', u'ava': {u'givenName': [u'Derek']}, u'session_id': -1, u'not_on_or_after': 0}
ava = info["ava"]
print(ava)
assert ava.keys() == ["givenName"]
assert list(ava.keys()) == ["givenName"]
assert ava["givenName"] == ["Derek"]
def test_set_get_2(self):

View File

@ -56,7 +56,7 @@ def test_filter_ava():
ava = policy.filter(ava, "https://connect.sunet.se/shibboleth", MDS)
assert _eq(ava.keys(), ['mail', 'givenName', 'sn', 'c'])
assert _eq(list(ava.keys()), ['mail', 'givenName', 'sn', 'c'])
assert _eq(ava["mail"], ["derek@nyy.mlb.com", "dj@example.com"])
@ -77,7 +77,7 @@ def test_filter_ava2():
# Mismatch, policy deals with eduGAIN, metadata says SWAMID
# So only minimum should come out
assert _eq(ava.keys(), ['eduPersonTargetedID'])
assert _eq(list(ava.keys()), ['eduPersonTargetedID'])
def test_filter_ava3():
@ -100,7 +100,7 @@ def test_filter_ava3():
ava = policy.filter(ava, "urn:mace:example.com:saml:roland:sp", mds)
assert _eq(ava.keys(), ['eduPersonTargetedID', "norEduPersonNIN"])
assert _eq(list(ava.keys()), ['eduPersonTargetedID', "norEduPersonNIN"])
def test_filter_ava4():
@ -123,7 +123,7 @@ def test_filter_ava4():
ava = policy.filter(ava, "urn:mace:example.com:saml:roland:sp", mds)
assert _eq(ava.keys(), ['eduPersonTargetedID', "givenName", "c", "mail",
assert _eq(list(ava.keys()), ['eduPersonTargetedID', "givenName", "c", "mail",
"sn"])
@ -147,7 +147,7 @@ def test_filter_ava5():
ava = policy.filter(ava, "urn:mace:example.com:saml:roland:sp", mds)
assert _eq(ava.keys(), ['eduPersonTargetedID'])
assert _eq(list(ava.keys()), ['eduPersonTargetedID'])
def test_idp_policy_filter():
@ -161,7 +161,7 @@ def test_idp_policy_filter():
ava = policy.filter(ava, "urn:mace:example.com:saml:roland:sp", idp.metadata)
print(ava)
assert ava.keys() == ["eduPersonTargetedID"] # because no entity category
assert list(ava.keys()) == ["eduPersonTargetedID"] # because no entity category
if __name__ == "__main__":
test_idp_policy_filter()