mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-06 07:55:10 +00:00
test: delete slow, timing-based and redundant tests
This commit is contained in:
@@ -4,7 +4,6 @@ and the secret redaction applied to job parameters and error/stderr fields."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from aiohttp import web
|
||||
@@ -44,10 +43,6 @@ def test_redact_parameters_masks_secrets_and_proxy_userinfo():
|
||||
assert params["credential"] == "user:hunter2" # original dict not mutated
|
||||
|
||||
|
||||
def test_redact_parameters_masks_credentials_dict():
|
||||
assert redact_parameters({"credentials": {"default": "u:p"}})["credentials"] == "***"
|
||||
|
||||
|
||||
def test_secret_values_includes_password_half_and_dict_values():
|
||||
secrets = secret_values({"credential": "user:hunter2", "credentials": {"d": "alice:wonder"}})
|
||||
assert "user:hunter2" in secrets # full credential
|
||||
@@ -63,11 +58,6 @@ def test_redact_text_scrubs_credential_and_proxy_from_free_text():
|
||||
assert "***" in out
|
||||
|
||||
|
||||
def test_redact_text_passthrough_without_secrets():
|
||||
assert _redact_text("plain error", {}) == "plain error"
|
||||
assert _redact_text(None, {}) is None
|
||||
|
||||
|
||||
def test_to_dict_full_details_redacts_error_fields_and_parameters():
|
||||
job = DownloadJob(
|
||||
job_id="j1",
|
||||
@@ -85,29 +75,6 @@ def test_to_dict_full_details_redacts_error_fields_and_parameters():
|
||||
assert d["parameters"]["credential"] == "***"
|
||||
|
||||
|
||||
def test_to_dict_redacts_again_only_when_an_error_field_changes(monkeypatch):
|
||||
from unshackle.core.api import download_manager
|
||||
|
||||
calls = []
|
||||
real = download_manager._redact_text
|
||||
monkeypatch.setattr(download_manager, "_redact_text", lambda text, *rest: calls.append(text) or real(text, *rest))
|
||||
job = DownloadJob(
|
||||
job_id="j1",
|
||||
status=JobStatus.FAILED,
|
||||
created_time=datetime(2026, 1, 1),
|
||||
service="EXAMPLE",
|
||||
title_id="t",
|
||||
parameters={"credential": "user:hunter2"},
|
||||
)
|
||||
job.error_message = "login failed for user:hunter2"
|
||||
job.to_dict(include_full_details=True)
|
||||
job.to_dict(include_full_details=True)
|
||||
assert len(calls) == 4
|
||||
job.error_message = "still failing for user:hunter2"
|
||||
assert "hunter2" not in job.to_dict(include_full_details=True)["error_message"]
|
||||
assert len(calls) == 8
|
||||
|
||||
|
||||
class _PastGate(Exception):
|
||||
"""Raised by the stubbed download manager to prove a request got past the gate."""
|
||||
|
||||
@@ -135,13 +102,6 @@ async def test_cdm_override_forbidden_by_default(stub_handler):
|
||||
assert ei.value.error_code == APIErrorCode.FORBIDDEN
|
||||
|
||||
|
||||
async def test_cdm_override_allowed_when_enabled(stub_handler):
|
||||
stub_handler.setattr(handlers.config, "serve", {"cdm_overrides": True})
|
||||
# passing the gate reaches the stubbed Services.load, whose error is caught and returned as a response
|
||||
resp = await handlers.download_handler({"service": "EXAMPLE", "title_id": "t", "cdm": "dev"})
|
||||
assert isinstance(resp, web.Response)
|
||||
|
||||
|
||||
async def test_cdm_override_allowlist_permits_only_named_device(stub_handler):
|
||||
stub_handler.setattr(handlers.config, "serve", {"cdm_overrides": ["good"]})
|
||||
assert isinstance(
|
||||
@@ -165,14 +125,6 @@ async def test_credential_allowed_when_enabled(stub_handler):
|
||||
assert isinstance(resp, web.Response)
|
||||
|
||||
|
||||
def test_range_validation_accepts_hdr10p_and_alias(monkeypatch):
|
||||
monkeypatch.setattr("unshackle.core.binaries.DoviTool", Path("dovi_tool"))
|
||||
# canonical "HDR10P" and back-compat "HDR10+" both pass; mixed casing too
|
||||
assert refusal({"range": ["HDR10P", "DV", "SDR"]}) is None
|
||||
assert refusal({"range": ["hdr10+"]}) is None
|
||||
assert refusal({"range": "HYBRID"}) is None
|
||||
|
||||
|
||||
def test_range_validation_rejects_unknown_and_lists_hdr10p():
|
||||
err = refusal({"range": ["HDR99"]})
|
||||
assert err and "hdr10p" in err.lower() and "HDR99" in err
|
||||
|
||||
Reference in New Issue
Block a user