Skip to content

refactor: split squid-config.test.ts (1,964 lines) into 4 domain-focused test files#2556

Merged
lpcox merged 4 commits intomainfrom
copilot/refactor-squid-config-tests
May 5, 2026
Merged

refactor: split squid-config.test.ts (1,964 lines) into 4 domain-focused test files#2556
lpcox merged 4 commits intomainfrom
copilot/refactor-squid-config-tests

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 5, 2026

src/squid-config.test.ts had grown to 1,964 lines with 18 nested describe blocks across 8 distinct test domains, making it hard to navigate and audit security coverage independently.

Split

File Lines Scope
squid-config-security.test.ts 407 Injection defense, direct IP bypass, port validation, dangerous ports blocklist
squid-config-domains.test.ts 528 Protocol handling, subdomains, redundancy removal, wildcards, ordering
squid-config-features.test.ts 687 Logging, streaming timeouts, blocklist, SSL bump, DLP, empty domain list
squid-config.test.ts (reduced) 359 Configuration structure, protocol access rules, real-world patterns, generatePolicyManifest

All 158 tests preserved with no logic changes. Security-focused tests (defense-in-depth, direct IP bypass, dangerous ports) are now grouped in one file for easier auditability.

…t files

- squid-config-security.test.ts: injection defense, direct IP bypass,
  port validation, dangerous ports blocklist (407 lines)
- squid-config-domains.test.ts: protocol domain handling, subdomains,
  wildcards, redundancy, ordering (528 lines)
- squid-config-features.test.ts: logging, streaming, blocklist, SSL bump,
  DLP, empty domain list (687 lines)
- squid-config.test.ts: configuration structure, protocol access rules,
  real-world patterns, generatePolicyManifest (359 lines)

All 158 squid-config tests preserved and passing (1747 total).
Copilot AI changed the title [WIP] Refactor src/squid-config.test.ts by splitting test domains refactor: split squid-config.test.ts (1,964 lines) into 4 domain-focused test files May 5, 2026
Copilot finished work on behalf of lpcox May 5, 2026 13:50
Copilot AI requested a review from lpcox May 5, 2026 13:50
@lpcox lpcox marked this pull request as ready for review May 5, 2026 13:54
@lpcox lpcox requested a review from Mossaka as a code owner May 5, 2026 13:54
Copilot AI review requested due to automatic review settings May 5, 2026 13:54
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 86.45% 86.53% 📈 +0.08%
Statements 86.39% 86.46% 📈 +0.07%
Functions 90.61% 90.61% ➡️ +0.00%
Branches 79.23% 79.27% 📈 +0.04%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/container-lifecycle.ts 86.1% → 87.2% (+1.09%) 86.3% → 87.4% (+1.08%)

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

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

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

This PR reorganizes the squid-config unit suite by splitting the former large src/squid-config.test.ts file into smaller domain-focused test files. It fits the codebase by keeping the existing generateSquidConfig/generatePolicyManifest coverage while making individual areas of Squid policy behavior easier to locate and audit.

Changes:

  • Split security-related generateSquidConfig tests into src/squid-config-security.test.ts.
  • Split domain/protocol/wildcard behavior into src/squid-config-domains.test.ts and logging/SSL/DLP/blocklist behavior into src/squid-config-features.test.ts.
  • Reduced src/squid-config.test.ts to core config-structure, real-world pattern, protocol-order, and generatePolicyManifest coverage.
Show a summary per file
File Description
src/squid-config.test.ts Keeps the core Squid config and policy manifest assertions after the split.
src/squid-config-security.test.ts New focused suite for injection defense, direct-IP bypass, and host-port safety tests.
src/squid-config-features.test.ts New focused suite for logging, timeouts, blocklist, SSL bump, DLP, and empty-domain behavior.
src/squid-config-domains.test.ts New focused suite for domain normalization, wildcard handling, ordering, and protocol-specific domain behavior.

Copilot's findings

Tip

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

  • Files reviewed: 4/4 changed files
  • Comments generated: 3

Comment thread src/squid-config-domains.test.ts Outdated
Comment on lines +3 to +6

// Pattern constant for the safer domain character class (matches the implementation)
const DOMAIN_CHAR_PATTERN = '[a-zA-Z0-9.-]*';

Comment thread src/squid-config-features.test.ts Outdated
Comment on lines +6 to +7
// Pattern constant for the safer domain character class (matches the implementation)
const DOMAIN_CHAR_PATTERN = '[a-zA-Z0-9.-]*';

describe('generateSquidConfig', () => {
const defaultPort = 3128;

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@lpcox
Copy link
Copy Markdown
Collaborator

lpcox commented May 5, 2026

@copilot merge main and address the review feedback

Copilot AI added 2 commits May 5, 2026 18:29
…d-config-tests

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
…g test docs

- Export DOMAIN_CHAR_PATTERN from domain-patterns.ts as the single source of truth
- Replace local const definitions in squid-config-domains.test.ts and
  squid-config-features.test.ts with an import from domain-patterns.ts
- Update domain-patterns.test.ts to also import rather than redeclare the constant
- Update CLAUDE.md to reference squid-config-features.test.ts for logging tests
  and use the correct test file name in the run-tests command
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 5, 2026

@copilot merge main and address the review feedback

Done. In commit 6a2cae8:

  • Merged main.
  • Exported DOMAIN_CHAR_PATTERN from domain-patterns.ts as the single source of truth and replaced the three local copies in squid-config-domains.test.ts, squid-config-features.test.ts, and domain-patterns.test.ts with imports.
  • Updated CLAUDE.md to point to squid-config-features.test.ts (and the correct npm test command) for logging test validation.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Documentation Preview

Documentation build failed for this PR. View logs.

Built from commit 66b041b

Copilot finished work on behalf of lpcox May 5, 2026 18:35
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

✅ GitHub MCP: Last 2 merged PRs (#2571, #2538)
✅ Playwright: Page title contains 'GitHub'
✅ File Writing: Test file created
✅ Bash Verification: Content verified

Overall: PASS

💥 [THE END] — Illustrated by Smoke Claude

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

🔥 Smoke Test: Copilot BYOK (Offline Mode)

Test Result
GitHub MCP (list PRs)
GitHub.com connectivity ✅ (pre-step validated)
File write/read (smoke-test-copilot-byok-25394958741.txt)
BYOK inference (agent → api-proxy → api.githubcopilot.com)

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

Author: @Copilot | Assignees: @lpcox, @Copilot

Overall: PASS

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

🔬 Smoke Test Results

Test Result
GitHub MCP connectivity ✅ PASS
GitHub.com HTTP connectivity ⚠️ N/A (pre-step data not expanded)
File write/read ⚠️ N/A (pre-step data not expanded)

PR: refactor: split squid-config.test.ts (1,964 lines) into 4 domain-focused test files
Author: @Copilot | Assignees: @lpcox, @Copilot

Overall: PARTIAL — MCP ✅, pre-computed test data unavailable (template variables not expanded by workflow)

📰 BREAKING: Report filed by Smoke Copilot

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Smoke Test

PRs: api-proxy: inject X-Initiator: agent default on all Copilot-bound requests to prevent billing inflation; fix: one-shot-token.so fails to load on musl/Alpine hosts (ARC runners)
✅ GitHub PR review
❌ Safe Inputs GH CLI (tool unavailable; gh fallback returned 2 PRs)
✅ Playwright title contains GitHub
❌ Tavily search (no tools registered)
✅ File write/read
✅ Discussion comment
✅ npm ci && npm run 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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

🔍 Chroot Version Comparison

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

Result: Not all versions matched — smoke-chroot label not applied.

Tested by Smoke Chroot

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

🏗️ 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 #2556 · ● 1.6M ·

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Smoke Test Results — Services Connectivity

Check Result
Redis PING ❌ Timeout (no response)
PostgreSQL pg_isready ❌ No response on port 5432
PostgreSQL SELECT 1 ❌ Timeout

Overall: FAILhost.docker.internal is not reachable from this environment. Service containers are not accessible.

🔌 Service connectivity validated by Smoke Services

@lpcox lpcox enabled auto-merge (squash) May 5, 2026 20:17
@lpcox lpcox disabled auto-merge May 5, 2026 20:17
@lpcox lpcox merged commit 8084f09 into main May 5, 2026
64 of 70 checks passed
@lpcox lpcox deleted the copilot/refactor-squid-config-tests branch May 5, 2026 20:18
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.

[Refactoring] Split src/squid-config.test.ts (1,964 lines) by test domain

3 participants