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

Side by Side Diff: sync/internal_api/sync_manager_impl_unittest.cc

Issue 10827266: [Sync] Add SyncEncryptionHandler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months 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 | Annotate | Revision Log
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 // Unit tests for the SyncApi. Note that a lot of the underlying 5 // Unit tests for the SyncApi. Note that a lot of the underlying
6 // functionality is provided by the Syncable layer, which has its own 6 // functionality is provided by the Syncable layer, which has its own
7 // unit tests. We'll test SyncApi specific things in this harness. 7 // unit tests. We'll test SyncApi specific things in this harness.
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <map> 10 #include <map>
(...skipping 18 matching lines...) Expand all
29 #include "sync/internal_api/public/engine/model_safe_worker.h" 29 #include "sync/internal_api/public/engine/model_safe_worker.h"
30 #include "sync/internal_api/public/engine/polling_constants.h" 30 #include "sync/internal_api/public/engine/polling_constants.h"
31 #include "sync/internal_api/public/http_post_provider_factory.h" 31 #include "sync/internal_api/public/http_post_provider_factory.h"
32 #include "sync/internal_api/public/http_post_provider_interface.h" 32 #include "sync/internal_api/public/http_post_provider_interface.h"
33 #include "sync/internal_api/public/read_node.h" 33 #include "sync/internal_api/public/read_node.h"
34 #include "sync/internal_api/public/read_transaction.h" 34 #include "sync/internal_api/public/read_transaction.h"
35 #include "sync/internal_api/public/test/test_internal_components_factory.h" 35 #include "sync/internal_api/public/test/test_internal_components_factory.h"
36 #include "sync/internal_api/public/test/test_user_share.h" 36 #include "sync/internal_api/public/test/test_user_share.h"
37 #include "sync/internal_api/public/write_node.h" 37 #include "sync/internal_api/public/write_node.h"
38 #include "sync/internal_api/public/write_transaction.h" 38 #include "sync/internal_api/public/write_transaction.h"
39 #include "sync/internal_api/sync_encryption_handler_impl.h"
39 #include "sync/internal_api/sync_manager_impl.h" 40 #include "sync/internal_api/sync_manager_impl.h"
40 #include "sync/internal_api/syncapi_internal.h" 41 #include "sync/internal_api/syncapi_internal.h"
41 #include "sync/js/js_arg_list.h" 42 #include "sync/js/js_arg_list.h"
42 #include "sync/js/js_backend.h" 43 #include "sync/js/js_backend.h"
43 #include "sync/js/js_event_handler.h" 44 #include "sync/js/js_event_handler.h"
44 #include "sync/js/js_reply_handler.h" 45 #include "sync/js/js_reply_handler.h"
45 #include "sync/js/js_test_util.h" 46 #include "sync/js/js_test_util.h"
46 #include "sync/notifier/sync_notifier.h" 47 #include "sync/notifier/sync_notifier.h"
47 #include "sync/notifier/sync_notifier_observer.h" 48 #include "sync/notifier/sync_notifier_observer.h"
48 #include "sync/protocol/bookmark_specifics.pb.h" 49 #include "sync/protocol/bookmark_specifics.pb.h"
(...skipping 21 matching lines...) Expand all
70 #include "testing/gmock/include/gmock/gmock.h" 71 #include "testing/gmock/include/gmock/gmock.h"
71 #include "testing/gtest/include/gtest/gtest.h" 72 #include "testing/gtest/include/gtest/gtest.h"
72 73
73 using base::ExpectDictStringValue; 74 using base::ExpectDictStringValue;
74 using testing::_; 75 using testing::_;
75 using testing::AnyNumber; 76 using testing::AnyNumber;
76 using testing::AtLeast; 77 using testing::AtLeast;
77 using testing::DoAll; 78 using testing::DoAll;
78 using testing::InSequence; 79 using testing::InSequence;
79 using testing::Invoke; 80 using testing::Invoke;
81 using testing::NiceMock;
80 using testing::Return; 82 using testing::Return;
81 using testing::SaveArg; 83 using testing::SaveArg;
82 using testing::StrictMock; 84 using testing::StrictMock;
83 85
84 namespace syncer { 86 namespace syncer {
85 87
86 using sessions::SyncSessionSnapshot; 88 using sessions::SyncSessionSnapshot;
87 using syncable::IS_DEL; 89 using syncable::IS_DEL;
88 using syncable::IS_UNSYNCED; 90 using syncable::IS_UNSYNCED;
89 using syncable::kEncryptedString; 91 using syncable::kEncryptedString;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 entry.Put(syncable::SPECIFICS, specifics); 220 entry.Put(syncable::SPECIFICS, specifics);
219 return entry.Get(syncable::META_HANDLE); 221 return entry.Get(syncable::META_HANDLE);
220 } 222 }
221 223
222 } // namespace 224 } // namespace
223 225
224 class SyncApiTest : public testing::Test { 226 class SyncApiTest : public testing::Test {
225 public: 227 public:
226 virtual void SetUp() { 228 virtual void SetUp() {
227 test_user_share_.SetUp(); 229 test_user_share_.SetUp();
230 SetUpEncryption();
228 } 231 }
229 232
230 virtual void TearDown() { 233 virtual void TearDown() {
231 test_user_share_.TearDown(); 234 test_user_share_.TearDown();
232 } 235 }
233 236
237 void SetUpEncryption() {
238 ReadTransaction trans(FROM_HERE, test_user_share_.user_share());
239 encryption_handler_.reset(
240 new SyncEncryptionHandlerImpl(test_user_share_.user_share(),
241 trans.GetCryptographer()));
242 trans.GetCryptographer()->SetSyncEncryptionHandlerDelegate(
243 encryption_handler_.get());
244 }
245
234 protected: 246 protected:
235 MessageLoop message_loop_; 247 MessageLoop message_loop_;
236 TestUserShare test_user_share_; 248 TestUserShare test_user_share_;
249 scoped_ptr<SyncEncryptionHandler> encryption_handler_;
237 }; 250 };
238 251
239 TEST_F(SyncApiTest, SanityCheckTest) { 252 TEST_F(SyncApiTest, SanityCheckTest) {
240 { 253 {
241 ReadTransaction trans(FROM_HERE, test_user_share_.user_share()); 254 ReadTransaction trans(FROM_HERE, test_user_share_.user_share());
242 EXPECT_TRUE(trans.GetWrappedTrans() != NULL); 255 EXPECT_TRUE(trans.GetWrappedTrans() != NULL);
243 } 256 }
244 { 257 {
245 WriteTransaction trans(FROM_HERE, test_user_share_.user_share()); 258 WriteTransaction trans(FROM_HERE, test_user_share_.user_share());
246 EXPECT_TRUE(trans.GetWrappedTrans() != NULL); 259 EXPECT_TRUE(trans.GetWrappedTrans() != NULL);
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 password_node.GetPasswordSpecifics(); 478 password_node.GetPasswordSpecifics();
466 EXPECT_EQ("secret", data.password_value()); 479 EXPECT_EQ("secret", data.password_value());
467 } 480 }
468 } 481 }
469 482
470 TEST_F(SyncApiTest, WriteEncryptedTitle) { 483 TEST_F(SyncApiTest, WriteEncryptedTitle) {
471 KeyParams params = {"localhost", "username", "passphrase"}; 484 KeyParams params = {"localhost", "username", "passphrase"};
472 { 485 {
473 ReadTransaction trans(FROM_HERE, test_user_share_.user_share()); 486 ReadTransaction trans(FROM_HERE, test_user_share_.user_share());
474 trans.GetCryptographer()->AddKey(params); 487 trans.GetCryptographer()->AddKey(params);
475 trans.GetCryptographer()->set_encrypt_everything();
476 } 488 }
489 encryption_handler_->EnableEncryptEverything();
477 { 490 {
478 WriteTransaction trans(FROM_HERE, test_user_share_.user_share()); 491 WriteTransaction trans(FROM_HERE, test_user_share_.user_share());
479 ReadNode root_node(&trans); 492 ReadNode root_node(&trans);
480 root_node.InitByRootLookup(); 493 root_node.InitByRootLookup();
481 494
482 WriteNode bookmark_node(&trans); 495 WriteNode bookmark_node(&trans);
483 WriteNode::InitUniqueByCreationResult result = 496 WriteNode::InitUniqueByCreationResult result =
484 bookmark_node.InitUniqueByCreation(BOOKMARKS, 497 bookmark_node.InitUniqueByCreation(BOOKMARKS,
485 root_node, "foo"); 498 root_node, "foo");
486 EXPECT_EQ(WriteNode::INIT_SUCCESS, result); 499 EXPECT_EQ(WriteNode::INIT_SUCCESS, result);
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 }; 686 };
674 687
675 class SyncManagerObserverMock : public SyncManager::Observer { 688 class SyncManagerObserverMock : public SyncManager::Observer {
676 public: 689 public:
677 MOCK_METHOD1(OnSyncCycleCompleted, 690 MOCK_METHOD1(OnSyncCycleCompleted,
678 void(const SyncSessionSnapshot&)); // NOLINT 691 void(const SyncSessionSnapshot&)); // NOLINT
679 MOCK_METHOD3(OnInitializationComplete, 692 MOCK_METHOD3(OnInitializationComplete,
680 void(const WeakHandle<JsBackend>&, bool, 693 void(const WeakHandle<JsBackend>&, bool,
681 syncer::ModelTypeSet)); // NOLINT 694 syncer::ModelTypeSet)); // NOLINT
682 MOCK_METHOD1(OnConnectionStatusChange, void(ConnectionStatus)); // NOLINT 695 MOCK_METHOD1(OnConnectionStatusChange, void(ConnectionStatus)); // NOLINT
696 MOCK_METHOD0(OnStopSyncingPermanently, void()); // NOLINT
697 MOCK_METHOD1(OnUpdatedToken, void(const std::string&)); // NOLINT
698 MOCK_METHOD1(OnActionableError,
699 void(const SyncProtocolError&)); // NOLINT
700 };
701
702 class SyncEncryptionHandlerObserverMock
703 : public SyncEncryptionHandler::Observer {
704 public:
683 MOCK_METHOD2(OnPassphraseRequired, 705 MOCK_METHOD2(OnPassphraseRequired,
684 void(PassphraseRequiredReason, 706 void(PassphraseRequiredReason,
685 const sync_pb::EncryptedData&)); // NOLINT 707 const sync_pb::EncryptedData&)); // NOLINT
686 MOCK_METHOD0(OnPassphraseAccepted, void()); // NOLINT 708 MOCK_METHOD0(OnPassphraseAccepted, void()); // NOLINT
687 MOCK_METHOD1(OnBootstrapTokenUpdated, void(const std::string&)); // NOLINT 709 MOCK_METHOD1(OnBootstrapTokenUpdated, void(const std::string&)); // NOLINT
688 MOCK_METHOD0(OnStopSyncingPermanently, void()); // NOLINT
689 MOCK_METHOD1(OnUpdatedToken, void(const std::string&)); // NOLINT
690 MOCK_METHOD2(OnEncryptedTypesChanged, 710 MOCK_METHOD2(OnEncryptedTypesChanged,
691 void(ModelTypeSet, bool)); // NOLINT 711 void(ModelTypeSet, bool)); // NOLINT
692 MOCK_METHOD0(OnEncryptionComplete, void()); // NOLINT 712 MOCK_METHOD0(OnEncryptionComplete, void()); // NOLINT
693 MOCK_METHOD1(OnActionableError, 713 MOCK_METHOD1(OnCryptographerStateChanged, void(Cryptographer*)); // NOLINT
694 void(const SyncProtocolError&)); // NOLINT
695 }; 714 };
696 715
697 class SyncNotifierMock : public SyncNotifier { 716 class SyncNotifierMock : public SyncNotifier {
698 public: 717 public:
699 MOCK_METHOD2(UpdateRegisteredIds, 718 MOCK_METHOD2(UpdateRegisteredIds,
700 void(SyncNotifierObserver*, const ObjectIdSet&)); 719 void(SyncNotifierObserver*, const ObjectIdSet&));
701 MOCK_METHOD1(SetUniqueId, void(const std::string&)); 720 MOCK_METHOD1(SetUniqueId, void(const std::string&));
702 MOCK_METHOD1(SetStateDeprecated, void(const std::string&)); 721 MOCK_METHOD1(SetStateDeprecated, void(const std::string&));
703 MOCK_METHOD2(UpdateCredentials, 722 MOCK_METHOD2(UpdateCredentials,
704 void(const std::string&, const std::string&)); 723 void(const std::string&, const std::string&));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 SyncCredentials credentials; 755 SyncCredentials credentials;
737 credentials.email = "foo@bar.com"; 756 credentials.email = "foo@bar.com";
738 credentials.sync_token = "sometoken"; 757 credentials.sync_token = "sometoken";
739 758
740 sync_notifier_mock_ = new StrictMock<SyncNotifierMock>(); 759 sync_notifier_mock_ = new StrictMock<SyncNotifierMock>();
741 EXPECT_CALL(*sync_notifier_mock_, SetUniqueId(_)); 760 EXPECT_CALL(*sync_notifier_mock_, SetUniqueId(_));
742 EXPECT_CALL(*sync_notifier_mock_, SetStateDeprecated("")); 761 EXPECT_CALL(*sync_notifier_mock_, SetStateDeprecated(""));
743 EXPECT_CALL(*sync_notifier_mock_, 762 EXPECT_CALL(*sync_notifier_mock_,
744 UpdateCredentials(credentials.email, credentials.sync_token)); 763 UpdateCredentials(credentials.email, credentials.sync_token));
745 764
746 sync_manager_.AddObserver(&observer_); 765 sync_manager_.AddObserver(&manager_observer_);
747 EXPECT_CALL(observer_, OnInitializationComplete(_, _, _)). 766 EXPECT_CALL(manager_observer_, OnInitializationComplete(_, _, _)).
748 WillOnce(SaveArg<0>(&js_backend_)); 767 WillOnce(SaveArg<0>(&js_backend_));
749 768
750 EXPECT_FALSE(js_backend_.IsInitialized()); 769 EXPECT_FALSE(js_backend_.IsInitialized());
751 770
752 std::vector<ModelSafeWorker*> workers; 771 std::vector<ModelSafeWorker*> workers;
753 ModelSafeRoutingInfo routing_info; 772 ModelSafeRoutingInfo routing_info;
754 GetModelSafeRoutingInfo(&routing_info); 773 GetModelSafeRoutingInfo(&routing_info);
755 774
756 // Takes ownership of |sync_notifier_mock_|. 775 // Takes ownership of |sync_notifier_mock_|.
757 sync_manager_.Init(temp_dir_.path(), 776 sync_manager_.Init(temp_dir_.path(),
758 WeakHandle<JsEventHandler>(), 777 WeakHandle<JsEventHandler>(),
759 "bogus", 0, false, 778 "bogus", 0, false,
760 base::MessageLoopProxy::current(), 779 base::MessageLoopProxy::current(),
761 scoped_ptr<HttpPostProviderFactory>( 780 scoped_ptr<HttpPostProviderFactory>(
762 new TestHttpPostProviderFactory()), 781 new TestHttpPostProviderFactory()),
763 workers, &extensions_activity_monitor_, this, 782 workers, &extensions_activity_monitor_, this,
764 credentials, 783 credentials,
765 scoped_ptr<SyncNotifier>(sync_notifier_mock_), 784 scoped_ptr<SyncNotifier>(sync_notifier_mock_),
766 "", "", // bootstrap tokens 785 "", "", // bootstrap tokens
767 true, // enable keystore encryption 786 true, // enable keystore encryption
768 scoped_ptr<InternalComponentsFactory>(GetFactory()), 787 scoped_ptr<InternalComponentsFactory>(GetFactory()),
769 &encryptor_, 788 &encryptor_,
770 &handler_, 789 &handler_,
771 NULL); 790 NULL);
772 791
792 sync_manager_.GetEncryptionHandler()->AddObserver(&encryption_observer_);
793
773 EXPECT_TRUE(js_backend_.IsInitialized()); 794 EXPECT_TRUE(js_backend_.IsInitialized());
774 795
775 for (ModelSafeRoutingInfo::iterator i = routing_info.begin(); 796 for (ModelSafeRoutingInfo::iterator i = routing_info.begin();
776 i != routing_info.end(); ++i) { 797 i != routing_info.end(); ++i) {
777 type_roots_[i->first] = MakeServerNodeForType( 798 type_roots_[i->first] = MakeServerNodeForType(
778 sync_manager_.GetUserShare(), i->first); 799 sync_manager_.GetUserShare(), i->first);
779 } 800 }
780 PumpLoop(); 801 PumpLoop();
781 } 802 }
782 803
783 void TearDown() { 804 void TearDown() {
784 sync_manager_.RemoveObserver(&observer_); 805 sync_manager_.RemoveObserver(&manager_observer_);
785 EXPECT_CALL(*sync_notifier_mock_, UpdateRegisteredIds(_, ObjectIdSet())); 806 EXPECT_CALL(*sync_notifier_mock_, UpdateRegisteredIds(_, ObjectIdSet()));
786 sync_manager_.ShutdownOnSyncThread(); 807 sync_manager_.ShutdownOnSyncThread();
787 sync_notifier_mock_ = NULL; 808 sync_notifier_mock_ = NULL;
788 PumpLoop(); 809 PumpLoop();
789 } 810 }
790 811
791 void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { 812 void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) {
792 (*out)[NIGORI] = GROUP_PASSIVE; 813 (*out)[NIGORI] = GROUP_PASSIVE;
793 (*out)[BOOKMARKS] = GROUP_PASSIVE; 814 (*out)[BOOKMARKS] = GROUP_PASSIVE;
794 (*out)[THEMES] = GROUP_PASSIVE; 815 (*out)[THEMES] = GROUP_PASSIVE;
(...skipping 14 matching lines...) Expand all
809 EncryptionStatus encryption_status) { 830 EncryptionStatus encryption_status) {
810 UserShare* share = sync_manager_.GetUserShare(); 831 UserShare* share = sync_manager_.GetUserShare();
811 share->directory->set_initial_sync_ended_for_type(NIGORI, true); 832 share->directory->set_initial_sync_ended_for_type(NIGORI, true);
812 833
813 // We need to create the nigori node as if it were an applied server update. 834 // We need to create the nigori node as if it were an applied server update.
814 int64 nigori_id = GetIdForDataType(NIGORI); 835 int64 nigori_id = GetIdForDataType(NIGORI);
815 if (nigori_id == kInvalidId) 836 if (nigori_id == kInvalidId)
816 return false; 837 return false;
817 838
818 // Set the nigori cryptographer information. 839 // Set the nigori cryptographer information.
840 if (encryption_status == FULL_ENCRYPTION)
841 sync_manager_.GetEncryptionHandler()->EnableEncryptEverything();
842
819 WriteTransaction trans(FROM_HERE, share); 843 WriteTransaction trans(FROM_HERE, share);
820 Cryptographer* cryptographer = trans.GetCryptographer(); 844 Cryptographer* cryptographer = trans.GetCryptographer();
821 if (!cryptographer) 845 if (!cryptographer)
822 return false; 846 return false;
823 if (encryption_status != UNINITIALIZED) { 847 if (encryption_status != UNINITIALIZED) {
824 KeyParams params = {"localhost", "dummy", "foobar"}; 848 KeyParams params = {"localhost", "dummy", "foobar"};
825 cryptographer->AddKey(params); 849 cryptographer->AddKey(params);
826 } else { 850 } else {
827 DCHECK_NE(nigori_status, WRITE_TO_NIGORI); 851 DCHECK_NE(nigori_status, WRITE_TO_NIGORI);
828 } 852 }
829 if (encryption_status == FULL_ENCRYPTION)
830 cryptographer->set_encrypt_everything();
831 if (nigori_status == WRITE_TO_NIGORI) { 853 if (nigori_status == WRITE_TO_NIGORI) {
832 sync_pb::NigoriSpecifics nigori; 854 sync_pb::NigoriSpecifics nigori;
833 cryptographer->GetKeys(nigori.mutable_encrypted()); 855 cryptographer->GetKeys(nigori.mutable_encrypted());
834 cryptographer->UpdateNigoriFromEncryptedTypes(&nigori); 856 cryptographer->UpdateNigoriFromEncryptedTypes(&nigori);
835 WriteNode node(&trans); 857 WriteNode node(&trans);
836 EXPECT_EQ(BaseNode::INIT_OK, node.InitByIdLookup(nigori_id)); 858 EXPECT_EQ(BaseNode::INIT_OK, node.InitByIdLookup(nigori_id));
837 node.SetNigoriSpecifics(nigori); 859 node.SetNigoriSpecifics(nigori);
838 } 860 }
839 return cryptographer->is_ready(); 861 return cryptographer->is_ready();
840 } 862 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 return true; 902 return true;
881 } 903 }
882 904
883 virtual InternalComponentsFactory* GetFactory() { 905 virtual InternalComponentsFactory* GetFactory() {
884 return new TestInternalComponentsFactory(STORAGE_IN_MEMORY); 906 return new TestInternalComponentsFactory(STORAGE_IN_MEMORY);
885 } 907 }
886 908
887 // Returns true if we are currently encrypting all sync data. May 909 // Returns true if we are currently encrypting all sync data. May
888 // be called on any thread. 910 // be called on any thread.
889 bool EncryptEverythingEnabledForTest() { 911 bool EncryptEverythingEnabledForTest() {
890 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 912 return sync_manager_.GetEncryptionHandler()->EncryptEverythingEnabled();
891 return trans.GetCryptographer()->encrypt_everything();
892 } 913 }
893 914
894 // Gets the set of encrypted types from the cryptographer 915 // Gets the set of encrypted types from the cryptographer
895 // Note: opens a transaction. May be called from any thread. 916 // Note: opens a transaction. May be called from any thread.
896 syncer::ModelTypeSet GetEncryptedDataTypesForTest() { 917 syncer::ModelTypeSet GetEncryptedDataTypesForTest() {
897 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 918 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
898 return GetEncryptedTypes(&trans); 919 return GetEncryptedTypes(&trans);
899 } 920 }
900 921
901 void SimulateEnableNotificationsForTest() { 922 void SimulateEnableNotificationsForTest() {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 // Sync Id's for the roots of the enabled datatypes. 963 // Sync Id's for the roots of the enabled datatypes.
943 std::map<ModelType, int64> type_roots_; 964 std::map<ModelType, int64> type_roots_;
944 FakeExtensionsActivityMonitor extensions_activity_monitor_; 965 FakeExtensionsActivityMonitor extensions_activity_monitor_;
945 966
946 protected: 967 protected:
947 FakeEncryptor encryptor_; 968 FakeEncryptor encryptor_;
948 TestUnrecoverableErrorHandler handler_; 969 TestUnrecoverableErrorHandler handler_;
949 StrictMock<SyncNotifierMock>* sync_notifier_mock_; 970 StrictMock<SyncNotifierMock>* sync_notifier_mock_;
950 SyncManagerImpl sync_manager_; 971 SyncManagerImpl sync_manager_;
951 WeakHandle<JsBackend> js_backend_; 972 WeakHandle<JsBackend> js_backend_;
952 StrictMock<SyncManagerObserverMock> observer_; 973 StrictMock<SyncManagerObserverMock> manager_observer_;
974 StrictMock<SyncEncryptionHandlerObserverMock> encryption_observer_;
953 }; 975 };
954 976
955 TEST_F(SyncManagerTest, UpdateEnabledTypes) { 977 TEST_F(SyncManagerTest, UpdateEnabledTypes) {
956 ModelSafeRoutingInfo routes; 978 ModelSafeRoutingInfo routes;
957 GetModelSafeRoutingInfo(&routes); 979 GetModelSafeRoutingInfo(&routes);
958 const ModelTypeSet enabled_types = GetRoutingInfoTypes(routes); 980 const ModelTypeSet enabled_types = GetRoutingInfoTypes(routes);
959 981
960 EXPECT_CALL(*sync_notifier_mock_, 982 EXPECT_CALL(*sync_notifier_mock_,
961 UpdateRegisteredIds( 983 UpdateRegisteredIds(
962 _, ModelTypeSetToObjectIdSet(enabled_types))); 984 _, ModelTypeSetToObjectIdSet(enabled_types)));
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1323 1345
1324 TriggerOnIncomingNotificationForTest(empty_model_types); 1346 TriggerOnIncomingNotificationForTest(empty_model_types);
1325 TriggerOnIncomingNotificationForTest(model_types); 1347 TriggerOnIncomingNotificationForTest(model_types);
1326 1348
1327 // Should trigger the replies. 1349 // Should trigger the replies.
1328 PumpLoop(); 1350 PumpLoop();
1329 } 1351 }
1330 1352
1331 TEST_F(SyncManagerTest, RefreshEncryptionReady) { 1353 TEST_F(SyncManagerTest, RefreshEncryptionReady) {
1332 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION)); 1354 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION));
1333 EXPECT_CALL(observer_, OnEncryptionComplete()); 1355 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
1356 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
1334 1357
1335 sync_manager_.RefreshNigori(kTestChromeVersion, base::Bind(&DoNothing)); 1358 sync_manager_.GetEncryptionHandler()->ReloadNigori();
1336 PumpLoop(); 1359 PumpLoop();
1337 1360
1338 const ModelTypeSet encrypted_types = GetEncryptedDataTypesForTest(); 1361 const ModelTypeSet encrypted_types = GetEncryptedDataTypesForTest();
1339 EXPECT_TRUE(encrypted_types.Has(PASSWORDS)); 1362 EXPECT_TRUE(encrypted_types.Has(PASSWORDS));
1340 EXPECT_FALSE(EncryptEverythingEnabledForTest()); 1363 EXPECT_FALSE(EncryptEverythingEnabledForTest());
1341 1364
1342 { 1365 {
1343 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1366 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1344 ReadNode node(&trans); 1367 ReadNode node(&trans);
1345 EXPECT_EQ(BaseNode::INIT_OK, 1368 EXPECT_EQ(BaseNode::INIT_OK,
1346 node.InitByIdLookup(GetIdForDataType(NIGORI))); 1369 node.InitByIdLookup(GetIdForDataType(NIGORI)));
1347 sync_pb::NigoriSpecifics nigori = node.GetNigoriSpecifics(); 1370 sync_pb::NigoriSpecifics nigori = node.GetNigoriSpecifics();
1348 EXPECT_TRUE(nigori.has_encrypted()); 1371 EXPECT_TRUE(nigori.has_encrypted());
1349 Cryptographer* cryptographer = trans.GetCryptographer(); 1372 Cryptographer* cryptographer = trans.GetCryptographer();
1350 EXPECT_TRUE(cryptographer->is_ready()); 1373 EXPECT_TRUE(cryptographer->is_ready());
1351 EXPECT_TRUE(cryptographer->CanDecrypt(nigori.encrypted())); 1374 EXPECT_TRUE(cryptographer->CanDecrypt(nigori.encrypted()));
1352 } 1375 }
1353 } 1376 }
1354 1377
1355 // Attempt to refresh encryption when nigori not downloaded. 1378 // Attempt to refresh encryption when nigori not downloaded.
1356 TEST_F(SyncManagerTest, RefreshEncryptionNotReady) { 1379 TEST_F(SyncManagerTest, RefreshEncryptionNotReady) {
1357 // Don't set up encryption (no nigori node created). 1380 // Don't set up encryption (no nigori node created).
1358 1381
1359 // Should fail. 1382 // Should fail. Triggers an OnPassphraseRequired because the cryptographer
1360 sync_manager_.RefreshNigori(kTestChromeVersion, base::Bind(&DoNothing)); 1383 // is not ready.
1384 EXPECT_CALL(encryption_observer_, OnPassphraseRequired(_, _)).Times(1);
1385 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
1386 sync_manager_.GetEncryptionHandler()->ReloadNigori();
1361 PumpLoop(); 1387 PumpLoop();
1362 1388
1363 const ModelTypeSet encrypted_types = GetEncryptedDataTypesForTest(); 1389 const ModelTypeSet encrypted_types = GetEncryptedDataTypesForTest();
1364 EXPECT_TRUE(encrypted_types.Has(PASSWORDS)); // Hardcoded. 1390 EXPECT_TRUE(encrypted_types.Has(PASSWORDS)); // Hardcoded.
1365 EXPECT_FALSE(EncryptEverythingEnabledForTest()); 1391 EXPECT_FALSE(EncryptEverythingEnabledForTest());
1366 } 1392 }
1367 1393
1368 // Attempt to refresh encryption when nigori is empty. 1394 // Attempt to refresh encryption when nigori is empty.
1369 TEST_F(SyncManagerTest, RefreshEncryptionEmptyNigori) { 1395 TEST_F(SyncManagerTest, RefreshEncryptionEmptyNigori) {
1370 EXPECT_TRUE(SetUpEncryption(DONT_WRITE_NIGORI, DEFAULT_ENCRYPTION)); 1396 EXPECT_TRUE(SetUpEncryption(DONT_WRITE_NIGORI, DEFAULT_ENCRYPTION));
1371 EXPECT_CALL(observer_, OnEncryptionComplete()); 1397 EXPECT_CALL(encryption_observer_, OnEncryptionComplete()).Times(1);
1398 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
1372 1399
1373 // Should write to nigori. 1400 // Should write to nigori.
1374 sync_manager_.RefreshNigori(kTestChromeVersion, base::Bind(&DoNothing)); 1401 sync_manager_.GetEncryptionHandler()->ReloadNigori();
1375 PumpLoop(); 1402 PumpLoop();
1376 1403
1377 const ModelTypeSet encrypted_types = GetEncryptedDataTypesForTest(); 1404 const ModelTypeSet encrypted_types = GetEncryptedDataTypesForTest();
1378 EXPECT_TRUE(encrypted_types.Has(PASSWORDS)); // Hardcoded. 1405 EXPECT_TRUE(encrypted_types.Has(PASSWORDS)); // Hardcoded.
1379 EXPECT_FALSE(EncryptEverythingEnabledForTest()); 1406 EXPECT_FALSE(EncryptEverythingEnabledForTest());
1380 1407
1381 { 1408 {
1382 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1409 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1383 ReadNode node(&trans); 1410 ReadNode node(&trans);
1384 EXPECT_EQ(BaseNode::INIT_OK, 1411 EXPECT_EQ(BaseNode::INIT_OK,
1385 node.InitByIdLookup(GetIdForDataType(NIGORI))); 1412 node.InitByIdLookup(GetIdForDataType(NIGORI)));
1386 sync_pb::NigoriSpecifics nigori = node.GetNigoriSpecifics(); 1413 sync_pb::NigoriSpecifics nigori = node.GetNigoriSpecifics();
1387 EXPECT_TRUE(nigori.has_encrypted()); 1414 EXPECT_TRUE(nigori.has_encrypted());
1388 Cryptographer* cryptographer = trans.GetCryptographer(); 1415 Cryptographer* cryptographer = trans.GetCryptographer();
1389 EXPECT_TRUE(cryptographer->is_ready()); 1416 EXPECT_TRUE(cryptographer->is_ready());
1390 EXPECT_TRUE(cryptographer->CanDecrypt(nigori.encrypted())); 1417 EXPECT_TRUE(cryptographer->CanDecrypt(nigori.encrypted()));
1391 } 1418 }
1392 } 1419 }
1393 1420
1394 TEST_F(SyncManagerTest, EncryptDataTypesWithNoData) { 1421 TEST_F(SyncManagerTest, EncryptDataTypesWithNoData) {
1395 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION)); 1422 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION));
1396 EXPECT_CALL(observer_, 1423 EXPECT_CALL(encryption_observer_,
1397 OnEncryptedTypesChanged( 1424 OnEncryptedTypesChanged(
1398 HasModelTypes(ModelTypeSet::All()), true)); 1425 HasModelTypes(ModelTypeSet::All()), true));
1399 EXPECT_CALL(observer_, OnEncryptionComplete()); 1426 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
1400 sync_manager_.EnableEncryptEverything(); 1427 sync_manager_.GetEncryptionHandler()->EnableEncryptEverything();
1401 EXPECT_TRUE(EncryptEverythingEnabledForTest()); 1428 EXPECT_TRUE(EncryptEverythingEnabledForTest());
1402 } 1429 }
1403 1430
1404 TEST_F(SyncManagerTest, EncryptDataTypesWithData) { 1431 TEST_F(SyncManagerTest, EncryptDataTypesWithData) {
1405 size_t batch_size = 5; 1432 size_t batch_size = 5;
1406 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION)); 1433 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION));
1407 1434
1408 // Create some unencrypted unsynced data. 1435 // Create some unencrypted unsynced data.
1409 int64 folder = MakeFolderWithParent(sync_manager_.GetUserShare(), 1436 int64 folder = MakeFolderWithParent(sync_manager_.GetUserShare(),
1410 BOOKMARKS, 1437 BOOKMARKS,
(...skipping 14 matching lines...) Expand all
1425 // Last batch_size nodes are a third type that will not need encryption. 1452 // Last batch_size nodes are a third type that will not need encryption.
1426 for (; i < 3*batch_size; ++i) { 1453 for (; i < 3*batch_size; ++i) {
1427 MakeNodeWithParent(sync_manager_.GetUserShare(), THEMES, 1454 MakeNodeWithParent(sync_manager_.GetUserShare(), THEMES,
1428 base::StringPrintf("%"PRIuS"", i), 1455 base::StringPrintf("%"PRIuS"", i),
1429 GetIdForDataType(THEMES)); 1456 GetIdForDataType(THEMES));
1430 } 1457 }
1431 1458
1432 { 1459 {
1433 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1460 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1434 EXPECT_TRUE(GetEncryptedTypes(&trans).Equals( 1461 EXPECT_TRUE(GetEncryptedTypes(&trans).Equals(
1435 Cryptographer::SensitiveTypes())); 1462 SyncEncryptionHandler::SensitiveTypes()));
1436 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest( 1463 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
1437 trans.GetWrappedTrans(), 1464 trans.GetWrappedTrans(),
1438 trans.GetCryptographer(), 1465 trans.GetCryptographer(),
1439 BOOKMARKS, 1466 BOOKMARKS,
1440 false /* not encrypted */)); 1467 false /* not encrypted */));
1441 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest( 1468 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
1442 trans.GetWrappedTrans(), 1469 trans.GetWrappedTrans(),
1443 trans.GetCryptographer(), 1470 trans.GetCryptographer(),
1444 SESSIONS, 1471 SESSIONS,
1445 false /* not encrypted */)); 1472 false /* not encrypted */));
1446 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest( 1473 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
1447 trans.GetWrappedTrans(), 1474 trans.GetWrappedTrans(),
1448 trans.GetCryptographer(), 1475 trans.GetCryptographer(),
1449 THEMES, 1476 THEMES,
1450 false /* not encrypted */)); 1477 false /* not encrypted */));
1451 } 1478 }
1452 1479
1453 EXPECT_CALL(observer_, 1480 EXPECT_CALL(encryption_observer_,
1454 OnEncryptedTypesChanged( 1481 OnEncryptedTypesChanged(
1455 HasModelTypes(ModelTypeSet::All()), true)); 1482 HasModelTypes(ModelTypeSet::All()), true));
1456 EXPECT_CALL(observer_, OnEncryptionComplete()); 1483 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
1457 sync_manager_.EnableEncryptEverything(); 1484 sync_manager_.GetEncryptionHandler()->EnableEncryptEverything();
1458 EXPECT_TRUE(EncryptEverythingEnabledForTest()); 1485 EXPECT_TRUE(EncryptEverythingEnabledForTest());
1459 { 1486 {
1460 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1487 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1461 EXPECT_TRUE(GetEncryptedTypes(&trans).Equals( 1488 EXPECT_TRUE(GetEncryptedTypes(&trans).Equals(
1462 ModelTypeSet::All())); 1489 ModelTypeSet::All()));
1463 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest( 1490 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
1464 trans.GetWrappedTrans(), 1491 trans.GetWrappedTrans(),
1465 trans.GetCryptographer(), 1492 trans.GetCryptographer(),
1466 BOOKMARKS, 1493 BOOKMARKS,
1467 true /* is encrypted */)); 1494 true /* is encrypted */));
1468 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest( 1495 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
1469 trans.GetWrappedTrans(), 1496 trans.GetWrappedTrans(),
1470 trans.GetCryptographer(), 1497 trans.GetCryptographer(),
1471 SESSIONS, 1498 SESSIONS,
1472 true /* is encrypted */)); 1499 true /* is encrypted */));
1473 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest( 1500 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
1474 trans.GetWrappedTrans(), 1501 trans.GetWrappedTrans(),
1475 trans.GetCryptographer(), 1502 trans.GetCryptographer(),
1476 THEMES, 1503 THEMES,
1477 true /* is encrypted */)); 1504 true /* is encrypted */));
1478 } 1505 }
1479 1506
1480 // Trigger's a ReEncryptEverything with new passphrase. 1507 // Trigger's a ReEncryptEverything with new passphrase.
1481 testing::Mock::VerifyAndClearExpectations(&observer_); 1508 testing::Mock::VerifyAndClearExpectations(&encryption_observer_);
1482 EXPECT_CALL(observer_, OnBootstrapTokenUpdated(_)); 1509 EXPECT_CALL(encryption_observer_, OnBootstrapTokenUpdated(_));
1483 EXPECT_CALL(observer_, OnPassphraseAccepted()); 1510 EXPECT_CALL(encryption_observer_, OnPassphraseAccepted());
1484 EXPECT_CALL(observer_, OnEncryptionComplete()); 1511 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
1485 sync_manager_.SetEncryptionPassphrase("new_passphrase", true); 1512 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
1513 sync_manager_.GetEncryptionHandler()->SetEncryptionPassphrase(
1514 "new_passphrase", true);
1486 EXPECT_TRUE(EncryptEverythingEnabledForTest()); 1515 EXPECT_TRUE(EncryptEverythingEnabledForTest());
1487 { 1516 {
1488 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1517 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1489 EXPECT_TRUE(GetEncryptedTypes(&trans).Equals(ModelTypeSet::All())); 1518 EXPECT_TRUE(GetEncryptedTypes(&trans).Equals(ModelTypeSet::All()));
1490 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest( 1519 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
1491 trans.GetWrappedTrans(), 1520 trans.GetWrappedTrans(),
1492 trans.GetCryptographer(), 1521 trans.GetCryptographer(),
1493 BOOKMARKS, 1522 BOOKMARKS,
1494 true /* is encrypted */)); 1523 true /* is encrypted */));
1495 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest( 1524 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
1496 trans.GetWrappedTrans(), 1525 trans.GetWrappedTrans(),
1497 trans.GetCryptographer(), 1526 trans.GetCryptographer(),
1498 SESSIONS, 1527 SESSIONS,
1499 true /* is encrypted */)); 1528 true /* is encrypted */));
1500 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest( 1529 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
1501 trans.GetWrappedTrans(), 1530 trans.GetWrappedTrans(),
1502 trans.GetCryptographer(), 1531 trans.GetCryptographer(),
1503 THEMES, 1532 THEMES,
1504 true /* is encrypted */)); 1533 true /* is encrypted */));
1505 } 1534 }
1506 // Calling EncryptDataTypes with an empty encrypted types should not trigger 1535 // Calling EncryptDataTypes with an empty encrypted types should not trigger
1507 // a reencryption and should just notify immediately. 1536 // a reencryption and should just notify immediately.
1508 // TODO(zea): add logic to ensure nothing was written. 1537 testing::Mock::VerifyAndClearExpectations(&encryption_observer_);
1509 testing::Mock::VerifyAndClearExpectations(&observer_); 1538 EXPECT_CALL(encryption_observer_, OnBootstrapTokenUpdated(_)).Times(0);
1510 EXPECT_CALL(observer_, OnBootstrapTokenUpdated(_)).Times(0); 1539 EXPECT_CALL(encryption_observer_, OnPassphraseAccepted()).Times(0);
1511 EXPECT_CALL(observer_, OnPassphraseAccepted()).Times(0); 1540 EXPECT_CALL(encryption_observer_, OnEncryptionComplete()).Times(0);
1512 EXPECT_CALL(observer_, OnEncryptionComplete()); 1541 sync_manager_.GetEncryptionHandler()->EnableEncryptEverything();
1513 sync_manager_.EnableEncryptEverything();
1514 } 1542 }
1515 1543
1516 // Test that when there are no pending keys and the cryptographer is not 1544 // Test that when there are no pending keys and the cryptographer is not
1517 // initialized, we add a key based on the current GAIA password. 1545 // initialized, we add a key based on the current GAIA password.
1518 // (case 1 in SyncManager::SyncInternal::SetEncryptionPassphrase) 1546 // (case 1 in SyncManager::SyncInternal::SetEncryptionPassphrase)
1519 TEST_F(SyncManagerTest, SetInitialGaiaPass) { 1547 TEST_F(SyncManagerTest, SetInitialGaiaPass) {
1520 EXPECT_FALSE(SetUpEncryption(DONT_WRITE_NIGORI, UNINITIALIZED)); 1548 EXPECT_FALSE(SetUpEncryption(DONT_WRITE_NIGORI, UNINITIALIZED));
1521 EXPECT_CALL(observer_, OnBootstrapTokenUpdated(_)); 1549 EXPECT_CALL(encryption_observer_, OnBootstrapTokenUpdated(_));
1522 EXPECT_CALL(observer_, OnPassphraseAccepted()); 1550 EXPECT_CALL(encryption_observer_, OnPassphraseAccepted());
1523 EXPECT_CALL(observer_, OnEncryptionComplete()); 1551 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
1524 sync_manager_.SetEncryptionPassphrase("new_passphrase", false); 1552 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
1553 sync_manager_.GetEncryptionHandler()->SetEncryptionPassphrase(
1554 "new_passphrase",
1555 false);
1525 EXPECT_FALSE(EncryptEverythingEnabledForTest()); 1556 EXPECT_FALSE(EncryptEverythingEnabledForTest());
1526 { 1557 {
1527 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1558 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1528 ReadNode node(&trans); 1559 ReadNode node(&trans);
1529 EXPECT_EQ(BaseNode::INIT_OK, node.InitByTagLookup(kNigoriTag)); 1560 EXPECT_EQ(BaseNode::INIT_OK, node.InitByTagLookup(kNigoriTag));
1530 sync_pb::NigoriSpecifics nigori = node.GetNigoriSpecifics(); 1561 sync_pb::NigoriSpecifics nigori = node.GetNigoriSpecifics();
1531 Cryptographer* cryptographer = trans.GetCryptographer(); 1562 Cryptographer* cryptographer = trans.GetCryptographer();
1532 EXPECT_TRUE(cryptographer->is_ready()); 1563 EXPECT_TRUE(cryptographer->is_ready());
1533 EXPECT_TRUE(cryptographer->CanDecrypt(nigori.encrypted())); 1564 EXPECT_TRUE(cryptographer->CanDecrypt(nigori.encrypted()));
1534 } 1565 }
1535 } 1566 }
1536 1567
1537 // Test that when there are no pending keys and we have on the old GAIA 1568 // Test that when there are no pending keys and we have on the old GAIA
1538 // password, we update and re-encrypt everything with the new GAIA password. 1569 // password, we update and re-encrypt everything with the new GAIA password.
1539 // (case 1 in SyncManager::SyncInternal::SetEncryptionPassphrase) 1570 // (case 1 in SyncManager::SyncInternal::SetEncryptionPassphrase)
1540 TEST_F(SyncManagerTest, UpdateGaiaPass) { 1571 TEST_F(SyncManagerTest, UpdateGaiaPass) {
1541 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION)); 1572 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION));
1542 Cryptographer verifier(&encryptor_); 1573 Cryptographer verifier(&encryptor_);
1543 { 1574 {
1544 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1575 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1545 Cryptographer* cryptographer = trans.GetCryptographer(); 1576 Cryptographer* cryptographer = trans.GetCryptographer();
1546 std::string bootstrap_token; 1577 std::string bootstrap_token;
1547 cryptographer->GetBootstrapToken(&bootstrap_token); 1578 cryptographer->GetBootstrapToken(&bootstrap_token);
1548 verifier.Bootstrap(bootstrap_token); 1579 verifier.Bootstrap(bootstrap_token);
1549 } 1580 }
1550 EXPECT_CALL(observer_, OnBootstrapTokenUpdated(_)); 1581 EXPECT_CALL(encryption_observer_, OnBootstrapTokenUpdated(_));
1551 EXPECT_CALL(observer_, OnPassphraseAccepted()); 1582 EXPECT_CALL(encryption_observer_, OnPassphraseAccepted());
1552 EXPECT_CALL(observer_, OnEncryptionComplete()); 1583 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
1553 sync_manager_.SetEncryptionPassphrase("new_passphrase", false); 1584 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
1585 sync_manager_.GetEncryptionHandler()->SetEncryptionPassphrase(
1586 "new_passphrase",
1587 false);
1554 EXPECT_FALSE(EncryptEverythingEnabledForTest()); 1588 EXPECT_FALSE(EncryptEverythingEnabledForTest());
1555 { 1589 {
1556 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1590 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1557 Cryptographer* cryptographer = trans.GetCryptographer(); 1591 Cryptographer* cryptographer = trans.GetCryptographer();
1558 EXPECT_TRUE(cryptographer->is_ready()); 1592 EXPECT_TRUE(cryptographer->is_ready());
1559 // Verify the default key has changed. 1593 // Verify the default key has changed.
1560 sync_pb::EncryptedData encrypted; 1594 sync_pb::EncryptedData encrypted;
1561 cryptographer->GetKeys(&encrypted); 1595 cryptographer->GetKeys(&encrypted);
1562 EXPECT_FALSE(verifier.CanDecrypt(encrypted)); 1596 EXPECT_FALSE(verifier.CanDecrypt(encrypted));
1563 } 1597 }
(...skipping 18 matching lines...) Expand all
1582 1616
1583 WriteNode password_node(&trans); 1617 WriteNode password_node(&trans);
1584 WriteNode::InitUniqueByCreationResult result = 1618 WriteNode::InitUniqueByCreationResult result =
1585 password_node.InitUniqueByCreation(PASSWORDS, 1619 password_node.InitUniqueByCreation(PASSWORDS,
1586 root_node, "foo"); 1620 root_node, "foo");
1587 EXPECT_EQ(WriteNode::INIT_SUCCESS, result); 1621 EXPECT_EQ(WriteNode::INIT_SUCCESS, result);
1588 sync_pb::PasswordSpecificsData data; 1622 sync_pb::PasswordSpecificsData data;
1589 data.set_password_value("secret"); 1623 data.set_password_value("secret");
1590 password_node.SetPasswordSpecifics(data); 1624 password_node.SetPasswordSpecifics(data);
1591 } 1625 }
1592 EXPECT_CALL(observer_, OnBootstrapTokenUpdated(_)); 1626 EXPECT_CALL(encryption_observer_, OnBootstrapTokenUpdated(_));
1593 EXPECT_CALL(observer_, OnPassphraseAccepted()); 1627 EXPECT_CALL(encryption_observer_, OnPassphraseAccepted());
1594 EXPECT_CALL(observer_, OnEncryptionComplete()); 1628 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
1595 sync_manager_.SetEncryptionPassphrase("new_passphrase", true); 1629 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
1630 sync_manager_.GetEncryptionHandler()->SetEncryptionPassphrase(
1631 "new_passphrase",
1632 true);
1596 EXPECT_FALSE(EncryptEverythingEnabledForTest()); 1633 EXPECT_FALSE(EncryptEverythingEnabledForTest());
1597 { 1634 {
1598 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1635 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1599 Cryptographer* cryptographer = trans.GetCryptographer(); 1636 Cryptographer* cryptographer = trans.GetCryptographer();
1600 EXPECT_TRUE(cryptographer->is_ready()); 1637 EXPECT_TRUE(cryptographer->is_ready());
1601 // Verify the default key has changed. 1638 // Verify the default key has changed.
1602 sync_pb::EncryptedData encrypted; 1639 sync_pb::EncryptedData encrypted;
1603 cryptographer->GetKeys(&encrypted); 1640 cryptographer->GetKeys(&encrypted);
1604 EXPECT_FALSE(verifier.CanDecrypt(encrypted)); 1641 EXPECT_FALSE(verifier.CanDecrypt(encrypted));
1605 1642
(...skipping 22 matching lines...) Expand all
1628 other_cryptographer.Bootstrap(bootstrap_token); 1665 other_cryptographer.Bootstrap(bootstrap_token);
1629 1666
1630 // Now update the nigori to reflect the new keys, and update the 1667 // Now update the nigori to reflect the new keys, and update the
1631 // cryptographer to have pending keys. 1668 // cryptographer to have pending keys.
1632 KeyParams params = {"localhost", "dummy", "passphrase2"}; 1669 KeyParams params = {"localhost", "dummy", "passphrase2"};
1633 other_cryptographer.AddKey(params); 1670 other_cryptographer.AddKey(params);
1634 WriteNode node(&trans); 1671 WriteNode node(&trans);
1635 EXPECT_EQ(BaseNode::INIT_OK, node.InitByTagLookup(kNigoriTag)); 1672 EXPECT_EQ(BaseNode::INIT_OK, node.InitByTagLookup(kNigoriTag));
1636 sync_pb::NigoriSpecifics nigori; 1673 sync_pb::NigoriSpecifics nigori;
1637 other_cryptographer.GetKeys(nigori.mutable_encrypted()); 1674 other_cryptographer.GetKeys(nigori.mutable_encrypted());
1638 cryptographer->Update(nigori); 1675 cryptographer->SetPendingKeys(nigori.encrypted());
1639 EXPECT_TRUE(cryptographer->has_pending_keys()); 1676 EXPECT_TRUE(cryptographer->has_pending_keys());
1640 node.SetNigoriSpecifics(nigori); 1677 node.SetNigoriSpecifics(nigori);
1641 } 1678 }
1642 EXPECT_CALL(observer_, OnBootstrapTokenUpdated(_)); 1679 EXPECT_CALL(encryption_observer_, OnBootstrapTokenUpdated(_));
1643 EXPECT_CALL(observer_, OnPassphraseAccepted()); 1680 EXPECT_CALL(encryption_observer_, OnPassphraseAccepted());
1644 EXPECT_CALL(observer_, OnEncryptionComplete()); 1681 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
1645 sync_manager_.SetDecryptionPassphrase("passphrase2"); 1682 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
1683 sync_manager_.GetEncryptionHandler()->SetDecryptionPassphrase("passphrase2");
1646 EXPECT_FALSE(EncryptEverythingEnabledForTest()); 1684 EXPECT_FALSE(EncryptEverythingEnabledForTest());
1647 { 1685 {
1648 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1686 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1649 Cryptographer* cryptographer = trans.GetCryptographer(); 1687 Cryptographer* cryptographer = trans.GetCryptographer();
1650 EXPECT_TRUE(cryptographer->is_ready()); 1688 EXPECT_TRUE(cryptographer->is_ready());
1651 // Verify we're encrypting with the new key. 1689 // Verify we're encrypting with the new key.
1652 sync_pb::EncryptedData encrypted; 1690 sync_pb::EncryptedData encrypted;
1653 cryptographer->GetKeys(&encrypted); 1691 cryptographer->GetKeys(&encrypted);
1654 EXPECT_TRUE(other_cryptographer.CanDecrypt(encrypted)); 1692 EXPECT_TRUE(other_cryptographer.CanDecrypt(encrypted));
1655 } 1693 }
(...skipping 17 matching lines...) Expand all
1673 1711
1674 // Now update the nigori to reflect the new keys, and update the 1712 // Now update the nigori to reflect the new keys, and update the
1675 // cryptographer to have pending keys. 1713 // cryptographer to have pending keys.
1676 KeyParams params = {"localhost", "dummy", "old_gaia"}; 1714 KeyParams params = {"localhost", "dummy", "old_gaia"};
1677 other_cryptographer.AddKey(params); 1715 other_cryptographer.AddKey(params);
1678 WriteNode node(&trans); 1716 WriteNode node(&trans);
1679 EXPECT_EQ(BaseNode::INIT_OK, node.InitByTagLookup(kNigoriTag)); 1717 EXPECT_EQ(BaseNode::INIT_OK, node.InitByTagLookup(kNigoriTag));
1680 sync_pb::NigoriSpecifics nigori; 1718 sync_pb::NigoriSpecifics nigori;
1681 other_cryptographer.GetKeys(nigori.mutable_encrypted()); 1719 other_cryptographer.GetKeys(nigori.mutable_encrypted());
1682 node.SetNigoriSpecifics(nigori); 1720 node.SetNigoriSpecifics(nigori);
1683 cryptographer->Update(nigori); 1721 cryptographer->SetPendingKeys(nigori.encrypted());
1684 1722
1685 // other_cryptographer now contains all encryption keys, and is encrypting 1723 // other_cryptographer now contains all encryption keys, and is encrypting
1686 // with the newest gaia. 1724 // with the newest gaia.
1687 KeyParams new_params = {"localhost", "dummy", "new_gaia"}; 1725 KeyParams new_params = {"localhost", "dummy", "new_gaia"};
1688 other_cryptographer.AddKey(new_params); 1726 other_cryptographer.AddKey(new_params);
1689 } 1727 }
1690 // The bootstrap token should have been updated. Save it to ensure it's based 1728 // The bootstrap token should have been updated. Save it to ensure it's based
1691 // on the new GAIA password. 1729 // on the new GAIA password.
1692 std::string bootstrap_token; 1730 std::string bootstrap_token;
1693 EXPECT_CALL(observer_, OnBootstrapTokenUpdated(_)) 1731 EXPECT_CALL(encryption_observer_, OnBootstrapTokenUpdated(_))
1694 .WillOnce(SaveArg<0>(&bootstrap_token)); 1732 .WillOnce(SaveArg<0>(&bootstrap_token));
1695 EXPECT_CALL(observer_, OnPassphraseRequired(_,_)); 1733 EXPECT_CALL(encryption_observer_, OnPassphraseRequired(_,_));
1696 sync_manager_.SetEncryptionPassphrase("new_gaia", false); 1734 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
1735 sync_manager_.GetEncryptionHandler()->SetEncryptionPassphrase(
1736 "new_gaia",
1737 false);
1697 EXPECT_FALSE(EncryptEverythingEnabledForTest()); 1738 EXPECT_FALSE(EncryptEverythingEnabledForTest());
1698 testing::Mock::VerifyAndClearExpectations(&observer_); 1739 testing::Mock::VerifyAndClearExpectations(&encryption_observer_);
1699 { 1740 {
1700 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1741 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1701 Cryptographer* cryptographer = trans.GetCryptographer(); 1742 Cryptographer* cryptographer = trans.GetCryptographer();
1702 EXPECT_TRUE(cryptographer->is_initialized()); 1743 EXPECT_TRUE(cryptographer->is_initialized());
1703 EXPECT_FALSE(cryptographer->is_ready()); 1744 EXPECT_FALSE(cryptographer->is_ready());
1704 // Verify we're encrypting with the new key, even though we have pending 1745 // Verify we're encrypting with the new key, even though we have pending
1705 // keys. 1746 // keys.
1706 sync_pb::EncryptedData encrypted; 1747 sync_pb::EncryptedData encrypted;
1707 other_cryptographer.GetKeys(&encrypted); 1748 other_cryptographer.GetKeys(&encrypted);
1708 EXPECT_TRUE(cryptographer->CanDecrypt(encrypted)); 1749 EXPECT_TRUE(cryptographer->CanDecrypt(encrypted));
1709 } 1750 }
1710 EXPECT_CALL(observer_, OnBootstrapTokenUpdated(_)); 1751 EXPECT_CALL(encryption_observer_, OnBootstrapTokenUpdated(_));
1711 EXPECT_CALL(observer_, OnPassphraseAccepted()); 1752 EXPECT_CALL(encryption_observer_, OnPassphraseAccepted());
1712 EXPECT_CALL(observer_, OnEncryptionComplete()); 1753 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
1713 sync_manager_.SetEncryptionPassphrase("old_gaia", false); 1754 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
1755 sync_manager_.GetEncryptionHandler()->SetEncryptionPassphrase(
1756 "old_gaia",
1757 false);
1714 { 1758 {
1715 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1759 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1716 Cryptographer* cryptographer = trans.GetCryptographer(); 1760 Cryptographer* cryptographer = trans.GetCryptographer();
1717 EXPECT_TRUE(cryptographer->is_ready()); 1761 EXPECT_TRUE(cryptographer->is_ready());
1718 1762
1719 // Verify we're encrypting with the new key. 1763 // Verify we're encrypting with the new key.
1720 sync_pb::EncryptedData encrypted; 1764 sync_pb::EncryptedData encrypted;
1721 other_cryptographer.GetKeys(&encrypted); 1765 other_cryptographer.GetKeys(&encrypted);
1722 EXPECT_TRUE(cryptographer->CanDecrypt(encrypted)); 1766 EXPECT_TRUE(cryptographer->CanDecrypt(encrypted));
1723 1767
(...skipping 19 matching lines...) Expand all
1743 other_cryptographer.Bootstrap(bootstrap_token); 1787 other_cryptographer.Bootstrap(bootstrap_token);
1744 1788
1745 // Now update the nigori to reflect the new keys, and update the 1789 // Now update the nigori to reflect the new keys, and update the
1746 // cryptographer to have pending keys. 1790 // cryptographer to have pending keys.
1747 KeyParams params = {"localhost", "dummy", "explicit"}; 1791 KeyParams params = {"localhost", "dummy", "explicit"};
1748 other_cryptographer.AddKey(params); 1792 other_cryptographer.AddKey(params);
1749 WriteNode node(&trans); 1793 WriteNode node(&trans);
1750 EXPECT_EQ(BaseNode::INIT_OK, node.InitByTagLookup(kNigoriTag)); 1794 EXPECT_EQ(BaseNode::INIT_OK, node.InitByTagLookup(kNigoriTag));
1751 sync_pb::NigoriSpecifics nigori; 1795 sync_pb::NigoriSpecifics nigori;
1752 other_cryptographer.GetKeys(nigori.mutable_encrypted()); 1796 other_cryptographer.GetKeys(nigori.mutable_encrypted());
1753 cryptographer->Update(nigori); 1797 cryptographer->SetPendingKeys(nigori.encrypted());
1754 EXPECT_TRUE(cryptographer->has_pending_keys()); 1798 EXPECT_TRUE(cryptographer->has_pending_keys());
1755 nigori.set_using_explicit_passphrase(true); 1799 nigori.set_using_explicit_passphrase(true);
1756 node.SetNigoriSpecifics(nigori); 1800 node.SetNigoriSpecifics(nigori);
1757 } 1801 }
1758 EXPECT_CALL(observer_, OnBootstrapTokenUpdated(_)); 1802 EXPECT_CALL(encryption_observer_, OnBootstrapTokenUpdated(_));
1759 EXPECT_CALL(observer_, OnPassphraseAccepted()); 1803 EXPECT_CALL(encryption_observer_, OnPassphraseAccepted());
1760 EXPECT_CALL(observer_, OnEncryptionComplete()); 1804 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
1761 sync_manager_.SetDecryptionPassphrase("explicit"); 1805 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
1806 sync_manager_.GetEncryptionHandler()->SetDecryptionPassphrase("explicit");
1762 EXPECT_FALSE(EncryptEverythingEnabledForTest()); 1807 EXPECT_FALSE(EncryptEverythingEnabledForTest());
1763 { 1808 {
1764 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1809 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1765 Cryptographer* cryptographer = trans.GetCryptographer(); 1810 Cryptographer* cryptographer = trans.GetCryptographer();
1766 EXPECT_TRUE(cryptographer->is_ready()); 1811 EXPECT_TRUE(cryptographer->is_ready());
1767 // Verify we're encrypting with the new key. 1812 // Verify we're encrypting with the new key.
1768 sync_pb::EncryptedData encrypted; 1813 sync_pb::EncryptedData encrypted;
1769 cryptographer->GetKeys(&encrypted); 1814 cryptographer->GetKeys(&encrypted);
1770 EXPECT_TRUE(other_cryptographer.CanDecrypt(encrypted)); 1815 EXPECT_TRUE(other_cryptographer.CanDecrypt(encrypted));
1771 } 1816 }
(...skipping 11 matching lines...) Expand all
1783 Cryptographer* cryptographer = trans.GetCryptographer(); 1828 Cryptographer* cryptographer = trans.GetCryptographer();
1784 // Now update the nigori to reflect the new keys, and update the 1829 // Now update the nigori to reflect the new keys, and update the
1785 // cryptographer to have pending keys. 1830 // cryptographer to have pending keys.
1786 KeyParams params = {"localhost", "dummy", "passphrase"}; 1831 KeyParams params = {"localhost", "dummy", "passphrase"};
1787 other_cryptographer.AddKey(params); 1832 other_cryptographer.AddKey(params);
1788 WriteNode node(&trans); 1833 WriteNode node(&trans);
1789 EXPECT_EQ(BaseNode::INIT_OK, node.InitByTagLookup(kNigoriTag)); 1834 EXPECT_EQ(BaseNode::INIT_OK, node.InitByTagLookup(kNigoriTag));
1790 sync_pb::NigoriSpecifics nigori; 1835 sync_pb::NigoriSpecifics nigori;
1791 other_cryptographer.GetKeys(nigori.mutable_encrypted()); 1836 other_cryptographer.GetKeys(nigori.mutable_encrypted());
1792 node.SetNigoriSpecifics(nigori); 1837 node.SetNigoriSpecifics(nigori);
1793 cryptographer->Update(nigori); 1838 cryptographer->SetPendingKeys(nigori.encrypted());
1794 EXPECT_FALSE(cryptographer->is_ready()); 1839 EXPECT_FALSE(cryptographer->is_ready());
1795 } 1840 }
1796 EXPECT_CALL(observer_, OnBootstrapTokenUpdated(_)); 1841 EXPECT_CALL(encryption_observer_, OnBootstrapTokenUpdated(_));
1797 EXPECT_CALL(observer_, OnPassphraseAccepted()); 1842 EXPECT_CALL(encryption_observer_, OnPassphraseAccepted());
1798 EXPECT_CALL(observer_, OnEncryptionComplete()); 1843 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
1799 sync_manager_.SetEncryptionPassphrase("passphrase", false); 1844 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
1845 sync_manager_.GetEncryptionHandler()->SetEncryptionPassphrase(
1846 "passphrase",
1847 false);
1800 EXPECT_FALSE(EncryptEverythingEnabledForTest()); 1848 EXPECT_FALSE(EncryptEverythingEnabledForTest());
1801 { 1849 {
1802 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1850 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1803 Cryptographer* cryptographer = trans.GetCryptographer(); 1851 Cryptographer* cryptographer = trans.GetCryptographer();
1804 EXPECT_TRUE(cryptographer->is_ready()); 1852 EXPECT_TRUE(cryptographer->is_ready());
1805 } 1853 }
1806 } 1854 }
1807 1855
1808 TEST_F(SyncManagerTest, SetPassphraseWithEmptyPasswordNode) { 1856 TEST_F(SyncManagerTest, SetPassphraseWithEmptyPasswordNode) {
1809 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION)); 1857 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION));
1810 int64 node_id = 0; 1858 int64 node_id = 0;
1811 std::string tag = "foo"; 1859 std::string tag = "foo";
1812 { 1860 {
1813 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1861 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1814 ReadNode root_node(&trans); 1862 ReadNode root_node(&trans);
1815 root_node.InitByRootLookup(); 1863 root_node.InitByRootLookup();
1816 1864
1817 WriteNode password_node(&trans); 1865 WriteNode password_node(&trans);
1818 WriteNode::InitUniqueByCreationResult result = 1866 WriteNode::InitUniqueByCreationResult result =
1819 password_node.InitUniqueByCreation(PASSWORDS, root_node, tag); 1867 password_node.InitUniqueByCreation(PASSWORDS, root_node, tag);
1820 EXPECT_EQ(WriteNode::INIT_SUCCESS, result); 1868 EXPECT_EQ(WriteNode::INIT_SUCCESS, result);
1821 node_id = password_node.GetId(); 1869 node_id = password_node.GetId();
1822 } 1870 }
1823 EXPECT_CALL(observer_, OnBootstrapTokenUpdated(_)); 1871 EXPECT_CALL(encryption_observer_, OnBootstrapTokenUpdated(_));
1824 EXPECT_CALL(observer_, OnPassphraseAccepted()); 1872 EXPECT_CALL(encryption_observer_, OnPassphraseAccepted());
1825 EXPECT_CALL(observer_, OnEncryptionComplete()); 1873 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
1826 sync_manager_.SetEncryptionPassphrase("new_passphrase", true); 1874 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
1875 sync_manager_.GetEncryptionHandler()->SetEncryptionPassphrase(
1876 "new_passphrase",
1877 true);
1827 EXPECT_FALSE(EncryptEverythingEnabledForTest()); 1878 EXPECT_FALSE(EncryptEverythingEnabledForTest());
1828 { 1879 {
1829 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1880 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1830 ReadNode password_node(&trans); 1881 ReadNode password_node(&trans);
1831 EXPECT_EQ(BaseNode::INIT_FAILED_DECRYPT_IF_NECESSARY, 1882 EXPECT_EQ(BaseNode::INIT_FAILED_DECRYPT_IF_NECESSARY,
1832 password_node.InitByClientTagLookup(PASSWORDS, 1883 password_node.InitByClientTagLookup(PASSWORDS,
1833 tag)); 1884 tag));
1834 } 1885 }
1835 { 1886 {
1836 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1887 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1918 1969
1919 { 1970 {
1920 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1971 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1921 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest( 1972 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
1922 trans.GetWrappedTrans(), 1973 trans.GetWrappedTrans(),
1923 trans.GetCryptographer(), 1974 trans.GetCryptographer(),
1924 BOOKMARKS, 1975 BOOKMARKS,
1925 false /* not encrypted */)); 1976 false /* not encrypted */));
1926 } 1977 }
1927 1978
1928 EXPECT_CALL(observer_, 1979 EXPECT_CALL(encryption_observer_,
1929 OnEncryptedTypesChanged( 1980 OnEncryptedTypesChanged(
1930 HasModelTypes(ModelTypeSet::All()), true)); 1981 HasModelTypes(ModelTypeSet::All()), true));
1931 EXPECT_CALL(observer_, OnEncryptionComplete()); 1982 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
1932 sync_manager_.EnableEncryptEverything(); 1983 sync_manager_.GetEncryptionHandler()->EnableEncryptEverything();
1933 EXPECT_TRUE(EncryptEverythingEnabledForTest()); 1984 EXPECT_TRUE(EncryptEverythingEnabledForTest());
1934 1985
1935 { 1986 {
1936 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1987 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1937 EXPECT_TRUE(GetEncryptedTypes(&trans).Equals(ModelTypeSet::All())); 1988 EXPECT_TRUE(GetEncryptedTypes(&trans).Equals(ModelTypeSet::All()));
1938 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest( 1989 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
1939 trans.GetWrappedTrans(), 1990 trans.GetWrappedTrans(),
1940 trans.GetCryptographer(), 1991 trans.GetCryptographer(),
1941 BOOKMARKS, 1992 BOOKMARKS,
1942 true /* is encrypted */)); 1993 true /* is encrypted */));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2006 { 2057 {
2007 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 2058 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2008 WriteNode node(&trans); 2059 WriteNode node(&trans);
2009 EXPECT_EQ(BaseNode::INIT_OK, 2060 EXPECT_EQ(BaseNode::INIT_OK,
2010 node.InitByClientTagLookup(BOOKMARKS, client_tag)); 2061 node.InitByClientTagLookup(BOOKMARKS, client_tag));
2011 node.SetEntitySpecifics(entity_specifics); 2062 node.SetEntitySpecifics(entity_specifics);
2012 } 2063 }
2013 EXPECT_FALSE(ResetUnsyncedEntry(BOOKMARKS, client_tag)); 2064 EXPECT_FALSE(ResetUnsyncedEntry(BOOKMARKS, client_tag));
2014 2065
2015 // Encrypt the datatatype, should set is_unsynced. 2066 // Encrypt the datatatype, should set is_unsynced.
2016 EXPECT_CALL(observer_, 2067 EXPECT_CALL(encryption_observer_,
2017 OnEncryptedTypesChanged( 2068 OnEncryptedTypesChanged(
2018 HasModelTypes(ModelTypeSet::All()), true)); 2069 HasModelTypes(ModelTypeSet::All()), true));
2019 EXPECT_CALL(observer_, OnEncryptionComplete()); 2070 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
2020 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, FULL_ENCRYPTION)); 2071 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, FULL_ENCRYPTION));
2021 2072
2022 sync_manager_.RefreshNigori(kTestChromeVersion, base::Bind(&DoNothing)); 2073 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
2074 sync_manager_.GetEncryptionHandler()->ReloadNigori();
2023 PumpLoop(); 2075 PumpLoop();
2024 { 2076 {
2025 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 2077 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2026 ReadNode node(&trans); 2078 ReadNode node(&trans);
2027 EXPECT_EQ(BaseNode::INIT_OK, 2079 EXPECT_EQ(BaseNode::INIT_OK,
2028 node.InitByClientTagLookup(BOOKMARKS, client_tag)); 2080 node.InitByClientTagLookup(BOOKMARKS, client_tag));
2029 const syncable::Entry* node_entry = node.GetEntry(); 2081 const syncable::Entry* node_entry = node.GetEntry();
2030 const sync_pb::EntitySpecifics& specifics = node_entry->Get(SPECIFICS); 2082 const sync_pb::EntitySpecifics& specifics = node_entry->Get(SPECIFICS);
2031 EXPECT_TRUE(specifics.has_encrypted()); 2083 EXPECT_TRUE(specifics.has_encrypted());
2032 EXPECT_EQ(kEncryptedString, node_entry->Get(NON_UNIQUE_NAME)); 2084 EXPECT_EQ(kEncryptedString, node_entry->Get(NON_UNIQUE_NAME));
2033 Cryptographer* cryptographer = trans.GetCryptographer(); 2085 Cryptographer* cryptographer = trans.GetCryptographer();
2034 EXPECT_TRUE(cryptographer->is_ready()); 2086 EXPECT_TRUE(cryptographer->is_ready());
2035 EXPECT_TRUE(cryptographer->CanDecryptUsingDefaultKey( 2087 EXPECT_TRUE(cryptographer->CanDecryptUsingDefaultKey(
2036 specifics.encrypted())); 2088 specifics.encrypted()));
2037 } 2089 }
2038 EXPECT_TRUE(ResetUnsyncedEntry(BOOKMARKS, client_tag)); 2090 EXPECT_TRUE(ResetUnsyncedEntry(BOOKMARKS, client_tag));
2039 2091
2040 // Set a new passphrase. Should set is_unsynced. 2092 // Set a new passphrase. Should set is_unsynced.
2041 testing::Mock::VerifyAndClearExpectations(&observer_); 2093 testing::Mock::VerifyAndClearExpectations(&encryption_observer_);
2042 EXPECT_CALL(observer_, OnBootstrapTokenUpdated(_)); 2094 EXPECT_CALL(encryption_observer_, OnBootstrapTokenUpdated(_));
2043 EXPECT_CALL(observer_, OnPassphraseAccepted()); 2095 EXPECT_CALL(encryption_observer_, OnPassphraseAccepted());
2044 EXPECT_CALL(observer_, OnEncryptionComplete()); 2096 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
2045 sync_manager_.SetEncryptionPassphrase("new_passphrase", true); 2097 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
2098 sync_manager_.GetEncryptionHandler()->SetEncryptionPassphrase(
2099 "new_passphrase",
2100 true);
2046 { 2101 {
2047 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 2102 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2048 ReadNode node(&trans); 2103 ReadNode node(&trans);
2049 EXPECT_EQ(BaseNode::INIT_OK, 2104 EXPECT_EQ(BaseNode::INIT_OK,
2050 node.InitByClientTagLookup(BOOKMARKS, client_tag)); 2105 node.InitByClientTagLookup(BOOKMARKS, client_tag));
2051 const syncable::Entry* node_entry = node.GetEntry(); 2106 const syncable::Entry* node_entry = node.GetEntry();
2052 const sync_pb::EntitySpecifics& specifics = node_entry->Get(SPECIFICS); 2107 const sync_pb::EntitySpecifics& specifics = node_entry->Get(SPECIFICS);
2053 EXPECT_TRUE(specifics.has_encrypted()); 2108 EXPECT_TRUE(specifics.has_encrypted());
2054 EXPECT_EQ(kEncryptedString, node_entry->Get(NON_UNIQUE_NAME)); 2109 EXPECT_EQ(kEncryptedString, node_entry->Get(NON_UNIQUE_NAME));
2055 Cryptographer* cryptographer = trans.GetCryptographer(); 2110 Cryptographer* cryptographer = trans.GetCryptographer();
2056 EXPECT_TRUE(cryptographer->is_ready()); 2111 EXPECT_TRUE(cryptographer->is_ready());
2057 EXPECT_TRUE(cryptographer->CanDecryptUsingDefaultKey( 2112 EXPECT_TRUE(cryptographer->CanDecryptUsingDefaultKey(
2058 specifics.encrypted())); 2113 specifics.encrypted()));
2059 } 2114 }
2060 EXPECT_TRUE(ResetUnsyncedEntry(BOOKMARKS, client_tag)); 2115 EXPECT_TRUE(ResetUnsyncedEntry(BOOKMARKS, client_tag));
2061 2116
2062 // Force a re-encrypt everything. Should not set is_unsynced. 2117 // Force a re-encrypt everything. Should not set is_unsynced.
2063 testing::Mock::VerifyAndClearExpectations(&observer_); 2118 testing::Mock::VerifyAndClearExpectations(&encryption_observer_);
2064 EXPECT_CALL(observer_, OnEncryptionComplete()); 2119 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
2120 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
2065 2121
2066 sync_manager_.RefreshNigori(kTestChromeVersion, base::Bind(&DoNothing)); 2122 sync_manager_.GetEncryptionHandler()->ReloadNigori();
2067 PumpLoop(); 2123 PumpLoop();
2068 2124
2069 { 2125 {
2070 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 2126 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2071 ReadNode node(&trans); 2127 ReadNode node(&trans);
2072 EXPECT_EQ(BaseNode::INIT_OK, 2128 EXPECT_EQ(BaseNode::INIT_OK,
2073 node.InitByClientTagLookup(BOOKMARKS, client_tag)); 2129 node.InitByClientTagLookup(BOOKMARKS, client_tag));
2074 const syncable::Entry* node_entry = node.GetEntry(); 2130 const syncable::Entry* node_entry = node.GetEntry();
2075 const sync_pb::EntitySpecifics& specifics = node_entry->Get(SPECIFICS); 2131 const sync_pb::EntitySpecifics& specifics = node_entry->Get(SPECIFICS);
2076 EXPECT_TRUE(specifics.has_encrypted()); 2132 EXPECT_TRUE(specifics.has_encrypted());
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
2222 entity_specifics.mutable_password()->mutable_encrypted()); 2278 entity_specifics.mutable_password()->mutable_encrypted());
2223 } 2279 }
2224 MakeServerNode(sync_manager_.GetUserShare(), PASSWORDS, client_tag, 2280 MakeServerNode(sync_manager_.GetUserShare(), PASSWORDS, client_tag,
2225 BaseNode::GenerateSyncableHash(PASSWORDS, 2281 BaseNode::GenerateSyncableHash(PASSWORDS,
2226 client_tag), 2282 client_tag),
2227 entity_specifics); 2283 entity_specifics);
2228 // New node shouldn't start off unsynced. 2284 // New node shouldn't start off unsynced.
2229 EXPECT_FALSE(ResetUnsyncedEntry(PASSWORDS, client_tag)); 2285 EXPECT_FALSE(ResetUnsyncedEntry(PASSWORDS, client_tag));
2230 2286
2231 // Set a new passphrase. Should set is_unsynced. 2287 // Set a new passphrase. Should set is_unsynced.
2232 testing::Mock::VerifyAndClearExpectations(&observer_); 2288 testing::Mock::VerifyAndClearExpectations(&encryption_observer_);
2233 EXPECT_CALL(observer_, OnBootstrapTokenUpdated(_)); 2289 EXPECT_CALL(encryption_observer_, OnBootstrapTokenUpdated(_));
2234 EXPECT_CALL(observer_, OnPassphraseAccepted()); 2290 EXPECT_CALL(encryption_observer_, OnPassphraseAccepted());
2235 EXPECT_CALL(observer_, OnEncryptionComplete()); 2291 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
2236 sync_manager_.SetEncryptionPassphrase("new_passphrase", true); 2292 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
2293 sync_manager_.GetEncryptionHandler()->SetEncryptionPassphrase(
2294 "new_passphrase",
2295 true);
2237 EXPECT_TRUE(ResetUnsyncedEntry(PASSWORDS, client_tag)); 2296 EXPECT_TRUE(ResetUnsyncedEntry(PASSWORDS, client_tag));
2238 } 2297 }
2239 2298
2240 // Passwords have their own handling for encryption. Verify it does not result 2299 // Passwords have their own handling for encryption. Verify it does not result
2241 // in unnecessary writes via ReencryptEverything. 2300 // in unnecessary writes via ReencryptEverything.
2242 TEST_F(SyncManagerTest, UpdatePasswordReencryptEverything) { 2301 TEST_F(SyncManagerTest, UpdatePasswordReencryptEverything) {
2243 std::string client_tag = "title"; 2302 std::string client_tag = "title";
2244 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION)); 2303 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION));
2245 sync_pb::EntitySpecifics entity_specifics; 2304 sync_pb::EntitySpecifics entity_specifics;
2246 { 2305 {
2247 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 2306 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2248 Cryptographer* cryptographer = trans.GetCryptographer(); 2307 Cryptographer* cryptographer = trans.GetCryptographer();
2249 sync_pb::PasswordSpecificsData data; 2308 sync_pb::PasswordSpecificsData data;
2250 data.set_password_value("secret"); 2309 data.set_password_value("secret");
2251 cryptographer->Encrypt( 2310 cryptographer->Encrypt(
2252 data, 2311 data,
2253 entity_specifics.mutable_password()->mutable_encrypted()); 2312 entity_specifics.mutable_password()->mutable_encrypted());
2254 } 2313 }
2255 MakeServerNode(sync_manager_.GetUserShare(), PASSWORDS, client_tag, 2314 MakeServerNode(sync_manager_.GetUserShare(), PASSWORDS, client_tag,
2256 BaseNode::GenerateSyncableHash(PASSWORDS, 2315 BaseNode::GenerateSyncableHash(PASSWORDS,
2257 client_tag), 2316 client_tag),
2258 entity_specifics); 2317 entity_specifics);
2259 // New node shouldn't start off unsynced. 2318 // New node shouldn't start off unsynced.
2260 EXPECT_FALSE(ResetUnsyncedEntry(PASSWORDS, client_tag)); 2319 EXPECT_FALSE(ResetUnsyncedEntry(PASSWORDS, client_tag));
2261 2320
2262 // Force a re-encrypt everything. Should not set is_unsynced. 2321 // Force a re-encrypt everything. Should not set is_unsynced.
2263 testing::Mock::VerifyAndClearExpectations(&observer_); 2322 testing::Mock::VerifyAndClearExpectations(&encryption_observer_);
2264 EXPECT_CALL(observer_, OnEncryptionComplete()); 2323 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
2265 sync_manager_.RefreshNigori(kTestChromeVersion, base::Bind(&DoNothing)); 2324 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
2325 sync_manager_.GetEncryptionHandler()->ReloadNigori();
2266 PumpLoop(); 2326 PumpLoop();
2267 EXPECT_FALSE(ResetUnsyncedEntry(PASSWORDS, client_tag)); 2327 EXPECT_FALSE(ResetUnsyncedEntry(PASSWORDS, client_tag));
2268 } 2328 }
2269 2329
2270 // Verify SetTitle(..) doesn't unnecessarily set IS_UNSYNCED for bookmarks 2330 // Verify SetTitle(..) doesn't unnecessarily set IS_UNSYNCED for bookmarks
2271 // when we write the same data, but does set it when we write new data. 2331 // when we write the same data, but does set it when we write new data.
2272 TEST_F(SyncManagerTest, SetBookmarkTitle) { 2332 TEST_F(SyncManagerTest, SetBookmarkTitle) {
2273 std::string client_tag = "title"; 2333 std::string client_tag = "title";
2274 sync_pb::EntitySpecifics entity_specifics; 2334 sync_pb::EntitySpecifics entity_specifics;
2275 entity_specifics.mutable_bookmark()->set_url("url"); 2335 entity_specifics.mutable_bookmark()->set_url("url");
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2311 entity_specifics.mutable_bookmark()->set_url("url"); 2371 entity_specifics.mutable_bookmark()->set_url("url");
2312 entity_specifics.mutable_bookmark()->set_title("title"); 2372 entity_specifics.mutable_bookmark()->set_title("title");
2313 MakeServerNode(sync_manager_.GetUserShare(), BOOKMARKS, client_tag, 2373 MakeServerNode(sync_manager_.GetUserShare(), BOOKMARKS, client_tag,
2314 BaseNode::GenerateSyncableHash(BOOKMARKS, 2374 BaseNode::GenerateSyncableHash(BOOKMARKS,
2315 client_tag), 2375 client_tag),
2316 entity_specifics); 2376 entity_specifics);
2317 // New node shouldn't start off unsynced. 2377 // New node shouldn't start off unsynced.
2318 EXPECT_FALSE(ResetUnsyncedEntry(BOOKMARKS, client_tag)); 2378 EXPECT_FALSE(ResetUnsyncedEntry(BOOKMARKS, client_tag));
2319 2379
2320 // Encrypt the datatatype, should set is_unsynced. 2380 // Encrypt the datatatype, should set is_unsynced.
2321 EXPECT_CALL(observer_, 2381 EXPECT_CALL(encryption_observer_,
2322 OnEncryptedTypesChanged( 2382 OnEncryptedTypesChanged(
2323 HasModelTypes(ModelTypeSet::All()), true)); 2383 HasModelTypes(ModelTypeSet::All()), true));
2324 EXPECT_CALL(observer_, OnEncryptionComplete()); 2384 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
2325 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, FULL_ENCRYPTION)); 2385 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, FULL_ENCRYPTION));
2326 sync_manager_.RefreshNigori(kTestChromeVersion, base::Bind(&DoNothing)); 2386 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
2387 sync_manager_.GetEncryptionHandler()->ReloadNigori();
2327 PumpLoop(); 2388 PumpLoop();
2328 EXPECT_TRUE(ResetUnsyncedEntry(BOOKMARKS, client_tag)); 2389 EXPECT_TRUE(ResetUnsyncedEntry(BOOKMARKS, client_tag));
2329 2390
2330 // Manually change to the same title. Should not set is_unsynced. 2391 // Manually change to the same title. Should not set is_unsynced.
2331 // NON_UNIQUE_NAME should be kEncryptedString. 2392 // NON_UNIQUE_NAME should be kEncryptedString.
2332 { 2393 {
2333 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 2394 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2334 WriteNode node(&trans); 2395 WriteNode node(&trans);
2335 EXPECT_EQ(BaseNode::INIT_OK, 2396 EXPECT_EQ(BaseNode::INIT_OK,
2336 node.InitByClientTagLookup(BOOKMARKS, client_tag)); 2397 node.InitByClientTagLookup(BOOKMARKS, client_tag));
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2406 MakeServerNode(sync_manager_.GetUserShare(), 2467 MakeServerNode(sync_manager_.GetUserShare(),
2407 PREFERENCES, 2468 PREFERENCES,
2408 client_tag, 2469 client_tag,
2409 BaseNode::GenerateSyncableHash(PREFERENCES, 2470 BaseNode::GenerateSyncableHash(PREFERENCES,
2410 client_tag), 2471 client_tag),
2411 entity_specifics); 2472 entity_specifics);
2412 // New node shouldn't start off unsynced. 2473 // New node shouldn't start off unsynced.
2413 EXPECT_FALSE(ResetUnsyncedEntry(PREFERENCES, client_tag)); 2474 EXPECT_FALSE(ResetUnsyncedEntry(PREFERENCES, client_tag));
2414 2475
2415 // Encrypt the datatatype, should set is_unsynced. 2476 // Encrypt the datatatype, should set is_unsynced.
2416 EXPECT_CALL(observer_, 2477 EXPECT_CALL(encryption_observer_,
2417 OnEncryptedTypesChanged( 2478 OnEncryptedTypesChanged(
2418 HasModelTypes(ModelTypeSet::All()), true)); 2479 HasModelTypes(ModelTypeSet::All()), true));
2419 EXPECT_CALL(observer_, OnEncryptionComplete()); 2480 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
2420 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, FULL_ENCRYPTION)); 2481 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, FULL_ENCRYPTION));
2421 sync_manager_.RefreshNigori(kTestChromeVersion, base::Bind(&DoNothing)); 2482 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
2483 sync_manager_.GetEncryptionHandler()->ReloadNigori();
2422 PumpLoop(); 2484 PumpLoop();
2423 EXPECT_TRUE(ResetUnsyncedEntry(PREFERENCES, client_tag)); 2485 EXPECT_TRUE(ResetUnsyncedEntry(PREFERENCES, client_tag));
2424 2486
2425 // Manually change to the same title. Should not set is_unsynced. 2487 // Manually change to the same title. Should not set is_unsynced.
2426 // NON_UNIQUE_NAME should be kEncryptedString. 2488 // NON_UNIQUE_NAME should be kEncryptedString.
2427 { 2489 {
2428 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 2490 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2429 WriteNode node(&trans); 2491 WriteNode node(&trans);
2430 EXPECT_EQ(BaseNode::INIT_OK, 2492 EXPECT_EQ(BaseNode::INIT_OK,
2431 node.InitByClientTagLookup(PREFERENCES, client_tag)); 2493 node.InitByClientTagLookup(PREFERENCES, client_tag));
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
2783 2845
2784 // Verify only the non-disabled types remain after cleanup. 2846 // Verify only the non-disabled types remain after cleanup.
2785 sync_manager_.PurgeDisabledTypes(enabled_types, new_enabled_types); 2847 sync_manager_.PurgeDisabledTypes(enabled_types, new_enabled_types);
2786 EXPECT_TRUE(new_enabled_types.Equals( 2848 EXPECT_TRUE(new_enabled_types.Equals(
2787 Union(sync_manager_.InitialSyncEndedTypes(), partial_enabled_types))); 2849 Union(sync_manager_.InitialSyncEndedTypes(), partial_enabled_types)));
2788 EXPECT_TRUE(disabled_types.Equals( 2850 EXPECT_TRUE(disabled_types.Equals(
2789 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()))); 2851 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All())));
2790 } 2852 }
2791 2853
2792 } // namespace 2854 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698