From dfc3658e1bdb080e6dbb581fd6354090e69bf72e Mon Sep 17 00:00:00 2001 From: Czier Norbert Date: Wed, 18 Jun 2025 08:49:55 +0200 Subject: [PATCH 1/2] Fix(mdq): normalize entityID to preserve trailing slash and file extension --- src/pyff/api.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pyff/api.py b/src/pyff/api.py index 10e7b3ad..c520e37f 100644 --- a/src/pyff/api.py +++ b/src/pyff/api.py @@ -173,7 +173,11 @@ def _d(x: Optional[str], do_split: bool = True) -> tuple[Optional[str], Optional (pth, dot, extn) = x.rpartition('.') assert dot == '.' if extn in _ctypes: - return pth, extn + hash_prefixes = ("{sha1}", "{sha256}", "{md5}") + if any(pth.startswith(prefix) for prefix in hash_prefixes): + return pth, extn + + return x, extn return x, None @@ -202,6 +206,9 @@ def _d(x: Optional[str], do_split: bool = True) -> tuple[Optional[str], Optional alias = path_elem.pop(0) path = '/'.join(path_elem) + if request.path.endswith('/'): + path += '/' + # Ugly workaround bc WSGI drops double-slashes. path = path.replace(':/', '://') From d91e9c097d790f3a52d9386cee5d91f1bd15da4f Mon Sep 17 00:00:00 2001 From: Czier Norbert Date: Fri, 20 Jun 2025 13:43:52 +0200 Subject: [PATCH 2/2] Created tests --- src/pyff/test/test_md_api.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/pyff/test/test_md_api.py b/src/pyff/test/test_md_api.py index a9fc8a40..2cac7232 100644 --- a/src/pyff/test/test_md_api.py +++ b/src/pyff/test/test_md_api.py @@ -4,6 +4,7 @@ import unittest from datetime import datetime, timezone from urllib.parse import quote as urlescape +from xml.etree import ElementTree as ET import pytest import requests @@ -146,6 +147,20 @@ def test_load_and_query(self): 'https://box-idp.nordu.net/simplesaml/module.php/saml/sp/discoResponse' in info['discovery_responses'] ) + r = requests.get(f"{url}/entities/https%3A%2F%2Fclarino.uib.no%2F", headers={'Accept':'application/json'}) + assert r.status_code == 200 + data = r.json() + info = data[0] + assert ( + 'https://clarino.uib.no/feide/single-login' in info['discovery_responses'] + ) + + r = requests.get(f"{url}/entities/https%3A%2F%2Fshibboleth.mzk.cz%2Fsimplesaml%2Fmetadata.xml", headers={'Accept':'application/xml'}) + assert r.status_code == 200 + + root = ET.fromstring(r.content) + assert root.tag.endswith('EntityDescriptor') + class PyFFAPITestResources(PipeLineTest): """