Repository navigation
[Test Quality] Assert exact Squid protocol rule lines in access-rules tests - #11778
Conversation
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]>
There was a problem hiding this comment.
🟢 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
_regexACLs. - 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)
|
✅ Copilot review passed with no inline comments. @github-actions[bot] Add the |
|
@copilot merge main and resolve conflicts |
…ules-exact-rule-lines-5ac8932d5b1ec586 Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Merged |
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 insrc/squid/access-rules.ts.Weakness
src/squid/access-rules.test.tschecked these rules withtoContainon the whole access-rules section.http_access allow !CONNECT allowed_http_onlyis a substring ofhttp_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)
_regexvariant. Old tests: 89/89 pass acrossaccess-rules,acl-generator, andsquid-config-domainssuites. A plain HTTP domain would then be matched against the wrong ACL.access-rulestests: 20/20 pass.Change
The eight protocol-rule assertions now compare whole lines via a small
ruleLines()helper. No production code changed. Onlysrc/squid/access-rules.test.tsis modified.Regression sensitivity (after)
allows !CONNECT allowed_http_onlyfor plain domains; both!CONNECTrules when coexisting)Mutations were temporary edits to
src/squid/access-rules.ts, reverted withgit checkoutbefore 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 passnpx eslint src/squid/access-rules.test.ts: cleanCI discovery
.github/workflows/root-unit-tests.ymlrunsnpm test(root Jest)../node_modules/.bin/jest --listTestslists the file.Limitations