mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 06:37:52 +00:00
Allow GET in webhook triggers (#56446)
This commit is contained in:
parent
ce16d8eeac
commit
47f5160154
@ -160,6 +160,7 @@ class WebhookView(HomeAssistantView):
|
|||||||
head = _handle
|
head = _handle
|
||||||
post = _handle
|
post = _handle
|
||||||
put = _handle
|
put = _handle
|
||||||
|
get = _handle
|
||||||
|
|
||||||
|
|
||||||
@websocket_api.websocket_command(
|
@websocket_api.websocket_command(
|
||||||
|
@ -131,6 +131,25 @@ async def test_webhook_put(hass: HomeAssistant, mock_client) -> None:
|
|||||||
assert hooks[0][2].method == "PUT"
|
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:
|
async def test_webhook_head(hass: HomeAssistant, mock_client) -> None:
|
||||||
"""Test sending a head request to a webhook."""
|
"""Test sending a head request to a webhook."""
|
||||||
hooks = []
|
hooks = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user