maint: Dependency upgrades and High backlog items (v2.11.0)
- All dependencies to current releases (97 known vulnerabilities -> 0), Python 3.14, uv pinned, requirements-test.txt, lxml/dateutil pinned - CSRF tokens on admin forms, logout and IndieAuth consent - IndieAuth client and crosspost link-card fetches via safe_get - FLASK_DEBUG/FLASK_ENV default off/production; image sets them - Foreign keys enforced on pooled connections; migration 018 removes orphans - Rate limits shared across processes (rate_limits, migration 019) - datetime.utcnow() and sqlite3 default adapters replaced - compose.yaml fixed; duplicate dev_auth.py and test.ini removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9f17e145ff
commit
75946be7b2
67 files changed
+885
-498
No files matched your search
+41
-14
@@ -129,27 +129,54 @@ class TestValidation:
|
||||
|
||||
|
||||
class TestClientMetadata:
|
||||
def _response(self, content_type, body, links=None):
|
||||
response = MagicMock(status_code=200, text=body, url="https://quill.example/")
|
||||
response.headers = {"Content-Type": content_type}
|
||||
response.links = links or {}
|
||||
response.json.return_value = __import__("json").loads(body) if "json" in content_type else None
|
||||
return response
|
||||
"""Client metadata is fetched through the SSRF-safe fetcher (v2.11.0)"""
|
||||
|
||||
def test_json_metadata(self, app):
|
||||
@staticmethod
|
||||
def _serve(monkeypatch, handler, private=()):
|
||||
import httpx
|
||||
|
||||
def resolve(host, *args, **kwargs):
|
||||
return [(2, 1, 6, "", ("10.0.0.5" if host in private else "93.184.216.34", 0))]
|
||||
|
||||
monkeypatch.setattr("starpunk.webmention_ssrf.TRANSPORT", httpx.MockTransport(handler))
|
||||
monkeypatch.setattr("starpunk.webmention_ssrf.socket.getaddrinfo", resolve)
|
||||
|
||||
def test_json_metadata(self, app, monkeypatch):
|
||||
import httpx
|
||||
body = '{"client_id": "https://quill.example/", "redirect_uris": ["app://cb"]}'
|
||||
with app.test_request_context(), patch(
|
||||
"starpunk.webmention_ssrf.validate_url_for_fetch"
|
||||
), patch("starpunk.indieauth.httpx.get", return_value=self._response("application/json", body)):
|
||||
self._serve(monkeypatch, lambda r: httpx.Response(
|
||||
200, headers={"Content-Type": "application/json"}, text=body))
|
||||
with app.test_request_context():
|
||||
assert fetch_client_redirect_uris(CLIENT_ID) == ["app://cb"]
|
||||
|
||||
def test_html_link(self, app):
|
||||
def test_html_link(self, app, monkeypatch):
|
||||
import httpx
|
||||
body = '<html><head><link rel="redirect_uri" href="/cb"></head></html>'
|
||||
with app.test_request_context(), patch(
|
||||
"starpunk.webmention_ssrf.validate_url_for_fetch"
|
||||
), patch("starpunk.indieauth.httpx.get", return_value=self._response("text/html", body)):
|
||||
self._serve(monkeypatch, lambda r: httpx.Response(
|
||||
200, headers={"Content-Type": "text/html"}, text=body))
|
||||
with app.test_request_context():
|
||||
assert fetch_client_redirect_uris(CLIENT_ID) == ["https://quill.example/cb"]
|
||||
|
||||
def test_link_header(self, app, monkeypatch):
|
||||
import httpx
|
||||
self._serve(monkeypatch, lambda r: httpx.Response(
|
||||
200, headers={"Content-Type": "text/html", "Link": '</cb2>; rel="redirect_uri"'}, text="<p>hi</p>"))
|
||||
with app.test_request_context():
|
||||
assert fetch_client_redirect_uris(CLIENT_ID) == ["https://quill.example/cb2"]
|
||||
|
||||
def test_redirect_to_private_address_refused(self, app, monkeypatch):
|
||||
import httpx
|
||||
fetched = []
|
||||
|
||||
def handler(request):
|
||||
fetched.append(request.headers["host"])
|
||||
return httpx.Response(302, headers={"Location": "http://internal.example/"})
|
||||
|
||||
self._serve(monkeypatch, handler, private={"internal.example"})
|
||||
with app.test_request_context():
|
||||
assert fetch_client_redirect_uris(CLIENT_ID) == []
|
||||
assert "internal.example" not in fetched
|
||||
|
||||
|
||||
class TestCodesAndTokens:
|
||||
def test_full_exchange(self, app):
|
||||
|
||||
Reference in new issue
Block a user