[Test Coverage] mount-policy-validation.test.ts#6418
Conversation
Cover all error-handling paths in the validate() function and its helpers (assertAbsolutePathArray, assertHomeSubdirArray, parseCredentials) that were never exercised because module-load runs only with valid JSON. Uses jest.isolateModules() + jest.mock() to inject malformed JSON and trigger every error branch in isolation. 39 new tests; brings src/config/mount-policy.ts from ~80% to near-full line/branch coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds isolated Jest tests for mount-policy validation and credential hiding behavior.
Changes:
- Injects malformed policies with
jest.isolateModules(). - Covers validation failures and credential expansion edge cases.
Show a summary per file
| File | Description |
|---|---|
src/config/mount-policy-validation.test.ts |
Adds mount-policy validation tests. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Medium
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
✅ Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓 |
|
🔌 Smoke Services — All services reachable! ✅ |
|
Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded. |
|
📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅ |
|
✅ Smoke Gemini completed. All facets verified. 💎 |
|
📰 VERDICT: Smoke Docker Sbx has concluded. All systems operational. This is a developing story. 🎤 |
|
✅ Contribution Check completed successfully! PR #6418 follows the contribution guidelines: the change is test-only, includes new tests, keeps file placement under src/config, and the description is clear enough for the scope of the update. No review comment needed. |
|
🛡️ Smoke Copilot Network Isolation confirmed the egress allowlist is enforced. ✅ |
|
🚀 Security Guard has started processing this pull request |
|
📰 DEVELOPING STORY: Smoke Copilot reports failed. Our correspondents are investigating the incident... |
|
🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅ |
|
✅ Build Test Suite completed successfully! |
|
✅ Smoke Copilot BYOK AOAI (Entra) completed. Copilot AOAI BYOK (Entra) mode operational. 🔓 |
|
✅ Smoke Claude passed |
|
❌ Smoke Copilot BYOK AOAI (api-key) reports failed. AOAI BYOK (api-key) mode investigation needed... |
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 |
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (2 files)
Coverage comparison generated by |
|
Smoke Test: Copilot BYOK (Direct) Mode ✅ MCP connectivity (prompt received) Status: PASS Agent credentials routed through api-proxy sidecar. Inference path verified. Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Chroot Version Comparison Results
All runtimes match between host and chroot environment. Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Smoke Test Results
Author: Overall: PARTIAL — MCP ✅; pre-step template vars were not expanded (literal Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Smoke Test: Claude Engine Validation
Overall Result: PASS Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
|
Smoke test: Copilot network-isolation egress enforcement EGRESS_RESULT allow=pass deny=pass ✅ Allowed domain (api.github.com): Overall: PASS — Warning Firewall blocked 2 domainsThe following domains were blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"
- "example.com"See Network Configuration for more information.
|
|
✅ GitHub MCP connectivity Running in direct BYOK mode (AWF_AUTH_TYPE=github-oidc + AWF_AUTH_AZURE_* + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw) authenticated via Microsoft Entra Overall: PASS Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Smoke Test: Services Connectivity
Overall: FAIL Runner executes inside the AWF sandbox ( Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
Smoke Test: API Proxy OpenTelemetry Tracing
Overall: All completed scenarios passed. Diagnostics step pending — expected during active run. Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
|
Merged PRs:\n- Internalize dead Warning Firewall blocked 2 domainsThe following domains were blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"
- "registry.npmjs.org"See Network Configuration for more information.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
🔥 Smoke Test: Docker Sbx — PASS
Overall: PASS
|
Smoke Test Results
Overall Status: FAIL 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.
|
Summary
Adds 39 new unit tests covering all error-handling branches in
src/config/mount-policy.tsthat were unreachable by the existing test suite.Problem
The
validate()function and helpers (assertAbsolutePathArray,assertHomeSubdirArray,parseCredentials) run once at module-load time with valid JSON, so every error branch was dead code from Jest's perspective. Line coverage was ~80%.Solution
jest.isolateModules()+jest.mock('./sandbox-mount-policy.json')injects malformed JSON and reloads the module, triggering each validation error in isolation.Coverage improvements
system.directories, missinghomeassertAbsolutePathArray: non-array, non-string elements, empty/relative/../duplicate pathsassertHomeSubdirArray: non-array, empty/absolute/~-prefixed/nested/../duplicate entriesparseCredentials: null credentials, missingentries, non-object entries, invalid/empty/absolute/..paths, duplicate paths, invalidtype,filesonfile-type,fileswith empty/slashed/../duplicate filenames, missingreasoncredentialFilesToHide: dir entries with nofilesare omitted;filesarrays are fully expandedTests
39 new tests — all passing. No existing tests modified.
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
awmgmcpgSee Network Configuration for more information.