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

Unified Diff: sync/engine/syncer_unittest.cc

Issue 10455012: [Sync] Add support for performing a GetKey on startup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move GetEncryptionKey logic into GetUpdates Created 8 years, 5 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
Index: sync/engine/syncer_unittest.cc
diff --git a/sync/engine/syncer_unittest.cc b/sync/engine/syncer_unittest.cc
index c4686230e6150e367bcbb1f20879f6aaa6535952..acdbfd2449bb86a21090d9fae80495881b6f7e59 100644
--- a/sync/engine/syncer_unittest.cc
+++ b/sync/engine/syncer_unittest.cc
@@ -188,7 +188,9 @@ class SyncerTest : public testing::Test,
SyncScheduler::SyncSessionJob::SyncSessionJobPurpose purpose) {
SyncerStep start;
SyncerStep end;
- SyncScheduler::SetSyncerStepsForPurpose(purpose, &start, &end);
+ SyncScheduler::SetSyncerStepsForPurpose(purpose,
+ &start,
+ &end);
session_.reset(MakeSession());
syncer_->SyncShare(session_.get(), start, end);
@@ -237,7 +239,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 +253,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 +2311,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(),
@@ -4166,6 +4170,37 @@ 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, 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

Powered by Google App Engine
This is Rietveld 408576698