Reject config entries of other integrations in Reolink playback (#190460)

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Joost Lekkerkerker
2026-11-10 12:17:28 +01:00
committed by GitHub
co-authored by Claude Martin Hjelmare
parent e12f070eef
commit 85f2a29b01
2 changed files with 12 additions and 3 deletions
+1 -1
View File
@@ -60,7 +60,7 @@ def get_host(hass: HomeAssistant, config_entry_id: str) -> ReolinkHost:
config_entry: ReolinkConfigEntry | None = hass.config_entries.async_get_entry(
config_entry_id
)
if config_entry is None:
if config_entry is None or config_entry.domain != DOMAIN:
raise Unresolvable(
translation_domain=DOMAIN,
translation_key="config_entry_not_found",
+11 -2
View File
@@ -128,18 +128,27 @@ async def test_proxy_get_source_error(
assert response.status == HTTPStatus.BAD_REQUEST
@pytest.mark.parametrize(
"config_entry_id",
[
pytest.param("wrong_config_id", id="not_found"),
pytest.param("other_entry", id="other_integration"),
],
)
async def test_proxy_invalid_config_entry_id(
hass: HomeAssistant,
reolink_host: MagicMock,
config_entry: MockConfigEntry,
hass_client: ClientSessionGenerator,
config_entry_id: str,
) -> None:
"""Test config entry id not found for playback proxy URL."""
assert await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
MockConfigEntry(domain="other", entry_id="other_entry").add_to_hass(hass)
proxy_url = async_generate_playback_proxy_url(
"wrong_config_id",
config_entry_id,
TEST_CHANNEL,
TEST_FILE_NAME_MP4,
TEST_STREAM,
@@ -150,7 +159,7 @@ async def test_proxy_invalid_config_entry_id(
response = await http_client.get(proxy_url)
assert await response.content.read() == bytes(
"Reolink playback proxy could not find config entry id: wrong_config_id",
f"Reolink playback proxy could not find config entry id: {config_entry_id}",
"utf-8",
)
assert response.status == HTTPStatus.BAD_REQUEST