enhancement(api): API token auth: report-endpoint fallback, Valkey cache with immediate invalidation, and capacity test suite#199
Merged
therealbrad merged 2 commits intomainfrom Apr 15, 2026
Conversation
…lity handlers Extends the authenticateRequest() pattern from the previous PR to 4 additional report utility handlers that were still using getServerSession() only: - testCaseHealthUtils (cross-project health report) - flakyTestsUtils (cross-project flaky tests report) - automationTrendsUtils (cross-project automation trends) - issueTestCoverageUtils (cross-project issue-test coverage) Also updates k6 load test scripts to use the correct report request schema (reportType required, dimensions/metrics as string arrays) and fixes the testRuns include relation name (testCases, not testRunCases). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…API token integration - Expanded the API reference to include a comprehensive overview of global hourly rate limits, detailing tier limits and response headers. - Updated the API tokens documentation to clarify that requests made with tokens are subject to the same rate limits. - Enhanced the rate limiting functionality in the codebase, including the ability to disable rate limiting for load testing environments. - Added tests to verify the behavior of admin and non-admin tokens in cross-project report endpoints. This update aims to improve user understanding of rate limits and enhance the API's robustness in handling token-based authentication.
Contributor
Author
|
🎉 This PR is included in version 0.21.13 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
therealbrad
pushed a commit
that referenced
this pull request
Apr 15, 2026
## [0.21.13](v0.21.12...v0.21.13) (2026-04-15) ### Enhancements * **api:** API token auth: report-endpoint fallback, Valkey cache with immediate invalidation, and capacity test suite ([#199](#199)) ([cd82846](cd82846))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
handle{AutomationTrends,FlakyTests,TestCaseHealth,IssueTestCoverage}POSTnow fall back toauthenticateRequest()alongside the existinggetServerSession()check, closing a gap where cross-project reports rejected valid API tokens.lib/api-token-cache.tsand wiredinvalidateApiTokenCache()into the PrismaapiTokenupdate/delete/updateMany/deleteManyextensions. A revoked or deleted token is now rejected on the next request instead of the next ~30 seconds.server/auth.tsnow usesgetCachedSessionUser()andtouchLastActive()from the newlib/session-cache.tsmodule, eliminating a per-requestuser.findUniqueon every session check.lib/access-manifest.tsprecomputes per-user project access;lib/access-fast-path.tsuses it to short-circuit selected create operations (see file header for the whitelist) without going through ZenStack policy evaluation. Wired into the central/api/model/[...path]router.DISABLE_API_RATE_LIMITenv var.lib/api-rate-limit.tsnow honors a short-circuit flag used exclusively for isolated load-test stacks.testplanit/load-tests/capacity/— 8 k6 scenarios (concurrent users, import rate, result ingestion, report generation, run creation, search, audit throughput, concurrent runs), a tier seeder, runner shell script, and JSON report generator. Results and generated charts are.gitignored; reference sizing data lives outside the repo.api-reference.mdnow documents the global hourly rate-limit tiers and response headers;api-tokens.mdclarifies that token-authenticated requests are subject to the same limits.e2e/tests/auth/api-tokens.spec.ts:Test plan
pnpm type-checkpnpm vitest run lib/api-token-auth.test.ts— 25/25pnpm vitest run app/api/api-tokens/route.test.ts— 17/17E2E_PROD=on pnpm test:e2e e2e/tests/auth/api-tokens.spec.ts— 10/10 (includes AUTH-08-3 which was failing before the cache-invalidation fix, plus the two new tests AUTH-08-8/9)Notes for reviewers
dist/scheduler.jsanddist/workers/syncWorker.jsdiffs are regenerated build artifacts, not source changes.lib/api-token-auth.tsre-exportsinvalidateApiTokenCacheso external callers of the old import path keep working.load-tests/capacity/results/*,load-tests/capacity/charts/*.png) are gitignored. Theresults/.gitkeeppreserves the directory thatrun-capacity-tests.shwrites into.