Fix basic python3 issues in test_02_saml

- Strings/bytes encoding/decoding where necessary.
- Random hash seed producing test fails sometimes on keys(), sorting
  lists fixes this.
This commit is contained in:
Clint Byrum 2015-05-28 09:22:20 -07:00
parent efa12f0860
commit 9ec77050e8
2 changed files with 7 additions and 6 deletions

View File

@ -119,7 +119,7 @@ def _verify_value_type(typ, val):
if typ == XSD + "base64Binary":
import base64
return base64.decodestring(val)
return base64.decodestring(val.encode('utf-8'))
class AttributeValueBase(SamlBase):

View File

@ -183,7 +183,7 @@ class TestExtensionContainer:
ec = saml2.ExtensionContainer()
ec.add_extension_attribute("foo", "bar")
assert len(ec.extension_attributes) == 1
assert ec.extension_attributes.keys()[0] == "foo"
assert list(ec.extension_attributes.keys())[0] == "foo"
class TestSAMLBase:
@ -216,13 +216,14 @@ class TestSAMLBase:
attr = Attribute()
saml2.make_vals(ava, AttributeValue, attr, prop="attribute_value")
assert attr.keyswv() == ["name_format", "attribute_value"]
assert sorted(attr.keyswv()) == sorted(["name_format",
"attribute_value"])
assert len(attr.attribute_value) == 4
def test_to_string_nspair(self):
foo = saml2.make_vals("lions", AttributeValue, part=True)
txt = foo.to_string()
nsstr = foo.to_string({"saml": saml.NAMESPACE})
txt = foo.to_string().decode('utf-8')
nsstr = foo.to_string({"saml": saml.NAMESPACE}).decode('utf-8')
assert nsstr != txt
print(txt)
print(nsstr)
@ -1215,4 +1216,4 @@ class TestAssertion:
if __name__ == "__main__":
t = TestSAMLBase()
t.test_make_vals_multi_dict()
t.test_make_vals_multi_dict()