Skip to content

Commit c2f95cc

Browse files
committed
Fix assertion test failures in python3
More strings/bytes problems causing issues with hashing. This further cements that all data coming into pysaml2 will need to be utf-8, or the API will need to have more places to specify alternative encodings.
1 parent b928d81 commit c2f95cc

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/saml2/assertion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ def apply_policy(self, sp_entity_id, policy, metadata=None):
767767
policy.acs = self.acs
768768
ava = policy.restrict(self, sp_entity_id, metadata)
769769

770-
for key, val in self.items():
770+
for key, val in list(self.items()):
771771
if key in ava:
772772
self[key] = ava[key]
773773
else:

src/saml2/sdb.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from hashlib import sha1
44

5-
from saml2.ident import code
5+
from saml2.ident import code_binary
66

77
from saml2 import md
88
from saml2 import saml
@@ -49,7 +49,7 @@ def __init__(self):
4949

5050
def store_assertion(self, assertion, to_sign):
5151
self.assertion[assertion.id] = (assertion, to_sign)
52-
key = sha1(code(assertion.subject.name_id)).hexdigest()
52+
key = sha1(code_binary(assertion.subject.name_id)).hexdigest()
5353
try:
5454
self.authn[key].append(assertion.authn_statement)
5555
except KeyError:
@@ -68,7 +68,7 @@ def get_authn_statements(self, name_id, session_index=None,
6868
:return:
6969
"""
7070
result = []
71-
key = sha1(code(name_id)).hexdigest()
71+
key = sha1(code_binary(name_id)).hexdigest()
7272
try:
7373
statements = self.authn[key]
7474
except KeyError:
@@ -89,6 +89,6 @@ def get_authn_statements(self, name_id, session_index=None,
8989

9090
def remove_authn_statements(self, name_id):
9191
logger.debug("remove authn about: %s" % name_id)
92-
nkey = sha1(code(name_id)).hexdigest()
92+
nkey = sha1(code_binary(name_id)).hexdigest()
9393

9494
del self.authn[nkey]

0 commit comments

Comments
 (0)