OLD | NEW |
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 EXPECT_TRUE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); | 119 EXPECT_TRUE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); |
120 | 120 |
121 Syncer::UnsyncedMetaHandles handles; | 121 Syncer::UnsyncedMetaHandles handles; |
122 GetUnsyncedEntries(&trans, &handles); | 122 GetUnsyncedEntries(&trans, &handles); |
123 EXPECT_TRUE(handles.empty()); | 123 EXPECT_TRUE(handles.empty()); |
124 } | 124 } |
125 | 125 |
126 // Create unsynced bookmarks without encryption. | 126 // Create unsynced bookmarks without encryption. |
127 // First item is a folder | 127 // First item is a folder |
128 Id folder_id = id_factory_.NewLocalId(); | 128 Id folder_id = id_factory_.NewLocalId(); |
129 entry_factory_->CreateUnsyncedItem(folder_id, id_factory_.root(), "folder", | 129 entry_factory_->CreateUnsyncedBookmarkItem(folder_id, id_factory_.root(), |
130 true, BOOKMARKS, NULL); | 130 "folder", true, NULL); |
131 // Next five items are children of the folder | 131 // Next five items are children of the folder |
132 size_t i; | 132 size_t i; |
133 size_t batch_s = 5; | 133 size_t batch_s = 5; |
134 for (i = 0; i < batch_s; ++i) { | 134 for (i = 0; i < batch_s; ++i) { |
135 entry_factory_->CreateUnsyncedItem(id_factory_.NewLocalId(), folder_id, | 135 entry_factory_->CreateUnsyncedBookmarkItem( |
136 base::StringPrintf("Item %"PRIuS"", i), | 136 id_factory_.NewLocalId(), folder_id, |
137 false, BOOKMARKS, NULL); | 137 base::StringPrintf("Item %"PRIuS"", i), false, NULL); |
138 } | 138 } |
139 // Next five items are children of the root. | 139 // Next five items are children of the root. |
140 for (; i < 2*batch_s; ++i) { | 140 for (; i < 2*batch_s; ++i) { |
141 entry_factory_->CreateUnsyncedItem( | 141 entry_factory_->CreateUnsyncedBookmarkItem( |
142 id_factory_.NewLocalId(), id_factory_.root(), | 142 id_factory_.NewLocalId(), id_factory_.root(), |
143 base::StringPrintf("Item %"PRIuS"", i), false, | 143 base::StringPrintf("Item %"PRIuS"", i), false, NULL); |
144 BOOKMARKS, NULL); | |
145 } | 144 } |
146 | 145 |
147 KeyParams params = {"localhost", "dummy", "foobar"}; | 146 KeyParams params = {"localhost", "dummy", "foobar"}; |
148 cryptographer->AddKey(params); | 147 cryptographer->AddKey(params); |
149 sync_pb::EntitySpecifics specifics; | 148 sync_pb::EntitySpecifics specifics; |
150 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); | 149 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); |
151 cryptographer->GetKeys(nigori->mutable_encryption_keybag()); | 150 cryptographer->GetKeys(nigori->mutable_encryption_keybag()); |
152 nigori->set_encrypt_everything(true); | 151 nigori->set_encrypt_everything(true); |
153 encrypted_types.Put(BOOKMARKS); | 152 encrypted_types.Put(BOOKMARKS); |
154 entry_factory_->CreateUnappliedNewItem( | 153 entry_factory_->CreateUnappliedNewItem( |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 EXPECT_TRUE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); | 231 EXPECT_TRUE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); |
233 | 232 |
234 Syncer::UnsyncedMetaHandles handles; | 233 Syncer::UnsyncedMetaHandles handles; |
235 GetUnsyncedEntries(&trans, &handles); | 234 GetUnsyncedEntries(&trans, &handles); |
236 EXPECT_TRUE(handles.empty()); | 235 EXPECT_TRUE(handles.empty()); |
237 } | 236 } |
238 | 237 |
239 // Create unsynced bookmarks without encryption. | 238 // Create unsynced bookmarks without encryption. |
240 // First item is a folder | 239 // First item is a folder |
241 Id folder_id = id_factory_.NewLocalId(); | 240 Id folder_id = id_factory_.NewLocalId(); |
242 entry_factory_->CreateUnsyncedItem( | 241 entry_factory_->CreateUnsyncedBookmarkItem( |
243 folder_id, id_factory_.root(), "folder", true, | 242 folder_id, id_factory_.root(), "folder", true, NULL); |
244 BOOKMARKS, NULL); | |
245 // Next five items are children of the folder | 243 // Next five items are children of the folder |
246 size_t i; | 244 size_t i; |
247 size_t batch_s = 5; | 245 size_t batch_s = 5; |
248 for (i = 0; i < batch_s; ++i) { | 246 for (i = 0; i < batch_s; ++i) { |
249 entry_factory_->CreateUnsyncedItem(id_factory_.NewLocalId(), folder_id, | 247 entry_factory_->CreateUnsyncedBookmarkItem( |
250 base::StringPrintf("Item %"PRIuS"", i), | 248 id_factory_.NewLocalId(), folder_id, |
251 false, BOOKMARKS, NULL); | 249 base::StringPrintf("Item %"PRIuS"", i), false, NULL); |
252 } | 250 } |
253 // Next five items are children of the root. | 251 // Next five items are children of the root. |
254 for (; i < 2*batch_s; ++i) { | 252 for (; i < 2*batch_s; ++i) { |
255 entry_factory_->CreateUnsyncedItem( | 253 entry_factory_->CreateUnsyncedBookmarkItem( |
256 id_factory_.NewLocalId(), id_factory_.root(), | 254 id_factory_.NewLocalId(), id_factory_.root(), |
257 base::StringPrintf("Item %"PRIuS"", i), false, | 255 base::StringPrintf("Item %"PRIuS"", i), false, NULL); |
258 BOOKMARKS, NULL); | |
259 } | 256 } |
260 | 257 |
261 // We encrypt with new keys, triggering the local cryptographer to be unready | 258 // We encrypt with new keys, triggering the local cryptographer to be unready |
262 // and unable to decrypt data (once updated). | 259 // and unable to decrypt data (once updated). |
263 Cryptographer other_cryptographer(cryptographer->encryptor()); | 260 Cryptographer other_cryptographer(cryptographer->encryptor()); |
264 KeyParams params = {"localhost", "dummy", "foobar"}; | 261 KeyParams params = {"localhost", "dummy", "foobar"}; |
265 other_cryptographer.AddKey(params); | 262 other_cryptographer.AddKey(params); |
266 sync_pb::EntitySpecifics specifics; | 263 sync_pb::EntitySpecifics specifics; |
267 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); | 264 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); |
268 other_cryptographer.GetKeys(nigori->mutable_encryption_keybag()); | 265 other_cryptographer.GetKeys(nigori->mutable_encryption_keybag()); |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 local_specifics); | 907 local_specifics); |
911 ApplyControlDataUpdates(session()); | 908 ApplyControlDataUpdates(session()); |
912 | 909 |
913 EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(experiment_handle)); | 910 EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(experiment_handle)); |
914 EXPECT_TRUE( | 911 EXPECT_TRUE( |
915 entry_factory_->GetLocalSpecificsForItem(experiment_handle). | 912 entry_factory_->GetLocalSpecificsForItem(experiment_handle). |
916 experiments().keystore_encryption().enabled()); | 913 experiments().keystore_encryption().enabled()); |
917 } | 914 } |
918 | 915 |
919 } // namespace syncer | 916 } // namespace syncer |
OLD | NEW |