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

Side by Side Diff: sync/engine/apply_control_data_updates_unittest.cc

Issue 10916036: [Sync] Implement keystore migration support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 3 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
« no previous file with comments | « sync/engine/apply_control_data_updates.cc ('k') | sync/engine/syncer_unittest.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 (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/format_macros.h" 5 #include "base/format_macros.h"
6 #include "base/location.h" 6 #include "base/location.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "sync/engine/apply_control_data_updates.h" 9 #include "sync/engine/apply_control_data_updates.h"
10 #include "sync/engine/syncer.h" 10 #include "sync/engine/syncer.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 .Equals(encrypted_types)); 75 .Equals(encrypted_types));
76 } 76 }
77 77
78 // Nigori node updates should update the Cryptographer. 78 // Nigori node updates should update the Cryptographer.
79 Cryptographer other_cryptographer(cryptographer->encryptor()); 79 Cryptographer other_cryptographer(cryptographer->encryptor());
80 KeyParams params = {"localhost", "dummy", "foobar"}; 80 KeyParams params = {"localhost", "dummy", "foobar"};
81 other_cryptographer.AddKey(params); 81 other_cryptographer.AddKey(params);
82 82
83 sync_pb::EntitySpecifics specifics; 83 sync_pb::EntitySpecifics specifics;
84 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); 84 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori();
85 other_cryptographer.GetKeys(nigori->mutable_encrypted()); 85 other_cryptographer.GetKeys(nigori->mutable_encryption_keybag());
86 nigori->set_encrypt_everything(true); 86 nigori->set_encrypt_everything(true);
87 entry_factory_->CreateUnappliedNewItem( 87 entry_factory_->CreateUnappliedNewItem(
88 ModelTypeToRootTag(NIGORI), specifics, true); 88 ModelTypeToRootTag(NIGORI), specifics, true);
89 EXPECT_FALSE(cryptographer->has_pending_keys()); 89 EXPECT_FALSE(cryptographer->has_pending_keys());
90 90
91 ApplyControlDataUpdates(directory()); 91 ApplyControlDataUpdates(directory());
92 92
93 EXPECT_FALSE(cryptographer->is_ready()); 93 EXPECT_FALSE(cryptographer->is_ready());
94 EXPECT_TRUE(cryptographer->has_pending_keys()); 94 EXPECT_TRUE(cryptographer->has_pending_keys());
95 { 95 {
(...skipping 23 matching lines...) Expand all
119 .Equals(encrypted_types)); 119 .Equals(encrypted_types));
120 } 120 }
121 121
122 // Nigori node updates should update the Cryptographer. 122 // Nigori node updates should update the Cryptographer.
123 Cryptographer other_cryptographer(cryptographer->encryptor()); 123 Cryptographer other_cryptographer(cryptographer->encryptor());
124 KeyParams params = {"localhost", "dummy", "foobar"}; 124 KeyParams params = {"localhost", "dummy", "foobar"};
125 other_cryptographer.AddKey(params); 125 other_cryptographer.AddKey(params);
126 126
127 sync_pb::EntitySpecifics specifics; 127 sync_pb::EntitySpecifics specifics;
128 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); 128 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori();
129 other_cryptographer.GetKeys(nigori->mutable_encrypted()); 129 other_cryptographer.GetKeys(nigori->mutable_encryption_keybag());
130 nigori->set_encrypt_everything(true); 130 nigori->set_encrypt_everything(true);
131 entry_factory_->CreateUnappliedNewItem( 131 entry_factory_->CreateUnappliedNewItem(
132 ModelTypeToRootTag(NIGORI), specifics, true); 132 ModelTypeToRootTag(NIGORI), specifics, true);
133 EXPECT_FALSE(cryptographer->has_pending_keys()); 133 EXPECT_FALSE(cryptographer->has_pending_keys());
134 134
135 ApplyControlDataUpdates(directory()); 135 ApplyControlDataUpdates(directory());
136 136
137 EXPECT_FALSE(cryptographer->is_ready()); 137 EXPECT_FALSE(cryptographer->is_ready());
138 EXPECT_TRUE(cryptographer->has_pending_keys()); 138 EXPECT_TRUE(cryptographer->has_pending_keys());
139 { 139 {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 entry_factory_->CreateUnsyncedItem( 187 entry_factory_->CreateUnsyncedItem(
188 id_factory_.NewLocalId(), id_factory_.root(), 188 id_factory_.NewLocalId(), id_factory_.root(),
189 base::StringPrintf("Item %"PRIuS"", i), false, 189 base::StringPrintf("Item %"PRIuS"", i), false,
190 BOOKMARKS, NULL); 190 BOOKMARKS, NULL);
191 } 191 }
192 192
193 KeyParams params = {"localhost", "dummy", "foobar"}; 193 KeyParams params = {"localhost", "dummy", "foobar"};
194 cryptographer->AddKey(params); 194 cryptographer->AddKey(params);
195 sync_pb::EntitySpecifics specifics; 195 sync_pb::EntitySpecifics specifics;
196 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); 196 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori();
197 cryptographer->GetKeys(nigori->mutable_encrypted()); 197 cryptographer->GetKeys(nigori->mutable_encryption_keybag());
198 nigori->set_encrypt_everything(true); 198 nigori->set_encrypt_everything(true);
199 encrypted_types.Put(BOOKMARKS); 199 encrypted_types.Put(BOOKMARKS);
200 entry_factory_->CreateUnappliedNewItem( 200 entry_factory_->CreateUnappliedNewItem(
201 ModelTypeToRootTag(NIGORI), specifics, true); 201 ModelTypeToRootTag(NIGORI), specifics, true);
202 EXPECT_FALSE(cryptographer->has_pending_keys()); 202 EXPECT_FALSE(cryptographer->has_pending_keys());
203 EXPECT_TRUE(cryptographer->is_ready()); 203 EXPECT_TRUE(cryptographer->is_ready());
204 204
205 { 205 {
206 // Ensure we have unsynced nodes that aren't properly encrypted. 206 // Ensure we have unsynced nodes that aren't properly encrypted.
207 syncable::ReadTransaction trans(FROM_HERE, directory()); 207 syncable::ReadTransaction trans(FROM_HERE, directory());
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 BOOKMARKS, NULL); 300 BOOKMARKS, NULL);
301 } 301 }
302 302
303 // We encrypt with new keys, triggering the local cryptographer to be unready 303 // We encrypt with new keys, triggering the local cryptographer to be unready
304 // and unable to decrypt data (once updated). 304 // and unable to decrypt data (once updated).
305 Cryptographer other_cryptographer(cryptographer->encryptor()); 305 Cryptographer other_cryptographer(cryptographer->encryptor());
306 KeyParams params = {"localhost", "dummy", "foobar"}; 306 KeyParams params = {"localhost", "dummy", "foobar"};
307 other_cryptographer.AddKey(params); 307 other_cryptographer.AddKey(params);
308 sync_pb::EntitySpecifics specifics; 308 sync_pb::EntitySpecifics specifics;
309 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); 309 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori();
310 other_cryptographer.GetKeys(nigori->mutable_encrypted()); 310 other_cryptographer.GetKeys(nigori->mutable_encryption_keybag());
311 nigori->set_encrypt_everything(true); 311 nigori->set_encrypt_everything(true);
312 encrypted_types.Put(BOOKMARKS); 312 encrypted_types.Put(BOOKMARKS);
313 entry_factory_->CreateUnappliedNewItem( 313 entry_factory_->CreateUnappliedNewItem(
314 ModelTypeToRootTag(NIGORI), specifics, true); 314 ModelTypeToRootTag(NIGORI), specifics, true);
315 EXPECT_FALSE(cryptographer->has_pending_keys()); 315 EXPECT_FALSE(cryptographer->has_pending_keys());
316 316
317 { 317 {
318 // Ensure we have unsynced nodes that aren't properly encrypted. 318 // Ensure we have unsynced nodes that aren't properly encrypted.
319 syncable::ReadTransaction trans(FROM_HERE, directory()); 319 syncable::ReadTransaction trans(FROM_HERE, directory());
320 EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); 320 EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types));
(...skipping 17 matching lines...) Expand all
338 EXPECT_FALSE(cryptographer->is_ready()); 338 EXPECT_FALSE(cryptographer->is_ready());
339 EXPECT_TRUE(cryptographer->has_pending_keys()); 339 EXPECT_TRUE(cryptographer->has_pending_keys());
340 340
341 Syncer::UnsyncedMetaHandles handles; 341 Syncer::UnsyncedMetaHandles handles;
342 GetUnsyncedEntries(&trans, &handles); 342 GetUnsyncedEntries(&trans, &handles);
343 EXPECT_EQ(2*batch_s+1, handles.size()); 343 EXPECT_EQ(2*batch_s+1, handles.size());
344 } 344 }
345 } 345 }
346 346
347 } // namespace syncer 347 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/apply_control_data_updates.cc ('k') | sync/engine/syncer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698