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

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

Issue 1915983003: [Sync] Fix crash in GCP when adding encrypted entry that already exists. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed HandleDecryptError() Created 4 years, 7 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
« no previous file with comments | « sync/internal_api/public/write_node.h ('k') | sync/internal_api/write_node.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "sync/internal_api/sync_manager_impl.h" 9 #include "sync/internal_api/sync_manager_impl.h"
10 10
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 WriteTransaction trans(FROM_HERE, user_share()); 774 WriteTransaction trans(FROM_HERE, user_share());
775 WriteNode node(&trans); 775 WriteNode node(&trans);
776 EXPECT_EQ(BaseNode::INIT_OK, node.InitByIdLookup(item1)); 776 EXPECT_EQ(BaseNode::INIT_OK, node.InitByIdLookup(item1));
777 node.Tombstone(); 777 node.Tombstone();
778 } 778 }
779 779
780 // Verify that it is gone from the index. 780 // Verify that it is gone from the index.
781 EXPECT_EQ(1, GetTotalNodeCount(user_share(), preferences_root)); 781 EXPECT_EQ(1, GetTotalNodeCount(user_share(), preferences_root));
782 } 782 }
783 783
784 // Tests that InitUniqueByCreation called for existing encrypted entry properly
785 // decrypts specifics and pust them in BaseNode::unencrypted_data_.
786 TEST_F(SyncApiTest, WriteNode_UniqueByCreation_EncryptedExistingEntry) {
787 KeyParams params = {"localhost", "username", "passphrase"};
788 {
789 ReadTransaction trans(FROM_HERE, user_share());
790 trans.GetCryptographer()->AddKey(params);
791 }
792 encryption_handler()->EnableEncryptEverything();
793 WriteTransaction trans(FROM_HERE, user_share());
794 ReadNode root_node(&trans);
795 root_node.InitByRootLookup();
796
797 {
798 WriteNode pref_node(&trans);
799 WriteNode::InitUniqueByCreationResult result =
800 pref_node.InitUniqueByCreation(PREFERENCES, root_node, "bar");
801 ASSERT_EQ(WriteNode::INIT_SUCCESS, result);
802 pref_node.SetTitle("bar");
803 sync_pb::EntitySpecifics entity_specifics;
804 entity_specifics.mutable_preference();
805 pref_node.SetEntitySpecifics(entity_specifics);
806 }
807 {
808 WriteNode pref_node(&trans);
809 WriteNode::InitUniqueByCreationResult result =
810 pref_node.InitUniqueByCreation(PREFERENCES, root_node, "bar");
811 ASSERT_EQ(WriteNode::INIT_SUCCESS, result);
812 // Call GetEntitySpecifics, ensure it doesn't DCHECK.
813 pref_node.GetEntitySpecifics();
814 }
815 }
816
784 namespace { 817 namespace {
785 818
786 class TestHttpPostProviderInterface : public HttpPostProviderInterface { 819 class TestHttpPostProviderInterface : public HttpPostProviderInterface {
787 public: 820 public:
788 ~TestHttpPostProviderInterface() override {} 821 ~TestHttpPostProviderInterface() override {}
789 822
790 void SetExtraRequestHeaders(const char* headers) override {} 823 void SetExtraRequestHeaders(const char* headers) override {}
791 void SetURL(const char* url, int port) override {} 824 void SetURL(const char* url, int port) override {}
792 void SetPostPayload(const char* content_type, 825 void SetPostPayload(const char* content_type,
793 int content_length, 826 int content_length,
(...skipping 2577 matching lines...) Expand 10 before | Expand all | Expand 10 after
3371 // SyncManagerInitInvalidStorageTest::GetFactory will return 3404 // SyncManagerInitInvalidStorageTest::GetFactory will return
3372 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. 3405 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails.
3373 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's 3406 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's
3374 // task is to ensure that SyncManagerImpl reported initialization failure in 3407 // task is to ensure that SyncManagerImpl reported initialization failure in
3375 // OnInitializationComplete callback. 3408 // OnInitializationComplete callback.
3376 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { 3409 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) {
3377 EXPECT_FALSE(initialization_succeeded_); 3410 EXPECT_FALSE(initialization_succeeded_);
3378 } 3411 }
3379 3412
3380 } // namespace syncer 3413 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/public/write_node.h ('k') | sync/internal_api/write_node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698