Generate withings webhook ID in config flow (#100395)

pull/95967/head
Joost Lekkerkerker 2023-09-15 12:58:56 +02:00 committed by GitHub
parent d1afcd773f
commit 1737b27dd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -8,8 +8,9 @@ from typing import Any
import voluptuous as vol
from withings_api.common import AuthScope
from homeassistant.components.webhook import async_generate_id
from homeassistant.config_entries import ConfigEntry, OptionsFlowWithConfigEntry
from homeassistant.const import CONF_TOKEN
from homeassistant.const import CONF_TOKEN, CONF_WEBHOOK_ID
from homeassistant.core import callback
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import config_entry_oauth2_flow
@ -77,7 +78,7 @@ class WithingsFlowHandler(
return self.async_create_entry(
title=DEFAULT_TITLE,
data=data,
data={**data, CONF_WEBHOOK_ID: async_generate_id()},
options={CONF_USE_WEBHOOK: False},
)

View File

@ -73,6 +73,7 @@ async def test_full_flow(
assert "result" in result
assert result["result"].unique_id == "600"
assert "token" in result["result"].data
assert "webhook_id" in result["result"].data
assert result["result"].data["token"]["access_token"] == "mock-access-token"
assert result["result"].data["token"]["refresh_token"] == "mock-refresh-token"