Skip to content

Commit c8f87a3

Browse files
Address review comments for UseUserAccessGroup implementation
- Added Android stub for UseUserAccessGroup. - Updated Doxygen comments in auth.h for clarity and accuracy regarding empty string handling. - Modified iOS implementation to pass empty strings verbatim to the native SDK. - Corrected error code used in iOS implementation when auth_data_ is null (kAuthErrorFailure instead of kAuthErrorUninitialized). - Added a basic smoke test to integration_test.cc for iOS to ensure UseUserAccessGroup can be called.
1 parent 41eb0e2 commit c8f87a3

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

auth/integration_test/src/integration_test.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,4 +1513,18 @@ TEST_F(FirebaseAuthTest, TestLinkFederatedProviderBadProviderIdFails) {
15131513

15141514
#endif // defined(ENABLE_OAUTH_TESTS)
15151515

1516+
#if TARGET_OS_IPHONE
1517+
TEST_F(FirebaseAuthTest, TestUseUserAccessGroup) {
1518+
// This is a simple smoke test to ensure the method can be called
1519+
// without crashing on iOS and returns the expected default success.
1520+
// Deeper testing of keychain access group functionality would require
1521+
// more complex setup and is typically done manually or with UI tests.
1522+
EXPECT_EQ(auth_->UseUserAccessGroup(nullptr),
1523+
firebase::auth::kAuthErrorNone);
1524+
EXPECT_EQ(auth_->UseUserAccessGroup("test-group"),
1525+
firebase::auth::kAuthErrorNone);
1526+
EXPECT_EQ(auth_->UseUserAccessGroup(""), firebase::auth::kAuthErrorNone);
1527+
}
1528+
#endif // TARGET_OS_IPHONE
1529+
15161530
} // namespace firebase_testapp_automated

auth/src/android/auth_android.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,5 +676,10 @@ void DisableTokenAutoRefresh(AuthData* auth_data) {}
676676
void InitializeTokenRefresher(AuthData* auth_data) {}
677677
void DestroyTokenRefresher(AuthData* auth_data) {}
678678

679+
AuthError Auth::UseUserAccessGroup(const char* access_group) {
680+
// This is an iOS-only feature. No-op on other platforms.
681+
return kAuthErrorNone;
682+
}
683+
679684
} // namespace auth
680685
} // namespace firebase

auth/src/include/firebase/auth.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -522,11 +522,9 @@ class Auth {
522522
/// This method is only functional on iOS. On other platforms, it is a no-op
523523
/// and will always return `kAuthErrorNone`.
524524
///
525-
/// If you are using iCloud keychain synchronization, you will need to call
526-
/// this method to set the user access group.
527-
///
528-
/// @param[in] access_group The user access group to use. Set to `nullptr` or
529-
/// an empty string to use the default access group.
525+
/// @param[in] access_group The user access group to use. Set to `nullptr`
526+
/// to use the default access group. An empty string will be passed as an
527+
/// empty string.
530528
///
531529
/// @return `kAuthErrorNone` on success, or an AuthError code if an error
532530
/// occurred.

auth/src/ios/auth_ios.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,10 +610,10 @@ void DestroyTokenRefresher(AuthData *auth_data) {}
610610

611611
AuthError Auth::UseUserAccessGroup(const char* access_group_str) {
612612
if (!auth_data_) {
613-
return kAuthErrorUninitialized;
613+
return kAuthErrorFailure;
614614
}
615615
NSString* access_group_ns_str = nil;
616-
if (access_group_str != nullptr && strlen(access_group_str) > 0) {
616+
if (access_group_str != nullptr) {
617617
access_group_ns_str = [NSString stringWithUTF8String:access_group_str];
618618
}
619619

0 commit comments

Comments
 (0)