fix(drm): keep the input when a cbcs, ClearKey, stripe or segment decrypt fails

This commit is contained in:
imSp4rky
2026-11-28 18:27:40 -07:00
parent 79cc16d290
commit 5a2680d63d
8 changed files with 214 additions and 36 deletions
+17
View File
@@ -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"