From 1ca701dda45fa56682350e80bd91221744cd78ba Mon Sep 17 00:00:00 2001 From: Erwin Douna Date: Tue, 30 Sep 2025 21:36:04 +0200 Subject: [PATCH] Portainer fix CONF_VERIFY_SSL (#153269) Co-authored-by: Robert Resch --- homeassistant/components/portainer/__init__.py | 5 +++++ tests/components/portainer/test_init.py | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/portainer/__init__.py b/homeassistant/components/portainer/__init__.py index ad57e66186d..79f7c02e4ba 100644 --- a/homeassistant/components/portainer/__init__.py +++ b/homeassistant/components/portainer/__init__.py @@ -57,4 +57,9 @@ async def async_migrate_entry(hass: HomeAssistant, entry: PortainerConfigEntry) data[CONF_API_TOKEN] = data.pop(CONF_API_KEY) hass.config_entries.async_update_entry(entry=entry, data=data, version=2) + if entry.version < 3: + data = dict(entry.data) + data[CONF_VERIFY_SSL] = True + hass.config_entries.async_update_entry(entry=entry, data=data, version=3) + return True diff --git a/tests/components/portainer/test_init.py b/tests/components/portainer/test_init.py index 00b4d5940e9..4e661e22505 100644 --- a/tests/components/portainer/test_init.py +++ b/tests/components/portainer/test_init.py @@ -11,7 +11,13 @@ import pytest from homeassistant.components.portainer.const import DOMAIN from homeassistant.config_entries import ConfigEntryState -from homeassistant.const import CONF_API_KEY, CONF_API_TOKEN, CONF_HOST, CONF_URL +from homeassistant.const import ( + CONF_API_KEY, + CONF_API_TOKEN, + CONF_HOST, + CONF_URL, + CONF_VERIFY_SSL, +) from homeassistant.core import HomeAssistant from . import setup_integration @@ -40,8 +46,8 @@ async def test_setup_exceptions( assert mock_config_entry.state == expected_state -async def test_v1_migration(hass: HomeAssistant) -> None: - """Test migration from v1 to v2 config entry.""" +async def test_migrations(hass: HomeAssistant) -> None: + """Test migration from v1 config entry.""" entry = MockConfigEntry( domain=DOMAIN, data={ @@ -52,11 +58,14 @@ async def test_v1_migration(hass: HomeAssistant) -> None: version=1, ) entry.add_to_hass(hass) + assert entry.version == 1 + assert CONF_VERIFY_SSL not in entry.data await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() - assert entry.version == 2 + assert entry.version == 3 assert CONF_HOST not in entry.data assert CONF_API_KEY not in entry.data assert entry.data[CONF_URL] == "http://test_host" assert entry.data[CONF_API_TOKEN] == "test_key" + assert entry.data[CONF_VERIFY_SSL] is True