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
+1 -29
View File
@@ -12,7 +12,7 @@ from aiohttp import web
from click.testing import CliRunner
from unshackle.commands.serve import serve
from unshackle.core.api.stats import SeqRing, cdm_calls, cdm_log_middleware, cdm_sessions, key_id
from unshackle.core.api.stats import SeqRing, cdm_calls, cdm_log_middleware, key_id
from unshackle.core.config import config
pytestmark = pytest.mark.unit
@@ -202,30 +202,6 @@ async def test_refusals_are_recorded_with_their_message(aiohttp_client, serve_ap
assert page["sessions"] == [] and "wrong-key" not in json.dumps(page)
async def test_gzipped_refusal_is_read_and_capped(aiohttp_client, serve_app) -> None:
"""compression_middleware runs inside the log middleware, so a long refusal arrives as gzip."""
client = await aiohttp_client(serve_app)
device = "d" * 400
resp = await client.get(f"/{device}/open", headers={**USER, "Accept-Encoding": "gzip"})
assert resp.status == 403 and resp.headers["Content-Encoding"] == "gzip"
(record,) = (await cdm_log(client))["records"]
assert record["device"] == device[:255] and len(record["error"]) == 300
assert record["error"].startswith("Device 'ddd")
async def test_refused_call_leaves_the_request_body_unread(aiohttp_client, serve_app) -> None:
"""A 401 is decided before the handler, so the body stays unread: no cost, and no session id, for an unknown key."""
client = await aiohttp_client(serve_app)
body = {"session_id": "ab" * 16, "license_message": LICENCE}
assert (
await client.post("/chrome_l3/parse_license", headers={"X-Secret-Key": "wrong-key"}, json=body)
).status == 401
assert (await client.post("/chrome_l3/parse_license", headers=USER, json=body)).status == 400
refused, unopened = (await cdm_log(client))["records"]
assert refused["status"] == 401 and refused["session_id"] is None
assert unopened["status"] == 400 and unopened["session_id"] == "ab" * 16
async def test_raised_http_exception_is_recorded_with_its_status(aiohttp_client) -> None:
"""aiohttp answers a raised ``HTTPException`` itself, so the record carries that status, not 500."""
@@ -295,7 +271,3 @@ def test_call_log_keeps_the_newest_and_counts_on() -> None:
log.append({"op": op})
assert [(r["seq"], r["op"]) for r in log.since()] == [(2, "get_keys"), (3, "close")]
assert log.since(2) == [{"seq": 3, "op": "close"}] and log.seq == 3
def test_sessions_snapshot_is_empty_without_a_cdm() -> None:
assert cdm_sessions(web.Application()) == []