Skip to content

[Test Quality] Assert exact Squid protocol rule lines in access-rules tests - #11778

Merged
lpcox merged 2 commits into
mainfrom
test-quality/access-rules-exact-rule-lines-5ac8932d5b1ec586
Nov 18, 2026
Merged

lpcox merged 2 commits into
mainfrom
test-quality/access-rules-exact-rule-lines-5ac8932d5b1ec586

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Contract

Protocol-restricted allowlist entries ((host/redacted) = HTTP only, (host/redacted)= HTTPS only) must produce the matching Squidhttp_accessrule. Documented indocs/usage.md(protocol prefixes:(secure.com/redacted)is HTTPS only,(legacy.com/redacted) is HTTP only). The rule text is generated in src/squid/access-rules.ts.

Weakness

src/squid/access-rules.test.ts checked these rules with toContain on the whole access-rules section. http_access allow !CONNECT allowed_http_only is a substring of http_access allow !CONNECT allowed_http_only_regex (and the same for the HTTPS pair). So the plain-domain assertions also passed when the regex rule was emitted in its place.

Missed regressions (verified)

  • Mutation A: the plain HTTP-only rule emitted as the _regex variant. Old tests: 89/89 pass across access-rules, acl-generator, and squid-config-domains suites. A plain HTTP domain would then be matched against the wrong ACL.
  • Mutation B: the plain HTTPS rule dropped when HTTPS patterns coexist. Old access-rules tests: 20/20 pass.

Change

The eight protocol-rule assertions now compare whole lines via a small ruleLines() helper. No production code changed. Only src/squid/access-rules.test.ts is modified.

Regression sensitivity (after)

Run Result
Unmutated 20/20 pass
Mutation A 2 fail (allows !CONNECT allowed_http_only for plain domains; both !CONNECT rules when coexisting)
Mutation B 1 fails (both CONNECT rules when HTTPS domains and patterns coexist)

Mutations were temporary edits to src/squid/access-rules.ts, reverted with git checkout before each clean run. The committed diff contains no production changes.

Commands

  • npm run build (exit 0)
  • ./node_modules/.bin/jest --runInBand --no-coverage --runTestsByPath src/squid/*.test.ts src/squid-config-domains.test.ts src/squid-config-core.test.ts src/domain-patterns.test.ts: 13 suites, 352 tests pass
  • npx eslint src/squid/access-rules.test.ts: clean

CI discovery

.github/workflows/root-unit-tests.yml runs npm test (root Jest). ./node_modules/.bin/jest --listTests lists the file.

Limitations

  • Docker is unavailable in this sandbox, so integration tests were not run. This change is component-level (generated rule text). It does not prove Squid enforces the rules. Enforcement is covered by the Docker-based integration suites, which were not run here.
  • No tests were removed or consolidated.

Generated by Test Quality Improver · copilot · routed: haiku55 xhigh · ~21 AIC · ⌖ ~2 AIC · ⊞ 5.4K · ◷

  • expires on Dec 18, 2026, 12:41 PM UTC

The protocol-restricted allowlist tests used toContain on the access
rules section. 'http_access allow !CONNECT allowed_http_only' is a
substring of the '_regex' variant, so the plain-domain assertions also
passed when the regex rule was emitted in its place, or when the plain
rule was dropped while patterns coexisted.

Compare whole rule lines for the eight protocol-rule assertions. Two
temporary production mutations (plain HTTP rule swapped for regex;
plain HTTPS rule dropped when HTTPS patterns coexist) now fail the
intended tests; the previous assertions passed both.

Co-authored-by: Copilot <[email protected]>
@lpcox
lpcox marked this pull request as ready for review November 18, 2026 14:56
Copilot AI adaptive review requested due to automatic review settings November 18, 2026 14:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain, and the change is limited to strengthening protocol-specific Squid rule tests without modifying production code.

No open issues 🎉

What changed in this PR

This PR strengthens tests for Squid protocol-specific access rules by requiring complete rule-line matches instead of substring matches, improving regression detection without changing production behavior.

Changes:

  • Adds a ruleLines() helper to split generated access-rule sections into individual lines.
  • Updates HTTP-only and HTTPS-only assertions to distinguish plain ACLs from _regex ACLs.
  • Leaves production code unchanged.
File Description
src/​squid/​access-rules.test.ts Adds exact line-based assertions for plain and regex protocol-specific Squid access rules.

Review effort: Lite (adaptive)

@github-actions

Copy link
Copy Markdown
Contributor Author

✅ Copilot review passed with no inline comments.

@github-actions[bot] Add the ready-for-aw label to this PR to trigger agentic CI smoke tests.

@lpcox

lpcox commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

@copilot merge main and resolve conflicts

…ules-exact-rule-lines-5ac8932d5b1ec586

Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Copilot AI commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

@copilot merge main and resolve conflicts

Merged main without conflicts; the two-parent merge commit is a6b12ca. Targeted Jest tests were blocked because this environment has Node 20 while the locked dependencies require Node 22+.

Copilot AI requested a review from lpcox November 18, 2026 18:27
@lpcox
lpcox merged commit 6e447e1 into main Nov 18, 2026
39 of 41 checks passed
@lpcox
lpcox deleted the test-quality/access-rules-exact-rule-lines-5ac8932d5b1ec586 branch November 18, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants