[Test Coverage] network-policy.ts validation error branches#6469
Conversation
Cover all error branches in the validate() call chain: - asObject: null, array, non-object inputs - assertString: empty string, non-string - assertPort: non-number, 0, >65535, float - assertIpv4: octet >255, wrong format - assertCidr: octet >255, prefix >32 - parseHost: unrecognized role, non-boolean required, non-boolean dualHomed - parseHosts: duplicate IP addresses - parseDns: empty/non-array defaultUpstreamServers - parseLegacyIptables: empty/non-array blockedPorts, duplicate ports, empty/non-array blockedCidrs, duplicate CIDRs Brings network-policy.ts from 86.95%/74.54% branches to 100%/100%. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds focused Jest coverage for all validation failure branches in the network policy loader.
Changes:
- Mocks malformed policy JSON during module initialization.
- Tests invalid objects, strings, ports, addresses, hosts, DNS, and iptables entries.
Show a summary per file
| File | Description |
|---|---|
src/config/network-policy-validation.test.ts |
Adds 23 validation-error 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: 0
- Review effort level: Medium
|
📰 VERDICT: Smoke Docker Sbx has concluded. All systems operational. This is a developing story. 🎤 |
|
✅ Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓 |
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 |
|
🚀 Security Guard has started processing this pull request |
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
|
✅ Smoke Gemini completed. All facets verified. 💎 Gemini smoke test completed with failures. Comment added to PR #6469. |
|
✅ Build Test Suite completed successfully! |
|
✅ Smoke Copilot BYOK AOAI (Entra) completed. Copilot AOAI BYOK (Entra) mode operational. 🔓 |
|
🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅ |
|
🛡️ Smoke Copilot Network Isolation confirmed the egress allowlist is enforced. ✅ |
|
📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅ |
|
Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded. |
|
🔌 Smoke Services — All services reachable! ✅ |
|
✅ Smoke Claude passed |
|
✅ Contribution Check completed successfully! |
|
✅ Smoke Copilot BYOK AOAI (api-key) completed. Copilot AOAI BYOK (api-key) mode operational. 🔓 |
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (2 files)
Coverage comparison generated by |
|
EGRESS_RESULT allow=pass deny=pass ✅ Allowed domain ( Overall: PASS Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "example.com"See Network Configuration for more information.
|
🔬 Smoke Test Results — PAT Auth
Overall: PARTIAL — MCP auth ✅, pre-step data unavailable. Auth mode: PAT (COPILOT_GITHUB_TOKEN)
|
Smoke Test: Copilot BYOK (Direct) Mode✅ PASS - All tests passed
Running via COPILOT_PROVIDER_API_KEY → api-proxy sidecar → api.githubcopilot.com
|
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
- "registry.npmjs.org"See Network Configuration for more information.
|
Smoke Test Results
Overall: FAIL —
|
Gemini 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.
|
Smoke Test: API Proxy OpenTelemetry Tracing
All 5 scenarios passed. OTEL tracing integration is fully operational.
|
|
Looks good overall: the new tests are in the right place and satisfy the CONTRIBUTING.md requirement to include tests for new functionality. The only missing guideline item is the PR description not referencing any related issue.
|
|
✅ GitHub MCP testing 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) Overall: PASS
|
🔬 Smoke Test Results
Overall: PARTIAL — MCP is reachable; pre-computed test data was not injected (workflow template variables unexpanded).
|
Chroot Version Comparison Results ✅
All runtimes match between host and chroot environments.
|
|
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
🔬 Smoke Test Results
Overall: PASS (MCP operational; pre-step outputs not resolved in this context) cc
|
Adds 23 Jest unit tests covering all validation error branches in
src/config/network-policy.ts.What changed
New test file:
src/config/network-policy-validation.test.tsUses
jest.doMock+jest.resetModules()to inject invalid JSON at module load time, exercising everyfail()call in the validation chain:asObjectassertStringassertPortassertIpv4assertCidrparseHostrequired, non-booleandualHomedparseHostsparseDnsdefaultUpstreamServersparseLegacyIptablesblockedPorts, duplicate ports, empty/non-arrayblockedCidrs, duplicate CIDRsCoverage impact
src/config/network-policy.ts: 86.95% → 100% statements, 74.54% → 100% branchesNo existing tests were modified.