mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-29 12:35:13 +00:00
fix(drm): keep the input when a cbcs, ClearKey, stripe or segment decrypt fails
This commit is contained in:
@@ -13,6 +13,7 @@ Covers the correctness guards on the whole-segment AES-128-CBC path:
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
from pathlib import Path
|
||||
|
||||
import m3u8
|
||||
import pytest
|
||||
@@ -48,6 +49,22 @@ def test_valid_encrypted_segment_decrypts(tmp_path) -> None:
|
||||
assert seg.read_bytes() == plaintext
|
||||
|
||||
|
||||
def test_a_failed_swap_keeps_the_input(tmp_path, monkeypatch) -> None:
|
||||
def refuse(self, target):
|
||||
raise PermissionError(target)
|
||||
|
||||
seg = tmp_path / "0.ts"
|
||||
seg.write_bytes(encrypt(b"the quick brown fox jumps over" * 4))
|
||||
original = seg.read_bytes()
|
||||
monkeypatch.setattr(Path, "replace", refuse)
|
||||
|
||||
with pytest.raises(PermissionError):
|
||||
ClearKey(key=KEY, iv=IV).decrypt(seg)
|
||||
|
||||
assert seg.read_bytes() == original
|
||||
assert list(tmp_path.iterdir()) == [seg]
|
||||
|
||||
|
||||
def test_clear_ts_passes_through(tmp_path) -> None:
|
||||
data = clear_ts()
|
||||
seg = tmp_path / "0.ts"
|
||||
|
||||
Reference in New Issue
Block a user