mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Auto lower case username for Schlage auth flows (#128730)
This commit is contained in:
parent
7fa359764d
commit
0b3f660626
@ -31,7 +31,7 @@ class SchlageConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle the initial step."""
|
||||
if user_input is None:
|
||||
return self._show_user_form({})
|
||||
username = user_input[CONF_USERNAME]
|
||||
username = user_input[CONF_USERNAME].lower()
|
||||
password = user_input[CONF_PASSWORD]
|
||||
user_id, errors = await self.hass.async_add_executor_job(
|
||||
_authenticate, username, password
|
||||
@ -40,7 +40,13 @@ class SchlageConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
return self._show_user_form(errors)
|
||||
|
||||
await self.async_set_unique_id(user_id)
|
||||
return self.async_create_entry(title=username, data=user_input)
|
||||
return self.async_create_entry(
|
||||
title=username,
|
||||
data={
|
||||
CONF_USERNAME: username,
|
||||
CONF_PASSWORD: password,
|
||||
},
|
||||
)
|
||||
|
||||
def _show_user_form(self, errors: dict[str, str]) -> ConfigFlowResult:
|
||||
"""Show the user form."""
|
||||
|
@ -15,8 +15,18 @@ from tests.common import MockConfigEntry
|
||||
pytestmark = pytest.mark.usefixtures("mock_setup_entry")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"username",
|
||||
[
|
||||
"test-username",
|
||||
"TEST-USERNAME",
|
||||
],
|
||||
)
|
||||
async def test_form(
|
||||
hass: HomeAssistant, mock_setup_entry: AsyncMock, mock_pyschlage_auth: Mock
|
||||
hass: HomeAssistant,
|
||||
mock_setup_entry: AsyncMock,
|
||||
mock_pyschlage_auth: Mock,
|
||||
username: str,
|
||||
) -> None:
|
||||
"""Test we get the form."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@ -28,7 +38,7 @@ async def test_form(
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{
|
||||
"username": "test-username",
|
||||
"username": username,
|
||||
"password": "test-password",
|
||||
},
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user