test(settings): fix certificate fixture validity flakiness #50580

Merged
LegendaryBlair opened 3:51am on September 15, 2026 wanted to merge 47 Ξ” into microsoft/powertoys main from
LegendaryBlair/fix-settings-certificate-fixture

Pull Request Overview

  • Opened on September 15, 2026
  • Status Merged
  • Commit count 1 with first commit September 15, 2026

Total Delta

47 Total Diff Delta

Open Days

Open 4 weekdays

Test Delta

0 Diff Delta in Test Files
Breakdown by Phase

How long has this pull request spent in each phase of its lifecycle?

Fraction of total time Business days Phase
 
0.0 days Authoring 1 commit before pull request opened for review
 
0.3 days Awaiting first review
 
0.1 days Revising work with 0 commits in response to 2 reviews that left 2 comments
 
3.0 days Merge to deploy (still awaiting deployment)

Total time for pull request 0.4 business days from first commit authored to merge
Still awaiting deployment

Author avatar

test(settings): fix certificate fixture validity flakiness

Summary of the Pull Request

Fix intermittent certificate-generation failures in the existing Settings unit test CustomRootTrustChainAcceptsIntermediateFromExtraStore.

Intermediate and leaf test certificates now inherit their issuer's UTC validity interval instead of independently calculating an expiry from the current time. This prevents a child certificate from expiring after its issuer when generation crosses a second boundary.

This is an independent, single-file test fix. It does not include the Workspaces feature or diagnostic test exclusions from #50508 / #50576.

PR Checklist


  • [x] Communication: The test-fixture fix was discussed and requested during the CI investigation.

  • [x] Tests: Added a deterministic regression; both affected certificate-chain tests pass locally.

N/A: end-user localization, developer/user documentation, new binaries, installer changes, and product settings migrations.

Detailed Description of the Pull Request / Additional comments

Only src/settings-ui/Settings.UI.UnitTests/MouseWithoutBordersIpcSecurityTests.cs changes:


  • Reuse issuer.NotBefore and issuer.NotAfter, converted to UTC, when generating intermediate and leaf certificates.

  • Preserve the root fixture's default seven-day expiry and all existing certificate-chain assertions.

  • Add GeneratedCertificateChainUsesIssuerValidity, using a one-day issuer to deterministically expose the old seven-day child expiry without sleeps or dependence on clock timing.

The original failure occurred in test setup, before the intended chain-validation assertions. Examples:



  • Build 388854: leaf expiry was one second later than its issuer; CertificateRequest.Create threw ArgumentException.


  • Build 388859: the same issue occurred while creating the intermediate certificate.

Production signing/trust policy, IPC, and Windows trust stores are unchanged. No tests or assertions are disabled by this PR.

Validation Steps Performed


  • Built the real Settings.UI.UnitTests project in x64 Release with the repository build scripts.

  • Confirmed the new short-lived-issuer regression fails on the old helpers with the expected notAfter exception.

  • After the fix, ran the original chain test and the new regression: 2 passed, 0 failed, 0 skipped.

  • The exact tested file was cherry-picked from the diagnostic worktree onto a clean main-based branch; verified byte-identical source and a single-file diff.

  • Full CI 388863: succeeded, including x64 and ARM64 builds.

  • Native Tests completed successfully: 7,972 passed, 18 existing skipped cases, 0 failures; vstest.console.exe exited with code 0. The original certificate-chain test and the new regression both explicitly passed in CI.

Comments Threads Pending Resolution

ljharb reviewed on September 16, 2026
ljharb left a comment

### 🟒 Approval recommended

The focused fixture correction is consistent, deterministic, and adequately covered by the new regression test.

Pull request overview

Fixes flaky Settings certificate fixtures by aligning child certificate validity with their issuers.

**Changes:**
- Propagates issuer validity to intermediate and leaf certificates.
- Adds a deterministic regression test with a short-lived root.

File summaries

| File | Description |
| ---- | ----------- |
| `src/settings-ui/Settings.UI.UnitTests/MouseWithoutBordersIpcSecurityTests.cs` | Stabilizes certificate generation and verifies inherited validity. |

Review details

- **Files reviewed:** 1/1 changed files
- **Comments generated:** 0
- **Review effort level:** Balanced

---

πŸ’‘ Add a `code-review` agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Resolved Comment Threads

No resolved comments have been left on this PR.