Skip to content
Merged
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
1 change: 1 addition & 0 deletions homeassistant/components/webhook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ async def _handle(self, request: Request, webhook_id: str) -> Response:
head = _handle
post = _handle
put = _handle
get = _handle


@websocket_api.websocket_command(
Expand Down
19 changes: 19 additions & 0 deletions tests/components/webhook/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,25 @@ async def handle(*args):
assert hooks[0][2].method == "PUT"


async def test_webhook_get(hass, mock_client):
"""Test sending a get request to a webhook."""
hooks = []
webhook_id = hass.components.webhook.async_generate_id()

async def handle(*args):
"""Handle webhook."""
hooks.append(args)

hass.components.webhook.async_register("test", "Test hook", webhook_id, handle)

resp = await mock_client.get(f"/api/webhook/{webhook_id}")
assert resp.status == 200
assert len(hooks) == 1
assert hooks[0][0] is hass
assert hooks[0][1] == webhook_id
assert hooks[0][2].method == "GET"


async def test_webhook_head(hass: HomeAssistant, mock_client) -> None:
"""Test sending a head request to a webhook."""
hooks = []
Expand Down