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

Unified 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, 8 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/internal_api/sync_manager_impl_unittest.cc
diff --git a/sync/internal_api/sync_manager_impl_unittest.cc b/sync/internal_api/sync_manager_impl_unittest.cc
index aace4a9e5ee9dfc8cb7541c6040f186ceef7b22c..41c9e254154523142dc4947fa3a68fa164b544d9 100644
--- a/sync/internal_api/sync_manager_impl_unittest.cc
+++ b/sync/internal_api/sync_manager_impl_unittest.cc
@@ -781,6 +781,39 @@ TEST_F(SyncApiTest, WriteNode_UniqueByCreation_UndeleteCase) {
EXPECT_EQ(1, GetTotalNodeCount(user_share(), preferences_root));
}
+// Tests that InitUniqueByCreation called for existing encrypted entry properly
+// decrypts specifics and pust them in BaseNode::unencrypted_data_.
+TEST_F(SyncApiTest, WriteNode_UniqueByCreation_EncryptedExistingEntry) {
+ KeyParams params = {"localhost", "username", "passphrase"};
+ {
+ ReadTransaction trans(FROM_HERE, user_share());
+ trans.GetCryptographer()->AddKey(params);
+ }
+ encryption_handler()->EnableEncryptEverything();
+ WriteTransaction trans(FROM_HERE, user_share());
+ ReadNode root_node(&trans);
+ root_node.InitByRootLookup();
+
+ {
+ WriteNode pref_node(&trans);
+ WriteNode::InitUniqueByCreationResult result =
+ pref_node.InitUniqueByCreation(PREFERENCES, root_node, "bar");
+ ASSERT_EQ(WriteNode::INIT_SUCCESS, result);
+ pref_node.SetTitle("bar");
+ sync_pb::EntitySpecifics entity_specifics;
+ entity_specifics.mutable_preference();
+ pref_node.SetEntitySpecifics(entity_specifics);
+ }
+ {
+ WriteNode pref_node(&trans);
+ WriteNode::InitUniqueByCreationResult result =
+ pref_node.InitUniqueByCreation(PREFERENCES, root_node, "bar");
+ ASSERT_EQ(WriteNode::INIT_SUCCESS, result);
+ // Call GetEntitySpecifics, ensure it doesn't DCHECK.
+ pref_node.GetEntitySpecifics();
+ }
+}
+
namespace {
class TestHttpPostProviderInterface : public HttpPostProviderInterface {
« 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