| Index: sync/engine/syncer_unittest.cc
|
| diff --git a/sync/engine/syncer_unittest.cc b/sync/engine/syncer_unittest.cc
|
| index c4686230e6150e367bcbb1f20879f6aaa6535952..e7c014e394cfef047253fdc43047d1a55d97b2ff 100644
|
| --- a/sync/engine/syncer_unittest.cc
|
| +++ b/sync/engine/syncer_unittest.cc
|
| @@ -188,7 +188,16 @@ class SyncerTest : public testing::Test,
|
| SyncScheduler::SyncSessionJob::SyncSessionJobPurpose purpose) {
|
| SyncerStep start;
|
| SyncerStep end;
|
| - SyncScheduler::SetSyncerStepsForPurpose(purpose, &start, &end);
|
| + ConfigurationParams config_params;
|
| + if (purpose == SyncScheduler::SyncSessionJob::CONFIGURATION) {
|
| + config_params.keystore_key_status =
|
| + ConfigurationParams::KEYSTORE_KEY_NEEDED;
|
| + config_params.types_to_download = ModelTypeSet(BOOKMARKS);
|
| + }
|
| + SyncScheduler::SetSyncerStepsForPurpose(purpose,
|
| + config_params,
|
| + &start,
|
| + &end);
|
|
|
| session_.reset(MakeSession());
|
| syncer_->SyncShare(session_.get(), start, end);
|
| @@ -237,7 +246,8 @@ class SyncerTest : public testing::Test,
|
| new SyncSessionContext(
|
| mock_server_.get(), directory(), routing_info, workers,
|
| &extensions_activity_monitor_, throttled_data_type_tracker_.get(),
|
| - listeners, NULL, &traffic_recorder_));
|
| + listeners, NULL, &traffic_recorder_,
|
| + true /* enable keystore encryption */));
|
| ASSERT_FALSE(context_->resolver());
|
| syncer_ = new Syncer();
|
| session_.reset(MakeSession());
|
| @@ -250,6 +260,8 @@ class SyncerTest : public testing::Test,
|
| root_id_ = TestIdFactory::root();
|
| parent_id_ = ids_.MakeServer("parent id");
|
| child_id_ = ids_.MakeServer("child id");
|
| + directory()->set_store_birthday(mock_server_->store_birthday());
|
| + mock_server_->SetKeystoreKey("encryption_key");
|
| }
|
|
|
| virtual void TearDown() {
|
| @@ -2306,7 +2318,6 @@ class EntryCreatedInNewFolderTest : public SyncerTest {
|
| };
|
|
|
| TEST_F(EntryCreatedInNewFolderTest, EntryCreatedInNewFolderMidSync) {
|
| - directory()->set_store_birthday(mock_server_->store_birthday());
|
| {
|
| WriteTransaction trans(FROM_HERE, UNITTEST, directory());
|
| MutableEntry entry(&trans, syncable::CREATE, trans.root_id(),
|
| @@ -4137,7 +4148,7 @@ TEST_F(SyncerTest, ConfigureFailsDontApplyUpdates) {
|
| // normal confgure step would download all the updates one batch at a time and
|
| // apply them. This configure will succeed in downloading the first batch
|
| // then fail when downloading the second.
|
| - mock_server_->FailNthPostBufferToPathCall(2);
|
| + mock_server_->FailNthPostBufferToPathCall(3);
|
|
|
| // Construct the first GetUpdates response.
|
| mock_server_->AddUpdateDirectory(node1, ids_.root(), "one", 1, 10);
|
| @@ -4166,6 +4177,53 @@ TEST_F(SyncerTest, ConfigureFailsDontApplyUpdates) {
|
| EXPECT_FALSE(initial_sync_ended_for_type(syncer::BOOKMARKS));
|
| }
|
|
|
| +TEST_F(SyncerTest, GetKeySuccess) {
|
| + {
|
| + syncable::ReadTransaction rtrans(FROM_HERE, directory());
|
| + EXPECT_FALSE(cryptographer(&rtrans)->HasKeystoreKey());
|
| + }
|
| +
|
| + SyncShareConfigure();
|
| +
|
| + EXPECT_EQ(session_->status_controller().last_get_key_result(), SYNCER_OK);
|
| + {
|
| + syncable::ReadTransaction rtrans(FROM_HERE, directory());
|
| + EXPECT_TRUE(cryptographer(&rtrans)->HasKeystoreKey());
|
| + }
|
| +}
|
| +
|
| +TEST_F(SyncerTest, GetKeyError) {
|
| + {
|
| + syncable::ReadTransaction rtrans(FROM_HERE, directory());
|
| + EXPECT_FALSE(cryptographer(&rtrans)->HasKeystoreKey());
|
| + }
|
| +
|
| + mock_server_->SetGetKeyResponseStatus(sync_pb::SyncEnums::TRANSIENT_ERROR);
|
| + SyncShareConfigure();
|
| +
|
| + EXPECT_NE(session_->status_controller().last_get_key_result(), SYNCER_OK);
|
| + {
|
| + syncable::ReadTransaction rtrans(FROM_HERE, directory());
|
| + EXPECT_FALSE(cryptographer(&rtrans)->HasKeystoreKey());
|
| + }
|
| +}
|
| +
|
| +TEST_F(SyncerTest, GetKeyEmpty) {
|
| + {
|
| + syncable::ReadTransaction rtrans(FROM_HERE, directory());
|
| + EXPECT_FALSE(cryptographer(&rtrans)->HasKeystoreKey());
|
| + }
|
| +
|
| + mock_server_->SetKeystoreKey("");
|
| + SyncShareConfigure();
|
| +
|
| + EXPECT_NE(session_->status_controller().last_get_key_result(), SYNCER_OK);
|
| + {
|
| + syncable::ReadTransaction rtrans(FROM_HERE, directory());
|
| + EXPECT_FALSE(cryptographer(&rtrans)->HasKeystoreKey());
|
| + }
|
| +}
|
| +
|
| // Test what happens if a client deletes, then recreates, an object very
|
| // quickly. It is possible that the deletion gets sent as a commit, and
|
| // the undelete happens during the commit request. The principle here
|
|
|