mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-10-15 11:12:49 +03:00
Restore the environment after go2rtc exec override tests
Tests that removed or set GO2RTC_ALLOW_ARBITRARY_EXEC did not restore a value that was already present, so later tests could run with a changed security setting. They now use patch.dict on os.environ. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
20962bb12d
commit
3dad2605db
@@ -56,6 +56,9 @@ class TestConfigGo2rtcStreamRestrictions(BaseTestHttp):
|
|||||||
find_patch.start()
|
find_patch.start()
|
||||||
self.addCleanup(find_patch.stop)
|
self.addCleanup(find_patch.stop)
|
||||||
|
|
||||||
|
env_patch = patch.dict(os.environ)
|
||||||
|
env_patch.start()
|
||||||
|
self.addCleanup(env_patch.stop)
|
||||||
os.environ.pop("GO2RTC_ALLOW_ARBITRARY_EXEC", None)
|
os.environ.pop("GO2RTC_ALLOW_ARBITRARY_EXEC", None)
|
||||||
|
|
||||||
def _read_config(self) -> str:
|
def _read_config(self) -> str:
|
||||||
|
|||||||
@@ -232,6 +232,9 @@ class TestEnvVars(unittest.TestCase):
|
|||||||
"""The go2rtc exec override cannot be enabled from the config."""
|
"""The go2rtc exec override cannot be enabled from the config."""
|
||||||
from frigate.util.services import is_go2rtc_arbitrary_exec_allowed
|
from frigate.util.services import is_go2rtc_arbitrary_exec_allowed
|
||||||
|
|
||||||
|
env_patch = patch.dict(os.environ)
|
||||||
|
env_patch.start()
|
||||||
|
self.addCleanup(env_patch.stop)
|
||||||
os.environ.pop("GO2RTC_ALLOW_ARBITRARY_EXEC", None)
|
os.environ.pop("GO2RTC_ALLOW_ARBITRARY_EXEC", None)
|
||||||
ctx = self._make_context(install=True)
|
ctx = self._make_context(install=True)
|
||||||
with patch("frigate.util.services.os.path.isfile", return_value=False):
|
with patch("frigate.util.services.os.path.isfile", return_value=False):
|
||||||
@@ -243,10 +246,10 @@ class TestEnvVars(unittest.TestCase):
|
|||||||
|
|
||||||
def test_install_keeps_container_go2rtc_exec_override(self):
|
def test_install_keeps_container_go2rtc_exec_override(self):
|
||||||
"""An override set in the container environment is left untouched."""
|
"""An override set in the container environment is left untouched."""
|
||||||
os.environ["GO2RTC_ALLOW_ARBITRARY_EXEC"] = "true"
|
|
||||||
ctx = self._make_context(install=True)
|
ctx = self._make_context(install=True)
|
||||||
validate_env_vars({"GO2RTC_ALLOW_ARBITRARY_EXEC": "false"}, ctx)
|
with patch.dict(os.environ, {"GO2RTC_ALLOW_ARBITRARY_EXEC": "true"}):
|
||||||
self.assertEqual(os.environ.get("GO2RTC_ALLOW_ARBITRARY_EXEC"), "true")
|
validate_env_vars({"GO2RTC_ALLOW_ARBITRARY_EXEC": "false"}, ctx)
|
||||||
|
self.assertEqual(os.environ.get("GO2RTC_ALLOW_ARBITRARY_EXEC"), "true")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user