Fault Injection for Auth Endpoints in CI Pipelines
Stateful simulators let CI force auth failures at exact token transitions.

Integration testing against stateful APIs requires a local simulator that preserves state across calls and lets the test harness force failures at precise points. For auth endpoints in CI pipelines, that means testing expired-token 401s, rate-limit 429s, and 503s after the relevant token lifecycle transition, without live credentials. Checking the simulator against the real API on an ongoing basis keeps those recovery tests aligned with current API behavior.
Why auth error paths break in production but pass in CI
CI passes because authentication succeeds, while production breaks when a token expires and the recovery path fails. A suite that never exercises an expired-token 401, a rate-limit 429, or a 503 during token refresh leaves retry, fallback, and re-authentication logic untested. Token rotation and multi-step OAuth grants depend on both what earlier calls established and the response to the current request.
SequenceFI research found that half of all API operations across public API specification corpora could change state. For those operations, a failure before a downstream side effect creates different recovery obligations from a failure after it. Auth flows have the same distinction. A token may already have been issued when an error reaches the client, so testing only a failed issuance request misses how the application recovers after issuance.
Why live auth endpoints cannot fill this gap in CI
Calling the real endpoint does not provide control over when it fails. Its responses depend on network conditions, quota state, and third-party uptime, none of which the pipeline controls. Repeated pull-request runs also consume quotas on aggressively throttled endpoints. An unexpected 429 then adds unrequested noise to the pipeline. Even a genuine provider outage cannot reliably reproduce the exact token transition a test needs.
Live credentials also put secrets at risk in the same workflow. GitGuardian documents the GhostAction campaign of September 2025, which stole secrets through injected workflow files across 817 repositories. Adding secrets that work in production to CI widens the attack surface but still leaves tests without a way to repeat failures. A local stand-in removes both constraints from the fault-injection run, rather than pushing error-path testing into manual staging work.
What stateless mocks get wrong about auth fault injection
A stateless mock can establish that the application handles a 401 response. It cannot, by itself, establish that the application handles a token becoming invalid after successful use. Consider a sequence in which a token is issued, an authenticated call succeeds, the token expires, and re-authentication also fails. The history determines which response is valid next. A canned auth-failure response gives the same result whether or not authentication ever worked.
The reverse produces an equally misleading test. A mock that returns an authenticated response without checking token history can accept a request before any token has been issued, although the real endpoint would reject it with 401. A response sequence set up by hand can show the expected order, but a stateful test must also check that each response is valid when it is returned.
SequenceFI illustrates the underlying distinction with a payment response dropped after a charge has been issued. Recovery from that failure differs from recovery when the request fails before the charge. Auth tests need the same temporal discrimination. Injecting an error against the wrong occurrence of a repeated call can miss the defect, even when the error code itself is correct.
What a stateful simulator must do to make auth fault injection reliable
A credible simulator must track token issuance, expiry, and refresh attempts across calls. Subsequent responses must agree with that history. Its control interface must also let the harness force an expired-token 401, a rate-limit 429, or a 503 at a selected point in the sequence. Random faults are not enough for this purpose. The harness needs to reproduce the same failure after the same transition on each run.
A configurable fault proxy provides a useful model for that control interface. It sits between the application and its dependency and exposes controls for fault type, probability, error code, and latency. Those controls can change during the test run. The simulator must use the history of the operation to decide when to activate a fault, including which instance of a repeated call should fail.
Protocol fidelity is another independent requirement. Kalshi request signatures, Stripe webhook verification before version routing, GitHub HMAC-SHA256 verification, and PayPal’s distinct webhook and IPN protocols are not interchangeable ceremonies. A simulator that bypasses them cannot test their rejection paths. Its state model and fault controls are useful only if the application must first satisfy the same authentication conditions that the real API imposes.
The fidelity problem — how simulators drift from the real API and why it matters for fault injection
A simulator can keep state perfectly and still model an API that is out of date. If a token response schema changes but the simulator keeps the old field shapes, passing tests no longer show how the integration works in production. Auth drift can therefore invalidate the test’s premise. Even when deterministic execution puts a failure at the exact point intended, the test is still misleading if the contract is wrong.
Updrift watches providers including Stripe for semantic API drift, maps affected repository lines, and opens sandbox-verified migration PRs. The open-source apidrift tool polls Stripe’s OpenAPI specification and classifies changes as breaking, warning, or informational. These approaches make contract changes visible to maintainers. They do not remove the need to verify the simulator’s behavior against the real endpoint.
Webhook verification also needs both current transport tests and historical schema tests. The Stripe CLI can forward test events to test current transport, while frozen fixtures keep the older payload shapes that regression coverage needs. Neither layer replaces the other. Because stripe trigger follows current fixtures, it is not a regression corpus for older versions. The simulator should be checked against the real API before every release, and published fidelity scores should show how well it matches the behavior the tests rely on.
How to test stateful auth APIs in CI without hitting production

The CI job starts the simulator locally or in a container and seeds a known authenticated session with a valid token. The first authenticated call must succeed before the harness introduces a fault. This establishes the baseline for the recovery test. Tokens, accounts, and webhook configurations belong in the initial state where the scenario requires them, rather than leaving the application to operate against an empty stand-in. No live credentials or external endpoint are needed during this run.
For an expired-token 401 scenario, the harness expires the token after issuance and before the next authenticated call. The assertion checks for a re-authentication attempt and detects silent failure. A separate scenario injects a 429 at token refresh and checks backoff without a tight retry loop. A 503 at the auth endpoint tests circuit-breaker activation or graceful degradation. Each scenario needs an explicit recovery expectation.
Fault timing must follow the state-changing operation. SequenceFI formalizes this requirement as an occurrence-sensitive temporal guard, which distinguishes the relevant call from other occurrences in the sequence. This keeps a fault that happens too early from taking the place of the post-auth failure the test was meant to check. After the assertion, the harness resets state through the simulator’s control API or starts a fresh container.
Call-site targeting keeps this workflow focused. FastFI research targets specific API call-site boundaries instead of the whole service and reports that this cuts end-to-end fault-injection time by 76.12% against state-of-the-art baselines. In the pipeline, the fault-injection stage runs after deployment to the test environment and before promotion. AWS FIS pipeline patterns provide the corresponding structure of checking preconditions, injecting the fault, waiting, asserting recovery, and failing the stage if recovery exceeds the threshold.
API-specific auth fault modes worth reproducing in your simulator
Stripe webhook tests must preserve the boundary between unauthenticated input and trusted routing data. constructEvent() must authenticate the raw payload before the application inspects the version field for dispatch. Until then, the version is attacker-controlled input. A useful failure scenario rejects verification before version routing can run. Separately, a webhook endpoint with a null api_version creates drift risk because a later account upgrade can change payloads without a code deployment.
Slack auth tests need to check token precedence as well as whether a string is invalid. Empirical probing of the API on 2026-10-11 found that a non-resolving token, a non-empty token query parameter, and an empty token beside a header token are all classified as invalid_auth. In Go integrations, supplying a mock Slack client through the root context is one documented injection seam, although constructor injection is the more broadly idiomatic pattern.
GitHub webhook tests must verify X-Hub-Signature-256 using HMAC-SHA256 and the configured webhook secret. Delivery behavior also shapes the recovery test. GitHub does not automatically redeliver failed webhook deliveries, so a dropped-delivery scenario must not silently supply an automatic retry. Redelivery has to be triggered manually. A simulator that invents retries would let the application depend on recovery behavior the provider does not supply.
PayPal REST webhooks can use PayPal’s verification service, while legacy IPN uses a separate postback protocol. The two must remain distinct in the simulator. Every delivery should also be treated as potentially duplicated, making idempotency part of the fault test. Faultline can run PayPal scenarios that duplicate, delay, drop, and replay deliveries. If PayPal returns 401, the tool fetches a new token and retries that request once, with no other automatic retries and with timeouts reported.
Kalshi requires an Ed25519 or RSA key signature on every authenticated request, generated from the request timestamp, HTTP method, and path and included in request headers. Omitting that ceremony removes the authentication boundary under test. A useful simulator therefore has to reproduce signing requirements rather than accept any nominally authenticated request. Resend and Lob are also within the stated simulator coverage, but their specific auth fault modes are not independently documented in the available material.
How stateful, verified simulators fit into a mature CI fault injection workflow
State memory establishes whether an authenticated operation is valid, realistic seeded data makes the initial workflow executable, and temporal controls place the fault after the intended transition. That transition must pass API-specific verification to represent the real integration. Fidelity evidence then helps maintainers trust the result from one release to the next. None of these properties substitutes for another.
The release-verification process and the CI fault run serve different purposes. Verification compares simulator behavior with the live API, while the fault run uses the verified local behavior without contacting that API. This separation supports offline and air-gapped execution on a laptop or in a container. It also keeps live credentials and provider quotas out of repeated fault tests. Latency, 429s, and 503s should be part of the simulator’s test controls from the start, instead of being added as exceptions to a fixture that otherwise tests only the happy path.
The same foundation extends to agents that call auth-protected APIs. A stateful simulator can provide a deterministic, horizontally scalable environment for RL training and agent evaluation, using failures such as a 429 during refresh or a 503 at authentication. The failure must occur in a valid workflow, at a known transition, under an API contract supported by verification evidence.


