refactor(tests): extract setupDefaultIptablesMocks to eliminate repeated iptables mock sequences#3140
Conversation
…cate iptables mock setup
There was a problem hiding this comment.
Pull request overview
Refactors duplicated iptables mock setup sequences across two test files into a shared setupDefaultIptablesMocks helper to reduce ~200 lines of boilerplate.
Changes:
- Adds
setupDefaultIptablesMockshelper tosrc/test-helpers/host-iptables-test-setup.tswith configurablechainExists,bridgeName, andcatchAllStdoutoptions. - Replaces 26 inline
mockedExecasetup sequences inhost-iptables-setup.test.tsandhost-iptables-host-access.test.tswith helper calls. - Removes unused
execaResultimport fromhost-iptables-host-access.test.ts.
Show a summary per file
| File | Description |
|---|---|
| src/test-helpers/host-iptables-test-setup.ts | New shared helper consolidating bridge/permission/chain-existence mock sequence. |
| src/host-iptables-setup.test.ts | Replaces inline mock sequences with helper calls. |
| src/host-iptables-host-access.test.ts | Replaces inline mock sequences with helper calls; drops unused import. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 0
Smoke Test Results
Overall: FAIL (1 of 3 tests failed) The GitHub API test failure is expected per documentation: gh CLI is not authenticated. The two operational tests (Playwright navigation and file verification) both passed successfully.
|
🔬 Smoke Test Results
Overall: FAIL The workflow template variables (
|
Smoke Test: Copilot BYOK (Offline) Mode
Note: Running in BYOK offline mode ( Overall: FAIL — workflow template variables (
|
|
Smoke Test Results: File Writing ✅, Bash Tool ✅, GitHub MCP ❌, Connectivity ❌. 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: FAIL 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.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Chroot Version Comparison — Smoke Test Results
Result: FAILED — Python and Node.js versions differ between host and chroot. The chroot environment uses the system-installed binaries (Ubuntu 22.04 defaults), while the host has newer versions installed separately.
|
Smoke Test Results — FAIL
Overall: FAIL
|
✨ Enhancement
26 occurrences of a 3–5 line
mockedExecasetup sequence (bridge name lookup → permission check → chain existence check → catch-all) were copy-pasted acrosshost-iptables-setup.test.tsandhost-iptables-host-access.test.ts.What does this improve?
Implementation approach:
Added
setupDefaultIptablesMocksto the existing sharedsrc/test-helpers/host-iptables-test-setup.ts:chainExists— controls whether the FW_WRAPPER chain existence check returns 0 or 1catchAllStdout— overrides the default catch-all stdout for tests that need specific listing output (e.g. skip-jump-rule test)mockImplementationnaturally override the catch-all sincemockImplementationtakes precedence overmockResolvedValueDropped the now-unused
execaResultimport fromhost-iptables-host-access.test.ts.