Table-drive token-pattern detector tests #293

Open
didericis-claude wants to merge 1 commits from table-drive-dlp-tests into main
Collaborator

Closes #289.

Summary

The token-pattern detector had 15 near-identical test methods spread across TestScanTokenPatterns and TestScanTokenPatternsExtended — each scanned a body carrying one synthetic token and asserted the reason names the credential type.

This collapses them into a single _TOKEN_PATTERN_CASES table driven by unittest's subTest, so adding a new token shape is a one-line row and a failure reports the offending case id. Each case now also asserts block severity (previously only the AWS case did). TestScanTokenPatternsExtended is removed; its rows live in the table. The non-matrix cases (clean text, location, context, reason) stay as explicit methods.

No production code change. The file drops from 110 to 96 test methods with the same coverage; full unit suite passes; pyright clean; pylint 9.95.

Closes #289. ## Summary The token-pattern detector had 15 near-identical test methods spread across `TestScanTokenPatterns` and `TestScanTokenPatternsExtended` — each scanned a body carrying one synthetic token and asserted the reason names the credential type. This collapses them into a single `_TOKEN_PATTERN_CASES` table driven by `unittest`'s `subTest`, so adding a new token shape is a one-line row and a failure reports the offending case id. Each case now also asserts block severity (previously only the AWS case did). `TestScanTokenPatternsExtended` is removed; its rows live in the table. The non-matrix cases (clean text, location, context, reason) stay as explicit methods. No production code change. The file drops from 110 to 96 test methods with the same coverage; full unit suite passes; pyright clean; pylint 9.95.
didericis-claude added 1 commit 2026-06-25 19:41:32 -04:00
test(dlp): table-drive token-pattern detector cases
lint / lint (push) Successful in 1m51s
test / unit (pull_request) Successful in 46s
test / integration (pull_request) Successful in 18s
c97c01d300
The token-pattern detector had 15 near-identical test methods across
`TestScanTokenPatterns` and `TestScanTokenPatternsExtended`, each
scanning a body carrying one synthetic token and asserting the reason
names the credential type.

Collapse them into a single `_TOKEN_PATTERN_CASES` table driven by
`subTest`, so adding a new token shape is a one-line row. Each case now
also asserts block severity (previously only the AWS case did).
`TestScanTokenPatternsExtended` is removed; its rows live in the table.
The non-matrix cases (clean text, location, context, reason) stay as
explicit methods. No production code change.

Closes #289

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NkwFXLFff9PYPy4wgVBJp9
Some checks are pending
lint / lint (push) Successful in 1m51s
test / unit (pull_request) Successful in 46s
test / integration (pull_request) Successful in 18s
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin table-drive-dlp-tests:table-drive-dlp-tests
git checkout table-drive-dlp-tests
Sign in to join this conversation.