Skip to content

Commit b150105

Browse files
committed
Adjust tests to default namespace prefix
tests/test_88_nsprefix.py: Adjust "ns0" to namespace prefix "samlp" tests/test_02_saml.py: Use different prefix than the default one. tests/test_42_enc.py: The order of the namespace arguments in the string representation has changed (sorted alphabetical)
1 parent ab97b78 commit b150105

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

tests/test_02_saml.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,13 @@ def test_make_vals_multi_dict(self):
225225
def test_to_string_nspair(self):
226226
foo = saml2.make_vals("lions", AttributeValue, part=True)
227227
txt = foo.to_string().decode('utf-8')
228-
nsstr = foo.to_string({"saml": saml.NAMESPACE}).decode('utf-8')
228+
nsstr = foo.to_string({"saml2": saml.NAMESPACE}).decode('utf-8')
229229
assert nsstr != txt
230230
print(txt)
231231
print(nsstr)
232-
assert "saml:AttributeValue" in nsstr
233-
assert "saml:AttributeValue" not in txt
232+
assert "saml2:AttributeValue" in nsstr
233+
assert "saml2:AttributeValue" not in txt
234+
assert "saml:AttributeValue" in txt
234235

235236
def test_set_text_empty(self):
236237
av = AttributeValue()

tests/test_42_enc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
__author__ = 'roland'
1414

15-
TMPL_NO_HEADER = """<xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="{ed_id}" Type="http://www.w3.org/2001/04/xmlenc#Element"><xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" /><ds:KeyInfo><xenc:EncryptedKey Id="{ek_id}"><xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" /><ds:KeyInfo><ds:KeyName>my-rsa-key</ds:KeyName></ds:KeyInfo><xenc:CipherData><xenc:CipherValue /></xenc:CipherData></xenc:EncryptedKey></ds:KeyInfo><xenc:CipherData><xenc:CipherValue /></xenc:CipherData></xenc:EncryptedData>"""
15+
TMPL_NO_HEADER = """<xenc:EncryptedData xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Id="{ed_id}" Type="http://www.w3.org/2001/04/xmlenc#Element"><xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" /><ds:KeyInfo><xenc:EncryptedKey Id="{ek_id}"><xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" /><ds:KeyInfo><ds:KeyName>my-rsa-key</ds:KeyName></ds:KeyInfo><xenc:CipherData><xenc:CipherValue /></xenc:CipherData></xenc:EncryptedKey></ds:KeyInfo><xenc:CipherData><xenc:CipherValue /></xenc:CipherData></xenc:EncryptedData>"""
1616
TMPL = "<?xml version='1.0' encoding='UTF-8'?>\n%s" % TMPL_NO_HEADER
1717

1818
IDENTITY = {"eduPersonAffiliation": ["staff", "member"],
@@ -123,5 +123,6 @@ def test_enc2():
123123

124124
assert enc_resp
125125

126+
126127
if __name__ == "__main__":
127128
test_enc1()

tests/test_88_nsprefix.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_nsprefix():
1313

1414
txt = "%s" % status_message
1515

16-
assert "ns0:StatusMessage" in txt
16+
assert "samlp:StatusMessage" in txt
1717

1818
status_message.register_prefix({"saml2": saml.NAMESPACE,
1919
"saml2p": samlp.NAMESPACE})
@@ -41,5 +41,6 @@ def test_nsprefix2():
4141
assert "saml2p:AuthnRequest" in txt
4242
assert "saml2:Issuer" in txt
4343

44+
4445
if __name__ == "__main__":
45-
test_nsprefix2()
46+
test_nsprefix2()

0 commit comments

Comments
 (0)