Skip to content

Commit aeeccd3

Browse files
committed
tests: Do not hardcode the namespace prefix for encrypted assertions
Signed-off-by: Ivan Kanakarakis <[email protected]>
1 parent a0539a2 commit aeeccd3

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tests/test_50_server.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from contextlib import closing
77
from six.moves.urllib.parse import parse_qs
88
import uuid
9+
import re
910

1011
from saml2.cert import OpenSSLWrapper
1112
from saml2.sigver import make_temp, DecryptError, EncryptError, CertificateError
@@ -129,8 +130,10 @@ def verify_encrypted_assertion(self, assertion, decr_text):
129130
self.verify_assertion(assertion)
130131
assert assertion[0].signature is None
131132

132-
assert 'EncryptedAssertion><encas1:Assertion xmlns:encas0="http://www.w3.org/2001/XMLSchema-instance" ' \
133-
'xmlns:encas1="urn:oasis:names:tc:SAML:2.0:assertion"' in decr_text
133+
assert re.search(
134+
r':EncryptedAssertion><encas[0-9]:Assertion ([^ >]* )*xmlns:encas[0-9]="urn:oasis:names:tc:SAML:2.0:assertion"',
135+
decr_text,
136+
)
134137

135138
def verify_advice_assertion(self, resp, decr_text):
136139
assert resp.assertion[0].signature is None
@@ -1188,9 +1191,10 @@ def verify_assertion(self, assertion):
11881191
def verify_encrypted_assertion(self, assertion, decr_text):
11891192
self.verify_assertion(assertion)
11901193
assert assertion[0].signature is None
1191-
1192-
assert 'EncryptedAssertion><encas1:Assertion xmlns:encas0="http://www.w3.org/2001/XMLSchema-instance" ' \
1193-
'xmlns:encas1="urn:oasis:names:tc:SAML:2.0:assertion"' in decr_text
1194+
assert re.search(
1195+
r':EncryptedAssertion><encas[0-9]:Assertion ([^ >]* )*xmlns:encas[0-9]="urn:oasis:names:tc:SAML:2.0:assertion"',
1196+
decr_text,
1197+
)
11941198

11951199
def verify_advice_assertion(self, resp, decr_text):
11961200
assert resp.assertion[0].signature is None

0 commit comments

Comments
 (0)