fix: address PR review feedback for client registry and DCR proxy

- Document wildcard scope policy in ClientRegistry class docstring
- Add hostname None guard and IPv6 loopback (::1) to redirect URI validation
- Simplify redirect URI scheme validation into single guard clause
- Add try/finally cleanup to DCR client deletion test
- Validate 302 Location header in unknown client rejection test
- Add unit tests for IPv6 loopback, malformed URIs, and DCR proxy paths

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Chris Coutinho
2026-04-05 19:29:23 +02:00
co-authored by Claude Opus 4.6
parent 7d775d2a52
commit b07b713146
4 changed files with 144 additions and 14 deletions
+33
View File
@@ -165,3 +165,36 @@ def test_client_name_resolution(monkeypatch):
registry = _get_registry(monkeypatch, "claude-desktop, custom-tool")
assert registry.get_client("claude-desktop").name == "Claude Desktop"
assert registry.get_client("custom-tool").name == "Custom Tool"
def test_ipv6_loopback_allowed(monkeypatch):
registry = _get_registry(monkeypatch, "ipv6-app|http://[::1]:3000/cb")
client = registry.get_client("ipv6-app")
assert client is not None
assert client.redirect_uris == ["http://[::1]:3000/cb"]
def test_malformed_uri_no_hostname_skipped(monkeypatch, caplog):
with caplog.at_level(logging.WARNING):
registry = _get_registry(monkeypatch, "bad|http:///no-host")
assert registry.get_client("bad") is None
assert "cannot parse hostname" in caplog.text
def test_validate_redirect_uri_ipv6_loopback(monkeypatch):
"""IPv6 loopback redirect URIs should match wildcard localhost patterns."""
registry = _get_registry(monkeypatch, "ipv6-app|http://[::1]:3000/cb")
valid, err = registry.validate_client(
"ipv6-app", redirect_uri="http://[::1]:3000/cb"
)
assert valid is True
assert err is None
def test_validate_redirect_uri_no_hostname(monkeypatch):
"""Redirect URIs with no parseable hostname should be rejected."""
registry = _get_registry(monkeypatch, "test-client")
valid, err = registry.validate_client("test-client", redirect_uri="not-a-uri")
assert valid is False
assert "redirect_uri" in err.lower()