mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-29 20:45:11 +00:00
refactor(drm): read PlayReady result codes from pyplayready DrmResult and drop the hand-copied table
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
from collections import Counter
|
||||
|
||||
import pytest
|
||||
from pyplayready.misc.drmresults import DrmResult
|
||||
|
||||
from unshackle.core.drm.playready import PlayReady
|
||||
from unshackle.core.drm.playready_errors import REVOCATION_CODES, describe, is_revocation
|
||||
|
||||
|
||||
def test_only_oem_code_repeats_upstream() -> None:
|
||||
counts = Counter(m.value[0] for m in DrmResult)
|
||||
assert [code for code, n in counts.items() if n > 1] == [0x8004DFF]
|
||||
|
||||
|
||||
def test_revocation_codes() -> None:
|
||||
assert REVOCATION_CODES == {0x8004C065, 0x8004C053, 0x8004C07D}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("code", [0x8004C065, -2147172251, 0x8004C053, 0x8004C07D])
|
||||
def test_is_revocation(code: int) -> None:
|
||||
assert is_revocation(code)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("code", [0x8004C006, 0x8004A013, 0x8004C0C4, 0x8004C0C2, -1021])
|
||||
def test_is_not_revocation(code: int) -> None:
|
||||
assert not is_revocation(code)
|
||||
|
||||
|
||||
def test_describe_signed_and_unsigned() -> None:
|
||||
text = "DRM_E_DEVCERT_REVOKED (0x8004C065): The device certificate given to DRM is revoked."
|
||||
assert describe(0x8004C065) == describe(-2147172251) == text
|
||||
|
||||
|
||||
def test_describe_uses_upstream_name() -> None:
|
||||
assert describe(0x8004C006) == "DRM_E_INVALID_LICENSE (0x8004C006): The license is invalid"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("code", "text"),
|
||||
[
|
||||
(0x80041100, "DRM_E_CH_BASECODE (0x80041100)"),
|
||||
(0x80048000, "DRM_E_LEGACY_BASECODE (0x80048000)"),
|
||||
(0x8004DFFC, "DRM_E_OEM_CONSTRAINT_1_FAIL (0x8004DFFC): Failed while OEM CONSTRAINT-1 check"),
|
||||
(0x8004DFFF, "DRM_E_HDCP_NON_SECURE (0x8004DFFF): Attempt to play back through insecure HDMI output path"),
|
||||
],
|
||||
)
|
||||
def test_describe_local_codes(code: int, text: str) -> None:
|
||||
assert describe(code) == text
|
||||
|
||||
|
||||
@pytest.mark.parametrize("code", [-1021, 0x08004DFF])
|
||||
def test_describe_unknown(code: int) -> None:
|
||||
assert describe(code) is None
|
||||
|
||||
|
||||
def test_detect_revocation_from_soap_body() -> None:
|
||||
body = "<soap:Fault><detail><StatusCode>0x8004C065</StatusCode></detail></soap:Fault>"
|
||||
assert PlayReady.detect_revocation(body) == describe(0x8004C065)
|
||||
|
||||
|
||||
def test_detect_revocation_from_signed_code() -> None:
|
||||
assert PlayReady.detect_revocation("licence error -2147172269") == describe(0x8004C053)
|
||||
|
||||
|
||||
def test_detect_revocation_ignores_other_codes() -> None:
|
||||
assert PlayReady.detect_revocation("<StatusCode>0x8004C006</StatusCode>") is None
|
||||
Reference in New Issue
Block a user