[Test Coverage] Add tests for parseDifcProxyHost and preserveIptablesAudit - #2471
Conversation
Add unit tests for two exported but previously untested functions in docker-manager.ts: - parseDifcProxyHost: tests empty/whitespace input, host:port, host without port, scheme prefixes, IPv6 bracketed notation, invalid format, port 0, and boundary ports (1, 65535). - preserveIptablesAudit: tests the copy-when-both-exist path, the no-op when source is missing, the no-op when target dir is missing, and the default audit dir (workDir/audit) behaviour. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds unit test coverage for two previously untested exported helpers in src/docker-manager.ts, improving confidence in DIFC proxy host parsing and iptables audit preservation behavior.
Changes:
- Added unit tests for
parseDifcProxyHostcovering defaulting, scheme stripping, IPv6 bracket parsing, and invalid/edge port handling. - Added unit tests for
preserveIptablesAuditcovering copy/no-op behavior and default audit directory selection.
Show a summary per file
| File | Description |
|---|---|
| src/docker-manager.test.ts | Adds new test suites validating parseDifcProxyHost parsing/error cases and preserveIptablesAudit file copy/no-op behavior. |
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
|
Smoke Test Results
Overall: PASS
|
🤖 Smoke Test Results
PR: [Test Coverage] Add tests for parseDifcProxyHost and preserveIptablesAudit Overall: FAIL — pre-computed test data was not injected (workflow template variables were unexpanded).
|
🔥 Smoke Test: Copilot BYOK (Offline) Mode
Running in BYOK offline mode ( Overall: PARTIAL — BYOK inference and MCP ✅; pre-step data tests skipped due to unresolved template variables. PR by
|
🏗️ Build Test Suite Results
Overall: 0/8 ecosystems passed — ❌ FAIL ❌ Error DetailsAll repository clones failed. The Error for all ecosystems: All 8 ecosystems (Bun, C++, Deno, .NET, Go, Java, Node.js, Rust) returned
|
|
PR titles: unavailable 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.
|
Chroot Runtime Version Comparison
Result:
|
Smoke Test Results
Overall: FAIL — service containers unreachable from this runner.
|
- Resolve rename conflict in docker-manager-compose.test.ts (keep split version) - Remove unused imports from docker-manager-compose.test.ts - Add parseDifcProxyHost tests to docker-manager-utils.test.ts (from #2471) - Add preserveIptablesAudit tests to docker-manager-cleanup.test.ts (from #2471) - Auto-merge log-streamer.ts refactor from #2495
Summary
Adds unit tests for two exported but previously untested functions in
src/docker-manager.ts.What was covered
parseDifcProxyHostThis function parses
--difc-proxy-hostvalues (host:port strings) used to configure the DIFC proxy. Coverage added:host.docker.internal:18443host:portwithout a scheme18443tcp://,https://) stripped correctly[::1]:18443Invalid --difc-proxy-hostportNum < 1guard (throwsInvalid --difc-proxy-host port: 0)Invalid --difc-proxy-host)preserveIptablesAuditThis function copies the iptables audit file from
workDir/init-signal/iptables-audit.txtto an audit directory. Coverage added:workDir/auditdirectory whenauditDiris not specifiedBefore / After Coverage (docker-manager.ts)
Security relevance
parseDifcProxyHostis used to configure network routing for the DIFC proxy sidecar. The input validation (port range, format) is security-relevant — malformed values should fail clearly rather than silently falling through. The new tests confirm correct error paths.