From ac467d0b3fa529b588d1505addf3cf5f5b63cf6f Mon Sep 17 00:00:00 2001 From: Quentame Date: Mon, 21 Oct 2019 14:30:49 +0200 Subject: [PATCH] Not slugify cert_expiry name (#28055) --- .../components/cert_expiry/config_flow.py | 10 +++++----- tests/components/cert_expiry/test_config_flow.py | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/homeassistant/components/cert_expiry/config_flow.py b/homeassistant/components/cert_expiry/config_flow.py index d73762ce882..43931fe5830 100644 --- a/homeassistant/components/cert_expiry/config_flow.py +++ b/homeassistant/components/cert_expiry/config_flow.py @@ -5,7 +5,6 @@ import voluptuous as vol from homeassistant import config_entries from homeassistant.const import CONF_PORT, CONF_NAME, CONF_HOST from homeassistant.core import HomeAssistant, callback -from homeassistant.util import slugify from .const import DOMAIN, DEFAULT_PORT, DEFAULT_NAME from .helper import get_cert @@ -62,11 +61,12 @@ class CertexpiryConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): self._errors[CONF_HOST] = "host_port_exists" else: 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( - 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: user_input = {} diff --git a/tests/components/cert_expiry/test_config_flow.py b/tests/components/cert_expiry/test_config_flow.py index f44e65512e3..988f3e97106 100644 --- a/tests/components/cert_expiry/test_config_flow.py +++ b/tests/components/cert_expiry/test_config_flow.py @@ -5,7 +5,7 @@ from unittest.mock import patch from homeassistant import data_entry_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 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} ) 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_PORT] == PORT @@ -57,21 +57,21 @@ async def test_import(hass, test_connect): # import with only host result = await flow.async_step_import({CONF_HOST: HOST}) 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_PORT] == DEFAULT_PORT # import with host and 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["title"] == "cert_expiry_test_1_2_3" + assert result["title"] == NAME assert result["data"][CONF_HOST] == HOST assert result["data"][CONF_PORT] == DEFAULT_PORT # improt with host and 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["title"] == "ssl_certificate_expiry" + assert result["title"] == DEFAULT_NAME assert result["data"][CONF_HOST] == HOST 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} ) 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_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} ) 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_PORT] == 888