at_client_sdk
at_client_sdk copied to clipboard
fix: Enable at_client to initialize in offline when network is down
- What I did
- This PR introduces offline access capabilities to the AtClient SDK, allowing the client to initialize for offline access when network connection is not available during the authentication of an atSign.
- How I did it
- The "authenticate" method has been updated to support offline access for the AtClient. Within the method, the call to "authenticate" from the AtAuth package is enclosed in a try block. If a network failure occurs during this call, the exception is caught. The code then checks if the user is already onboarded. If the user is onboarded, the AtClient is subsequently initialized for offline access.
- Added AtLookup as optional parameter to AtAuthServiceImpl to enable injecting mock instance for writing unit tests. If the optional parameter "AtLookup" is not injected, then the it is initialized in "_initAtClient" method which is the existing behaviour.
- How to verify it
- Added unit tests for the below scenarios
- Test to verify AtClient initializes successfully in offline mode upon network failure when keychain manager contains keys.
- Test to verify AtClient initialization fails when network is offline and keychain manager does not have keys.
- Test to verify authenticate is successful and initialization is successful
- Description for the changelog
- Enable at_client to initialize in offline when network is down