Catch dhcp setup permission errors sooner (#47639)

This solves an unexpected thread exception on macs when running as
a user intead of root
This commit is contained in:
J. Nick Koston
2021-03-08 13:15:22 -10:00
committed by GitHub
parent 10eca5b986
commit 1dd35ff059
2 changed files with 14 additions and 14 deletions

View File

@@ -281,7 +281,7 @@ async def test_setup_and_stop(hass):
await hass.async_block_till_done()
with patch("homeassistant.components.dhcp.AsyncSniffer.start") as start_call, patch(
"homeassistant.components.dhcp._verify_l2socket_creation_permission",
"homeassistant.components.dhcp._verify_l2socket_setup",
), patch(
"homeassistant.components.dhcp.compile_filter",
):
@@ -307,7 +307,7 @@ async def test_setup_fails_as_root(hass, caplog):
wait_event = threading.Event()
with patch("os.geteuid", return_value=0), patch(
"homeassistant.components.dhcp._verify_l2socket_creation_permission",
"homeassistant.components.dhcp._verify_l2socket_setup",
side_effect=Scapy_Exception,
):
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
@@ -330,7 +330,7 @@ async def test_setup_fails_non_root(hass, caplog):
await hass.async_block_till_done()
with patch("os.geteuid", return_value=10), patch(
"homeassistant.components.dhcp._verify_l2socket_creation_permission",
"homeassistant.components.dhcp._verify_l2socket_setup",
side_effect=Scapy_Exception,
):
hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED)
@@ -351,9 +351,7 @@ async def test_setup_fails_with_broken_libpcap(hass, caplog):
)
await hass.async_block_till_done()
with patch(
"homeassistant.components.dhcp._verify_l2socket_creation_permission",
), patch(
with patch("homeassistant.components.dhcp._verify_l2socket_setup",), patch(
"homeassistant.components.dhcp.compile_filter",
side_effect=ImportError,
) as compile_filter, patch(