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

Unified Diff: sync/engine/syncer_unittest.cc

Issue 10905191: [Sync] Add keystore migration conflict 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 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 0165016b0fd7f4a171c90fa41e36a89ba8df7652..28650a68219f2857aa7b890d81d710fb434f4b0b 100644
--- a/sync/engine/syncer_unittest.cc
+++ b/sync/engine/syncer_unittest.cc
@@ -978,130 +978,6 @@ TEST_F(SyncerTest, EncryptionAwareConflicts) {
#undef VERIFY_ENTRY
-// Resolve a confict between two nigori's with different encrypted types,
-// and encryption keys (remote is explicit). Afterwards, the encrypted types
-// should be unioned and the cryptographer should have both keys and be
-// encrypting with the remote encryption key by default.
-// TODO(zea): Test conflicts with keystore migration.
-TEST_F(SyncerTest, NigoriConflicts) {
- KeyParams local_key_params = {"localhost", "dummy", "blargle"};
- KeyParams other_key_params = {"localhost", "dummy", "foobar"};
- Cryptographer other_cryptographer(&encryptor_);
- other_cryptographer.AddKey(other_key_params);
- ModelTypeSet encrypted_types(PASSWORDS, NIGORI);
- sync_pb::EntitySpecifics initial_nigori_specifics;
- initial_nigori_specifics.mutable_nigori();
- mock_server_->SetNigori(1, 10, 10, initial_nigori_specifics);
-
- // Data for testing encryption/decryption.
- sync_pb::EntitySpecifics other_encrypted_specifics;
- other_encrypted_specifics.mutable_bookmark()->set_title("title");
- other_cryptographer.Encrypt(
- other_encrypted_specifics,
- other_encrypted_specifics.mutable_encrypted());
- sync_pb::EntitySpecifics our_encrypted_specifics;
- our_encrypted_specifics.mutable_bookmark()->set_title("title2");
-
- // Receive the initial nigori node.
- SyncShareNudge();
- encrypted_types = ModelTypeSet::All();
- {
- // Local changes with different passphrase, different types.
- WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- sync_pb::EntitySpecifics specifics;
- sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori();
- GetCryptographer(&wtrans)->AddKey(local_key_params);
- GetCryptographer(&wtrans)->Encrypt(
- our_encrypted_specifics,
- our_encrypted_specifics.mutable_encrypted());
- GetCryptographer(&wtrans)->GetKeys(
- nigori->mutable_encryption_keybag());
- dir_maker_.encryption_handler()->EnableEncryptEverything();
- directory()->GetNigoriHandler()->UpdateNigoriFromEncryptedTypes(
- nigori,
- &wtrans);
- MutableEntry nigori_entry(&wtrans, GET_BY_SERVER_TAG,
- ModelTypeToRootTag(NIGORI));
- ASSERT_TRUE(nigori_entry.good());
- nigori_entry.Put(SPECIFICS, specifics);
- nigori_entry.Put(IS_UNSYNCED, true);
- EXPECT_FALSE(GetCryptographer(&wtrans)->has_pending_keys());
- EXPECT_TRUE(encrypted_types.Equals(
- directory()->GetNigoriHandler()->GetEncryptedTypes(&wtrans)));
- }
- {
- sync_pb::EntitySpecifics specifics;
- sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori();
- other_cryptographer.GetKeys(nigori->mutable_encryption_keybag());
- nigori->set_encrypt_bookmarks(true);
- nigori->set_encrypt_preferences(true);
- nigori->set_encrypt_everything(false);
- nigori->set_keybag_is_frozen(true);
- mock_server_->SetNigori(1, 20, 20, specifics);
- }
-
- // Will result in downloading the server nigori, which puts the local nigori
- // in a state of conflict. This is resolved by merging the local and server
- // data (with priority given to the server's encryption keys if they are
- // undecryptable), which we then commit. The cryptographer should have pending
- // keys and merge the set of encrypted types.
- SyncShareNudge(); // Resolve conflict in this cycle.
- SyncShareNudge(); // Commit local change in this cycle.
- {
- // Ensure the nigori data merged (encrypted types).
- WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry nigori_entry(&wtrans, GET_BY_SERVER_TAG,
- ModelTypeToRootTag(NIGORI));
- ASSERT_TRUE(nigori_entry.good());
- EXPECT_FALSE(nigori_entry.Get(IS_UNAPPLIED_UPDATE));
- EXPECT_FALSE(nigori_entry.Get(IS_UNSYNCED));
- sync_pb::EntitySpecifics specifics = nigori_entry.Get(SPECIFICS);
- ASSERT_TRUE(GetCryptographer(&wtrans)->has_pending_keys());
- EXPECT_TRUE(encrypted_types.Equals(
- directory()->GetNigoriHandler()->GetEncryptedTypes(&wtrans)));
- EXPECT_TRUE(dir_maker_.encryption_handler()->EncryptEverythingEnabled());
- EXPECT_TRUE(specifics.nigori().keybag_is_frozen());
- // Supply the pending keys. Afterwards, we should be able to decrypt both
- // our own encrypted data and data encrypted by the other cryptographer,
- // but the key provided by the other cryptographer should be the default.
- EXPECT_TRUE(
- GetCryptographer(&wtrans)->DecryptPendingKeys(other_key_params));
- EXPECT_FALSE(GetCryptographer(&wtrans)->has_pending_keys());
- sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori();
- GetCryptographer(&wtrans)->GetKeys(nigori->mutable_encryption_keybag());
- directory()->GetNigoriHandler()->UpdateNigoriFromEncryptedTypes(
- nigori,
- &wtrans);
- // Normally this would be written as part of SetPassphrase, but we do it
- // manually for the test.
- nigori_entry.Put(SPECIFICS, specifics);
- nigori_entry.Put(IS_UNSYNCED, true);
- }
-
- SyncShareNudge();
- {
- // Ensure everything is committed and stable now. The cryptographer
- // should be able to decrypt both sets of keys, and the encrypted types
- // should have been unioned.
- WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
- MutableEntry nigori_entry(&wtrans, GET_BY_SERVER_TAG,
- ModelTypeToRootTag(NIGORI));
- ASSERT_TRUE(nigori_entry.good());
- EXPECT_FALSE(nigori_entry.Get(IS_UNAPPLIED_UPDATE));
- EXPECT_FALSE(nigori_entry.Get(IS_UNSYNCED));
- EXPECT_TRUE(GetCryptographer(&wtrans)->CanDecrypt(
- our_encrypted_specifics.encrypted()));
- EXPECT_FALSE(GetCryptographer(&wtrans)->
- CanDecryptUsingDefaultKey(our_encrypted_specifics.encrypted()));
- EXPECT_TRUE(GetCryptographer(&wtrans)->CanDecrypt(
- other_encrypted_specifics.encrypted()));
- EXPECT_TRUE(GetCryptographer(&wtrans)->
- CanDecryptUsingDefaultKey(other_encrypted_specifics.encrypted()));
- EXPECT_TRUE(nigori_entry.Get(SPECIFICS).nigori().
- keybag_is_frozen());
- }
-}
-
TEST_F(SyncerTest, TestGetUnsyncedAndSimpleCommit) {
{
WriteTransaction wtrans(FROM_HERE, UNITTEST, directory());
« no previous file with comments | « sync/engine/apply_control_data_updates_unittest.cc ('k') | sync/internal_api/public/test/test_entry_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698