mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-07 14:05:28 +03:00
Some checks are pending
CI / AMD64 Build (push) Waiting to run
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
* only send monitoring notifications to users with camera access * check access to similarity search event id camera * require admin role for storage usage endpoint * check camera access for jsmpeg and birdseye cameras * tests * formatting
30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
"""Tests for camera monitoring notification authorization."""
|
|
|
|
import unittest
|
|
from types import SimpleNamespace
|
|
from unittest.mock import MagicMock
|
|
|
|
from frigate.comms.webpush import WebPushClient
|
|
|
|
|
|
class TestCameraMonitoringNotifications(unittest.TestCase):
|
|
def test_send_camera_monitoring_filters_by_camera_access(self):
|
|
client = WebPushClient.__new__(WebPushClient)
|
|
client.config = SimpleNamespace(
|
|
cameras={"front_door": SimpleNamespace(friendly_name=None)}
|
|
)
|
|
client.web_pushers = {"allowed": [], "denied": []}
|
|
client.user_cameras = {"allowed": {"front_door"}, "denied": set()}
|
|
client.check_registrations = MagicMock()
|
|
client.cleanup_registrations = MagicMock()
|
|
client.send_push_notification = MagicMock()
|
|
|
|
client.send_camera_monitoring(
|
|
{"camera": "front_door", "message": "Monitoring condition met"}
|
|
)
|
|
|
|
self.assertEqual(client.send_push_notification.call_count, 1)
|
|
self.assertEqual(
|
|
client.send_push_notification.call_args.kwargs["user"], "allowed"
|
|
)
|