From d872d01ad5ba4d6aa1aa0d42897be9be7c9291f9 Mon Sep 17 00:00:00 2001 From: austinbenoit Date: Thu, 29 Oct 2026 13:39:30 +0000 Subject: [PATCH] fix(app_check): Reduce flakiness in TestGetTokenForcingRefresh Use force_refresh=false for the initial GetAppCheckToken call in TestGetTokenForcingRefresh so it coalesces with any in-flight background auto-refresh triggered during app initialization rather than racing against it on Keychain storage. Also increase the sleep intervals between token fetches from 500ms to 1000ms across all platforms to ensure distinct expiration timestamps even with 1-second fetch_time granularity. --- app_check/integration_test/src/integration_test.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app_check/integration_test/src/integration_test.cc b/app_check/integration_test/src/integration_test.cc index e81bc6d784..96bba68417 100644 --- a/app_check/integration_test/src/integration_test.cc +++ b/app_check/integration_test/src/integration_test.cc @@ -506,14 +506,14 @@ TEST_F(FirebaseAppCheckTest, TestGetTokenForcingRefresh) { ::firebase::app_check::AppCheck::GetInstance(app_); ASSERT_NE(app_check, nullptr); firebase::Future<::firebase::app_check::AppCheckToken> future = - app_check->GetAppCheckToken(true); + app_check->GetAppCheckToken(false); EXPECT_TRUE(WaitForCompletion(future, "GetToken #1")); ::firebase::app_check::AppCheckToken token = *future.result(); EXPECT_NE(token.token, ""); EXPECT_NE(token.expire_time_millis, 0); // Wait a bit to make sure the expire time would be different - std::this_thread::sleep_for(std::chrono::milliseconds(500)); + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); // GetToken with force_refresh=false will return the same token. firebase::Future<::firebase::app_check::AppCheckToken> future2 = @@ -522,7 +522,7 @@ TEST_F(FirebaseAppCheckTest, TestGetTokenForcingRefresh) { EXPECT_EQ(future.result()->expire_time_millis, future2.result()->expire_time_millis); - std::this_thread::sleep_for(std::chrono::milliseconds(500)); + std::this_thread::sleep_for(std::chrono::milliseconds(1000)); // GetToken with force_refresh=true will return a new token. firebase::Future<::firebase::app_check::AppCheckToken> future3 =