Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/pyff/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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(':/', '://')

Expand Down
15 changes: 15 additions & 0 deletions src/pyff/test/test_md_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
"""
Expand Down