-
Notifications
You must be signed in to change notification settings - Fork 13
Add configurable FlutterSecureStorage to FlutterSecureCredentialsStorage #479
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
Open
Copilot
wants to merge
14
commits into
master
Choose a base branch
from
copilot/fix-478
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
35d4415
Initial plan
Copilot 0c74b38
Add configurable FlutterSecureStorage support to FlutterSecureCredent…
Copilot a6a2031
Update README with custom FlutterSecureStorage configuration examples
Copilot a48315e
Remove redundant _secureStorage getter, move default to constructor
Copilot e0e260a
Use parameter default value instead of ?? operator in constructor
Copilot 51ae3fc
Fix tests
PiotrRogulski e49bf66
Update comment
PiotrRogulski 7a3e6b1
Fix analysis issues
PiotrRogulski 1be10e1
Update workflows & SDK bounds
PiotrRogulski 784bcd9
Update package version to 3.1.0 and add changelog entry for configura…
Copilot 2f72c8a
Update changelog to reflect actual dependency versions and SDK bounds
Copilot 7f8af6b
Remove empty Unreleased section from changelog
Copilot 7da9488
Export secure storage package
PiotrRogulski c546402
Remove import
PiotrRogulski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
72 changes: 72 additions & 0 deletions
72
packages/login_client_flutter/test/flutter_secure_credentials_storage_test.dart
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| import 'package:flutter_secure_storage/flutter_secure_storage.dart'; | ||
| import 'package:flutter_test/flutter_test.dart'; | ||
| import 'package:login_client_flutter/login_client_flutter.dart'; | ||
| import 'package:oauth2/oauth2.dart'; | ||
|
|
||
| // Mock FlutterSecureStorage for testing | ||
| class MockFlutterSecureStorage extends FlutterSecureStorage { | ||
| final Map<String, String> _storage = {}; | ||
|
|
||
| const MockFlutterSecureStorage() : super(); | ||
|
|
||
| @override | ||
| Future<String?> read({required String key}) async { | ||
| return _storage[key]; | ||
| } | ||
|
|
||
| @override | ||
| Future<void> write({required String key, required String value}) async { | ||
| _storage[key] = value; | ||
| } | ||
|
|
||
| @override | ||
| Future<void> delete({required String key}) async { | ||
| _storage.remove(key); | ||
| } | ||
| } | ||
|
|
||
| void main() { | ||
| group('FlutterSecureCredentialsStorage', () { | ||
| test('uses default storage when none provided', () { | ||
| const storage = FlutterSecureCredentialsStorage(); | ||
|
|
||
| // This test ensures the constructor works with no parameters | ||
| expect(storage, isA<FlutterSecureCredentialsStorage>()); | ||
| }); | ||
|
|
||
| test('accepts custom storage instance', () { | ||
| const customStorage = MockFlutterSecureStorage(); | ||
| const storage = FlutterSecureCredentialsStorage(storage: customStorage); | ||
|
|
||
| // This test ensures the constructor works with custom storage | ||
| expect(storage, isA<FlutterSecureCredentialsStorage>()); | ||
| }); | ||
|
|
||
| test('works with custom storage - read/write/clear operations', () async { | ||
| const customStorage = MockFlutterSecureStorage(); | ||
| const storage = FlutterSecureCredentialsStorage(storage: customStorage); | ||
|
|
||
| // Test initial read returns null | ||
| expect(await storage.read(), null); | ||
|
|
||
| // Test saving and reading credentials | ||
| final credentials = Credentials('test_token'); | ||
| await storage.save(credentials); | ||
|
|
||
| final readCredentials = await storage.read(); | ||
| expect(readCredentials?.accessToken, equals('test_token')); | ||
|
|
||
| // Test clearing | ||
| await storage.clear(); | ||
| expect(await storage.read(), null); | ||
| }); | ||
|
|
||
| test('maintains backward compatibility with default constructor', () async { | ||
| // This test verifies that existing code continues to work | ||
| const storage = FlutterSecureCredentialsStorage(); | ||
|
|
||
| // Should be able to perform operations without error | ||
| expect(storage.read(), completes); | ||
| }); | ||
| }); | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.