From 3976e4037b8866bff16be497dfc33d558f8f721d Mon Sep 17 00:00:00 2001 From: vasileios Date: Wed, 14 Feb 2024 16:38:40 +0100 Subject: [PATCH] Made it possible to save the xml contents to a file get_metadata method from saml library returns bytes but this was confusing in the docstrings as they mention str.So, what we get from this method is used directly to create the file (idp_metadata_file). --- digid_eherkenning/models/base.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/digid_eherkenning/models/base.py b/digid_eherkenning/models/base.py index 2a31ec1..3aaa2b8 100644 --- a/digid_eherkenning/models/base.py +++ b/digid_eherkenning/models/base.py @@ -181,20 +181,20 @@ class Meta: def __str__(self): return force_str(self._meta.verbose_name) - def populate_xml_fields(self, urls: dict[str, str], xml: str) -> None: + def populate_xml_fields(self, urls: dict[str, str], xml: bytes) -> None: """ Populates the idp_metadata_file and idp_service_entity_id fields based on the fetched xml metadata """ self.idp_service_entity_id = urls["entityId"] - content = ContentFile(xml.encode("utf-8")) + content = ContentFile(xml) self.idp_metadata_file.save("metadata.xml", content, save=False) - def process_metadata_from_xml_source(self) -> tuple[dict[str, str], str]: + def process_metadata_from_xml_source(self) -> tuple[dict[str, str], bytes]: """ Parses the xml metadata - :return a tuple of a dictionary with the useful urls and the xml string itself. + :return a tuple of a dictionary with the useful urls and the xml bytes. """ try: xml = OneLogin_Saml2_IdPMetadataParser.get_metadata(