Skip to content

Build request-outcome test owners through their provider, against an in-memory store - #301

Merged
matt-edmondson merged 2 commits into
mainfrom
fix/300-request-outcome-test-owners
Sep 26, 2026
Merged

matt-edmondson merged 2 commits into
mainfrom
fix/300-request-outcome-test-owners

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #300

What was wrong

GitHubRequestOutcomeTests built owners with new Owner { ... }, which leaves BuildProvider null. Since #285 moved tokens into the secret store, an owner's token persona is derived from BuildProvider.Name. Reading or writing the token therefore threw NullReferenceException, and the four workflow-action tests failed on main on every platform.

Change (test-only)

  • Owners are built with provider.CreateOwner(...), so BuildProvider is set.
  • Every test in the class now runs against an in-memory CredentialCache injected with TokenStorage.UseCache, the same pattern TokenStorageTests uses. Without it, the authorization-failure tests call OnAuthenticationFailure, which clears the provider token in the developer's real OS secret store.

Verification (Linux, .NET 10)

  • GitHubRequestOutcomeTests passes 11 of 11 with the change.
  • To prove the test catches the bug, I kept the in-memory store and put back only the new Owner { ... } construction. The four workflow-action tests then fail with NullReferenceException.
  • Full suite: 69 passed and 2 failed. The 2 failures are AzureDevOpsSessionTests.AProviderWithNoCredentialsHasNoSession and RepeatedLookupsOnAnUnconfiguredProviderStayNull. They are the Linux-without-libsecret TypeInitializationException tracked in On Linux without libsecret, every token read throws TypeInitializationException instead of reading as empty #296, which this PR doesn't touch. On Windows CI they should pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01T3Dc4pH8DW9RqEzV5znBXQ


Generated by Claude Code

… in-memory store

GitHubRequestOutcomeTests built owners with `new Owner { ... }`, so BuildProvider
was null. Since tokens moved into the secret store (#285), reading or writing an
owner's token derives its persona from BuildProvider.Name, so the four workflow
action tests threw NullReferenceException on every platform.

Build owners with provider.CreateOwner(...), and inject an in-memory credential
store for every test so an authorization failure clearing the provider token
never reaches the developer's real OS secret store.

Fixes #300

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T3Dc4pH8DW9RqEzV5znBXQ
…iled [patch]

On Linux the credential store first reaches libsecret from a static
constructor, so a missing libsecret-1.so.0 arrives as a
TypeInitializationException wrapping the DllNotFoundException. IsUnavailable
only matched the bare exception types, so the wrapped form escaped every
TokenStorage read and write, and the runtime rethrows it on each later access.

Unwrap TypeInitializationException in IsUnavailable, and cover the wrapped
form with a test double.

Fixes #296

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01T3Dc4pH8DW9RqEzV5znBXQ
(cherry picked from commit 2137658)

Copy link
Copy Markdown
Contributor Author

Test on ubuntu-latest failed on ecf9023 with 2 failures: AzureDevOpsSessionTests.AProviderWithNoCredentialsHasNoSession and RepeatedLookupsOnAnUnconfiguredProviderStayNull. They are not this PR's failures. They come from the Linux-without-libsecret TypeInitializationException (#296), which is also red on main.

I've ported the fix from #302 into this branch as cf0ede3 (cherry-picked). It becomes a no-op once either PR merges. With it, the full suite passes 72/72 locally on Linux.


Generated by Claude Code

@sonarqubecloud

Copy link
Copy Markdown

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.

GitHubRequestOutcomeTests fail with NullReferenceException on main: #288's tests build an Owner with no BuildProvider after #285

2 participants