Skip to content

The agent that grows with you

test(webhook): pin the per-request blank-secret guard

kshitijk4poore123550d43b7
diff --git a/tests/gateway/test_webhook_adapter.py b/tests/gateway/test_webhook_adapter.py
index ea087dd780e..d80574d5215 100644
--- a/tests/gateway/test_webhook_adapter.py
+++ b/tests/gateway/test_webhook_adapter.py
@@ -498,7 +498,7 @@ class TestHTTPHandling:
@pytest.mark.asyncio
async def test_route_without_secret_rejects_unsigned_request(self):
"""Missing HMAC secret must fail closed even if connect() was bypassed."""
- routes = {"test": {"prompt": "hi"}}
+ routes = {"test": {"prompt": "hi"}, "blank": {"prompt": "hi", "secret": " "}}
adapter = _make_adapter(routes=routes, secret="")
adapter.handle_message = AsyncMock()
@@ -506,6 +506,11 @@ class TestHTTPHandling:
async with TestClient(TestServer(app)) as cli:
resp = await cli.post("/webhooks/test", json={"data": "value"})
assert resp.status == 403
+ # A whitespace-only secret is unset too, even when the request is signed with it.
+ body = b'{"data": "value"}'
+ resp = await cli.post("/webhooks/blank", data=body, headers={
+ "Content-Type": "application/json", "X-Hub-Signature-256": _github_signature(body, " ")})
+ assert resp.status == 403
adapter.handle_message.assert_not_called()
@@ -1251,7 +1256,3 @@ class TestBlankRouteSecretFailsClosed:
adapter = _make_adapter(routes={"hook": {"secret": blank}})
with pytest.raises(ValueError, match="HMAC secret"):
asyncio.run(adapter.connect())
-
- def test_connect_still_accepts_a_real_secret(self):
- adapter = _make_adapter(routes={"hook": {"secret": "s3cr3t"}})
- assert asyncio.run(adapter.connect()) is True