Skip to content

refactor: split host-iptables-setup.test.ts into focused test modules#5571

Merged
lpcox merged 4 commits into
mainfrom
copilot/refactor-host-iptables-test
Jun 26, 2026
Merged

refactor: split host-iptables-setup.test.ts into focused test modules#5571
lpcox merged 4 commits into
mainfrom
copilot/refactor-host-iptables-test

Conversation

Copilot AI commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

src/host-iptables-setup.test.ts (579 lines) mixed seven independent testing concerns for the L3/L4 security boundary, making it hard to navigate and diagnose failures in isolation.

Changes

Deleted the monolithic file and replaced it with five focused modules, each independently runnable:

  • host-iptables-setup-core.test.ts — core setupHostIptables chain installation (11 tests, ~301 lines of original coverage)
  • host-iptables-setup-validation.test.tsisValidPortSpec + empty-entry allowHostPorts edge case (4 tests)
  • host-iptables-setup-proxy.test.tscliProxyConfig / DIFC proxy integration variant (3 tests)
  • host-iptables-setup-ipv6.test.ts — IPv6 DNS server handling and FW_WRAPPER_V6 lifecycle (3 tests)
  • host-iptables-setup-errors.test.tsDOCKER-USER chain creation failure + cleanup resilience (2 tests)

Shared test infrastructure (host-iptables-test-setup.ts, host-iptables-rules.test-utils.ts, host-iptables-shared.test-utils.ts) is unchanged; each new file re-imports only the helpers it uses. All 27 tests pass.

Copilot AI changed the title [WIP] Refactor test file by splitting concerns in src/host-iptables-setup.test.ts refactor: split host-iptables-setup.test.ts into focused test modules Jun 26, 2026
Copilot AI requested a review from lpcox June 26, 2026 15:54
Copilot finished work on behalf of lpcox June 26, 2026 15:54
@lpcox lpcox marked this pull request as ready for review June 26, 2026 16:36
Copilot AI review requested due to automatic review settings June 26, 2026 16:36

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

This PR refactors the host-level iptables setup unit tests by splitting the previously monolithic src/host-iptables-setup.test.ts into smaller, focused test modules, improving navigability and failure isolation for the L3/L4 security boundary behavior.

Changes:

  • Replaced the single large host iptables setup test file with five focused, independently-runnable test suites.
  • Moved port-spec validation, CLI proxy integration, IPv6 DNS handling, and error/cleanup-path coverage into dedicated test modules.
  • Slimmed host-iptables-setup-core.test.ts to only cover core chain installation behavior.
Show a summary per file
File Description
src/host-iptables-setup.test.ts Removed monolithic test file in favor of focused suites.
src/host-iptables-setup-core.test.ts Retains core setupHostIptables chain installation coverage and drops unrelated cases.
src/host-iptables-setup-validation.test.ts Adds focused coverage for isValidPortSpec and empty-entry parsing in allowHostPorts.
src/host-iptables-setup-proxy.test.ts Adds focused coverage for cliProxyConfig gateway allow rules and bridge gateway resolution behavior.
src/host-iptables-setup-ipv6.test.ts Adds focused coverage for IPv6 DNS server handling and FW_WRAPPER_V6 lifecycle behavior.
src/host-iptables-setup-errors.test.ts Adds focused coverage for failure paths (DOCKER-USER creation) and cleanup resilience.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Low

Comment thread src/host-iptables-setup-errors.test.ts Outdated
Comment thread src/host-iptables-setup-errors.test.ts Outdated
lpcox and others added 2 commits June 26, 2026 12:04
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

✅ Copilot review passed with no inline comments.

@copilot Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 98.24% 98.28% 📈 +0.04%
Statements 98.17% 98.21% 📈 +0.04%
Functions 99.53% 99.53% ➡️ +0.00%
Branches 94.00% 94.00% ➡️ +0.00%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/workdir-setup.ts 92.7% → 94.5% (+1.82%) 92.7% → 94.5% (+1.82%)

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

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Smoke Gemini completed. All facets verified. 💎

Smoke test completed with FAIL status. Connectivity and GitHub MCP tools were not available.

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Smoke Claude passed

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Smoke Copilot BYOK completed. Copilot BYOK mode operational. 🔓

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

🔌 Smoke Services — All services reachable! ✅

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Build Test Suite completed successfully!

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Security Guard has started processing this pull request

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Contribution Check failed. Please review the logs for details.

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Claude Engine Validation

Check Status
API ✅ PASS
gh CLI ✅ PASS
File ✅ PASS

Overall result: PASS

Generated by Smoke Claude for issue #5571 · 61.6 AIC · ⊞ 3.3K ·

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: Copilot BYOK (Direct) — PASS ✅

Test Results:

  • ✅ GitHub MCP connectivity — verified merged PR list
  • ✅ GitHub.com connectivity — HTTP 200
  • ✅ File write/read — confirmed in /tmp/gh-aw/agent/
  • ✅ BYOK inference — processing via api-proxy → api.githubcopilot.com

Mode: Direct BYOK (COPILOT_PROVIDER_API_KEY via api-proxy sidecar)

Authors: @Copilot, @lpcox

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions

Copy link
Copy Markdown
Contributor

@Copilot @lpcox

Smoke Test Results:

  • Listing merged PRs: ✅
  • GitHub.com Connectivity: ✅
  • File I/O Test: ✅
  • 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)

@github-actions

Copy link
Copy Markdown
Contributor

🔥 Smoke Test: Copilot PAT Auth — PASS

Test Result
GitHub MCP connectivity
GitHub.com HTTP ✅ 200
File write/read

Overall: PASS · Auth mode: PAT (COPILOT_GITHUB_TOKEN)

PR: refactor: split host-iptables-setup.test.ts into focused test modules · @Copilot @lpcox

🔑 PAT report filed by Smoke Copilot PAT

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Smoke Test Results

PR: refactor: split host-iptables-setup.test.ts into focused test modules
Author: @Copilot | Assignees: @lpcox @Copilot

Test Result
GitHub MCP connectivity
GitHub.com HTTP connectivity ✅ 200
File write/read ⚠️ pre-step template vars unsubstituted

Overall: PASS (functional tests passed; file test skipped due to workflow template substitution issue)

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

Copy link
Copy Markdown
Contributor

@Copilot @lpcox
GitHub MCP Testing: ✅
GitHub.com Connectivity: ✅
File Write/Read Test: ✅
BYOK Inference Test: ✅

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

🪪 BYOK (AOAI Entra) report filed by Smoke Copilot BYOK AOAI (Entra)

@github-actions

Copy link
Copy Markdown
Contributor

Merged PRs:

Tests: GitHub reads ✅ | Playwright ✅ | File write ✅ | Discussion ✅ | Build ✅
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

@github-actions

Copy link
Copy Markdown
Contributor

Gemini Smoke Test Results

  • GitHub MCP Testing: ❌ (Tools not found in environment)
  • GitHub.com Connectivity: ❌ (SSL error: wrong version number)
  • 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

@github-actions

Copy link
Copy Markdown
Contributor

Chroot Version Comparison

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3
Node.js v24.17.0 v22.23.0
Go go1.22.12 go1.22.12

Result: Not all tests passed — Python and Node.js versions differ between host and chroot.

Tested by Smoke Chroot

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test Results — FAIL

host.docker.internal resolves to 172.17.0.1 but service ports are unreachable.

Check Result
Redis PING ❌ timeout
PostgreSQL pg_isready ❌ no response
PostgreSQL SELECT 1 ❌ no response

Overall: FAIL — TCP connections to ports 6379 and 5432 on host.docker.internal timed out. The service containers are not reachable from this runner environment.

🔌 Service connectivity validated by Smoke Services

@github-actions

Copy link
Copy Markdown
Contributor

Smoke Test: API Proxy OpenTelemetry Tracing

Scenario Result Summary
1. Module Loading otel.js loads; isEnabled: true; exports 7 public functions (startRequestSpan, setTokenAttributes, setBudgetAttributes, endSpan, endSpanError, shutdown, isEnabled)
2. Test Suite 59/59 tests passed across otel.test.js + otel-fanout.test.js — span creation, token attributes, parent context, exporters, serialization
3. Env Var Forwarding ⚠️ Workflow grep checks api-proxy-service.ts (no match), but OTEL vars are correctly forwarded via api-proxy-env-config.ts via pickEnvVars() for GH_AW_OTLP_ENDPOINTS, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS, GITHUB_AW_OTEL_TRACE_ID, GITHUB_AW_OTEL_PARENT_SPAN_ID — functional, wrong file in check
4. Token Tracker Integration onUsage callback present in token-tracker-http.js::finalizeHttpTracking(); onSpanEnd also wired
5. OTEL Diagnostics i️ No api-proxy-logs/otel.jsonl (api-proxy not running in static validation); workflow runner spans exported to Sentry ✓

Overall: All scenarios pass or match expected-pending behavior.

Note on Scenario 3: The check in the workflow looks at src/services/api-proxy-service.ts but OTEL env var forwarding lives in src/services/api-proxy-env-config.ts (via buildApiProxyBaseEnv). The "⚠️ not yet forwarded" message is a false negative — forwarding is correctly implemented.

📡 OTel tracing validated by Smoke OTel Tracing

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ 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 passed ✅ PASS
Go env passed ✅ PASS
Go uuid 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 issue #5571 · 47.4 AIC · ⊞ 7.8K ·

@lpcox lpcox merged commit 597121d into main Jun 26, 2026
90 of 92 checks passed
@lpcox lpcox deleted the copilot/refactor-host-iptables-test branch June 26, 2026 19:58
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.

3 participants