mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-29 20:45:11 +00:00
refactor(remote): hold who licenses a remote session as one licensing mode
This commit is contained in:
@@ -20,7 +20,7 @@ from unshackle.core.api.errors import APIError
|
||||
from unshackle.core.api.input_bridge import InputBridge
|
||||
from unshackle.core.cdm.client_relay import ClientDeviceCdm, answer_cdm_call
|
||||
from unshackle.core.launch import served_context
|
||||
from unshackle.core.remote_protocol import APIErrorCode, AuthStatus
|
||||
from unshackle.core.remote_protocol import APIErrorCode, AuthStatus, LicensingMode, Licensor
|
||||
from unshackle.core.run_plan import served_plan
|
||||
from unshackle.core.utils.click_types import ContextData
|
||||
|
||||
@@ -244,7 +244,7 @@ def test_a_lent_server_device_marks_the_stand_in() -> None:
|
||||
|
||||
|
||||
def test_a_lent_device_session_never_licenses_live() -> None:
|
||||
refusal = handlers.live_licence_refusal(session_entry(server_device=True, server_cdm=False), object())
|
||||
refusal = handlers.live_licence_refusal(session_entry(licensing=LicensingMode(Licensor.LENT_DEVICE)), object())
|
||||
assert refusal is not None
|
||||
assert refusal.details == {"reason": "server_device"}
|
||||
|
||||
@@ -252,7 +252,7 @@ def test_a_lent_device_session_never_licenses_live() -> None:
|
||||
def test_a_vault_only_miss_raises_the_refusal(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(handlers, "check_vaults", lambda kids, service, **_: None)
|
||||
monkeypatch.setattr(handlers, "ensure_track_drm", lambda *a, **k: None)
|
||||
refusal = handlers.live_licence_refusal(session_entry(server_device=True), object())
|
||||
refusal = handlers.live_licence_refusal(session_entry(licensing=LicensingMode(Licensor.LENT_DEVICE)), object())
|
||||
with pytest.raises(APIError) as caught:
|
||||
handlers.handle_single_server_cdm(
|
||||
SimpleNamespace(),
|
||||
@@ -434,8 +434,7 @@ def test_a_client_map_entry_replaces_the_server_entry_of_the_same_number() -> No
|
||||
|
||||
def lent_device_session() -> Any:
|
||||
return session_entry(
|
||||
server_cdm=False,
|
||||
server_device=True,
|
||||
licensing=LicensingMode(Licensor.LENT_DEVICE),
|
||||
client_auth=True,
|
||||
cache_tag="_sessions/abc/sid/EXAMPLE1",
|
||||
service_instance=SimpleNamespace(
|
||||
@@ -488,9 +487,7 @@ def test_a_lent_device_without_the_vault_grant_asks_the_server_for_no_key() -> N
|
||||
svc = object.__new__(RemoteService)
|
||||
svc.log = logging.getLogger("test")
|
||||
svc._session_id = "sid"
|
||||
svc._server_cdm = True
|
||||
svc._server_device = True
|
||||
svc._local_vaults_only = True
|
||||
svc.licensing = LicensingMode(Licensor.LENT_DEVICE)
|
||||
svc.client_licensed = set()
|
||||
svc.deferred_refusals = {}
|
||||
svc.client = SimpleNamespace(post=lambda *a, **k: pytest.fail("the server refuses every key request"))
|
||||
@@ -544,7 +541,11 @@ def test_cancel_wakes_a_call_waiting_for_a_client() -> None:
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("fields", "forbidden"),
|
||||
[({"server_cdm": False}, True), ({"server_cdm": False, "server_vault": True}, False), ({}, False)],
|
||||
[
|
||||
({"licensing": LicensingMode(Licensor.CLIENT_DEVICE)}, True),
|
||||
({"licensing": LicensingMode(Licensor.CLIENT_DEVICE, server_vault=True)}, False),
|
||||
({}, False),
|
||||
],
|
||||
)
|
||||
def test_the_server_licence_route_follows_the_licensing_mode(
|
||||
monkeypatch: pytest.MonkeyPatch, fields: dict, forbidden: bool
|
||||
|
||||
Reference in New Issue
Block a user