How ProxyAuth tests itself: a deep gate on every pull request, a wide one on every merge
Was this useful?
0 unique visitors
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.
| Pull-request gate | Main-branch pipeline | |
|---|---|---|
| trigger | PR against main, every push to it | every push to main, on demand |
| question | is this change safe to let in? | does the system still hold everywhere? |
| shape | deep, one environment | wide, six distributions |
| build | debug with light optimisation | release |
| adversarial tests | yes — rate limits, stress | core 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 fmtmust have been applied; Cargo.lockin sync withCargo.toml— otherwise every later--lockedbuild, 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_sizearrives 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; /auththrottles 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:
- latency at rest (baseline);
- thousands of requests over kept-alive connections;
- hundreds over a fresh TLS connection each;
- a batch of concurrent logins;
- 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 itszerocryptdependency 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.