From 4a568c964b5dc59f3620249ead45b5c75225346f Mon Sep 17 00:00:00 2001 From: Nate Otto Date: Sat, 4 Jul 2020 12:36:35 -0700 Subject: Add test for generation of signed metadata --- tests/test_39_metadata.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/test_39_metadata.py b/tests/test_39_metadata.py index a3796083..8ab6dfa5 100644 --- a/tests/test_39_metadata.py +++ b/tests/test_39_metadata.py @@ -1,7 +1,10 @@ import copy from saml2.config import SPConfig -from saml2.metadata import entity_descriptor +from saml2.metadata import create_metadata_string, entity_descriptor from saml2.saml import NAME_FORMAT_URI, NAME_FORMAT_BASIC +from saml2 import sigver + +from pathutils import full_path __author__ = 'roland' @@ -47,5 +50,17 @@ def test_requested_attribute_name_format(): assert req_attr.name_format == NAME_FORMAT_BASIC +def test_signed_metadata_proper_str_bytes_handling(): + sp_conf_2 = sp_conf.copy() + sp_conf_2['key_file'] = full_path("test.key") + sp_conf_2['cert_file'] = full_path("inc-md-cert.pem") + # requires xmlsec binaries per https://pysaml2.readthedocs.io/en/latest/examples/sp.html + sp_conf_2['xmlsec_binary'] = sigver.get_xmlsec_binary(["/opt/local/bin"]) + cnf = SPConfig().load(sp_conf_2, metadata_construction=True) + + # This will raise TypeError if string/bytes handling is not correct + sp_metadata = create_metadata_string('', config=cnf, sign=True) + + if __name__ == '__main__': - test_requested_attribute_name_format() \ No newline at end of file + test_requested_attribute_name_format() -- cgit v1.2.1