Update Radarr config flow to standardize ports (#127620)
parent
213cc14494
commit
62ae2a3bd5
|
@ -10,6 +10,7 @@ from aiopyarr import exceptions
|
|||
from aiopyarr.models.host_configuration import PyArrHostConfiguration
|
||||
from aiopyarr.radarr_client import RadarrClient
|
||||
import voluptuous as vol
|
||||
from yarl import URL
|
||||
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_API_KEY, CONF_URL, CONF_VERIFY_SSL
|
||||
|
@ -54,6 +55,12 @@ class RadarrConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||
user_input = dict(self.entry.data) if self.entry else None
|
||||
|
||||
else:
|
||||
# aiopyarr defaults to the service port if one isn't given
|
||||
# this is counter to standard practice where http = 80
|
||||
# and https = 443.
|
||||
url = URL(user_input[CONF_URL])
|
||||
user_input[CONF_URL] = f"{url.scheme}://{url.host}:{url.port}{url.path}"
|
||||
|
||||
try:
|
||||
if result := await validate_input(self.hass, user_input):
|
||||
user_input[CONF_API_KEY] = result[1]
|
||||
|
|
|
@ -137,6 +137,23 @@ async def test_zero_conf(hass: HomeAssistant) -> None:
|
|||
assert result["data"] == CONF_DATA
|
||||
|
||||
|
||||
async def test_url_rewrite(hass: HomeAssistant) -> None:
|
||||
"""Test auth flow url rewrite."""
|
||||
with patch(
|
||||
"homeassistant.components.radarr.config_flow.RadarrClient.async_try_zeroconf",
|
||||
return_value=("v3", API_KEY, "/test"),
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={CONF_SOURCE: SOURCE_USER},
|
||||
data={CONF_URL: "https://192.168.1.100/test", CONF_VERIFY_SSL: False},
|
||||
)
|
||||
|
||||
assert result["type"] is FlowResultType.CREATE_ENTRY
|
||||
assert result["title"] == DEFAULT_NAME
|
||||
assert result["data"][CONF_URL] == "https://192.168.1.100:443/test"
|
||||
|
||||
|
||||
@pytest.mark.freeze_time("2021-12-03 00:00:00+00:00")
|
||||
async def test_full_reauth_flow_implementation(
|
||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
||||
|
|
Loading…
Reference in New Issue