mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 14:27:07 +00:00
Add reconfiguration to azure_storage (#139414)
* Add reauthentication to azure_storage * Add reconfigure to azure_storage * iqs * update string * ruff
This commit is contained in:
parent
8c98cede60
commit
df59adf5d1
@ -120,3 +120,41 @@ class AzureStorageConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
),
|
),
|
||||||
errors=errors,
|
errors=errors,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
async def async_step_reconfigure(
|
||||||
|
self, user_input: dict[str, Any] | None = None
|
||||||
|
) -> ConfigFlowResult:
|
||||||
|
"""Reconfigure the entry."""
|
||||||
|
errors: dict[str, str] = {}
|
||||||
|
reconfigure_entry = self._get_reconfigure_entry()
|
||||||
|
|
||||||
|
if user_input is not None:
|
||||||
|
container_client = ContainerClient(
|
||||||
|
account_url=self.get_account_url(
|
||||||
|
reconfigure_entry.data[CONF_ACCOUNT_NAME]
|
||||||
|
),
|
||||||
|
container_name=user_input[CONF_CONTAINER_NAME],
|
||||||
|
credential=user_input[CONF_STORAGE_ACCOUNT_KEY],
|
||||||
|
transport=AioHttpTransport(session=async_get_clientsession(self.hass)),
|
||||||
|
)
|
||||||
|
errors = await self.validate_config(container_client)
|
||||||
|
if not errors:
|
||||||
|
return self.async_update_reload_and_abort(
|
||||||
|
reconfigure_entry,
|
||||||
|
data={**reconfigure_entry.data, **user_input},
|
||||||
|
)
|
||||||
|
return self.async_show_form(
|
||||||
|
data_schema=vol.Schema(
|
||||||
|
{
|
||||||
|
vol.Required(
|
||||||
|
CONF_CONTAINER_NAME,
|
||||||
|
default=reconfigure_entry.data[CONF_CONTAINER_NAME],
|
||||||
|
): str,
|
||||||
|
vol.Required(
|
||||||
|
CONF_STORAGE_ACCOUNT_KEY,
|
||||||
|
default=reconfigure_entry.data[CONF_STORAGE_ACCOUNT_KEY],
|
||||||
|
): str,
|
||||||
|
}
|
||||||
|
),
|
||||||
|
errors=errors,
|
||||||
|
)
|
||||||
|
@ -121,7 +121,7 @@ rules:
|
|||||||
status: exempt
|
status: exempt
|
||||||
comment: |
|
comment: |
|
||||||
This integration does not have entities.
|
This integration does not have entities.
|
||||||
reconfiguration-flow: todo
|
reconfiguration-flow: done
|
||||||
repair-issues: done
|
repair-issues: done
|
||||||
stale-devices:
|
stale-devices:
|
||||||
status: exempt
|
status: exempt
|
||||||
|
@ -29,11 +29,24 @@
|
|||||||
},
|
},
|
||||||
"description": "Provide a new storage account key.",
|
"description": "Provide a new storage account key.",
|
||||||
"title": "Reauthenticate Azure storage account"
|
"title": "Reauthenticate Azure storage account"
|
||||||
|
},
|
||||||
|
"reconfigure": {
|
||||||
|
"data": {
|
||||||
|
"container_name": "[%key:component::azure_storage::config::step::user::data::container_name%]",
|
||||||
|
"storage_account_key": "[%key:component::azure_storage::config::step::user::data::storage_account_key%]"
|
||||||
|
},
|
||||||
|
"data_description": {
|
||||||
|
"container_name": "[%key:component::azure_storage::config::step::user::data_description::container_name%]",
|
||||||
|
"storage_account_key": "[%key:component::azure_storage::config::step::user::data_description::storage_account_key%]"
|
||||||
|
},
|
||||||
|
"description": "Change the settings of the Azure storage integration.",
|
||||||
|
"title": "Reconfigure Azure storage account"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"abort": {
|
"abort": {
|
||||||
"already_configured": "[%key:common::config_flow::abort::already_configured_account%]",
|
"already_configured": "[%key:common::config_flow::abort::already_configured_account%]",
|
||||||
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]"
|
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]",
|
||||||
|
"reconfigure_successful": "[%key:common::config_flow::abort::reconfigure_successful%]"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"issues": {
|
"issues": {
|
||||||
|
@ -172,3 +172,27 @@ async def test_reauth_flow_errors(
|
|||||||
**USER_INPUT,
|
**USER_INPUT,
|
||||||
CONF_STORAGE_ACCOUNT_KEY: "new_key",
|
CONF_STORAGE_ACCOUNT_KEY: "new_key",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async def test_reconfigure_flow(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
mock_setup_entry: AsyncMock,
|
||||||
|
mock_config_entry: MockConfigEntry,
|
||||||
|
) -> None:
|
||||||
|
"""Test that the reconfigure flow works."""
|
||||||
|
|
||||||
|
mock_config_entry.add_to_hass(hass)
|
||||||
|
result = await mock_config_entry.start_reconfigure_flow(hass)
|
||||||
|
|
||||||
|
assert result["type"] is FlowResultType.FORM
|
||||||
|
assert result["step_id"] == "reconfigure"
|
||||||
|
|
||||||
|
result = await hass.config_entries.flow.async_configure(
|
||||||
|
result["flow_id"], {CONF_CONTAINER_NAME: "new_container"}
|
||||||
|
)
|
||||||
|
assert result["type"] is FlowResultType.ABORT
|
||||||
|
assert result["reason"] == "reconfigure_successful"
|
||||||
|
assert mock_config_entry.data == {
|
||||||
|
**USER_INPUT,
|
||||||
|
CONF_CONTAINER_NAME: "new_container",
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user