ProxyAuth / Engineering

How ProxyAuth tests itself: a deep gate on every pull request, a wide one on every merge

ProxyAuthCI / TestingUpdated on 2026-09-18

An access layer you cannot trust is worse than none. The tests behind ProxyAuth have settled into two pipelines with genuinely different jobs: one decides whether a change may enter, the other verifies that what has entered still holds together everywhere it is meant to run.

A tree of ProxyAuth's two CI pipelines. The pull request trigger branches into three jobs — Format and lint (formatting, Cargo.lock, clippy), Build and tests (unit and integration, end-to-end flow, rate limit, stress test), and Security audit (cargo audit). The push-to-main trigger branches into one per-distribution job that runs setup, security and coverage, release build and unit tests, and the end-to-end flow, across six distributions: Alpine, Arch Linux, CentOS Stream 9, Debian, Fedora and Ubuntu.
Pull-request gateMain-branch pipeline
triggerPR against main, every push to itevery push to main, on demand
questionis this change safe to let in?does the system still hold everywhere?
shapedeep, one environmentwide, six distributions
builddebug with light optimisationrelease
adversarial testsyes — rate limits, stresscore flow only

Pipeline one — the pull-request gate

Older runs for the same pull request are cancelled on each push, so only the latest commit is checked. Three jobs run in parallel for one quick round of feedback.

Job 1 — format and lint

The cheapest rejection comes first:

  • formatting — cargo fmt must have been applied;
  • Cargo.lock in sync with Cargo.toml — otherwise every later --locked build, including the one the install script runs, would fail with a confusing error;
  • Clippy across all targets and features.

Cargo dependencies are cached between runs.

Job 2 — build and tests

The core, long on purpose.

Unit, integration and doc tests. A debug build with a little optimisation — so the crypto-heavy paths are not unbearably slow — and the suite runs under cargo-nextest, plus doctests.

A real instance, end to end. The job prepares the proxyauth system user, generates a self-signed certificate, writes a routes.yml with one protected route, wipes the test database, starts a dummy backend on port 8500, and boots ProxyAuth in front of it. Then it checks the promises made to the outside world:

  • HTTPS answers;
  • a protected route refuses an anonymous request;
  • login issues a token that reaches the backend, and reusing it — the verification-cache path — still works;
  • a tampered token is refused;
  • a wrong password is refused;
  • an upload under max_body_size arrives byte for byte, verified by SHA-256, and one over the limit is rejected;
  • a large download comes back intact with the backend’s declared length preserved, showing it is not buffered whole first.

Rate limits, attacked. ProxyAuth restarts with deliberately strict limits:

  • a burst is capped at exactly the configured size;
  • access returns once the window passes;
  • a flood of 2 000 requests is absorbed with no connection error and no 5xx, and never lets more through than the configured rate;
  • /auth throttles password guessing, and the correct password is also blocked while the limiter is engaged — so guessing right is not a way around it.

These exist because the behaviour was wrong at least once.

Stress, with a regression verdict. Another restart, limits off:

  1. latency at rest (baseline);
  2. thousands of requests over kept-alive connections;
  3. hundreds over a fresh TLS connection each;
  4. a batch of concurrent logins;
  5. latency at rest again.

It prints requests per second and p50/p95/p99/max for each phase, and fails the build if the server degraded: resting latency more than tripled, memory grew by more than a couple of hundred megabytes, any request errored, or the process did not survive. The thresholds are relative — before versus after — so the verdict means the same on a fast runner and a slow one.

On failure, logs from ProxyAuth and the backend are dumped automatically; servers are always shut down cleanly.

Job 3 — security audit

cargo audit over the whole dependency tree against the RustSec advisory database, with cargo-audit cached. A known vulnerability in a dependency shows up on the pull request, not in a release.

Pipeline two — rebuild the world

Once a change is in, the question becomes: does the whole thing still build and run on every system someone might install it on?

The full pass runs in parallel in six containers: Alpine, Arch Linux, CentOS Stream 9, Debian, Fedora and Ubuntu. The spread matters. A crate that links against glibc can fail on Alpine’s musl; a system library gets renamed or bumped on one distribution and not another; package names differ everywhere. The matrix does not fail fast, so one broken distribution does not hide the other five.

On each:

  • bootstrap — Node.js the native way (or the one the image ships), with OS packages cached;
  • real build dependencies under their local names — C toolchain, OpenSSL, PostgreSQL and MySQL/MariaDB client libraries, nettle, pkg-config — the same set the install script installs;
  • check the MySQL client library is present before building, so a missing dev package fails clearly instead of as a linker error;
  • Rust, with the core count reported and the Cargo cache restored;
  • security checks — cargo audit, a check that ProxyAuth and its zerocrypt dependency agree on crypto crate versions, and a duplicate-dependency report;
  • coverage with cargo-tarpaulin;
  • release build, unit tests, then a real TLS instance proving the core flow: HTTPS answers, anonymous is refused, a real login works, a tampered token is rejected.

That list mirrors the distributions the installer supports, which is the point: “it worked on Ubuntu” has never meant “it works”.

Running the same checks locally

Roughly what the gate runs, before you open a pull request:

cargo fmt --all -- --check
cargo check --locked
cargo clippy --all-targets --all-features
cargo nextest run
cargo test --doc
cargo audit

The end-to-end, rate-limit and stress phases need a prepared host with the proxyauth user and a certificate; they are easiest to run in a disposable container.

Two questions, not one

The pull-request gate is deep: adversarial rate-limit checks and a stress verdict would be too slow to run six times. The main pipeline is wide: real release builds on every supported distribution. Neither could do the other’s job well.

The tests that matter most are rarely glamorous — a disguised URL that must still land on the protected route, a missing config value that must fall back to a sane default instead of panicking. Those are exactly the failures that would matter in production: an access layer silently letting something through, or falling over on the one distribution a server happens to run.

A deep gate before merge, a wide one after, both automatic so they cannot be skipped. Better to find the break in CI than to have someone find it in production.