Skip to content

[Test Quality] test: assert DLP ACLs are defined before their deny rule - #11936

Merged
lpcox merged 2 commits into
mainfrom
test-quality/dlp-acl-definition-order-d618c5041896b02a
Nov 22, 2026
Merged

lpcox merged 2 commits into
mainfrom
test-quality/dlp-acl-definition-order-d618c5041896b02a

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Contract

Squid parses squid.conf top-down. Every acl must be defined before any http_access line references it, otherwise Squid rejects the config at startup or the rule is ineffective. The DLP block (generateDlpSquidConfig, emitted via src/squid/config-generator.ts) must therefore place its acl dlp_blocked url_regex ... definitions before http_access deny dlp_blocked.

Reference: src/squid/config-generator.ts emits ${dlpAclSection} before ${dlpAccessSection} in the template.

Previous weakness and missed regression

src/squid-config-dlp.test.ts only asserted that http_access deny dlp_blocked precedes http_access deny !allowed_domains. It never checked the definitions. I confirmed the gap by moving the ${dlpAclSection} template line after ${dlpAccessSection}: all 8 existing DLP tests still passed, so the regression was undetected.

Change

Adds one test case in the existing DLP Integration block. It takes the generated config and asserts that every acl dlp_blocked line (at least 10) appears before the single http_access deny dlp_blocked line. This is a config-output oracle with no mocks; it uses the real generator.

Test-only change: src/squid-config-dlp.test.ts (+21 lines). No production code, manifests, or workflows changed.

Regression sensitivity

  • Clean tree: src/squid-config-dlp.test.ts passes 9/9.
  • Mutation (temporary, reverted): swapped the DLP ACL and access sections in src/squid/config-generator.ts. The new test fails at expect(Math.max(...aclLineIndexes)).toBeLessThan(denyLineIndexes[0]) (Expected < 99, Received 118). The other 8 tests still pass, so the failure is the intended assertion, not setup or syntax. The production file was restored with no diff.

Validation

  • ./node_modules/.bin/jest --runInBand --no-coverage --testPathPatterns 'squid|dlp|domain': 34 suites, 751 tests passed.
  • npx eslint src/squid-config-dlp.test.ts: exit 0.
  • npx tsc --noEmit -p tsconfig.json: exit 0.

CI discovery

The file runs in root npm test (jest, roots src/ and scripts/), executed by the build.yml unit-test job on every PR. No new test file was added.

Limitations

This verifies the generated Squid config text, not a running Squid. I did not run real Squid because Docker and the Squid container are unavailable in this environment. The assertion checks ordering only, not that the regexes are accepted by Squid's POSIX engine.

Notes on docs

docs/INTEGRATION-TESTS.md and the code comments say DLP denies come "before allow rules". The generated config puts the DLP deny after the API-proxy allow rules (lines 118 and 125 in a sample render). This PR does not change that behavior or encode it as the spec. It only pins the definition-before-reference invariant.

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

  • expires on Dec 22, 2026, 12:40 PM UTC

The DLP ordering test only checked that the dlp_blocked deny precedes the
domain deny. It did not check that the acl dlp_blocked definitions precede
the http_access rule that references them. Squid parses squid.conf top-down,
so a misplaced definition is a startup failure or silently ineffective.

Add an assertion over the generated config. It passes on the current
template and fails when the DLP ACL section is moved after its deny rule.

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

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.

🟡 Changes recommended

The new fixture does not exercise API-proxy upstreams, so it could miss a regression where the DLP ACL definition appears after API-proxy rules that reference it.

1 open issue
What changed in this PR

This PR strengthens DLP configuration regression coverage by verifying that generated Squid ACL definitions appear before the access rule that references them, without changing production behavior.

Changes:

  • Adds an integration test using the real Squid configuration generator.
  • Verifies the expected DLP ACL definitions precede the standalone http_access deny dlp_blocked rule.
  • Keeps the change limited to the existing DLP test suite.
File Description
src/​squid-config-dlp.test.ts Adds generated-config assertions covering the ordering of DLP ACL definitions before the DLP deny rule.

Review effort: Lite (adaptive)

Comment thread src/squid-config-dlp.test.ts Resolved
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@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 merged commit 329170a into main Nov 22, 2026
39 of 41 checks passed
@lpcox
lpcox deleted the test-quality/dlp-acl-definition-order-d618c5041896b02a branch November 22, 2026 17:24
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.

2 participants