mock-nexus 0.1.0

Mock Sonatype Nexus raw server with a failure-scenario table for conformance tests
Documentation

mock-nexus

A mock Sonatype Nexus raw server with a failure-scenario table. It is the shared conformance fixture: the Rust test suites, a human debugging a client and external test suites all drive the exact same list of scenarios.

Run

cargo run -p mock-nexus -- atomic --port 8080
# prints: listening http://127.0.0.1:8080

Point any client at the printed address — nxr, your own code, a curl loop.

Scenarios

Scenario Behavior
atomic the correct server: PUT/GET/HEAD, Range: bytes=N- resume (206/416), 404 on unknown paths
partial-put cuts the first PUT body short and closes the connection
drop-connection resets the first request per path after reading its headers
slow writes response bodies in small delayed chunks
foreign-marker stores markers with a foreign digest
markerless accepts markers but silently drops them
auth-401 requires Authorization: Basic <base64 user:pass>
doc-drift diverges GET version.json once drift is enabled by the test
flaky answers 503 for the first K requests per path

Scenario-specific flags: --partial-bytes N, --chunk-delay-ms N, --chunk-size N, --flaky K, --auth user:pass (default ci:secret).

As a library

The same server is a lib, so Rust tests start it in-process:

use mock_nexus::{MockNexus, Scenario};

let server = MockNexus::start(Scenario::Flaky { first_failures: 2 })?;
// ... run the client against server.base_url(), assert on server.requests()

The SCENARIOS list in src/lib.rs is the conformance contract: a new scenario lands in the same change as the client behavior that needs it.

More