refactor: split api-proxy-service.test.ts into focused test modules#3299
Conversation
Split 1,195-line monolithic test into four focused files + shared test-utils: - api-proxy-service-config.test.ts service config, image, healthcheck, limits - api-proxy-service-key-isolation.test.ts security: key non-leakage (ANTHROPIC/OPENAI/GEMINI) - api-proxy-service-rate-limit.test.ts rate limiting, token guard, max-runs, timeout - api-proxy-service-env-forwarding.test.ts OIDC, Anthropic, Copilot, Gemini env forwarding - api-proxy-service.test-utils.ts shared mockNetworkConfigWithProxy All 114 tests pass across 4 new files (same count as original).
Smoke Test: Copilot BYOK (Offline) Mode
Running in BYOK offline mode ( Overall: PARTIAL — BYOK inference path works; GitHub MCP blocked by sandbox credential isolation (expected in this environment).
|
🔬 Smoke Test Results
Overall: FAIL — Workflow template variables ( cc
|
There was a problem hiding this comment.
Pull request overview
Refactors the api-proxy-service test suite by splitting an oversized monolithic test file into smaller, concern-focused Jest modules so that security-critical behaviors (like API key non-leakage) are easier to find and maintain.
Changes:
- Adds a shared test fixture module exporting
mockNetworkConfigWithProxy. - Splits tests into focused modules for service configuration, API key isolation (security), rate limiting/token-guard behavior, and env var forwarding.
- Updates the remaining env-forwarding test module to use the shared network fixture and a clearer top-level
describelabel.
Show a summary per file
| File | Description |
|---|---|
| src/services/api-proxy-service.test-utils.ts | Adds shared mockNetworkConfigWithProxy fixture used by the new test modules. |
| src/services/api-proxy-service-config.test.ts | Contains service existence/image/healthcheck/security limits and agent env wiring tests. |
| src/services/api-proxy-service-key-isolation.test.ts | Contains security-focused tests ensuring provider API keys don’t leak to the agent env (incl. envAll). |
| src/services/api-proxy-service-rate-limit.test.ts | Contains rate limiting + effective token guard/maxRuns/agentTimeout/OpenCode env wiring tests. |
| src/services/api-proxy-service-env-forwarding.test.ts | Removes unrelated tests from this module and re-centers it on env var forwarding, using shared proxy network config. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 5/5 changed files
- Comments generated: 0
Smoke Test Results
Overall: FAIL (2/3 tests passed) Note: GitHub API authentication issue detected in test environment. Playwright and file verification tests passed successfully.
|
Smoke TestPRs: chore: recompile test-coverage-improver lock file; chore: run test coverage improver twice daily Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
Chroot Version Comparison Results
Overall: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Smoke Test Results
Overall: FAIL —
|
Smoke Test Results
Overall status: PASS Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
src/services/api-proxy-service.test.tshad grown to 1,195 lines with 114 tests across 6+ distinct concern areas in a single flatdescribeblock, making security-critical tests hard to locate and targeted CI runs noisy.Changes
api-proxy-service.test.ts(1,195 lines)api-proxy-service.test-utils.ts— exports sharedmockNetworkConfigWithProxyconstantapi-proxy-service-config.test.tsapi-proxy-service-key-isolation.test.tsANTHROPIC_API_KEY/OPENAI_API_KEY/CODEX_API_KEY/GEMINI_API_KEYnon-leakage, with and withoutenvAllapi-proxy-service-rate-limit.test.tsmaxRuns,agentTimeout, OpenCode flagapi-proxy-service-env-forwarding.test.tsAWF_ANTHROPIC_*, OpenAI/Anthropic/Copilot/Gemini API target & base-path forwardingNotes
jest.mock('execa', ...)andlet mockConfigare intentionally kept per-file — Jest hoistsjest.mock()before imports so the factory cannot reference variables from an imported module.**/*.test.ts); no config changes needed.