mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-06 07:55:10 +00:00
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
import pytest
|
|
|
|
from unshackle.core.drm.playready import PlayReady
|
|
from unshackle.core.drm.playready_errors import describe, is_revocation
|
|
|
|
|
|
@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
|
|
|
|
|
|
@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
|