test: delete slow, timing-based and redundant tests

This commit is contained in:
imSp4rky
2026-12-05 15:20:05 -07:00
parent 783a2fc185
commit 3a0a74e694
292 changed files with 153 additions and 15174 deletions
-50
View File
@@ -15,7 +15,6 @@ from __future__ import annotations
import base64
from pathlib import Path
import m3u8
import pytest
import requests
from Cryptodome.Cipher import AES
@@ -179,29 +178,6 @@ def test_raw_data_uri_key_materialises_and_validates() -> None:
assert drm.key == KEY
def test_raw_data_uri_key_wrong_length_rejected() -> None:
with pytest.raises(ValueError, match="Unexpected Length"):
ClearKey.from_m3u_key(data_key(b"\x01" * 8, base64_encoded=False))
def test_data_uri_split_tolerates_commas_in_payload() -> None:
# base64 with padding contains no comma, but the split must only break on the first comma
# so a payload that itself contains a comma is not truncated. Encode a 16-byte key whose
# base64 happens to be split-safe, and assert the mediatype comma is the only split point.
raw = bytes(range(16))
b64 = base64.b64encode(raw).decode("ascii")
key = Key(
method="AES-128",
uri=f"data:application/octet-stream;base64,{b64}",
base_uri="",
keyformat=None,
keyformatversions=None,
iv=None,
)
drm = ClearKey.from_m3u_key(key)
assert drm.key == raw
SEQ_PLAYLIST = """#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:6
@@ -217,29 +193,3 @@ seg2.ts
seg3.ts
#EXT-X-ENDLIST
"""
def test_sequence_number_iv_uses_absolute_media_sequence() -> None:
"""IV must be the segment's absolute media sequence number, not the download index.
Mirrors the derivation in ``HLS.download_track``: filtered segments are dropped, the
surviving segments are named by post-filter download index, and the IV comes from the
wanted segment's ``media_sequence`` (EXT-X-MEDIA-SEQUENCE + absolute position).
"""
master = m3u8.loads(SEQ_PLAYLIST)
# media sequence numbers are the offset (100) plus absolute playlist position.
assert [s.media_sequence for s in master.segments] == [100, 101, 102, 103]
# Drop an early segment (index 1), as an OnSegmentFilter would.
unwanted = {master.segments[1]}
wanted_segments = [s for s in master.segments if s not in unwanted]
# download index 1 is the SECOND surviving segment (absolute seq 102), not 101.
download_i = 1
seq = wanted_segments[download_i].media_sequence
assert seq == 102
iv = int(seq).to_bytes(16, "big")
assert iv == (102).to_bytes(16, "big")
# the old download-index derivation would have produced the wrong IV (100 + 1 = 101)
assert iv != (100 + download_i).to_bytes(16, "big")