Refactor host iptables tests and fix follow-up CI regressions#2901
Conversation
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (2 files)
✨ New Files (4 files)
Coverage comparison generated by |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Refactors the previously monolithic host-iptables Jest test suite into several focused modules to make security-critical firewall contract coverage easier to navigate and extend.
Changes:
- Split
src/host-iptables.test.tsinto focused test files for network, setup, host-access, cleanup, and DoH scenarios - Preserved existing mocking patterns and assertions while redistributing coverage
- Removed the original monolithic test file after migrating scenarios
Show a summary per file
| File | Description |
|---|---|
| src/host-iptables.test.ts | Deletes the monolithic host iptables test suite after scenarios are redistributed. |
| src/host-iptables-setup.test.ts | Adds focused coverage for setupHostIptables, IPv6 behavior, CLI proxy rules, and isValidPortSpec. |
| src/host-iptables-network.test.ts | Adds focused coverage for firewall network ensure/remove behavior. |
| src/host-iptables-host-access.test.ts | Adds focused coverage for host-access and gateway rule variants. |
| src/host-iptables-doh.test.ts | Adds focused coverage for DoH-specific setup rules. |
| src/host-iptables-cleanup.test.ts | Adds focused coverage for cleanupHostIptables including IPv6 best-effort cleanup and sysctl behavior. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 6/6 changed files
- Comments generated: 5
| import { isValidPortSpec, setupHostIptables, __testing } from './host-iptables'; | ||
| import execa from 'execa'; | ||
|
|
||
| // Mock execa | ||
| jest.mock('execa'); | ||
| const mockedExeca = execa as jest.MockedFunction<typeof execa>; | ||
|
|
||
| // Mock getLocalDockerEnv to return a predictable env for assertions | ||
| jest.mock('./docker-manager', () => ({ | ||
| getLocalDockerEnv: () => process.env, | ||
| })); | ||
|
|
||
| // Mock logger to avoid console output during tests | ||
| // eslint-disable-next-line @typescript-eslint/no-require-imports | ||
| jest.mock('./logger', () => require('./test-helpers/mock-logger.test-utils').loggerMockFactory()); |
| // eslint-disable-next-line @typescript-eslint/no-require-imports | ||
| jest.mock('./logger', () => require('./test-helpers/mock-logger.test-utils').loggerMockFactory()); | ||
|
|
||
| describe('host-iptables', () => { |
| __testing._resetIpv6State(); | ||
| }); | ||
|
|
||
| describe('setupHostIptables with host access', () => { |
| .mockResolvedValueOnce({ | ||
| stdout: 'fw-bridge', | ||
| stderr: '', | ||
| exitCode: 0, | ||
| } as any) |
| // Verify API proxy sidecar rule was added with port range | ||
| expect(mockedExeca).toHaveBeenCalledWith('iptables', expect.arrayContaining([ | ||
| '-t', 'filter', '-A', 'FW_WRAPPER', | ||
| '-p', 'tcp', '-d', '172.30.0.30', | ||
| ])); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@copilot address review feedback |
Addressed in 0270d4b. I extracted the shared host-iptables test bootstrap into |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Addressed in e8e37f7. I added a one-line markdownlint suppression in |
|
@copilot merge main |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Addressed in 5524a98. I merged the latest |
Smoke Test: Copilot BYOK (Offline) Mode
Running in BYOK offline mode (COPILOT_OFFLINE=true) via api-proxy → api.githubcopilot.com Overall: FAIL — pre-step outputs not available; GitHub MCP unauthenticated.
|
Smoke Test Results❌ GitHub MCP Testing (gh CLI not authenticated per system config) Status: 3/4 PASS
|
|
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 Smoke Test Results
Overall: ❌ FAILED — Python and Node.js versions differ between host and chroot environments.
|
🔍 Smoke Test Results — PR #2901
PR author: Overall: FAIL — GitHub MCP returned 401; template substitution did not resolve
|
Smoke Test Results — FAIL
Overall: FAIL
|
mainmaininto the PR branch and resolve any conflicts minimally