Fix Pro config SSOT, event FSM, FFmpeg error tiers, relay heartbeat, and ingest auth while keeping relay snapshot, quality guard, and event hub hidden in the UI. Co-authored-by: Cursor <cursoragent@cursor.com>
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
import os
|
|
import unittest
|
|
from unittest import mock
|
|
|
|
from src.youtube_ingest_auth import ingest_auth_required, verify_ingest_payload
|
|
|
|
|
|
class YoutubeIngestAuthTests(unittest.TestCase):
|
|
def test_auth_disabled_without_token(self) -> None:
|
|
with mock.patch.dict(os.environ, {"YOUTUBE_INGEST_REQUIRE_AUTH": "0"}, clear=False):
|
|
self.assertFalse(ingest_auth_required())
|
|
ok, reason = verify_ingest_payload({})
|
|
self.assertTrue(ok)
|
|
self.assertEqual(reason, "")
|
|
|
|
def test_auth_accepts_matching_token(self) -> None:
|
|
with mock.patch.dict(
|
|
os.environ,
|
|
{"YOUTUBE_INGEST_TOKEN": "secret-token", "YOUTUBE_INGEST_REQUIRE_AUTH": "1"},
|
|
clear=False,
|
|
):
|
|
ok, reason = verify_ingest_payload({"ingest_token": "secret-token"})
|
|
self.assertTrue(ok)
|
|
self.assertEqual(reason, "")
|
|
|
|
def test_auth_rejects_missing_token(self) -> None:
|
|
with mock.patch.dict(
|
|
os.environ,
|
|
{"YOUTUBE_INGEST_TOKEN": "secret-token", "YOUTUBE_INGEST_REQUIRE_AUTH": "1"},
|
|
clear=False,
|
|
):
|
|
ok, reason = verify_ingest_payload({})
|
|
self.assertFalse(ok)
|
|
self.assertIn("invalid", reason.lower())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|