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

Unified Diff: sync/internal_api/sync_encryption_handler_impl_unittest.cc

Issue 1250503002: [Sync] Don't require keystore migration time to be set in nigori node (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comment Created 5 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
« no previous file with comments | « sync/internal_api/sync_encryption_handler_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/internal_api/sync_encryption_handler_impl_unittest.cc
diff --git a/sync/internal_api/sync_encryption_handler_impl_unittest.cc b/sync/internal_api/sync_encryption_handler_impl_unittest.cc
index f1be922ebda7f3d55ec851c722b9ef7dc0fed9e6..c25571bbe8fba12903fcfac41061d8d57dd24df0 100644
--- a/sync/internal_api/sync_encryption_handler_impl_unittest.cc
+++ b/sync/internal_api/sync_encryption_handler_impl_unittest.cc
@@ -2451,4 +2451,54 @@ TEST_F(SyncEncryptionHandlerImplTest, RotateKeysMigratedCustomPassphrase) {
captured_nigori_state, CUSTOM_PASSPHRASE);
}
+// Verify that the client can gracefully handle a nigori node that is missing
+// the keystore migration time field.
+TEST_F(SyncEncryptionHandlerImplTest, MissingKeystoreMigrationTime) {
+ EXPECT_CALL(*observer(),
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
+ EXPECT_CALL(*observer(),
+ OnPassphraseRequired(_, _));
+ EXPECT_CALL(*observer(),
+ OnEncryptedTypesChanged(_, false));
+ encryption_handler()->Init();
+ Mock::VerifyAndClearExpectations(observer());
+
+ // Now simulate downloading a nigori node that that is missing the keystore
+ // migration time. It should be interpreted properly, and the passphrase type
+ // should switch to keystore passphrase.
+ EXPECT_CALL(*observer(),
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
+ EXPECT_CALL(*observer(),
+ OnPassphraseRequired(_, _));
+ EXPECT_CALL(*observer(),
+ OnPassphraseTypeChanged(KEYSTORE_PASSPHRASE, _));
+ {
+ sync_pb::NigoriSpecifics nigori = BuildMigratedNigori(
+ KEYSTORE_PASSPHRASE,
+ 1,
+ kKeystoreKey,
+ kKeystoreKey);
+ nigori.clear_keystore_migration_time();
+ // Update the encryption handler.
+ WriteTransaction trans(FROM_HERE, user_share());
+ encryption_handler()->ApplyNigoriUpdate(
+ nigori,
+ trans.GetWrappedTrans());
+ }
+ Mock::VerifyAndClearExpectations(observer());
+
+ // Now provide the keystore key to fully initialize the cryptographer.
+ EXPECT_CALL(*observer(),
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
+ EXPECT_CALL(*observer(),
+ OnBootstrapTokenUpdated(_, KEYSTORE_BOOTSTRAP_TOKEN));
+ {
+ ReadTransaction trans(FROM_HERE, user_share());
+ encryption_handler()->SetKeystoreKeys(BuildEncryptionKeyProto(
+ kRawKeystoreKey),
+ trans.GetWrappedTrans());
+
+ }
+}
+
} // namespace syncer
« no previous file with comments | « sync/internal_api/sync_encryption_handler_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698