Add support for accessing Squeezebox over over https (#95088)

* Supports access to squeezebox server behind https reverse proxy

* Update squeezebox test

* Update homeassistant/components/squeezebox/config_flow.py

Co-authored-by: Robert Resch <robert@resch.dev>

* Update homeassistant/components/squeezebox/config_flow.py

Co-authored-by: Robert Resch <robert@resch.dev>

* Update squeezebox unit tests based on code review

* Migration unit test

* Run black on suggestions accepted in code review

* Apply suggestions from code review

Instead of upgrading squeezebox config, just assume a default of https=False.

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Update test_init.py

Remove migrate entry test since we are no longer migrating

* Delete tests/components/squeezebox/test_init.py

Remove unused test

---------

Co-authored-by: Robert Resch <robert@resch.dev>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
Raj Laud
2023-12-08 15:51:19 +01:00
committed by GitHub
co-authored by Robert Resch Erik Montnemery
parent a10f580815
commit 45f7ffb34c
8 changed files with 33 additions and 11 deletions
@@ -6,7 +6,7 @@ from pysqueezebox import Server
from homeassistant import config_entries
from homeassistant.components import dhcp
from homeassistant.components.squeezebox.const import DOMAIN
from homeassistant.components.squeezebox.const import CONF_HTTPS, DOMAIN
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_USERNAME
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResultType
@@ -59,7 +59,13 @@ async def test_user_form(hass: HomeAssistant) -> None:
# test the edit step
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
{CONF_HOST: HOST, CONF_PORT: PORT, CONF_USERNAME: "", CONF_PASSWORD: ""},
{
CONF_HOST: HOST,
CONF_PORT: PORT,
CONF_USERNAME: "",
CONF_PASSWORD: "",
CONF_HTTPS: False,
},
)
assert result["type"] == FlowResultType.CREATE_ENTRY
assert result["title"] == HOST
@@ -68,6 +74,7 @@ async def test_user_form(hass: HomeAssistant) -> None:
CONF_PORT: PORT,
CONF_USERNAME: "",
CONF_PASSWORD: "",
CONF_HTTPS: False,
}
await hass.async_block_till_done()
@@ -107,7 +114,11 @@ async def test_user_form_duplicate(hass: HomeAssistant) -> None:
"homeassistant.components.squeezebox.async_setup_entry",
return_value=True,
):
entry = MockConfigEntry(domain=DOMAIN, unique_id=UUID)
entry = MockConfigEntry(
domain=DOMAIN,
unique_id=UUID,
data={CONF_HOST: HOST, CONF_PORT: PORT, CONF_HTTPS: False},
)
await hass.config_entries.async_add(entry)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}
@@ -186,7 +197,7 @@ async def test_discovery_no_uuid(hass: HomeAssistant) -> None:
result = await hass.config_entries.flow.async_init(
DOMAIN,
context={"source": config_entries.SOURCE_INTEGRATION_DISCOVERY},
data={CONF_HOST: HOST, CONF_PORT: PORT},
data={CONF_HOST: HOST, CONF_PORT: PORT, CONF_HTTPS: False},
)
assert result["type"] == FlowResultType.FORM
assert result["step_id"] == "edit"