Skip to content

Commit

Permalink
fix test for secure requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
farmio committed Nov 30, 2022
1 parent bc04923 commit a54cf70
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/knx/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ async def async_step_manual_tunnel(
except CommunicationError:
errors["base"] = "cannot_connect"
else:
if self._selected_tunnel.tunnelling_requires_secure and not (
if bool(self._selected_tunnel.tunnelling_requires_secure) is not (
selected_tunnelling_type == CONF_KNX_TUNNELING_TCP_SECURE
):
errors[CONF_KNX_TUNNELING_TYPE] = "unsupported_tunnel_type"
Expand Down
30 changes: 29 additions & 1 deletion tests/components/knx/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,29 @@ async def test_tunneling_setup_manual_request_description_error(
"base": "no_tunnel_discovered",
"tunneling_type": "unsupported_tunnel_type",
}
# Secure configured but not enabled on gateway
with patch(
"homeassistant.components.knx.config_flow.request_description",
return_value=_gateway_descriptor(
"192.168.0.1",
3671,
supports_tunnelling_tcp=True,
requires_secure=False,
),
):
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
{
CONF_KNX_TUNNELING_TYPE: CONF_KNX_TUNNELING_TCP_SECURE,
CONF_HOST: "192.168.0.1",
CONF_PORT: 3671,
},
)
assert result["step_id"] == "manual_tunnel"
assert result["errors"] == {
"base": "no_tunnel_discovered",
"tunneling_type": "unsupported_tunnel_type",
}
# No connection to gateway
with patch(
"homeassistant.components.knx.config_flow.request_description",
Expand Down Expand Up @@ -847,7 +870,12 @@ async def _get_menu_step(hass: HomeAssistant) -> FlowResult:

@patch(
"homeassistant.components.knx.config_flow.request_description",
return_value=_gateway_descriptor("192.168.0.1", 3675),
return_value=_gateway_descriptor(
"192.168.0.1",
3675,
supports_tunnelling_tcp=True,
requires_secure=True,
),
)
async def test_get_secure_menu_step_manual_tunnelling(
_request_description_mock,
Expand Down

0 comments on commit a54cf70

Please sign in to comment.