Index: components/sync/engine_impl/apply_control_data_updates_unittest.cc |
diff --git a/sync/engine/apply_control_data_updates_unittest.cc b/components/sync/engine_impl/apply_control_data_updates_unittest.cc |
similarity index 83% |
rename from sync/engine/apply_control_data_updates_unittest.cc |
rename to components/sync/engine_impl/apply_control_data_updates_unittest.cc |
index 39acb214e55320f74e3596e6fd9ae0c5b3e6e3ed..878d59695914a7b990fe5b4e46c18fb0713f2f39 100644 |
--- a/sync/engine/apply_control_data_updates_unittest.cc |
+++ b/components/sync/engine_impl/apply_control_data_updates_unittest.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "sync/engine/apply_control_data_updates.h" |
+#include "components/sync/engine_impl/apply_control_data_updates.h" |
#include <stddef.h> |
#include <stdint.h> |
@@ -15,21 +15,21 @@ |
#include "base/macros.h" |
#include "base/message_loop/message_loop.h" |
#include "base/strings/stringprintf.h" |
-#include "sync/engine/syncer.h" |
-#include "sync/engine/syncer_util.h" |
-#include "sync/internal_api/public/test/test_entry_factory.h" |
-#include "sync/protocol/nigori_specifics.pb.h" |
-#include "sync/syncable/directory.h" |
-#include "sync/syncable/mutable_entry.h" |
-#include "sync/syncable/nigori_util.h" |
-#include "sync/syncable/syncable_read_transaction.h" |
-#include "sync/syncable/syncable_util.h" |
-#include "sync/syncable/syncable_write_transaction.h" |
-#include "sync/test/engine/fake_model_worker.h" |
-#include "sync/test/engine/test_directory_setter_upper.h" |
-#include "sync/test/engine/test_id_factory.h" |
-#include "sync/test/fake_sync_encryption_handler.h" |
-#include "sync/util/cryptographer.h" |
+#include "components/sync/base/cryptographer.h" |
+#include "components/sync/core/test/test_entry_factory.h" |
+#include "components/sync/engine_impl/syncer.h" |
+#include "components/sync/engine_impl/syncer_util.h" |
+#include "components/sync/protocol/nigori_specifics.pb.h" |
+#include "components/sync/syncable/directory.h" |
+#include "components/sync/syncable/mutable_entry.h" |
+#include "components/sync/syncable/nigori_util.h" |
+#include "components/sync/syncable/syncable_read_transaction.h" |
+#include "components/sync/syncable/syncable_util.h" |
+#include "components/sync/syncable/syncable_write_transaction.h" |
+#include "components/sync/test/engine/fake_model_worker.h" |
+#include "components/sync/test/engine/test_directory_setter_upper.h" |
+#include "components/sync/test/engine/test_id_factory.h" |
+#include "components/sync/test/fake_sync_encryption_handler.h" |
#include "testing/gtest/include/gtest/gtest.h" |
namespace syncer { |
@@ -51,9 +51,7 @@ class ApplyControlDataUpdatesTest : public ::testing::Test { |
void TearDown() override { dir_maker_.TearDown(); } |
- syncable::Directory* directory() { |
- return dir_maker_.directory(); |
- } |
+ syncable::Directory* directory() { return dir_maker_.directory(); } |
TestIdFactory id_factory_; |
std::unique_ptr<TestEntryFactory> entry_factory_; |
@@ -90,8 +88,8 @@ TEST_F(ApplyControlDataUpdatesTest, NigoriUpdate) { |
sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); |
other_cryptographer.GetKeys(nigori->mutable_encryption_keybag()); |
nigori->set_encrypt_everything(true); |
- entry_factory_->CreateUnappliedNewItem( |
- ModelTypeToRootTag(NIGORI), specifics, true); |
+ entry_factory_->CreateUnappliedNewItem(ModelTypeToRootTag(NIGORI), specifics, |
+ true); |
EXPECT_FALSE(cryptographer->has_pending_keys()); |
ApplyControlDataUpdates(directory()); |
@@ -144,11 +142,10 @@ TEST_F(ApplyControlDataUpdatesTest, EncryptUnsyncedChanges) { |
false, BOOKMARKS, NULL); |
} |
// Next five items are children of the root. |
- for (; i < 2*batch_s; ++i) { |
+ for (; i < 2 * batch_s; ++i) { |
entry_factory_->CreateUnsyncedItem( |
id_factory_.NewLocalId(), id_factory_.root(), |
- base::StringPrintf("Item %" PRIuS "", i), false, |
- BOOKMARKS, NULL); |
+ base::StringPrintf("Item %" PRIuS "", i), false, BOOKMARKS, NULL); |
} |
KeyParams params = {"localhost", "dummy", "foobar"}; |
@@ -158,8 +155,8 @@ TEST_F(ApplyControlDataUpdatesTest, EncryptUnsyncedChanges) { |
cryptographer->GetKeys(nigori->mutable_encryption_keybag()); |
nigori->set_encrypt_everything(true); |
encrypted_types.Put(BOOKMARKS); |
- entry_factory_->CreateUnappliedNewItem( |
- ModelTypeToRootTag(NIGORI), specifics, true); |
+ entry_factory_->CreateUnappliedNewItem(ModelTypeToRootTag(NIGORI), specifics, |
+ true); |
EXPECT_FALSE(cryptographer->has_pending_keys()); |
EXPECT_TRUE(cryptographer->is_ready()); |
@@ -170,7 +167,7 @@ TEST_F(ApplyControlDataUpdatesTest, EncryptUnsyncedChanges) { |
Syncer::UnsyncedMetaHandles handles; |
GetUnsyncedEntries(&trans, &handles); |
- EXPECT_EQ(2*batch_s+1, handles.size()); |
+ EXPECT_EQ(2 * batch_s + 1, handles.size()); |
} |
ApplyControlDataUpdates(directory()); |
@@ -188,7 +185,7 @@ TEST_F(ApplyControlDataUpdatesTest, EncryptUnsyncedChanges) { |
Syncer::UnsyncedMetaHandles handles; |
GetUnsyncedEntries(&trans, &handles); |
- EXPECT_EQ(2*batch_s+1, handles.size()); |
+ EXPECT_EQ(2 * batch_s + 1, handles.size()); |
} |
// Simulate another nigori update that doesn't change anything. |
@@ -214,7 +211,7 @@ TEST_F(ApplyControlDataUpdatesTest, EncryptUnsyncedChanges) { |
Syncer::UnsyncedMetaHandles handles; |
GetUnsyncedEntries(&trans, &handles); |
- EXPECT_EQ(2*batch_s+1, handles.size()); |
+ EXPECT_EQ(2 * batch_s + 1, handles.size()); |
} |
} |
@@ -245,9 +242,8 @@ TEST_F(ApplyControlDataUpdatesTest, CannotEncryptUnsyncedChanges) { |
// Create unsynced bookmarks without encryption. |
// First item is a folder |
Id folder_id = id_factory_.NewLocalId(); |
- entry_factory_->CreateUnsyncedItem( |
- folder_id, id_factory_.root(), "folder", true, |
- BOOKMARKS, NULL); |
+ entry_factory_->CreateUnsyncedItem(folder_id, id_factory_.root(), "folder", |
+ true, BOOKMARKS, NULL); |
// Next five items are children of the folder |
size_t i; |
size_t batch_s = 5; |
@@ -257,11 +253,10 @@ TEST_F(ApplyControlDataUpdatesTest, CannotEncryptUnsyncedChanges) { |
false, BOOKMARKS, NULL); |
} |
// Next five items are children of the root. |
- for (; i < 2*batch_s; ++i) { |
+ for (; i < 2 * batch_s; ++i) { |
entry_factory_->CreateUnsyncedItem( |
id_factory_.NewLocalId(), id_factory_.root(), |
- base::StringPrintf("Item %" PRIuS "", i), false, |
- BOOKMARKS, NULL); |
+ base::StringPrintf("Item %" PRIuS "", i), false, BOOKMARKS, NULL); |
} |
// We encrypt with new keys, triggering the local cryptographer to be unready |
@@ -274,8 +269,8 @@ TEST_F(ApplyControlDataUpdatesTest, CannotEncryptUnsyncedChanges) { |
other_cryptographer.GetKeys(nigori->mutable_encryption_keybag()); |
nigori->set_encrypt_everything(true); |
encrypted_types.Put(BOOKMARKS); |
- entry_factory_->CreateUnappliedNewItem( |
- ModelTypeToRootTag(NIGORI), specifics, true); |
+ entry_factory_->CreateUnappliedNewItem(ModelTypeToRootTag(NIGORI), specifics, |
+ true); |
EXPECT_FALSE(cryptographer->has_pending_keys()); |
{ |
@@ -284,7 +279,7 @@ TEST_F(ApplyControlDataUpdatesTest, CannotEncryptUnsyncedChanges) { |
EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); |
Syncer::UnsyncedMetaHandles handles; |
GetUnsyncedEntries(&trans, &handles); |
- EXPECT_EQ(2*batch_s+1, handles.size()); |
+ EXPECT_EQ(2 * batch_s + 1, handles.size()); |
} |
ApplyControlDataUpdates(directory()); |
@@ -304,7 +299,7 @@ TEST_F(ApplyControlDataUpdatesTest, CannotEncryptUnsyncedChanges) { |
Syncer::UnsyncedMetaHandles handles; |
GetUnsyncedEntries(&trans, &handles); |
- EXPECT_EQ(2*batch_s+1, handles.size()); |
+ EXPECT_EQ(2 * batch_s + 1, handles.size()); |
} |
} |
@@ -349,16 +344,14 @@ TEST_F(ApplyControlDataUpdatesTest, |
cryptographer->GetKeys(local_nigori->mutable_encryption_keybag()); |
local_nigori->set_encrypt_everything(false); |
local_nigori->set_keybag_is_frozen(true); |
- ASSERT_TRUE(entry_factory_->SetLocalSpecificsForItem( |
- nigori_handle, local_specifics)); |
+ ASSERT_TRUE( |
+ entry_factory_->SetLocalSpecificsForItem(nigori_handle, local_specifics)); |
// Apply the update locally so that UpdateFromEncryptedTypes knows what state |
// to use. |
{ |
syncable::ReadTransaction trans(FROM_HERE, directory()); |
cryptographer = directory()->GetCryptographer(&trans); |
- directory()->GetNigoriHandler()->ApplyNigoriUpdate( |
- *local_nigori, |
- &trans); |
+ directory()->GetNigoriHandler()->ApplyNigoriUpdate(*local_nigori, &trans); |
} |
EXPECT_TRUE(entry_factory_->GetIsUnsyncedForItem(nigori_handle)); |
@@ -371,12 +364,15 @@ TEST_F(ApplyControlDataUpdatesTest, |
EXPECT_TRUE(cryptographer->is_initialized()); |
EXPECT_TRUE(cryptographer->has_pending_keys()); |
EXPECT_TRUE(other_cryptographer.CanDecryptUsingDefaultKey( |
- entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().encryption_keybag())); |
- EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().keybag_is_frozen()); |
- EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().encrypt_everything()); |
+ entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .encryption_keybag())); |
+ EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .keybag_is_frozen()); |
+ EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .encrypt_everything()); |
{ |
syncable::ReadTransaction trans(FROM_HERE, directory()); |
EXPECT_EQ(ModelTypeSet::All(), |
@@ -425,16 +421,14 @@ TEST_F(ApplyControlDataUpdatesTest, |
cryptographer->GetKeys(local_nigori->mutable_encryption_keybag()); |
local_nigori->set_encrypt_everything(true); |
local_nigori->set_keybag_is_frozen(true); |
- ASSERT_TRUE(entry_factory_->SetLocalSpecificsForItem( |
- nigori_handle, local_specifics)); |
+ ASSERT_TRUE( |
+ entry_factory_->SetLocalSpecificsForItem(nigori_handle, local_specifics)); |
// Apply the update locally so that UpdateFromEncryptedTypes knows what state |
// to use. |
{ |
syncable::ReadTransaction trans(FROM_HERE, directory()); |
cryptographer = directory()->GetCryptographer(&trans); |
- directory()->GetNigoriHandler()->ApplyNigoriUpdate( |
- *local_nigori, |
- &trans); |
+ directory()->GetNigoriHandler()->ApplyNigoriUpdate(*local_nigori, &trans); |
} |
EXPECT_TRUE(entry_factory_->GetIsUnsyncedForItem(nigori_handle)); |
@@ -447,12 +441,15 @@ TEST_F(ApplyControlDataUpdatesTest, |
EXPECT_TRUE(cryptographer->is_initialized()); |
EXPECT_TRUE(cryptographer->has_pending_keys()); |
EXPECT_TRUE(other_cryptographer.CanDecryptUsingDefaultKey( |
- entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().encryption_keybag())); |
- EXPECT_FALSE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().keybag_is_frozen()); |
- EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().encrypt_everything()); |
+ entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .encryption_keybag())); |
+ EXPECT_FALSE(entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .keybag_is_frozen()); |
+ EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .encrypt_everything()); |
{ |
syncable::ReadTransaction trans(FROM_HERE, directory()); |
EXPECT_EQ(ModelTypeSet::All(), |
@@ -463,8 +460,7 @@ TEST_F(ApplyControlDataUpdatesTest, |
// If the conflicting nigori has a subset of the local keys, the conflict |
// resolution should preserve the full local keys. Initial sync ended should be |
// set. |
-TEST_F(ApplyControlDataUpdatesTest, |
- NigoriConflictOldKeys) { |
+TEST_F(ApplyControlDataUpdatesTest, NigoriConflictOldKeys) { |
Cryptographer* cryptographer; |
ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes()); |
KeyParams old_params = {"localhost", "dummy", "old"}; |
@@ -496,16 +492,14 @@ TEST_F(ApplyControlDataUpdatesTest, |
sync_pb::NigoriSpecifics* local_nigori = local_specifics.mutable_nigori(); |
cryptographer->GetKeys(local_nigori->mutable_encryption_keybag()); |
local_nigori->set_encrypt_everything(false); |
- ASSERT_TRUE(entry_factory_->SetLocalSpecificsForItem( |
- nigori_handle, local_specifics)); |
+ ASSERT_TRUE( |
+ entry_factory_->SetLocalSpecificsForItem(nigori_handle, local_specifics)); |
// Apply the update locally so that UpdateFromEncryptedTypes knows what state |
// to use. |
{ |
syncable::ReadTransaction trans(FROM_HERE, directory()); |
cryptographer = directory()->GetCryptographer(&trans); |
- directory()->GetNigoriHandler()->ApplyNigoriUpdate( |
- *local_nigori, |
- &trans); |
+ directory()->GetNigoriHandler()->ApplyNigoriUpdate(*local_nigori, &trans); |
} |
EXPECT_TRUE(entry_factory_->GetIsUnsyncedForItem(nigori_handle)); |
@@ -516,12 +510,15 @@ TEST_F(ApplyControlDataUpdatesTest, |
EXPECT_TRUE(cryptographer->is_ready()); |
EXPECT_TRUE(cryptographer->CanDecryptUsingDefaultKey( |
- entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().encryption_keybag())); |
- EXPECT_FALSE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().keybag_is_frozen()); |
- EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().encrypt_everything()); |
+ entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .encryption_keybag())); |
+ EXPECT_FALSE(entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .keybag_is_frozen()); |
+ EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .encrypt_everything()); |
{ |
syncable::ReadTransaction trans(FROM_HERE, directory()); |
EXPECT_EQ(ModelTypeSet::All(), |
@@ -531,8 +528,7 @@ TEST_F(ApplyControlDataUpdatesTest, |
// If both nigoris are migrated, but we also set a custom passphrase locally, |
// the local nigori should be preserved. |
-TEST_F(ApplyControlDataUpdatesTest, |
- NigoriConflictBothMigratedLocalCustom) { |
+TEST_F(ApplyControlDataUpdatesTest, NigoriConflictBothMigratedLocalCustom) { |
Cryptographer* cryptographer; |
ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes()); |
KeyParams old_params = {"localhost", "dummy", "old"}; |
@@ -573,16 +569,14 @@ TEST_F(ApplyControlDataUpdatesTest, |
local_nigori->set_keybag_is_frozen(true); |
local_nigori->set_passphrase_type( |
sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE); |
- ASSERT_TRUE(entry_factory_->SetLocalSpecificsForItem( |
- nigori_handle, local_specifics)); |
+ ASSERT_TRUE( |
+ entry_factory_->SetLocalSpecificsForItem(nigori_handle, local_specifics)); |
// Apply the update locally so that UpdateFromEncryptedTypes knows what state |
// to use. |
{ |
syncable::ReadTransaction trans(FROM_HERE, directory()); |
cryptographer = directory()->GetCryptographer(&trans); |
- directory()->GetNigoriHandler()->ApplyNigoriUpdate( |
- *local_nigori, |
- &trans); |
+ directory()->GetNigoriHandler()->ApplyNigoriUpdate(*local_nigori, &trans); |
} |
EXPECT_TRUE(entry_factory_->GetIsUnsyncedForItem(nigori_handle)); |
@@ -593,15 +587,19 @@ TEST_F(ApplyControlDataUpdatesTest, |
EXPECT_TRUE(cryptographer->is_ready()); |
EXPECT_TRUE(cryptographer->CanDecryptUsingDefaultKey( |
- entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().encryption_keybag())); |
- EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().keybag_is_frozen()); |
- EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().encrypt_everything()); |
+ entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .encryption_keybag())); |
+ EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .keybag_is_frozen()); |
+ EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .encrypt_everything()); |
EXPECT_EQ(sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE, |
- entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().passphrase_type()); |
+ entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .passphrase_type()); |
{ |
syncable::ReadTransaction trans(FROM_HERE, directory()); |
EXPECT_EQ(ModelTypeSet::All(), |
@@ -611,8 +609,7 @@ TEST_F(ApplyControlDataUpdatesTest, |
// If both nigoris are migrated, but a custom passphrase with a new key was |
// set remotely, the remote nigori should be preserved. |
-TEST_F(ApplyControlDataUpdatesTest, |
- NigoriConflictBothMigratedServerCustom) { |
+TEST_F(ApplyControlDataUpdatesTest, NigoriConflictBothMigratedServerCustom) { |
Cryptographer* cryptographer; |
ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes()); |
KeyParams old_params = {"localhost", "dummy", "old"}; |
@@ -653,16 +650,14 @@ TEST_F(ApplyControlDataUpdatesTest, |
local_nigori->set_passphrase_type( |
sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE); |
server_nigori->mutable_keystore_decryptor_token(); |
- ASSERT_TRUE(entry_factory_->SetLocalSpecificsForItem( |
- nigori_handle, local_specifics)); |
+ ASSERT_TRUE( |
+ entry_factory_->SetLocalSpecificsForItem(nigori_handle, local_specifics)); |
// Apply the update locally so that UpdateFromEncryptedTypes knows what state |
// to use. |
{ |
syncable::ReadTransaction trans(FROM_HERE, directory()); |
cryptographer = directory()->GetCryptographer(&trans); |
- directory()->GetNigoriHandler()->ApplyNigoriUpdate( |
- *local_nigori, |
- &trans); |
+ directory()->GetNigoriHandler()->ApplyNigoriUpdate(*local_nigori, &trans); |
} |
EXPECT_TRUE(entry_factory_->GetIsUnsyncedForItem(nigori_handle)); |
@@ -674,15 +669,19 @@ TEST_F(ApplyControlDataUpdatesTest, |
EXPECT_TRUE(cryptographer->is_initialized()); |
EXPECT_TRUE(cryptographer->has_pending_keys()); |
EXPECT_TRUE(other_cryptographer.CanDecryptUsingDefaultKey( |
- entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().encryption_keybag())); |
- EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().keybag_is_frozen()); |
- EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().encrypt_everything()); |
+ entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .encryption_keybag())); |
+ EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .keybag_is_frozen()); |
+ EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .encrypt_everything()); |
EXPECT_EQ(sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE, |
- entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().passphrase_type()); |
+ entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .passphrase_type()); |
{ |
syncable::ReadTransaction trans(FROM_HERE, directory()); |
EXPECT_EQ(ModelTypeSet::All(), |
@@ -692,8 +691,7 @@ TEST_F(ApplyControlDataUpdatesTest, |
// If the local nigori is migrated but the server is not, preserve the local |
// nigori. |
-TEST_F(ApplyControlDataUpdatesTest, |
- NigoriConflictLocalMigrated) { |
+TEST_F(ApplyControlDataUpdatesTest, NigoriConflictLocalMigrated) { |
Cryptographer* cryptographer; |
ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes()); |
KeyParams old_params = {"localhost", "dummy", "old"}; |
@@ -731,16 +729,14 @@ TEST_F(ApplyControlDataUpdatesTest, |
local_nigori->set_keybag_is_frozen(true); |
local_nigori->set_passphrase_type( |
sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE); |
- ASSERT_TRUE(entry_factory_->SetLocalSpecificsForItem( |
- nigori_handle, local_specifics)); |
+ ASSERT_TRUE( |
+ entry_factory_->SetLocalSpecificsForItem(nigori_handle, local_specifics)); |
// Apply the update locally so that UpdateFromEncryptedTypes knows what state |
// to use. |
{ |
syncable::ReadTransaction trans(FROM_HERE, directory()); |
cryptographer = directory()->GetCryptographer(&trans); |
- directory()->GetNigoriHandler()->ApplyNigoriUpdate( |
- *local_nigori, |
- &trans); |
+ directory()->GetNigoriHandler()->ApplyNigoriUpdate(*local_nigori, &trans); |
} |
EXPECT_TRUE(entry_factory_->GetIsUnsyncedForItem(nigori_handle)); |
@@ -751,15 +747,19 @@ TEST_F(ApplyControlDataUpdatesTest, |
EXPECT_TRUE(cryptographer->is_ready()); |
EXPECT_TRUE(cryptographer->CanDecryptUsingDefaultKey( |
- entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().encryption_keybag())); |
- EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().keybag_is_frozen()); |
- EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().encrypt_everything()); |
+ entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .encryption_keybag())); |
+ EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .keybag_is_frozen()); |
+ EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .encrypt_everything()); |
EXPECT_EQ(sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE, |
- entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().passphrase_type()); |
+ entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .passphrase_type()); |
{ |
syncable::ReadTransaction trans(FROM_HERE, directory()); |
EXPECT_EQ(ModelTypeSet::All(), |
@@ -769,8 +769,7 @@ TEST_F(ApplyControlDataUpdatesTest, |
// If the server nigori is migrated but the local is not, preserve the server |
// nigori. |
-TEST_F(ApplyControlDataUpdatesTest, |
- NigoriConflictServerMigrated) { |
+TEST_F(ApplyControlDataUpdatesTest, NigoriConflictServerMigrated) { |
Cryptographer* cryptographer; |
ModelTypeSet encrypted_types(SyncEncryptionHandler::SensitiveTypes()); |
KeyParams old_params = {"localhost", "dummy", "old"}; |
@@ -809,16 +808,14 @@ TEST_F(ApplyControlDataUpdatesTest, |
cryptographer->GetKeys(local_nigori->mutable_encryption_keybag()); |
local_nigori->set_encrypt_everything(false); |
local_nigori->set_keybag_is_frozen(false); |
- ASSERT_TRUE(entry_factory_->SetLocalSpecificsForItem( |
- nigori_handle, local_specifics)); |
+ ASSERT_TRUE( |
+ entry_factory_->SetLocalSpecificsForItem(nigori_handle, local_specifics)); |
// Apply the update locally so that UpdateFromEncryptedTypes knows what state |
// to use. |
{ |
syncable::ReadTransaction trans(FROM_HERE, directory()); |
cryptographer = directory()->GetCryptographer(&trans); |
- directory()->GetNigoriHandler()->ApplyNigoriUpdate( |
- *local_nigori, |
- &trans); |
+ directory()->GetNigoriHandler()->ApplyNigoriUpdate(*local_nigori, &trans); |
} |
EXPECT_TRUE(entry_factory_->GetIsUnsyncedForItem(nigori_handle)); |
@@ -832,37 +829,41 @@ TEST_F(ApplyControlDataUpdatesTest, |
// sync encryption handler will do that when it detects that the new |
// keybag is out of date (and update the keystore bootstrap if necessary). |
EXPECT_FALSE(cryptographer->CanDecryptUsingDefaultKey( |
- entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().encryption_keybag())); |
+ entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .encryption_keybag())); |
EXPECT_TRUE(cryptographer->CanDecrypt( |
- entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().encryption_keybag())); |
- EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().keybag_is_frozen()); |
- EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().has_keystore_decryptor_token()); |
+ entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .encryption_keybag())); |
+ EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .keybag_is_frozen()); |
+ EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .has_keystore_decryptor_token()); |
EXPECT_EQ(sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE, |
- entry_factory_->GetLocalSpecificsForItem(nigori_handle). |
- nigori().passphrase_type()); |
- { |
- syncable::ReadTransaction trans(FROM_HERE, directory()); |
- } |
+ entry_factory_->GetLocalSpecificsForItem(nigori_handle) |
+ .nigori() |
+ .passphrase_type()); |
+ { syncable::ReadTransaction trans(FROM_HERE, directory()); } |
} |
// Check that we can apply a simple control datatype node successfully. |
TEST_F(ApplyControlDataUpdatesTest, ControlApply) { |
std::string experiment_id = "experiment"; |
sync_pb::EntitySpecifics specifics; |
- specifics.mutable_experiments()->mutable_keystore_encryption()-> |
- set_enabled(true); |
+ specifics.mutable_experiments()->mutable_keystore_encryption()->set_enabled( |
+ true); |
int64_t experiment_handle = |
entry_factory_->CreateUnappliedNewItem(experiment_id, specifics, false); |
ApplyControlDataUpdates(directory()); |
EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(experiment_handle)); |
- EXPECT_TRUE( |
- entry_factory_->GetLocalSpecificsForItem(experiment_handle). |
- experiments().keystore_encryption().enabled()); |
+ EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(experiment_handle) |
+ .experiments() |
+ .keystore_encryption() |
+ .enabled()); |
} |
// Verify that we apply top level folders before their children. |
@@ -870,8 +871,8 @@ TEST_F(ApplyControlDataUpdatesTest, ControlApplyParentBeforeChild) { |
std::string parent_id = "parent"; |
std::string experiment_id = "experiment"; |
sync_pb::EntitySpecifics specifics; |
- specifics.mutable_experiments()->mutable_keystore_encryption()-> |
- set_enabled(true); |
+ specifics.mutable_experiments()->mutable_keystore_encryption()->set_enabled( |
+ true); |
int64_t experiment_handle = entry_factory_->CreateUnappliedNewItemWithParent( |
experiment_id, specifics, parent_id); |
int64_t parent_handle = |
@@ -880,9 +881,10 @@ TEST_F(ApplyControlDataUpdatesTest, ControlApplyParentBeforeChild) { |
EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(parent_handle)); |
EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(experiment_handle)); |
- EXPECT_TRUE( |
- entry_factory_->GetLocalSpecificsForItem(experiment_handle). |
- experiments().keystore_encryption().enabled()); |
+ EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(experiment_handle) |
+ .experiments() |
+ .keystore_encryption() |
+ .enabled()); |
} |
// Verify that we handle control datatype conflicts by preserving the server |
@@ -890,22 +892,24 @@ TEST_F(ApplyControlDataUpdatesTest, ControlApplyParentBeforeChild) { |
TEST_F(ApplyControlDataUpdatesTest, ControlConflict) { |
std::string experiment_id = "experiment"; |
sync_pb::EntitySpecifics local_specifics, server_specifics; |
- server_specifics.mutable_experiments()->mutable_keystore_encryption()-> |
- set_enabled(true); |
- local_specifics.mutable_experiments()->mutable_keystore_encryption()-> |
- set_enabled(false); |
+ server_specifics.mutable_experiments() |
+ ->mutable_keystore_encryption() |
+ ->set_enabled(true); |
+ local_specifics.mutable_experiments() |
+ ->mutable_keystore_encryption() |
+ ->set_enabled(false); |
int64_t experiment_handle = |
entry_factory_->CreateSyncedItem(experiment_id, EXPERIMENTS, false); |
entry_factory_->SetServerSpecificsForItem(experiment_handle, |
server_specifics); |
- entry_factory_->SetLocalSpecificsForItem(experiment_handle, |
- local_specifics); |
+ entry_factory_->SetLocalSpecificsForItem(experiment_handle, local_specifics); |
ApplyControlDataUpdates(directory()); |
EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(experiment_handle)); |
- EXPECT_TRUE( |
- entry_factory_->GetLocalSpecificsForItem(experiment_handle). |
- experiments().keystore_encryption().enabled()); |
+ EXPECT_TRUE(entry_factory_->GetLocalSpecificsForItem(experiment_handle) |
+ .experiments() |
+ .keystore_encryption() |
+ .enabled()); |
} |
// Check that applying a EXPERIMENTS update marks the datatype as downloaded. |