diff options
author | Vlastimil Zíma <vlastimil.zima@nic.cz> | 2019-06-17 10:27:56 +0200 |
---|---|---|
committer | Vlastimil Zíma <vlastimil.zima@nic.cz> | 2019-06-17 11:04:07 +0200 |
commit | f6719a7fa179481df547757ec20acc322d6c60c4 (patch) | |
tree | 1bd91560c6be9993ecf4a7230632ae27f7706325 | |
parent | 1f4bfe9a75c029b54fc37d0cf3c546673b45bd5b (diff) | |
download | openid-f6719a7fa179481df547757ec20acc322d6c60c4.tar.gz |
Fix #29 - Fix assoc type as bytes in Association
-rw-r--r-- | openid/association.py | 4 | ||||
-rw-r--r-- | openid/test/test_association.py | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/openid/association.py b/openid/association.py index f29a4c3..9025ff8 100644 --- a/openid/association.py +++ b/openid/association.py @@ -327,6 +327,7 @@ class Association(object): defined in the future. @type assoc_type: six.text_type, six.binary_type is deprecated """ + assoc_type = string_to_text(assoc_type, "Binary values for assoc_type are deprecated. Use text input instead.") if assoc_type not in all_association_types: fmt = '%r is not a supported association type' raise ValueError(fmt % (assoc_type,)) @@ -341,8 +342,7 @@ class Association(object): self.secret = secret self.issued = issued self.lifetime = lifetime - self.assoc_type = string_to_text(assoc_type, - "Binary values for assoc_type are deprecated. Use text input instead.") + self.assoc_type = assoc_type def getExpiresIn(self, now=None): """ diff --git a/openid/test/test_association.py b/openid/test/test_association.py index 0763b12..7a6b2ea 100644 --- a/openid/test/test_association.py +++ b/openid/test/test_association.py @@ -11,6 +11,12 @@ from openid.message import BARE_NS, OPENID2_NS, OPENID_NS, Message from openid.server.server import DiffieHellmanSHA1ServerSession, PlainTextServerSession +class TestAssociation(unittest.TestCase): + def test_assoc_type_bytes(self): + assoc = association.Association('handle', b'secret', 1000, 1000, b'HMAC-SHA1') + self.assertEqual(assoc.assoc_type, 'HMAC-SHA1') + + class AssociationSerializationTest(unittest.TestCase): def test_roundTrip(self): issued = int(time.time()) |