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

Unified Diff: sync/internal_api/sync_encryption_handler_impl_unittest.cc

Issue 10917246: [Sync] Add keystore encryption info to about:sync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + address comments 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/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 996394e9e8218ed97bf56d9c85107bfc4f95d5b2..9a0a4ed21561a965c6124f35021eefb8b870a694 100644
--- a/sync/internal_api/sync_encryption_handler_impl_unittest.cc
+++ b/sync/internal_api/sync_encryption_handler_impl_unittest.cc
@@ -31,6 +31,7 @@ namespace syncer {
namespace {
using ::testing::_;
+using ::testing::AnyNumber;
using ::testing::Mock;
using ::testing::StrictMock;
@@ -379,7 +380,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveOldNigori) {
current_nigori_specifics.mutable_encryption_keybag());
current_nigori_specifics.set_encrypt_everything(true);
- EXPECT_CALL(*observer(), OnCryptographerStateChanged(_));
+ EXPECT_CALL(*observer(), OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(), OnEncryptedTypesChanged(
HasModelTypes(UserTypes()), true));
{
@@ -396,7 +397,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveOldNigori) {
sync_pb::NigoriSpecifics old_nigori;
other_cryptographer.GetKeys(old_nigori.mutable_encryption_keybag());
- EXPECT_CALL(*observer(), OnCryptographerStateChanged(_));
+ EXPECT_CALL(*observer(), OnCryptographerStateChanged(_)).Times(AnyNumber());
{
// Update the encryption handler.
WriteTransaction trans(FROM_HERE, user_share());
@@ -502,7 +503,7 @@ TEST_F(SyncEncryptionHandlerImplTest, MigrateOnDecryptImplicitPass) {
nigori.set_keybag_is_frozen(false);
nigori.set_encrypt_everything(false);
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnPassphraseRequired(_, _));
encryption_handler()->ApplyNigoriUpdate(nigori, trans.GetWrappedTrans());
@@ -514,7 +515,7 @@ TEST_F(SyncEncryptionHandlerImplTest, MigrateOnDecryptImplicitPass) {
Mock::VerifyAndClearExpectations(observer());
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnPassphraseAccepted());
EXPECT_CALL(*observer(),
@@ -557,7 +558,7 @@ TEST_F(SyncEncryptionHandlerImplTest, MigrateOnDecryptCustomPass) {
nigori.set_keybag_is_frozen(true);
nigori.set_encrypt_everything(false);
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnPassphraseRequired(_, _));
EXPECT_CALL(*observer(),
@@ -571,7 +572,7 @@ TEST_F(SyncEncryptionHandlerImplTest, MigrateOnDecryptCustomPass) {
Mock::VerifyAndClearExpectations(observer());
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnPassphraseAccepted());
EXPECT_CALL(*observer(),
@@ -595,7 +596,7 @@ TEST_F(SyncEncryptionHandlerImplTest, MigrateOnKeystoreKeyAvailableImplicit) {
KeyParams current_key = {"localhost", "dummy", kCurKey};
GetCryptographer()->AddKey(current_key);
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnEncryptedTypesChanged(_, false));
EXPECT_CALL(*observer(),
@@ -607,6 +608,8 @@ TEST_F(SyncEncryptionHandlerImplTest, MigrateOnKeystoreKeyAvailableImplicit) {
ReadTransaction trans(FROM_HERE, user_share());
// Once we provide a keystore key, we should perform the migration.
EXPECT_CALL(*observer(),
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
+ EXPECT_CALL(*observer(),
OnBootstrapTokenUpdated(_, KEYSTORE_BOOTSTRAP_TOKEN));
encryption_handler()->SetKeystoreKey(kKeystoreKey, trans.GetWrappedTrans());
}
@@ -630,7 +633,7 @@ TEST_F(SyncEncryptionHandlerImplTest,
KeyParams current_key = {"localhost", "dummy", kCurKey};
GetCryptographer()->AddKey(current_key);
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnEncryptedTypesChanged(_, false));
EXPECT_CALL(*observer(),
@@ -648,6 +651,8 @@ TEST_F(SyncEncryptionHandlerImplTest,
ReadTransaction trans(FROM_HERE, user_share());
// Once we provide a keystore key, we should perform the migration.
EXPECT_CALL(*observer(),
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
+ EXPECT_CALL(*observer(),
OnBootstrapTokenUpdated(_, KEYSTORE_BOOTSTRAP_TOKEN));
encryption_handler()->SetKeystoreKey(kKeystoreKey, trans.GetWrappedTrans());
}
@@ -669,7 +674,7 @@ TEST_F(SyncEncryptionHandlerImplTest,
MigrateOnKeystoreKeyAvailableCustomWithEncryption) {
const char kCurKey[] = "cur";
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_)).Times(2);
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnPassphraseRequired(_, _));
EXPECT_CALL(*observer(),
@@ -697,6 +702,8 @@ TEST_F(SyncEncryptionHandlerImplTest,
ReadTransaction trans(FROM_HERE, user_share());
// Once we provide a keystore key, we should perform the migration.
EXPECT_CALL(*observer(),
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
+ EXPECT_CALL(*observer(),
OnBootstrapTokenUpdated(_, KEYSTORE_BOOTSTRAP_TOKEN));
encryption_handler()->SetKeystoreKey(kKeystoreKey, trans.GetWrappedTrans());
}
@@ -716,7 +723,7 @@ TEST_F(SyncEncryptionHandlerImplTest,
MigrateOnKeystoreKeyAvailableCustomNoEncryption) {
const char kCurKey[] = "cur";
EXPECT_CALL(*observer(),
akalin 2012/09/18 00:19:21 Looks like it's time for another mock -> fake conv
- OnCryptographerStateChanged(_)).Times(2);
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnPassphraseRequired(_, _));
EXPECT_CALL(*observer(),
@@ -737,6 +744,8 @@ TEST_F(SyncEncryptionHandlerImplTest,
ReadTransaction trans(FROM_HERE, user_share());
// Once we provide a keystore key, we should perform the migration.
EXPECT_CALL(*observer(),
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
+ EXPECT_CALL(*observer(),
OnBootstrapTokenUpdated(_, KEYSTORE_BOOTSTRAP_TOKEN));
encryption_handler()->SetKeystoreKey(kKeystoreKey, trans.GetWrappedTrans());
}
@@ -793,7 +802,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveMigratedNigoriKeystorePass) {
EXPECT_CALL(*observer(),
OnPassphraseTypeChanged(KEYSTORE_PASSPHRASE));
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_)).Times(2);
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
encryption_handler()->SetKeystoreKey(kKeystoreKey, trans.GetWrappedTrans());
encryption_handler()->ApplyNigoriUpdate(nigori, trans.GetWrappedTrans());
nigori_node.SetNigoriSpecifics(nigori);
@@ -847,7 +856,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveMigratedNigoriFrozenImplicitPass) {
EXPECT_CALL(*observer(),
OnPassphraseRequired(_, _));
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnEncryptedTypesChanged(_, true));
WriteTransaction trans(FROM_HERE, user_share());
@@ -876,7 +885,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveMigratedNigoriFrozenImplicitPass) {
EXPECT_CALL(*observer(),
OnBootstrapTokenUpdated(_, PASSPHRASE_BOOTSTRAP_TOKEN));
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnEncryptionComplete());
EXPECT_CALL(*observer(),
@@ -927,7 +936,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveMigratedNigoriCustomPass) {
EXPECT_CALL(*observer(),
OnPassphraseRequired(_, _));
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnEncryptedTypesChanged(_, true));
WriteTransaction trans(FROM_HERE, user_share());
@@ -954,7 +963,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveMigratedNigoriCustomPass) {
EXPECT_CALL(*observer(),
OnBootstrapTokenUpdated(_, PASSPHRASE_BOOTSTRAP_TOKEN));
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnEncryptionComplete());
EXPECT_CALL(*observer(),
@@ -1007,7 +1016,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveUnmigratedNigoriAfterMigration) {
EXPECT_CALL(*observer(),
OnPassphraseTypeChanged(CUSTOM_PASSPHRASE));
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnEncryptedTypesChanged(_, true)).Times(2);
EXPECT_CALL(*observer(),
@@ -1030,7 +1039,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveUnmigratedNigoriAfterMigration) {
// Now build an old unmigrated nigori node with old encrypted types. We should
// properly overwrite it with the migrated + encrypt everything state.
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
{
Cryptographer other_cryptographer(GetCryptographer()->encryptor());
other_cryptographer.AddKey(old_key);
@@ -1084,7 +1093,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveOldMigratedNigori) {
EXPECT_CALL(*observer(),
OnPassphraseTypeChanged(CUSTOM_PASSPHRASE));
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnEncryptedTypesChanged(_, true)).Times(2);
EXPECT_CALL(*observer(),
@@ -1107,7 +1116,7 @@ TEST_F(SyncEncryptionHandlerImplTest, ReceiveOldMigratedNigori) {
// Now build an old keystore nigori node with old encrypted types. We should
// properly overwrite it with the migrated + encrypt everything state.
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
{
WriteTransaction trans(FROM_HERE, user_share());
WriteNode nigori_node(&trans);
@@ -1172,7 +1181,7 @@ TEST_F(SyncEncryptionHandlerImplTest, SetKeystoreAfterReceivingMigratedNigori) {
EXPECT_CALL(*observer(),
OnPassphraseTypeChanged(KEYSTORE_PASSPHRASE));
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnPassphraseRequired(_, _));
encryption_handler()->ApplyNigoriUpdate(nigori, trans.GetWrappedTrans());
@@ -1187,7 +1196,7 @@ TEST_F(SyncEncryptionHandlerImplTest, SetKeystoreAfterReceivingMigratedNigori) {
Mock::VerifyAndClearExpectations(observer());
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnBootstrapTokenUpdated(_, PASSPHRASE_BOOTSTRAP_TOKEN));
{
@@ -1255,7 +1264,7 @@ TEST_F(SyncEncryptionHandlerImplTest, SetCustomPassAfterMigration) {
EXPECT_CALL(*observer(),
OnPassphraseTypeChanged(KEYSTORE_PASSPHRASE));
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_)).Times(2);
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnEncryptedTypesChanged(_, false));
EXPECT_CALL(*observer(),
@@ -1271,7 +1280,7 @@ TEST_F(SyncEncryptionHandlerImplTest, SetCustomPassAfterMigration) {
const char kNewKey[] = "new_key";
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnPassphraseTypeChanged(CUSTOM_PASSPHRASE));
EXPECT_CALL(*observer(),
@@ -1352,7 +1361,7 @@ TEST_F(SyncEncryptionHandlerImplTest,
EXPECT_CALL(*observer(),
OnPassphraseTypeChanged(KEYSTORE_PASSPHRASE));
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnEncryptedTypesChanged(_, false));
encryption_handler()->Init();
@@ -1365,7 +1374,7 @@ TEST_F(SyncEncryptionHandlerImplTest,
EXPECT_CALL(*observer(),
OnPassphraseAccepted());
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnBootstrapTokenUpdated(_, PASSPHRASE_BOOTSTRAP_TOKEN));
EXPECT_CALL(*observer(),
@@ -1377,7 +1386,7 @@ TEST_F(SyncEncryptionHandlerImplTest,
const char kNewKey[] = "new_key";
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnPassphraseTypeChanged(CUSTOM_PASSPHRASE));
EXPECT_CALL(*observer(),
@@ -1458,7 +1467,7 @@ TEST_F(SyncEncryptionHandlerImplTest,
EXPECT_CALL(*observer(),
OnPassphraseTypeChanged(KEYSTORE_PASSPHRASE));
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnEncryptedTypesChanged(_, false));
encryption_handler()->Init();
@@ -1471,7 +1480,7 @@ TEST_F(SyncEncryptionHandlerImplTest,
EXPECT_CALL(*observer(),
OnPassphraseAccepted());
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnBootstrapTokenUpdated(_, PASSPHRASE_BOOTSTRAP_TOKEN));
EXPECT_CALL(*observer(),
@@ -1552,7 +1561,7 @@ TEST_F(SyncEncryptionHandlerImplTest,
EXPECT_CALL(*observer(),
OnPassphraseTypeChanged(KEYSTORE_PASSPHRASE));
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnEncryptedTypesChanged(_, false));
encryption_handler()->Init();
@@ -1565,7 +1574,7 @@ TEST_F(SyncEncryptionHandlerImplTest,
EXPECT_CALL(*observer(),
OnPassphraseAccepted());
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnBootstrapTokenUpdated(_, PASSPHRASE_BOOTSTRAP_TOKEN));
EXPECT_CALL(*observer(),
@@ -1579,6 +1588,8 @@ TEST_F(SyncEncryptionHandlerImplTest,
OnEncryptionComplete());
EXPECT_CALL(*observer(),
OnEncryptedTypesChanged(_, true));
+ EXPECT_CALL(*observer(),
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
encryption_handler()->EnableEncryptEverything();
Mock::VerifyAndClearExpectations(observer());
@@ -1622,7 +1633,7 @@ TEST_F(SyncEncryptionHandlerImplTest,
EXPECT_TRUE(other_cryptographer.is_ready());
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
EXPECT_CALL(*observer(),
OnEncryptedTypesChanged(_, false));
EXPECT_CALL(*observer(),
@@ -1647,7 +1658,7 @@ TEST_F(SyncEncryptionHandlerImplTest,
// Now build an old keystore passphrase nigori node.
EXPECT_CALL(*observer(),
- OnCryptographerStateChanged(_));
+ OnCryptographerStateChanged(_)).Times(AnyNumber());
{
WriteTransaction trans(FROM_HERE, user_share());
WriteNode nigori_node(&trans);

Powered by Google App Engine
This is Rietveld 408576698