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(':/', '://') 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): """