Skip to content

[Test Coverage] network-policy.ts validation error branches#6469

Merged
lpcox merged 1 commit into
mainfrom
test-coverage/network-policy-validation-ed1a3b7cc57ed5fc
Jul 21, 2026
Merged

[Test Coverage] network-policy.ts validation error branches#6469
lpcox merged 1 commit into
mainfrom
test-coverage/network-policy-validation-ed1a3b7cc57ed5fc

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

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.ts

Uses jest.doMock + jest.resetModules() to inject invalid JSON at module load time, exercising every fail() call in the validation chain:

Validation function Error paths covered
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 length >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

Coverage impact

src/config/network-policy.ts: 86.95% → 100% statements, 74.54% → 100% branches

No existing tests were modified.

Generated by Test Coverage Improver · 55.1 AIC · ⊞ 6.3K ·

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>
@lpcox
lpcox marked this pull request as ready for review July 21, 2026 12:26
Copilot AI review requested due to automatic review settings July 21, 2026 12:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

📰 VERDICT: Smoke Docker Sbx has concluded. All systems operational. This is a developing story. 🎤

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions

Copy link
Copy Markdown
Contributor Author

🚀 Security Guard has started processing this pull request

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Smoke Gemini completed. All facets verified. 💎

Gemini smoke test completed with failures. Comment added to PR #6469.

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Build Test Suite completed successfully!

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Smoke Copilot BYOK AOAI (Entra) completed. Copilot AOAI BYOK (Entra) mode operational. 🔓

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

🔑 Smoke Copilot PAT PAT auth validated. All systems operational. ✅

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

🛡️ Smoke Copilot Network Isolation confirmed the egress allowlist is enforced. ✅

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

📡 Smoke OTel Tracing completed. All tracing scenarios validated. ✅

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Chroot tests passed! Smoke Chroot - All security and functionality tests succeeded.

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

🔌 Smoke Services — All services reachable! ✅

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Smoke Claude passed

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Contribution Check completed successfully!

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Smoke Copilot BYOK AOAI (api-key) completed. Copilot AOAI BYOK (api-key) mode operational. 🔓

@github-actions

Copy link
Copy Markdown
Contributor Author

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 98.74% 99.01% 📈 +0.27%
Statements 98.69% 98.95% 📈 +0.26%
Functions 99.28% 99.40% 📈 +0.12%
Branches 94.95% 95.33% 📈 +0.38%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/log-directory-setup.ts 96.2% → 100.0% (+3.78%) 96.3% → 100.0% (+3.71%)
src/config/network-policy.ts 86.4% → 100.0% (+13.64%) 87.0% → 100.0% (+13.05%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

@github-actions

Copy link
Copy Markdown
Contributor Author

@lpcox — Smoke test: Copilot Network Isolation Egress Enforcement

EGRESS_RESULT allow=pass deny=pass

✅ Allowed domain (api.github.com): HTTP 200
✅ Blocked domain (example.com): connection denied (403 via proxy)

Overall: PASS

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • example.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "example.com"

See Network Configuration for more information.

🛡️ Egress verdict from Smoke Copilot Network Isolation
Add label ready-for-aw to run again

@github-actions github-actions Bot added the smoke-copilot-network-isolation Copilot network-isolation egress smoke test label Jul 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor Author

🔬 Smoke Test Results — PAT Auth

Test Status
GitHub MCP connectivity ✅ (MCP reachable, PR filtered by secrecy policy)
GitHub.com HTTP ⚠️ pre-step output not expanded (template vars unresolved)
File write/read ⚠️ pre-step output not expanded (template vars unresolved)

Note: steps.smoke-data.outputs.* variables were not substituted — the pre-agent step may not have run or outputs were not passed to this job.

Overall: PARTIAL — MCP auth ✅, pre-step data unavailable.

Auth mode: PAT (COPILOT_GITHUB_TOKEN)
Author: @lpcox

🔑 PAT report filed by Smoke Copilot PAT
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

Smoke Test: Copilot BYOK (Direct) Mode

PASS - All tests passed

  • MCP Connectivity: ✅
  • GitHub.com Access: ✅ (api.github.com returns 200)
  • File Operations: ✅
  • BYOK Inference: ✅ (running in direct BYOK mode)

Running via COPILOT_PROVIDER_API_KEY → api-proxy sidecar → api.githubcopilot.com

🔑 BYOK report filed by Smoke Copilot BYOK
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

Smoke Test: Claude Engine Validation

Check Status
API ✅ PASS
GH ✅ PASS
File ✅ PASS

Overall result: PASS

Generated by Smoke Claude for #6469 · 31.2 AIC · ⊞ 3.3K ·
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author
  • Support COPILOT_MODEL=auto in AWF validation and api-proxy resolution: ✅
  • Auto-allow topology-attached container hostnames in Squid ACL: ✅
  • Overall: PASS

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • registry.npmjs.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "registry.npmjs.org"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

Smoke Test Results

  • Redis PING: ❌ (host.docker.internal DNS resolution failed)
  • PostgreSQL pg_isready: ❌ (no response)
  • PostgreSQL SELECT 1: ❌ (DNS resolution failed)

Overall: FAILhost.docker.internal is not resolvable in this environment. Service containers are unreachable.

🔌 Service connectivity validated by Smoke Services
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

Gemini Smoke Test Results

  • GitHub MCP Testing: ❌ (Access Denied)
  • GitHub.com Connectivity: ❌ (Failed)
  • File Writing Testing: ✅
  • Bash Tool Testing: ✅

Overall status: FAIL

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • localhost

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "localhost"

See Network Configuration for more information.

💎 Faceted by Smoke Gemini
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

Smoke Test: API Proxy OpenTelemetry Tracing

Scenario Result Notes
Module Loading otel.js loads successfully; exports: startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled, and internal helpers
Test Suite 39/39 tests passed in otel.test.js across all suites (module init, span creation, token attrs, parent context, ProxyAwareOtlpExporter, FileSpanExporter, FanOutSpanExporter, shutdown)
Env Var Forwarding src/services/api-proxy-env-config.ts forwards GH_AW_OTLP_ENDPOINTS, GITHUB_AW_OTEL_TRACE_ID, GITHUB_AW_OTEL_PARENT_SPAN_ID to the api-proxy container
Token Tracker Integration onUsage callback exists in token-tracker-http.js (line 285/343) as the OTEL hook point
OTEL Diagnostics No OTLP endpoint configured in this run; fallback file exporter (/var/log/api-proxy/otel.jsonl) active — graceful degradation working as expected

All 5 scenarios passed. OTEL tracing integration is fully operational.

📡 OTel tracing validated by Smoke OTel Tracing
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

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. CONTRIBUTING.mdPull request requirements asks for a clear description and a reference to any related issues. If this change is tied to an issue, please link it in the PR body.

Generated by Contribution Check for #6469 · 1.76 AIC · ⊞ 23.6K ·
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

@lpcox

✅ GitHub MCP testing
✅ GitHub.com connectivity
✅ File write/read
✅ BYOK inference

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

🪪 BYOK (AOAI Entra) report filed by Smoke Copilot BYOK AOAI (Entra)
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

🔬 Smoke Test Results

Test Status
GitHub MCP connectivity ✅ MCP responded (PR data filtered by secrecy policy)
GitHub.com HTTP ⚠️ Pre-step template vars not expanded
File write/read ⚠️ Pre-step template vars not expanded

Overall: PARTIAL — MCP is reachable; pre-computed test data was not injected (workflow template variables unexpanded).

Author: @lpcox

📰 BREAKING: Report filed by Smoke Copilot
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

Chroot Version Comparison Results ✅

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.13
Node.js v24.18.0 v24.18.0
Go go1.22.12 go1.22.12

All runtimes match between host and chroot environments.

Tested by Smoke Chroot
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

@lpcox

  • GitHub MCP testing: ✅ (pre-fetched data validated)
  • GitHub.com connectivity: ✅
  • Agent file I/O: ✅
  • Direct BYOK inference: ✅
    Running in direct BYOK mode (COPILOT_PROVIDER_API_KEY + COPILOT_PROVIDER_BASE_URL) via api-proxy → Azure OpenAI (Foundry, o4-mini-aw)
    Overall: PASS

🔑 BYOK (AOAI api-key) report filed by Smoke Copilot BYOK AOAI (api-key)
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia 1/1 passed ✅ PASS
Bun hono 1/1 passed ✅ PASS
C++ fmt N/A ✅ PASS
C++ json N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world N/A ✅ PASS
.NET json-parse N/A ✅ PASS
Go color all passed ✅ PASS
Go env all passed ✅ PASS
Go uuid all passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx all passed ✅ PASS
Node.js execa all passed ✅ PASS
Node.js p-limit all passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Generated by Build Test Suite for #6469 · 43.7 AIC · ⊞ 8.3K ·
Add label ready-for-aw to run again

@github-actions

Copy link
Copy Markdown
Contributor Author

🔬 Smoke Test Results

Test Status
GitHub MCP connectivity ✅ PASS
GitHub.com HTTP ⚠️ N/A (pre-step value unexpanded)
File write/read ⚠️ N/A (pre-step value unexpanded)
PR data fetch ⚠️ Filtered by secrecy policy

Overall: PASS (MCP operational; pre-step outputs not resolved in this context)

cc @lpcox

📰 BREAKING: Report filed by Smoke Docker Sbx
Add label ready-for-aw to run again

@lpcox
lpcox enabled auto-merge (squash) July 21, 2026 17:00
@lpcox
lpcox merged commit 434e0dd into main Jul 21, 2026
142 of 143 checks passed
@lpcox
lpcox deleted the test-coverage/network-policy-validation-ed1a3b7cc57ed5fc branch July 21, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants