#include "components/sync/service/sync_auth_manager.h"
#include "base/functional/callback_helpers.h"
#include "base/run_loop.h"
#include "base/test/mock_callback.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "components/signin/public/identity_manager/primary_account_mutator.h"
#include "components/sync/engine/connection_status.h"
#include "components/sync/engine/sync_credentials.h"
#include "net/base/net_errors.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace syncer {
namespace {
class SyncAuthManagerTest : public testing::Test { … };
TEST_F(SyncAuthManagerTest, ProvidesNothingInLocalSyncMode) { … }
TEST_F(SyncAuthManagerTest, IgnoresEventsIfNotRegistered) { … }
#if !BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(SyncAuthManagerTest, ForwardsPrimaryAccountEvents) { … }
TEST_F(SyncAuthManagerTest, NotifiesOfSignoutBeforeAccessTokenIsGone) { … }
#endif
#if !BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
TEST_F(SyncAuthManagerTest, ForwardsUnconsentedAccountEvents) { … }
#endif
#if !BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(SyncAuthManagerTest, ClearsAuthErrorOnSignoutWithRefreshTokenRemoval) { … }
TEST_F(SyncAuthManagerTest,
ClearsAuthErrorOnSignoutWithoutRefreshTokenRemoval) { … }
#endif
TEST_F(SyncAuthManagerTest, DoesNotClearAuthErrorOnSyncDisable) { … }
TEST_F(SyncAuthManagerTest, ForwardsCredentialsEvents) { … }
TEST_F(SyncAuthManagerTest, RequestsAccessTokenOnSyncStartup) { … }
TEST_F(SyncAuthManagerTest,
RetriesAccessTokenFetchWithBackoffOnTransientFailure) { … }
TEST_F(SyncAuthManagerTest,
RetriesAccessTokenFetchWithoutBackoffOnceOnFirstCancelTransientFailure) { … }
TEST_F(SyncAuthManagerTest,
RetriesAccessTokenFetchOnFirstCancelTransientFailure) { … }
TEST_F(SyncAuthManagerTest, AbortsAccessTokenFetchOnPersistentFailure) { … }
TEST_F(SyncAuthManagerTest, FetchesNewAccessTokenWithBackoffOnServerError) { … }
TEST_F(SyncAuthManagerTest, DoesNotExposeServerError) { … }
TEST_F(SyncAuthManagerTest, ClearsServerErrorOnSyncDisable) { … }
TEST_F(SyncAuthManagerTest, RequestsNewAccessTokenOnExpiry) { … }
TEST_F(SyncAuthManagerTest, RequestsNewAccessTokenOnRefreshTokenUpdate) { … }
TEST_F(SyncAuthManagerTest, DoesNotRequestAccessTokenAutonomously) { … }
TEST_F(SyncAuthManagerTest, ClearsCredentialsOnRefreshTokenRemoval) { … }
TEST_F(SyncAuthManagerTest, ClearsCredentialsOnInvalidRefreshToken) { … }
TEST_F(SyncAuthManagerTest, EntersPausedStateOnPersistentAuthError) { … }
TEST_F(SyncAuthManagerTest,
RequestsAccessTokenWhenInvalidRefreshTokenResolved) { … }
TEST_F(SyncAuthManagerTest, DoesNotRequestAccessTokenIfSyncInactive) { … }
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
TEST_F(SyncAuthManagerTest, PrimaryAccountWithNoSyncConsent) { … }
#endif
#if !BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
TEST_F(SyncAuthManagerTest, PicksNewPrimaryAccountWithSyncConsent) { … }
TEST_F(SyncAuthManagerTest,
DropsAccountWhenPrimaryAccountWithNoSyncConsentGoesAway) { … }
#endif
TEST_F(SyncAuthManagerTest, DetectsInvalidRefreshTokenAtStartup) { … }
}
}