-
Notifications
You must be signed in to change notification settings - Fork 17
Adds keychain availability checks for all platforms #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Introduces `isAvailable` function to verify keychain accessibility on Linux, macOS, and Windows. On Linux, checks Secret Service status; on macOS, ensures a default keychain exists; on Windows, always returns true since CredentialManager is always present. Enhances platform-specific error handling for better diagnostics.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #46 +/- ##
==========================================
- Coverage 77.60% 76.17% -1.43%
==========================================
Files 4 4
Lines 250 340 +90
Branches 75 107 +32
==========================================
+ Hits 194 259 +65
- Misses 33 50 +17
- Partials 23 31 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
That looks very good and useful, thanks! I'll take a closer look as soon as I can. |
|
Thanks! Sorry for forgetting to mark the PR as WIP initially |
hrantzsch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this, very polished and thought-out. I did request a few changes. Don't hesitate to disagree though.
|
|
||
| bool isAvailable(Error &err) { | ||
| err = Error{}; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't consider any runtime failure here as an indicator of the keychain not being available, and I wouldn't shadow the lower-level errors with the Unavailable error type.
Can we use createQuery to make the query as usual, fail with any errors it might produce, and then only look at whether or not SecItemCopyMatching succeeds as an indicator of isAvailable?
I think we can do without the specific test cases for KEYCHAIN_TEST_FAIL_DICT and KEYCHAIN_TEST_FAIL_STRING too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that runtime errors should not be masked with Unavailable actually. I am not sure what I was thinking there. However, createQuery can block forever if no keychain exists at the time. This is an attempt to detect the potential of this happening beforehand.
I am okay with removing these test hooks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I needed to go back and review I do feel like you're right for everything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My only real thing is that the way I did it is more of a proactive probe... it's confirming the keychain is usable and can help indicate if ceateQuery is not safe to use (due to how it may hang).
By breaking it down to the lowest level parts and testing each step in isolation we can help improve the use experience
|
Looks great now! I think tests are failing because we need You can add the new build flag to the two Although seeing the errors from running without it, do you think it makes sense to run both configurations in the CI? We could add one more target to the matrix. For example (and |
|
Sorry for the delay on this, will be getting this squared tomorrow! |
Introduces
isAvailablefunction to verify keychain accessibility on Linux, macOS, and Windows.On Linux, checks Secret Service status
On macOS, ensures a default keychain exists
On Windows, always returns true since CredentialManager is always present.
Enhances platform-specific error handling for better diagnostics.