mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 02:37:08 +00:00
Not slugify cert_expiry name (#28055)
This commit is contained in:
parent
6ba437d83a
commit
ac467d0b3f
@ -5,7 +5,6 @@ import voluptuous as vol
|
|||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.const import CONF_PORT, CONF_NAME, CONF_HOST
|
from homeassistant.const import CONF_PORT, CONF_NAME, CONF_HOST
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.util import slugify
|
|
||||||
|
|
||||||
from .const import DOMAIN, DEFAULT_PORT, DEFAULT_NAME
|
from .const import DOMAIN, DEFAULT_PORT, DEFAULT_NAME
|
||||||
from .helper import get_cert
|
from .helper import get_cert
|
||||||
@ -62,11 +61,12 @@ class CertexpiryConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
self._errors[CONF_HOST] = "host_port_exists"
|
self._errors[CONF_HOST] = "host_port_exists"
|
||||||
else:
|
else:
|
||||||
if await self._test_connection(user_input):
|
if await self._test_connection(user_input):
|
||||||
host = user_input[CONF_HOST]
|
|
||||||
name = slugify(user_input.get(CONF_NAME, DEFAULT_NAME))
|
|
||||||
prt = user_input.get(CONF_PORT, DEFAULT_PORT)
|
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
title=name, data={CONF_HOST: host, CONF_PORT: prt}
|
title=user_input.get(CONF_NAME, DEFAULT_NAME),
|
||||||
|
data={
|
||||||
|
CONF_HOST: user_input[CONF_HOST],
|
||||||
|
CONF_PORT: user_input.get(CONF_PORT, DEFAULT_PORT),
|
||||||
|
},
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
user_input = {}
|
user_input = {}
|
||||||
|
@ -5,7 +5,7 @@ from unittest.mock import patch
|
|||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import data_entry_flow
|
||||||
from homeassistant.components.cert_expiry import config_flow
|
from homeassistant.components.cert_expiry import config_flow
|
||||||
from homeassistant.components.cert_expiry.const import DEFAULT_PORT
|
from homeassistant.components.cert_expiry.const import DEFAULT_NAME, DEFAULT_PORT
|
||||||
from homeassistant.const import CONF_PORT, CONF_NAME, CONF_HOST
|
from homeassistant.const import CONF_PORT, CONF_NAME, CONF_HOST
|
||||||
|
|
||||||
from tests.common import MockConfigEntry, mock_coro
|
from tests.common import MockConfigEntry, mock_coro
|
||||||
@ -45,7 +45,7 @@ async def test_user(hass, test_connect):
|
|||||||
{CONF_NAME: NAME, CONF_HOST: HOST, CONF_PORT: PORT}
|
{CONF_NAME: NAME, CONF_HOST: HOST, CONF_PORT: PORT}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
assert result["title"] == "cert_expiry_test_1_2_3"
|
assert result["title"] == NAME
|
||||||
assert result["data"][CONF_HOST] == HOST
|
assert result["data"][CONF_HOST] == HOST
|
||||||
assert result["data"][CONF_PORT] == PORT
|
assert result["data"][CONF_PORT] == PORT
|
||||||
|
|
||||||
@ -57,21 +57,21 @@ async def test_import(hass, test_connect):
|
|||||||
# import with only host
|
# import with only host
|
||||||
result = await flow.async_step_import({CONF_HOST: HOST})
|
result = await flow.async_step_import({CONF_HOST: HOST})
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
assert result["title"] == "ssl_certificate_expiry"
|
assert result["title"] == DEFAULT_NAME
|
||||||
assert result["data"][CONF_HOST] == HOST
|
assert result["data"][CONF_HOST] == HOST
|
||||||
assert result["data"][CONF_PORT] == DEFAULT_PORT
|
assert result["data"][CONF_PORT] == DEFAULT_PORT
|
||||||
|
|
||||||
# import with host and name
|
# import with host and name
|
||||||
result = await flow.async_step_import({CONF_HOST: HOST, CONF_NAME: NAME})
|
result = await flow.async_step_import({CONF_HOST: HOST, CONF_NAME: NAME})
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
assert result["title"] == "cert_expiry_test_1_2_3"
|
assert result["title"] == NAME
|
||||||
assert result["data"][CONF_HOST] == HOST
|
assert result["data"][CONF_HOST] == HOST
|
||||||
assert result["data"][CONF_PORT] == DEFAULT_PORT
|
assert result["data"][CONF_PORT] == DEFAULT_PORT
|
||||||
|
|
||||||
# improt with host and port
|
# improt with host and port
|
||||||
result = await flow.async_step_import({CONF_HOST: HOST, CONF_PORT: PORT})
|
result = await flow.async_step_import({CONF_HOST: HOST, CONF_PORT: PORT})
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
assert result["title"] == "ssl_certificate_expiry"
|
assert result["title"] == DEFAULT_NAME
|
||||||
assert result["data"][CONF_HOST] == HOST
|
assert result["data"][CONF_HOST] == HOST
|
||||||
assert result["data"][CONF_PORT] == PORT
|
assert result["data"][CONF_PORT] == PORT
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ async def test_import(hass, test_connect):
|
|||||||
{CONF_HOST: HOST, CONF_PORT: PORT, CONF_NAME: NAME}
|
{CONF_HOST: HOST, CONF_PORT: PORT, CONF_NAME: NAME}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
assert result["title"] == "cert_expiry_test_1_2_3"
|
assert result["title"] == NAME
|
||||||
assert result["data"][CONF_HOST] == HOST
|
assert result["data"][CONF_HOST] == HOST
|
||||||
assert result["data"][CONF_PORT] == PORT
|
assert result["data"][CONF_PORT] == PORT
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ async def test_abort_if_already_setup(hass, test_connect):
|
|||||||
{CONF_HOST: HOST, CONF_NAME: NAME, CONF_PORT: 888}
|
{CONF_HOST: HOST, CONF_NAME: NAME, CONF_PORT: 888}
|
||||||
)
|
)
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||||
assert result["title"] == "cert_expiry_test_1_2_3"
|
assert result["title"] == NAME
|
||||||
assert result["data"][CONF_HOST] == HOST
|
assert result["data"][CONF_HOST] == HOST
|
||||||
assert result["data"][CONF_PORT] == 888
|
assert result["data"][CONF_PORT] == 888
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user