From ca641a097b2a2a917048a87ac136a459b60f1a5f Mon Sep 17 00:00:00 2001 From: Erwin Douna Date: Sun, 8 Mar 2026 13:19:45 +0100 Subject: [PATCH] Fix forced VERIFY_SSL in Portainer (#165079) --- homeassistant/components/portainer/config_flow.py | 8 ++++++-- tests/components/portainer/test_config_flow.py | 12 ++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/portainer/config_flow.py b/homeassistant/components/portainer/config_flow.py index 9e8b3f14032..810a88ddd8e 100644 --- a/homeassistant/components/portainer/config_flow.py +++ b/homeassistant/components/portainer/config_flow.py @@ -159,8 +159,12 @@ class PortainerConfigFlow(ConfigFlow, domain=DOMAIN): _LOGGER.exception("Unexpected exception") errors["base"] = "unknown" else: - await self.async_set_unique_id(user_input[CONF_API_TOKEN]) - self._abort_if_unique_id_configured() + # Logic that can be reverted back once the new unique ID is in + existing_entry = await self.async_set_unique_id( + user_input[CONF_API_TOKEN] + ) + if existing_entry and existing_entry.entry_id != reconf_entry.entry_id: + return self.async_abort(reason="already_configured") return self.async_update_reload_and_abort( reconf_entry, data_updates={ diff --git a/tests/components/portainer/test_config_flow.py b/tests/components/portainer/test_config_flow.py index b606d36b997..6e82c21ad89 100644 --- a/tests/components/portainer/test_config_flow.py +++ b/tests/components/portainer/test_config_flow.py @@ -263,20 +263,28 @@ async def test_full_flow_reconfigure_unique_id( ) -> None: """Test the full flow of the config flow, this time with a known unique ID.""" mock_config_entry.add_to_hass(hass) + + other_entry = MockConfigEntry( + domain=DOMAIN, + title="Portainer other", + data=USER_INPUT_RECONFIGURE, + unique_id=USER_INPUT_RECONFIGURE[CONF_API_TOKEN], + ) + other_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"], - user_input=MOCK_USER_SETUP, + user_input=USER_INPUT_RECONFIGURE, ) assert result["type"] is FlowResultType.ABORT assert result["reason"] == "already_configured" assert mock_config_entry.data[CONF_API_TOKEN] == "test_api_token" assert mock_config_entry.data[CONF_URL] == "https://127.0.0.1:9000/" - assert mock_config_entry.data[CONF_VERIFY_SSL] is True assert len(mock_setup_entry.mock_calls) == 0