Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Address review comments for UseUserAccessGroup
- Moved stub implementations from auth_stub.cc to auth_desktop.cc and auth_android.cc. - Removed auth_stub.cc. - Removed unnecessary forward declaration for UseUserAccessGroupInternal from auth.cc. - Added a basic integration test for UseUserAccessGroup to ensure it doesn't crash on any platform.
  • Loading branch information
google-labs-jules[bot] committed Jun 27, 2025
commit 582010b858b17f8538da19bc4703f9ed94d682e6
43 changes: 43 additions & 0 deletions auth/integration_test/src/integration_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1513,4 +1513,47 @@ TEST_F(FirebaseAuthTest, TestLinkFederatedProviderBadProviderIdFails) {

#endif // defined(ENABLE_OAUTH_TESTS)

TEST_F(FirebaseAuthTest, TestUseUserAccessGroup) {
// This test simply calls the UseUserAccessGroup method to ensure it doesn't
// crash. It doesn't verify the underlying keychain behavior.
// On non-iOS platforms, this is a no-op and should return kAuthErrorNone.
// On iOS, it will call the underlying OS method.

LogDebug("Calling UseUserAccessGroup with a test group ID.");
firebase::auth::AuthError error =
auth_->UseUserAccessGroup("com.firebase.test.accessgroup");

#if TARGET_OS_IPHONE
// On iOS, the actual error code depends on keychain access and provisioning.
// For this test, we just ensure it doesn't crash.
// A specific error like kAuthErrorMissingIOSBundleID might occur if the
// environment isn't set up for keychain sharing, or kAuthErrorNone on
// success. For a simple "does not crash" test, we don't strictly check
// the error code, but kAuthErrorNone is the ideal outcome if keychain is
// usable.
LogDebug("UseUserAccessGroup returned %d on iOS.", error);
#else
// On other platforms, it should be a no-op.
EXPECT_EQ(error, firebase::auth::kAuthErrorNone);
#endif

LogDebug("Calling UseUserAccessGroup with nullptr to clear the group.");
error = auth_->UseUserAccessGroup(nullptr);

#if TARGET_OS_IPHONE
LogDebug("UseUserAccessGroup(nullptr) returned %d on iOS.", error);
#else
EXPECT_EQ(error, firebase::auth::kAuthErrorNone);
#endif

LogDebug("Calling UseUserAccessGroup with empty string to clear the group.");
error = auth_->UseUserAccessGroup("");

#if TARGET_OS_IPHONE
LogDebug("UseUserAccessGroup(\"\") returned %d on iOS.", error);
#else
EXPECT_EQ(error, firebase::auth::kAuthErrorNone);
#endif
}

} // namespace firebase_testapp_automated
6 changes: 0 additions & 6 deletions auth/src/auth.cc
Original file line number Diff line number Diff line change
Expand Up @@ -373,12 +373,6 @@ AUTH_RESULT_FN(Auth, SignInWithEmailAndPassword, AuthResult)

AUTH_RESULT_FN(Auth, CreateUserWithEmailAndPassword, AuthResult)

// Platform-specific implementation of UseUserAccessGroup.
// This is defined in auth_ios.mm for iOS, and auth_stub.cc for other
// platforms.
AuthError UseUserAccessGroupInternal(AuthData* auth_data,
const char* group_id);

AuthError Auth::UseUserAccessGroup(const char* group_id) {
if (!auth_data_) {
return kAuthErrorUninitialized;
Expand Down
9 changes: 9 additions & 0 deletions auth/src/desktop/auth_desktop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -768,5 +768,14 @@ void IdTokenRefreshThread::DisableAuthRefresh() {
ref_count_--;
}

// Stub implementation for UseUserAccessGroupInternal on desktop.
AuthError UseUserAccessGroupInternal(AuthData* auth_data,
const char* group_id) {
// This function is a no-op on desktop platforms.
(void)auth_data;
(void)group_id;
return kAuthErrorNone;
}

} // namespace auth
} // namespace firebase
35 changes: 0 additions & 35 deletions auth/src/stub/auth_stub.cc

This file was deleted.

Loading