Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(309)

Side by Side Diff: chrome/browser/sync/profile_sync_service_unittest.cc

Issue 1496573002: Ensure Sync access token is revoked when user is signed out. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/callback.h" 6 #include "base/callback.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 ->UpdateCredentials(secondary_account_id, "second_account_refresh_token"); 677 ->UpdateCredentials(secondary_account_id, "second_account_refresh_token");
678 ProfileOAuth2TokenServiceFactory::GetForProfile(profile()) 678 ProfileOAuth2TokenServiceFactory::GetForProfile(profile())
679 ->RevokeCredentials(secondary_account_id); 679 ->RevokeCredentials(secondary_account_id);
680 EXPECT_FALSE(service()->GetAccessTokenForTest().empty()); 680 EXPECT_FALSE(service()->GetAccessTokenForTest().empty());
681 681
682 ProfileOAuth2TokenServiceFactory::GetForProfile(profile()) 682 ProfileOAuth2TokenServiceFactory::GetForProfile(profile())
683 ->RevokeCredentials(primary_account_id); 683 ->RevokeCredentials(primary_account_id);
684 EXPECT_TRUE(service()->GetAccessTokenForTest().empty()); 684 EXPECT_TRUE(service()->GetAccessTokenForTest().empty());
685 } 685 }
686 686
687 TEST_F(ProfileSyncServiceTest, SignOutRevokeAccessToken) {
688 CreateService(browser_sync::AUTO_START);
689 IssueTestTokens();
690 ExpectDataTypeManagerCreation(1, GetDefaultConfigureCalledCallback());
691 ExpectSyncBackendHostCreation(1);
692 InitializeForNthSync();
693 EXPECT_TRUE(service()->IsSyncActive());
694
695 std::string primary_account_id =
696 SigninManagerFactory::GetForProfile(profile())
697 ->GetAuthenticatedAccountId();
698 ProfileOAuth2TokenServiceFactory::GetForProfile(profile())
699 ->LoadCredentials(primary_account_id);
700 base::RunLoop().RunUntilIdle();
701 EXPECT_FALSE(service()->GetAccessTokenForTest().empty());
702
703 SigninManagerFactory::GetForProfile(profile())
704 ->SignOut(signin_metrics::SIGNOUT_TEST);
705 EXPECT_TRUE(service()->GetAccessTokenForTest().empty());
706 }
707
687 #if defined(ENABLE_PRE_SYNC_BACKUP) 708 #if defined(ENABLE_PRE_SYNC_BACKUP)
688 TEST_F(ProfileSyncServiceTest, DontStartBackupOnBrowserStart) { 709 TEST_F(ProfileSyncServiceTest, DontStartBackupOnBrowserStart) {
689 CreateServiceWithoutSignIn(); 710 CreateServiceWithoutSignIn();
690 InitializeForFirstSync(); 711 InitializeForFirstSync();
691 PumpLoop(); 712 PumpLoop();
692 EXPECT_EQ(ProfileSyncService::IDLE, service()->backend_mode()); 713 EXPECT_EQ(ProfileSyncService::IDLE, service()->backend_mode());
693 } 714 }
694 715
695 TEST_F(ProfileSyncServiceTest, BackupBeforeFirstSync) { 716 TEST_F(ProfileSyncServiceTest, BackupBeforeFirstSync) {
696 CreateServiceWithoutSignIn(); 717 CreateServiceWithoutSignIn();
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 // dereferenced in OnSyncCycleCompleted. The fix is to use find() to check if 1091 // dereferenced in OnSyncCycleCompleted. The fix is to use find() to check if
1071 // entry for sessions exists in map. 1092 // entry for sessions exists in map.
1072 TEST_F(ProfileSyncServiceTest, ValidPointersInDTCMap) { 1093 TEST_F(ProfileSyncServiceTest, ValidPointersInDTCMap) {
1073 CreateService(browser_sync::AUTO_START); 1094 CreateService(browser_sync::AUTO_START);
1074 service()->OnSessionRestoreComplete(); 1095 service()->OnSessionRestoreComplete();
1075 service()->OnSyncCycleCompleted(); 1096 service()->OnSyncCycleCompleted();
1076 } 1097 }
1077 1098
1078 } // namespace 1099 } // namespace
1079 } // namespace browser_sync 1100 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698