diff options
Diffstat (limited to 'tests/test_42_enc.py')
-rw-r--r-- | tests/test_42_enc.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/test_42_enc.py b/tests/test_42_enc.py index c268aa76..54825902 100644 --- a/tests/test_42_enc.py +++ b/tests/test_42_enc.py @@ -12,7 +12,7 @@ from pathutils import full_path __author__ = 'roland' -TMPL_NO_HEADER = """<ns0:EncryptedData xmlns:ns0="http://www.w3.org/2001/04/xmlenc#" xmlns:ns1="http://www.w3.org/2000/09/xmldsig#" Id="{ed_id}" Type="http://www.w3.org/2001/04/xmlenc#Element"><ns0:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" /><ns1:KeyInfo><ns0:EncryptedKey Id="{ek_id}"><ns0:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p" /><ns1:KeyInfo><ns1:KeyName>my-rsa-key</ns1:KeyName></ns1:KeyInfo><ns0:CipherData><ns0:CipherValue /></ns0:CipherData></ns0:EncryptedKey></ns1:KeyInfo><ns0:CipherData><ns0:CipherValue /></ns0:CipherData></ns0:EncryptedData>""" +TMPL_NO_HEADER = """<ns0:EncryptedData xmlns:ns0="http://www.w3.org/2001/04/xmlenc#" xmlns:ns1="http://www.w3.org/2000/09/xmldsig#" Id="{ed_id}" Type="http://www.w3.org/2001/04/xmlenc#Element"><ns0:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" /><ns1:KeyInfo><ns0:EncryptedKey Id="{ek_id}"><ns0:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p" />{key_info}<ns0:CipherData><ns0:CipherValue /></ns0:CipherData></ns0:EncryptedKey></ns1:KeyInfo><ns0:CipherData><ns0:CipherValue /></ns0:CipherData></ns0:EncryptedData>""" TMPL = f"<?xml version='1.0' encoding='UTF-8'?>\n{TMPL_NO_HEADER}" IDENTITY = {"eduPersonAffiliation": ["staff", "member"], @@ -47,6 +47,7 @@ def test_pre_enc_with_pregenerated_key(): expected = TMPL_NO_HEADER.format( ed_id=tmpl.id, ek_id=tmpl.key_info.encrypted_key.id, + key_info='' ) assert str(tmpl) == expected @@ -56,6 +57,16 @@ def test_pre_enc_with_generated_key(): expected = TMPL_NO_HEADER.format( ed_id=tmpl.id, ek_id=tmpl.key_info.encrypted_key.id, + key_info='' + ) + assert str(tmpl) == expected + +def test_pre_enc_with_named_key(): + tmpl = pre_encryption_part(key_name="my-rsa-key") + expected = TMPL_NO_HEADER.format( + ed_id=tmpl.id, + ek_id=tmpl.key_info.encrypted_key.id, + key_info='<ns1:KeyInfo><ns1:KeyName>my-rsa-key</ns1:KeyName></ns1:KeyInfo>' ) assert str(tmpl) == expected |