This repository has been archived by the owner on Jan 11, 2023. It is now read-only.
Extract the keychain wrapper code and add tests for it #7
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.
The problem: the current code that interacts with the Keychain fails to remove the stored session data. This is not a big issue because the session username is removed from
UserDefaults
thus the stored data can't be retrieved, however it is still not good.How to know that the Keychain functions failed? - Currently those do not report success/failure and are not tested. The
SpotifyLogin
tests only check that the stored session username is saved/removed but not that the data associated with it is securely stored. We need to add tests that verify this in order to be sure that the app login flow works correctly.Solution: I split the Keychain-related code from the session-specific methods so that those could be tested. The only change to that code is making it return boolean success/failure indicating flag.
The diff is a bit weird although I used
git mv
to rename theKeychain
file..Anyway, the first commit does not modify the
SpotifyLogin
functionality, it just extracts the Keychain-related code to its own class and renames the Keychain class toSessionLocalStorage
which reflects better what it does (save
/load
/remove
).Then the next two commits setup the
Sample
project to include and actually execute a test which check if the keychain values are stored/removed properly.I added these tests to the
Sample
project because I was running into problems to interact with the Keychain APIs from the test target of theSpotifyLogin
framework (getting OSStatus -34018 all the time, looks like it is a known issue).Lastly, I will push another commit that fixes the problem and the tests should pass 馃