Skip to content

Commit

Permalink
Made it possible to save the xml contents to a file
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
vaszig committed Feb 14, 2024
1 parent 24758de commit 3976e40
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions digid_eherkenning/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 3976e40

Please sign in to comment.