@@ -1212,6 +1212,50 @@ async def test_reconfigure_flow_success(
12121212 assert entry .data [CONF_SSL ] is True
12131213
12141214
1215+ async def test_reconfigure_flow_updates_ssl_flag_when_cert_changes (
1216+ hass : HomeAssistant , mock_setup_entry : None , mock_api_client : MagicMock
1217+ ) -> None :
1218+ """Test reconfigure flow clears SSL flag when SSL fallback succeeds."""
1219+ entry = MockConfigEntry (
1220+ domain = DOMAIN ,
1221+ title = "tower" ,
1222+ data = {
1223+ CONF_HOST : "unraid.local" ,
1224+ CONF_API_KEY : "old-key" ,
1225+ CONF_SSL : True ,
1226+ },
1227+ options = {},
1228+ unique_id = "test-uuid" ,
1229+ )
1230+ entry .add_to_hass (hass )
1231+
1232+ result = await hass .config_entries .flow .async_init (
1233+ DOMAIN ,
1234+ context = {
1235+ "source" : config_entries .SOURCE_RECONFIGURE ,
1236+ "entry_id" : entry .entry_id ,
1237+ },
1238+ )
1239+
1240+ # Simulate SSL error on first attempt and success on fallback without SSL.
1241+ mock_api_client .test_connection = AsyncMock (
1242+ side_effect = [UnraidSSLError ("SSL error" ), True ]
1243+ )
1244+
1245+ with patch (
1246+ "custom_components.unraid.config_flow.UnraidClient" ,
1247+ return_value = mock_api_client ,
1248+ ):
1249+ result2 = await hass .config_entries .flow .async_configure (
1250+ result ["flow_id" ],
1251+ {CONF_HOST : "192.168.1.100" , CONF_API_KEY : "new-key" },
1252+ )
1253+
1254+ assert result2 ["type" ] is FlowResultType .ABORT
1255+ assert result2 ["reason" ] == "reconfigure_successful"
1256+ assert entry .data [CONF_HOST ] == "192.168.1.100"
1257+ assert entry .data [CONF_API_KEY ] == "new-key"
1258+ assert entry .data [CONF_SSL ] is False
12151259async def test_reconfigure_flow_connection_error (
12161260 hass : HomeAssistant , mock_setup_entry : None
12171261) -> None :
0 commit comments