Skip to content

NewznabClient and TorznabClient have no tests — HTTP status mapping and auth-failure paths are uncovered #459

Description

@forkwright

Finding

Neither crates/zetesis/src/client/newznab.rs nor crates/zetesis/src/client/torznab.rs contains a #[cfg(test)] module. The fetch_xml method holds several correctness-critical branches: HTTP 401/403 → AuthFailed, HTTP 429 → RateLimited (with Retry-After header parsing), cancellation, and non-2xx status falling through to a body read without an error. None of these branches is exercised by any test. The TorznabClient::download magnet-URI fast-path (starts_with("magnet:")) is likewise untested, and both the NewznabClient::download NZB body path and the TorznabClient::download torrent-file path are only reached indirectly through xml.rs tests that never touch the HTTP layer.

Evidence

crates/zetesis/src/client/newznab.rs:62 (no #[cfg(test)] anywhere in the file):

let status = response.status();

crates/zetesis/src/client/torznab.rs:62 (no #[cfg(test)] anywhere in the file):

let status = response.status();

Why this matters

The HTTP-status → error-variant mapping is the primary correctness interface of the indexer client layer. On a counter-surveillance device every indexer interaction is an outbound network exposure that must be accounted for precisely: a 401 silently unrecognized, or Retry-After parsing broken, lets the client keep hammering a hostile or rate-limiting endpoint instead of backing off — leaking a behavioral fingerprint and degrading or banning indexers without any signal. A regression in this mapping is invisible until an integration environment reveals already-degraded indexers, by which point the device has already advertised itself.

Desired correction

Add #[cfg(test)] modules to both files using wiremock or httpmock to provide a real HTTP test server. Cover: 200 OK with valid XML, 401, 403, 429 with Retry-After header, 429 without header, non-2xx body (e.g. 500), and TorznabClient::download with a magnet: URI.

Done when: all six branches in fetch_xml and the magnet-URI shortcut have at least one test exercising the expected return variant.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions