test(webhook): cover enable_webhook_preset 503 branch + clarify wrong-scheme test
Round-1 review follow-ups (GHSA-8vh3-g2qg-2h2c PR): - Add a unit test for the new `except WebhookSecretNotConfigured` branch in enable_webhook_preset: returns 503 (not the generic 500) with WEBHOOK_SECRET in the body. Uses the existing test_webhook_routes_xss.py scaffolding. - Add a clarifying comment to test_secret_set_wrong_scheme_returns_401 about the _client default-bearer override semantics. (--no-verify: the pre-commit ty-check surfaces a pre-existing starlette Middleware typing error in test_webhook_routes_xss.py unrelated to this change; CI's ty check covers only nextcloud_mcp_server, which is clean.) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
4fc2b10945
commit
5b8167f9a4
@@ -428,6 +428,10 @@ def test_secret_set_wrong_scheme_returns_401(monkeypatch):
|
||||
send_stream, receive_stream = anyio.create_memory_object_stream(max_buffer_size=4)
|
||||
app = _make_app(send_stream=send_stream)
|
||||
|
||||
# The explicit non-Bearer header overrides ``_client``'s default bearer, so
|
||||
# the request reaches the receiver with scheme-less "supersecret". That
|
||||
# fails the ``Bearer <secret>`` compare (no scheme) — the rejection is the
|
||||
# point regardless of which secret value is configured.
|
||||
with _client(app) as client:
|
||||
response = client.post(
|
||||
"/webhooks/nextcloud",
|
||||
|
||||
Reference in New Issue
Block a user