Implement Firebase Auth UseUserAccessGroup for C++ iOS SDK by jonsimantov · Pull Request #1760 · firebase/firebase-cpp-sdk
This commit introduces the `UseUserAccessGroup` method to the Firebase Authentication C++ SDK. This method is specific to iOS and allows developers to specify a keychain access group for user data. It calls the underlying Objective-C method `[FIRAuth useUserAccessGroup:error:]`. On Android and desktop platforms, this method is a no-op stub and returns `kAuthErrorNone` as per its documented behavior for non-iOS platforms. Key changes: - Added `Auth::UseUserAccessGroup(const char* access_group)` to the public header `auth/src/include/firebase/auth.h` with Doxygen comments. - Implemented the iOS-specific logic in `auth/src/ios/auth_ios.mm`, including error conversion from `NSError` to `AuthError`. - Added stub implementations in `auth/src/desktop/auth_desktop.cc` and `auth/src/android/auth_android.cc` returning `kAuthErrorNone`.
This commit incorporates feedback from the code review: - Updated Doxygen comments in `auth.h` for `UseUserAccessGroup` to refer to Firebase iOS SDK documentation for keychain details, removing the extensive inline explanation. - Corrected the error code in `auth_ios.mm` from the non-existent `kAuthErrorUninitialized` to `kAuthErrorFailure` when `auth_data_` is null. - Added a new integration test `TestUseUserAccessGroupDoesNotCrash` in `auth/integration_test/src/integration_test.cc`. This test calls the function with a sample group and nullptr, checking for `kAuthErrorNone` or `kAuthErrorKeychainError` on iOS (to ensure no crash even if keychain isn't fully set up in test env) and `kAuthErrorNone` on other platforms, primarily ensuring the calls do not crash.
This commit incorporates feedback from the code review regarding the integration test for `UseUserAccessGroup`: - Simplified the `TestUseUserAccessGroupDoesNotCrash` test in `auth/integration_test/src/integration_test.cc`. - Removed platform-specific checks (`#if TARGET_OS_IPHONE`) and associated `EXPECT_THAT` calls. - Removed `LogDebug` messages from the test. - Both calls to `UseUserAccessGroup` now uniformly expect `firebase::auth::kAuthErrorNone`. This aligns with the stub behavior on non-iOS platforms and simplifies the test as requested by the reviewer, focusing on ensuring the calls do not crash and stubs return the expected no-op error code.
This commit incorporates further feedback on the integration test for
`UseUserAccessGroup`:
- Removed the verbose explanatory comment block from
`TestUseUserAccessGroupDoesNotCrash` in
`auth/integration_test/src/integration_test.cc`.
- Reinstated platform-specific error checking within the test:
- On iOS, the test now uses `EXPECT_THAT` to allow either
`kAuthErrorNone` or `kAuthErrorKeychainError`. This handles
potential keychain configuration issues in test environments while
ensuring the call does not crash.
- On other platforms (Android/Desktop), the test continues to expect
`kAuthErrorNone`, verifying the stub implementation.
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