-
Notifications
You must be signed in to change notification settings - Fork 11
Decouple CustomCertManager from Android #82
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
Conversation
|
@bitfireAT/app-dev Not sure whether it's smart to test |
|
I'd leave it as it is for now. For future refactoring, I think it's not good design to have It may be better to separate concerns more in detail into separate classes: But that's only an idea for somewhen in the future. This PR should only be a small refactoring that allows to use a unit test. |
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.
Pull Request Overview
This PR decouples CustomCertManager from Android dependencies to enable better testability and separation of concerns. The main change introduces a CertStore interface that abstracts certificate storage operations, allowing CustomCertManager to work with any implementation rather than being tightly coupled to Android's Context.
Key changes:
- Introduced
CertStoreinterface defining certificate storage operations CustomCertStorenow implementsCertStoreinterfaceCustomCertManagerconstructor now acceptsCertStoreinstead ofContext- Migrated
CustomCertManagerTestfrom androidTest (integration) to test (unit) with aTestCertStoremock implementation
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| lib/src/main/java/at/bitfire/cert4android/CertStore.kt | New interface defining certificate storage operations |
| lib/src/main/java/at/bitfire/cert4android/CustomCertStore.kt | Now implements CertStore interface; companion object moved to end of file |
| lib/src/main/java/at/bitfire/cert4android/CustomCertManager.kt | Constructor changed to accept CertStore instead of Context; removed Android import |
| lib/src/test/java/at/bitfire/cert4android/CustomCertManagerTest.kt | Migrated from androidTest with new TestCertStore implementation for unit testing |
| lib/src/androidTest/java/at/bitfire/cert4android/CustomCertManagerTest.kt | Removed (moved to unit tests) |
| lib/src/androidTest/java/at/bitfire/cert4android/TestCertificates.kt | Removed unused getSiteCertificates() method and Android-specific imports |
| lib/src/androidTest/java/at/bitfire/cert4android/OkhttpTest.kt | Updated to use new constructor with CustomCertStore.getInstance() |
| sample-app/src/main/java/at/bitfire/cert4android/demo/MainActivity.kt | Updated to use new constructor with named parameter certStore |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Looks good!
It would have been possible to move the TestCertStore to a separate file.
Reason: Gain more control by decoupl from android.
Short description
CertStore