Skip to content

test: cover FileShredder denylist and ShredAll confirmation gate#822

Merged
laurentiu021 merged 2 commits into
mainfrom
test/r4-fileshredder-confirm-coverage
Jun 8, 2026
Merged

test: cover FileShredder denylist and ShredAll confirmation gate#822
laurentiu021 merged 2 commits into
mainfrom
test/r4-fileshredder-confirm-coverage

Conversation

@laurentiu021

Copy link
Copy Markdown
Owner

What

First PR of audit Round 4 (test seams & regression coverage). Closes the two highest-priority test gaps:

  • [Enhancement]: System Health ΓÇö BIOS update helper (version, manufacturer link, update guide) #1 (P0)FileShredderService system-path denylist had zero regression coverage. The new FileShredderServiceTests asserts:

    • SecurityException for a file under each protected root (Windows, System32, Program Files, Program Files (x86)) for both ShredFileAsync and ShredFolderAsync
    • case-insensitive enforcement (lowercased System32 path still blocked)
    • ArgumentException on null/empty/whitespace, FileNotFoundException / DirectoryNotFoundException on missing targets
    • positive path: a real temp file is overwritten and removed (Quick); a folder + nested file is fully removed
    • progress reaches 100; a pre-cancelled token throws OperationCanceledException and leaves the file intact
  • [Enhancement]: About ΓÇö seamless auto-update (download, replace, restart) #2 (P1) — no test verified the "every destructive op needs Confirm" contract. Added ShredAll confirmation-gate tests to FileShredderViewModelTests (same pattern as the Round 2a DeepCleanup tests): file survives on decline, is removed on confirm, and Confirm is never raised for an empty queue.

Why

The shredder denylist is the most data-loss-sensitive guard in the app. Before this, a refactor of the prefix list or the StartsWith comparison could silently allow shredding system files with no test failing (TEST-PROTOCOL Phase 2 mandate).

Notes

  • test: only — no production code changed, no version bump, no release, no CHANGELOG entry required.
  • Build verified locally: main + tests, 0 errors / 0 warnings (Release).
  • Regression sweep: only the two test files changed; API surface (ShredMethod values, ShredItem members, Confirm signature, headless-safe ToastService) verified against source.

Closes the highest-priority test gap from the audit (tests #1 P0, #2 P1):

- New FileShredderServiceTests: asserts SecurityException for paths under
  every protected root (Windows, System32, Program Files, Program Files x86),
  a case-insensitive variant, ArgumentException on null/empty, FileNotFound /
  DirectoryNotFound on missing targets, a positive temp-file Quick shred,
  progress-to-100 reporting, recursive folder shred, and no-delete on a
  pre-cancelled token.
- FileShredderViewModelTests: verifies ShredAll routes through
  DialogService.Instance.Confirm — file survives on decline, is removed on
  confirm, and Confirm is never raised when the queue is empty.

The denylist is the most data-loss-sensitive guard in the app and previously
had zero regression coverage; a refactor of the prefix list could have
silently allowed shredding system files with no test failing.
ThrowIfNullOrWhiteSpace throws ArgumentNullException (a subclass of
ArgumentException) for null input; Assert.ThrowsAsync requires an exact
type match, so the null cases failed. Use Assert.ThrowsAnyAsync to accept
both ArgumentNullException (null) and ArgumentException (empty/whitespace).
@laurentiu021 laurentiu021 merged commit d3c5e2e into main Jun 8, 2026
4 checks passed
@laurentiu021 laurentiu021 deleted the test/r4-fileshredder-confirm-coverage branch June 8, 2026 14:15
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.

1 participant