Repository navigation
[Test Quality] Cover wildcard pattern fallthrough after protocol mismatch - #11347
Conversation
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified, and the change is limited to targeted regression coverage for protocol-aware wildcard matching.
No open issues 🎉
What changed in this PR
This pull request adds regression coverage for wildcard domain matching when an earlier host match is incompatible by protocol, without changing production code.
Changes:
- Tests fallthrough from HTTP-only to HTTPS-only wildcard patterns.
- Covers
bothprotocol entries with a later compatible pattern. - Adds a negative control for unmatched domains.
| File | Description |
|---|---|
src/domain-patterns.test.ts |
Adds regression tests for protocol-aware wildcard pattern fallthrough. |
Review effort: Lite (auto)
|
One or more custom setup steps configured for this repository failed during this Copilot code review run: Setup steps run before each review. If the review above is missing context, or no review was posted at all, the failing step above may be the cause. See the workflow run for failure details, fix your setup steps configuration, and re-request a review. Note You can configure setup steps for Copilot code review separately from Copilot cloud agent with a |
|
✅ Copilot review passed with no inline comments. @github-actions[bot] Add the |
Contract
isDomainMatchedByPattern(src/domain-matchers.ts) decides whether a plain--allow-domainsentry is already covered by a wildcard pattern, using protocol compatibility rules ((redacted) It must evaluate *every* pattern; a protocol-incompatible match on an earlier pattern must not stop the search. See the doc comment insrc/domain-matchers.tsandsrc/domain-patterns.ts` header.Previous weakness
Every existing test used a single pattern for protocol cases, or multiple patterns with the same protocol. A regression that returns
falseon the first host-matching-but-protocol-incompatible pattern (instead of continuing) passed all 205 tests indomain-patterns,domain-utils,squid-config-domains(verified by temporary mutation). Impact: a domain would be wrongly treated as not covered, producing redundant/incorrect ACL entries.Change
One test added to
src/domain-patterns.test.ts(real function, no mocks): http-only then https-only pattern; http-only then both pattern for abothentry; and a negative control where no pattern covers the entry.Evidence
jest --runInBand --no-coverage --runTestsByPath src/domain-patterns.test.ts src/domain-utils.test.ts src/squid-config-domains.test.ts→ 205 passed (mutation missed).Expected: true / Received: falsein the new test), 88 passed.domain-patterns.test.ts. ESLint: 0 errors (6 pre-existing warnings).CI
Discovered by root Jest (
src/**/*.test.ts) in the existing unit test job. This is component-level evidence only, not Squid enforcement.