feat(drm)!: load DRM systems beyond the built-ins from plugins in directories.plugins

This commit is contained in:
imSp4rky
2026-12-03 15:51:42 -07:00
parent f8a248a29e
commit e9adc50594
65 changed files with 1651 additions and 2526 deletions
@@ -19,7 +19,7 @@ from tests.remote.key_source import install_reply, one_title, remote_keys
from tests.remote.sessions import hold_session, session_entry
from unshackle.core.api import handlers, server_keys
from unshackle.core.api.errors import APIError
from unshackle.core.drm import BlowfishStripe, ClearKeyCTR
from unshackle.core.drm import ClearKeyCTR, CustomDRM
from unshackle.core.drm.cenc import drm_stub
from unshackle.core.remote_protocol import LicensingMode, Licensor
from unshackle.core.remote_service import RemoteError, RemoteService, held_keys
@@ -212,12 +212,13 @@ async def test_batch_asks_again_when_a_cached_vault_answer_lacks_the_track_kid(m
@pytest.mark.parametrize(
("drm", "head"),
[(["drm"], b"head"), ([], None), ([BlowfishStripe(bytes(16))], None), ([KEYED_CIPHER], None)],
ids=["with-drm", "clear", "stripe", "ctr"],
[(["drm"], b"head"), ([], None), (["held-plugin"], None), ([KEYED_CIPHER], None)],
ids=["with-drm", "clear", "held-plugin", "ctr"],
)
def test_the_server_reads_the_head_of_a_one_file_track_with_drm(drm, head):
def test_the_server_reads_the_head_of_a_one_file_track_with_drm(example_plugins, drm, head):
from unshackle.core.tracks import Video
drm = [CustomDRM("other", data={"key": "00" * 16}) if d == "held-plugin" else d for d in drm]
fetched: list = []
track = SimpleNamespace(
id="v",
@@ -435,9 +436,9 @@ async def batch_answer(monkeypatch, track, request=None, licensing=None):
return json.loads(resp.body)
async def test_a_stripe_cipher_that_holds_its_key_is_never_licensed(monkeypatch):
"""A track whose only DRM is a stripe cipher that holds its key is named as clear and licensed by nothing."""
cipher = BlowfishStripe(bytes(16))
async def test_a_plugin_cipher_that_holds_its_key_is_never_licensed(monkeypatch, example_plugins):
"""A track whose only DRM is a plugin DRM that holds its key is named as clear and licensed by nothing."""
cipher = CustomDRM("other", data={"key": "00" * 16})
track = SimpleNamespace(id="aud", drm=[cipher])
body = await batch_answer(monkeypatch, track)