refactor(api): move server key resolution into server_keys and name the tracks reply's DRM system from the licence order

This commit is contained in:
imSp4rky
2026-11-29 11:12:15 -07:00
parent 6758d9e4fa
commit 1571236991
27 changed files with 1233 additions and 958 deletions
+9 -11
View File
@@ -4,6 +4,7 @@ import pytest
import requests
from tests.remote.sessions import session_entry
from unshackle.core.api import server_keys
from unshackle.core.api.errors import APIError
from unshackle.core.api.handlers import client_session_auth, resolve_handler_proxy, scrub_track_data
from unshackle.core.remote_service import apply_session_cookies
@@ -164,16 +165,14 @@ def test_profile_rejects_paths():
def test_client_pssh_must_match_track(monkeypatch):
import uuid
from unshackle.core.api import handlers
kid, other = uuid.uuid4(), uuid.uuid4()
monkeypatch.setattr(handlers, "pssh_kids", lambda pssh, drm_type: {other} if pssh == "OTHER" else {kid})
monkeypatch.setattr(server_keys, "pssh_kids", lambda pssh, drm_type: {other} if pssh == "OTHER" else {kid})
track = SimpleNamespace(id="t1", drm=[SimpleNamespace(kids=[kid])])
handlers.require_track_pssh(track, "MINE", "widevine")
server_keys.require_track_pssh(track, "MINE", "widevine")
with pytest.raises(APIError):
handlers.require_track_pssh(track, "OTHER", "widevine")
server_keys.require_track_pssh(track, "OTHER", "widevine")
with pytest.raises(APIError):
handlers.require_track_pssh(SimpleNamespace(id="t2", drm=[]), "MINE", "widevine")
server_keys.require_track_pssh(SimpleNamespace(id="t2", drm=[]), "MINE", "widevine")
def test_output_dir_stays_under_downloads(tmp_path, monkeypatch):
@@ -244,13 +243,12 @@ def test_server_login_strips_nested_and_unlisted_secrets():
def test_track_own_pssh_passes_without_kids(monkeypatch):
from unshackle.core.api import handlers
monkeypatch.setattr(handlers, "track_pssh", lambda track, drm_type: "OWN")
monkeypatch.setattr(handlers, "pssh_kids", lambda pssh, drm_type: set())
handlers.require_track_pssh(SimpleNamespace(id="t", drm=[]), "OWN", "widevine")
monkeypatch.setattr(server_keys, "track_pssh", lambda track, drm_type: "OWN")
monkeypatch.setattr(server_keys, "pssh_kids", lambda pssh, drm_type: set())
server_keys.require_track_pssh(SimpleNamespace(id="t", drm=[]), "OWN", "widevine")
with pytest.raises(APIError):
handlers.require_track_pssh(SimpleNamespace(id="t", drm=[]), "OTHER", "widevine")
server_keys.require_track_pssh(SimpleNamespace(id="t", drm=[]), "OTHER", "widevine")
def test_download_rejects_path_profile_and_bad_output_dir(tmp_path, monkeypatch):