Skip to content

[Test Coverage] Improve host-iptables.ts branch coverage#2829

Merged
lpcox merged 1 commit intomainfrom
test-coverage/host-iptables-branch-coverage-b77452fdb1d9455c
May 10, 2026
Merged

[Test Coverage] Improve host-iptables.ts branch coverage#2829
lpcox merged 1 commit intomainfrom
test-coverage/host-iptables-branch-coverage-b77452fdb1d9455c

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Summary

Adds 8 new tests covering previously uncovered branches in src/host-iptables.ts, improving branch coverage from 55.55% (10/18) toward higher coverage.

Changes

  • src/host-iptables.test.ts — 232 lines added, 8 new test cases

Security-Critical Paths Now Covered

Branch Description
cliProxyConfig path CLI proxy DIFC host access: allows cli-proxy IP to reach host gateway on DIFC port (both AWF and Docker bridge gateways)
cliProxyConfig + null Docker gateway Only AWF gateway rule added when Docker bridge is unavailable
IPv6 DNS + ip6tables available Creates FW_WRAPPER_V6 chain and adds IPv6 DNS allowlist rules
Existing FW_WRAPPER_V6 cleanup Flushes and deletes existing IPv6 chain before recreation
DOCKER-USER chain creation failure Throws specific error when chain creation fails after chain not found
getDockerBridgeGateway invalid IPv4 Skips gateway with non-IPv4 value, only uses AWF network gateway
cleanupHostIptables with null bridge Skips DOCKER-USER rule removal when bridge name is not found

Before / After

Metric Before After (estimated)
Branch coverage (host-iptables.ts) 55.55% (10/18) ~83%+ (15/18)
Overall branch coverage 31.78% ~33%+

Test Design

All tests follow existing patterns:

  • Mock execa with jest.mock()
  • Reset IPv6 state via __testing._resetIpv6State() in beforeEach
  • Test one behavior per test case
  • No Docker, no real iptables calls — fully deterministic

No Bugs Found

All uncovered branches appear to work correctly. The getDockerBridgeGateway IPv4 validation (preventing injection of arbitrary strings into iptables rules) is a good security safeguard that is now tested.

Generated by Weekly Test Coverage Improver · ● 4.1M ·

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lpcox lpcox marked this pull request as ready for review May 10, 2026 15:22
@lpcox lpcox requested a review from Mossaka as a code owner May 10, 2026 15:22
Copilot AI review requested due to automatic review settings May 10, 2026 15:22
@github-actions
Copy link
Copy Markdown
Contributor Author

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 87.37% 88.04% 📈 +0.67%
Statements 87.34% 87.98% 📈 +0.64%
Functions 82.70% 82.70% ➡️ +0.00%
Branches 79.43% 79.94% 📈 +0.51%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/container-lifecycle.ts 87.1% → 88.2% (+1.14%) 87.5% → 88.6% (+1.11%)
src/host-iptables.ts 88.7% → 97.7% (+8.95%) 88.5% → 97.3% (+8.84%)

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

@github-actions
Copy link
Copy Markdown
Contributor Author

Smoke Test Results

  • ✅ Playwright: github.com title verified
  • ✅ File Writing: test file created
  • ✅ Bash Tool: file verified
  • ❌ GitHub MCP: auth failed (401)

Status: 3/4 tests passed

💥 [THE END] — Illustrated by Smoke Claude

@github-actions
Copy link
Copy Markdown
Contributor Author

Smoke Test: Copilot BYOK (Offline) Mode

Test Result
GitHub MCP connectivity ❌ (401 - GitHub MCP auth unavailable in this run)
GitHub.com HTTP ❌ (pre-step template vars not resolved: ${{ steps.smoke-data.outputs.SMOKE_HTTP_CODE }})
File write/read ❌ (pre-step template vars not resolved)
BYOK inference (agent → api-proxy → api.githubcopilot.com)

Running in BYOK offline mode (COPILOT_OFFLINE=true) via api-proxy → api.githubcopilot.com.

Overall: FAIL — pre-step data was not injected (template variables unresolved). BYOK inference path itself is ✅.

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions
Copy link
Copy Markdown
Contributor Author

🤖 Smoke Test Results

Test Status
GitHub MCP connectivity ❌ (401 – unauthenticated)
GitHub.com HTTP ⚠️ pre-step data not injected
File write/read ✅ smoke file exists and readable

Overall: PARTIAL

Author: @copilot

📰 BREAKING: Report filed by Smoke Copilot

@github-actions github-actions Bot mentioned this pull request May 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor Author

Smoke Test

PRs: fix: unexport test-only command option types; refactor: extract shared logger mock factory to test-utils
GitHub MCP ❌; safeinputs-gh ❌; Playwright ✅; Tavily ❌
File write ✅; Bash read ✅; Discussion comment ✅; Build ✅
Overall status: FAIL

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds additional Jest unit tests to exercise previously uncovered branches in src/host-iptables.ts, increasing confidence in security-sensitive host iptables rule setup/cleanup behavior without requiring real Docker/iptables execution.

Changes:

  • Add new setupHostIptables tests covering cliProxyConfig host-gateway allow rules (including missing Docker bridge gateway).
  • Add new IPv6 DNS tests covering ip6tables available/unavailable paths and existing IPv6 chain cleanup.
  • Add targeted tests for error/edge branches: DOCKER-USER chain creation failure, invalid Docker bridge gateway IPv4 handling, and cleanup behavior when bridge name is unavailable.
Show a summary per file
File Description
src/host-iptables.test.ts Adds 8 new deterministic tests to cover additional host-iptables.ts branches (cli proxy host access, IPv6 DNS handling, and cleanup/error edge cases).

Copilot's findings

Tip

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

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@github-actions
Copy link
Copy Markdown
Contributor Author

Smoke Test Results

  • Redis PING: ❌ (connection timeout — host.docker.internal unreachable)
  • PostgreSQL pg_isready: ❌ (no response)
  • PostgreSQL SELECT 1: ❌ (not attempted)

Overall: FAIL — service containers are not reachable from this environment. host.docker.internal does not resolve/connect (no Docker bridge networking available in this runner context).

🔌 Service connectivity validated by Smoke Services

@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 1/1 passed ✅ PASS
Go env 1/1 passed ✅ PASS
Go uuid 1/1 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 #2829 · ● 527.1K ·

@github-actions
Copy link
Copy Markdown
Contributor Author

🧪 Chroot Runtime Version Comparison

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3 ❌ NO
Node.js v24.14.1 v20.20.2 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

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

Tested by Smoke Chroot

@lpcox lpcox merged commit 3fcb6bc into main May 10, 2026
68 of 72 checks passed
@lpcox lpcox deleted the test-coverage/host-iptables-branch-coverage-b77452fdb1d9455c branch May 10, 2026 15:39
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