Add native-store tests, split EnumerateKeys, bump to 2.0.0#61
Merged
Conversation
Follow-up to PR #59. Closes out the four items called out in the post-merge audit: 1. The native ICredentialStore implementations (Windows / macOS / Linux) were only compile-checked previously. Adds NativeCredentialStoreTests that exercise Save / TryLoad / Remove / cross-instance round-trip and an EnumerateKeys check against whichever store CredentialStoreFactory.CreateDefault returns for the host OS. Each test scopes itself to a unique service name (Guid.NewGuid()) so it can't collide with the user's real credentials. 2. EnumerateKeys was a silent no-op on macOS/Linux. Moved it onto a new ISearchableCredentialStore interface that only WindowsCredentialStore and InMemoryCredentialStore implement. Callers needing enumeration on other platforms now have to declare the dependency explicitly with a runtime cast, instead of getting an empty IEnumerable that looks like "no data". 3. AssertNativeStoreAvailableOrInconclusive turns "libsecret not installed" or "Secret Service unreachable" into Assert.Inconclusive rather than a red failure, so developers without a keyring set up don't see scary CI red. Detects via DllNotFoundException / CredentialStoreException, walking inner exceptions (libsecret schema init failures arrive as TypeInitializationException). 4. Cross-platform CI workflow now installs dbus + gnome-keyring on Linux and runs the test step inside dbus-run-session, unlocking gnome-keyring with an empty password first. Verified locally: 21/22 pass under that harness, the remaining one is the Windows-only EnumerateKeys test reported as inconclusive. VERSION.md bumped 1.3.0 -> 2.0.0 because removing EnumerateKeys from ICredentialStore (and the API rewrite in #59) is a SemVer-major break. https://claude.ai/code/session_017B9mN9F7C3pWGZRyoKBd6R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #59. Closes the four loose ends I called out post-merge.
What's in this PR
1. Native store integration tests (
CredentialCache.Test/NativeCredentialStoreTests.cs)The native
ICredentialStoreimplementations were only compile-checked in #59 — onlyInMemoryCredentialStorehad test coverage. This adds four tests that exercise whichever storeCredentialStoreFactory.CreateDefault(...)returns for the host OS:NativeStoreRoundTripsCredentialWithToken— basic Save / TryLoad / value preservation.NativeStoreSaveOverwritesExistingEntry— Save-after-Save replaces, not duplicates.NativeStoreRemoveReturnsFalseForUnknownPersona— idempotent Remove.NativeStoreSurvivesAcrossStoreInstances— cross-instance persistence (proves it really hits the OS keyring, not just an in-memory dictionary).WindowsStoreEnumerateKeysReturnsWrittenPersonas— checks theISearchableCredentialStorecast on Windows.Each test scopes itself to a unique service name (
Guid.NewGuid()) so it cannot collide with the user's real credentials, and usestry { Save; assert } finally { Remove }so a failure halfway through doesn't leak entries into the host keyring.AssertNativeStoreAvailableOrInconclusiveprobes the store with a no-opRemoveand turns missing platform dependencies (DLL not found, libsecret schema init failure, Secret Service unreachable) intoAssert.Inconclusiverather than a red failure — so a developer without a keyring set up doesn't see scary CI red just from running locally. It walks the inner-exception chain because libsecret'ssecret_schema_newcctor failure arrives wrapped inTypeInitializationException.2.
ISearchableCredentialStore(interface split)EnumerateKeysis gone fromICredentialStore. It lives on a newISearchableCredentialStore : ICredentialStoreinterface that onlyWindowsCredentialStore(viaCredEnumerateW) andInMemoryCredentialStoreimplement. Previously the macOS/Linux implementations returned an emptyIEnumerable— documented as a limitation but a quiet "no data" footgun. Callers now have to opt in:Anyone on macOS/Linux who tries to cast will get
nulland know to track persona GUIDs themselves instead of being silently lied to. (Implementing the real enumeration viaSecItemCopyMatching/secret_search_syncwould require non-trivial CoreFoundation / GLib marshalling that isn't justified by the use case.)3. Linux CI now actually runs the libsecret store
.github/workflows/cross-platform.yml:dbus,dbus-x11, andgnome-keyringalongsidelibsecret-1-0on the Linux runner.dotnet testindbus-run-sessionand unlocksgnome-keyring-daemonwith an empty password first, so the Secret Service is reachable for the duration of the test run.Verified locally on Ubuntu 24.04 inside
dbus-run-session: 21/22 pass, 1 inconclusive (the Windows-onlyEnumerateKeystest). Without the daemon, the native tests cleanly fall through to inconclusive instead of crashing.4. SemVer-major bump (
1.3.0->2.0.0)This is a breaking change relative to
main. The API surface that consumers of1.xdepended on is gone (ConfigurePersistenceProvider,Save/SaveAsync, on-disk JSON layout from #59) and nowEnumerateKeysmoves offICredentialStore. A major bump is the honest signal.CHANGELOG.md looks like it's regenerated by the release pipeline (the entries all match a "Changes since vX.Y.Z" template), so I haven't hand-edited it — if that's wrong, point me at the right place.
Test plan
dotnet build CredentialCache.slnclean on net9.0 + net10.0.dotnet testlocally: 17 pass + 5 inconclusive when no Secret Service is available.dbus-run-session+gnome-keyring-daemonlocally: 21 pass + 1 inconclusive (Windows-only).https://claude.ai/code/session_017B9mN9F7C3pWGZRyoKBd6R
Generated by Claude Code