Skip to content

test: pin the validators' anchors, the update target's canonicalisation and the uninstall list - #3233

Merged
laurentiu021 merged 1 commit into
mainfrom
test/pin-validators-and-uninstall-list
Nov 10, 2026
Merged

laurentiu021 merged 1 commit into
mainfrom
test/pin-validators-and-uninstall-list

Conversation

@laurentiu021

Copy link
Copy Markdown
Owner

Tests only, plus the two test seams the uninstall-list tests need. Nothing the app does changes, so this releases nothing.

What changes

  • A trailing line break for every anchored validator. WingetId.IsValid, WingetId.IsLocalUninstallId, ServiceManagerService's service name check and DebloaterService's package full name check use \A…\z, whose comments say why: $ also matches just before a final line break. Every newline case in their tests had text after the break ("pkg\nnewline"), which the character class refuses under either anchor, so reverting any pattern to ^…$ left the suites green. "pkg\n", "Git.Git\n", "svc\n", a full name ending in \n and local ids ending in \n are added to WingetIdTests, WingetServiceValidationTests, BulkInstallerServiceTests, ServiceManagerServiceTests and DebloaterServiceTests, and the WingetIdTests comment that called the mid-string case the \z case is corrected. App Blocker's name check already has a trailing-newline case.
  • Canonicalisation seen through the check it protects. ApplyTarget_ResolvesDotSegments_BeforeTheSystemFolderCheck gives UpdateApplier.IsValidApplyTarget a target such as C:\Users\..\Windows\System32\SysManager-vX.Y.Z.exe, whose raw form does not start with the Windows folder and whose canonical form does, and expects the system-directory refusal.
  • The uninstall list the leftover search refuses folders by. UninstallEntries.ReadAll gets an overload that takes the lists to read, and UninstallEntriesTests runs it over a throwaway HKCU\Software\SysManagerTests\… tree: the three lists in order with every value an entry carries, SystemComponent counting only as a DWORD 1, ParentKeyName and update release types, a missing list leaving the read whole, a list denied to the current user making it incomplete, one denied entry being skipped with the read still whole, and the lists production reads. The deny rules are real registry ACLs, checked to bite before the read and removed afterwards. SystemLeftoverEnvironment gets a constructor that takes its read, so a test checks the folders and uninstall commands that reach the search.

How it was checked

Each new case was run against its pattern with \A…\z changed to ^…$ and failed, and only the trailing-newline cases did: four cases for IsValid (winget id, upgrade, uninstall, bulk install), both local ids, both service name theories, and the package full name. With full = Path.GetFullPath(targetExe) replaced by the raw argument, the new update-target test failed and the old one still passed, which is the gap. For the uninstall list: reporting a denied list as whole, counting any SystemComponent value, dropping the user's list, ignoring ParentKeyName, and dropping the uninstall command on the way to the search each failed their test. Unit suite twice, the format check, and all four projects built with no warnings.

…on and the uninstall list

The winget id, service name and package full name checks anchor with
\A and \z, since $ also matches just before a last line break, and no
test gave any of them a trailing line break: every newline case had
text after it, which the character class refuses under either anchor.
Each now has one, and each new case failed with its pattern's anchors
changed to ^ and $.

ApplyTarget_ResolvesDotSegmentsBeforeDeciding passed with the
canonicalisation it is named for deleted. A target whose dot segments
climb into the Windows folder, so only its canonical form starts with
it, is refused as in a system directory, and with the canonicalisation
taken out the new test fails on "does not exist".

The uninstall entries the leftover search refuses folders by had no
test of their own. ReadAll takes the lists it reads, and is tested over
a registry tree written under HKCU\Software\SysManagerTests: the three
lists in order, hidden components and updates, a list that cannot be
read making the read incomplete and one entry that cannot leaving it
whole, and the lists production reads. SystemLeftoverEnvironment takes
its read, so a test sees what reaches the search.
@laurentiu021
laurentiu021 merged commit d69c034 into main Nov 10, 2026
7 checks passed
@laurentiu021
laurentiu021 deleted the test/pin-validators-and-uninstall-list branch November 10, 2026 09:28
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