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

Side by Side Diff: sync/internal_api/sync_manager_impl_unittest.cc

Issue 10916036: [Sync] Implement keystore migration support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Self review 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Unit tests for the SyncApi. Note that a lot of the underlying 5 // Unit tests for the SyncApi. Note that a lot of the underlying
6 // functionality is provided by the Syncable layer, which has its own 6 // functionality is provided by the Syncable layer, which has its own
7 // unit tests. We'll test SyncApi specific things in this harness. 7 // unit tests. We'll test SyncApi specific things in this harness.
8 8
9 #include <cstddef> 9 #include <cstddef>
10 #include <map> 10 #include <map>
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 if (!cryptographer) 825 if (!cryptographer)
826 return false; 826 return false;
827 if (encryption_status != UNINITIALIZED) { 827 if (encryption_status != UNINITIALIZED) {
828 KeyParams params = {"localhost", "dummy", "foobar"}; 828 KeyParams params = {"localhost", "dummy", "foobar"};
829 cryptographer->AddKey(params); 829 cryptographer->AddKey(params);
830 } else { 830 } else {
831 DCHECK_NE(nigori_status, WRITE_TO_NIGORI); 831 DCHECK_NE(nigori_status, WRITE_TO_NIGORI);
832 } 832 }
833 if (nigori_status == WRITE_TO_NIGORI) { 833 if (nigori_status == WRITE_TO_NIGORI) {
834 sync_pb::NigoriSpecifics nigori; 834 sync_pb::NigoriSpecifics nigori;
835 cryptographer->GetKeys(nigori.mutable_encrypted()); 835 cryptographer->GetKeys(nigori.mutable_encryption_keybag());
836 share->directory->GetNigoriHandler()->UpdateNigoriFromEncryptedTypes( 836 share->directory->GetNigoriHandler()->UpdateNigoriFromEncryptedTypes(
837 &nigori, 837 &nigori,
838 trans.GetWrappedTrans()); 838 trans.GetWrappedTrans());
839 WriteNode node(&trans); 839 WriteNode node(&trans);
840 EXPECT_EQ(BaseNode::INIT_OK, node.InitByIdLookup(nigori_id)); 840 EXPECT_EQ(BaseNode::INIT_OK, node.InitByIdLookup(nigori_id));
841 node.SetNigoriSpecifics(nigori); 841 node.SetNigoriSpecifics(nigori);
842 } 842 }
843 return cryptographer->is_ready(); 843 return cryptographer->is_ready();
844 } 844 }
845 845
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 const ModelTypeSet encrypted_types = GetEncryptedTypes(); 1361 const ModelTypeSet encrypted_types = GetEncryptedTypes();
1362 EXPECT_TRUE(encrypted_types.Has(PASSWORDS)); 1362 EXPECT_TRUE(encrypted_types.Has(PASSWORDS));
1363 EXPECT_FALSE(EncryptEverythingEnabledForTest()); 1363 EXPECT_FALSE(EncryptEverythingEnabledForTest());
1364 1364
1365 { 1365 {
1366 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1366 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1367 ReadNode node(&trans); 1367 ReadNode node(&trans);
1368 EXPECT_EQ(BaseNode::INIT_OK, 1368 EXPECT_EQ(BaseNode::INIT_OK,
1369 node.InitByIdLookup(GetIdForDataType(NIGORI))); 1369 node.InitByIdLookup(GetIdForDataType(NIGORI)));
1370 sync_pb::NigoriSpecifics nigori = node.GetNigoriSpecifics(); 1370 sync_pb::NigoriSpecifics nigori = node.GetNigoriSpecifics();
1371 EXPECT_TRUE(nigori.has_encrypted()); 1371 EXPECT_TRUE(nigori.has_encryption_keybag());
1372 Cryptographer* cryptographer = trans.GetCryptographer(); 1372 Cryptographer* cryptographer = trans.GetCryptographer();
1373 EXPECT_TRUE(cryptographer->is_ready()); 1373 EXPECT_TRUE(cryptographer->is_ready());
1374 EXPECT_TRUE(cryptographer->CanDecrypt(nigori.encrypted())); 1374 EXPECT_TRUE(cryptographer->CanDecrypt(nigori.encryption_keybag()));
1375 } 1375 }
1376 } 1376 }
1377 1377
1378 // Attempt to refresh encryption when nigori not downloaded. 1378 // Attempt to refresh encryption when nigori not downloaded.
1379 TEST_F(SyncManagerTest, RefreshEncryptionNotReady) { 1379 TEST_F(SyncManagerTest, RefreshEncryptionNotReady) {
1380 // Don't set up encryption (no nigori node created). 1380 // Don't set up encryption (no nigori node created).
1381 1381
1382 // Should fail. Triggers an OnPassphraseRequired because the cryptographer 1382 // Should fail. Triggers an OnPassphraseRequired because the cryptographer
1383 // is not ready. 1383 // is not ready.
1384 EXPECT_CALL(encryption_observer_, OnPassphraseRequired(_, _)).Times(1); 1384 EXPECT_CALL(encryption_observer_, OnPassphraseRequired(_, _)).Times(1);
(...skipping 21 matching lines...) Expand all
1406 const ModelTypeSet encrypted_types = GetEncryptedTypes(); 1406 const ModelTypeSet encrypted_types = GetEncryptedTypes();
1407 EXPECT_TRUE(encrypted_types.Has(PASSWORDS)); // Hardcoded. 1407 EXPECT_TRUE(encrypted_types.Has(PASSWORDS)); // Hardcoded.
1408 EXPECT_FALSE(EncryptEverythingEnabledForTest()); 1408 EXPECT_FALSE(EncryptEverythingEnabledForTest());
1409 1409
1410 { 1410 {
1411 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1411 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1412 ReadNode node(&trans); 1412 ReadNode node(&trans);
1413 EXPECT_EQ(BaseNode::INIT_OK, 1413 EXPECT_EQ(BaseNode::INIT_OK,
1414 node.InitByIdLookup(GetIdForDataType(NIGORI))); 1414 node.InitByIdLookup(GetIdForDataType(NIGORI)));
1415 sync_pb::NigoriSpecifics nigori = node.GetNigoriSpecifics(); 1415 sync_pb::NigoriSpecifics nigori = node.GetNigoriSpecifics();
1416 EXPECT_TRUE(nigori.has_encrypted()); 1416 EXPECT_TRUE(nigori.has_encryption_keybag());
1417 Cryptographer* cryptographer = trans.GetCryptographer(); 1417 Cryptographer* cryptographer = trans.GetCryptographer();
1418 EXPECT_TRUE(cryptographer->is_ready()); 1418 EXPECT_TRUE(cryptographer->is_ready());
1419 EXPECT_TRUE(cryptographer->CanDecrypt(nigori.encrypted())); 1419 EXPECT_TRUE(cryptographer->CanDecrypt(nigori.encryption_keybag()));
1420 } 1420 }
1421 } 1421 }
1422 1422
1423 TEST_F(SyncManagerTest, EncryptDataTypesWithNoData) { 1423 TEST_F(SyncManagerTest, EncryptDataTypesWithNoData) {
1424 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION)); 1424 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION));
1425 EXPECT_CALL(encryption_observer_, 1425 EXPECT_CALL(encryption_observer_,
1426 OnEncryptedTypesChanged( 1426 OnEncryptedTypesChanged(
1427 HasModelTypes(ModelTypeSet::All()), true)); 1427 HasModelTypes(ModelTypeSet::All()), true));
1428 EXPECT_CALL(encryption_observer_, OnEncryptionComplete()); 1428 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
1429 sync_manager_.GetEncryptionHandler()->EnableEncryptEverything(); 1429 sync_manager_.GetEncryptionHandler()->EnableEncryptEverything();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 } 1501 }
1502 1502
1503 // Trigger's a ReEncryptEverything with new passphrase. 1503 // Trigger's a ReEncryptEverything with new passphrase.
1504 testing::Mock::VerifyAndClearExpectations(&encryption_observer_); 1504 testing::Mock::VerifyAndClearExpectations(&encryption_observer_);
1505 EXPECT_CALL(encryption_observer_, 1505 EXPECT_CALL(encryption_observer_,
1506 OnBootstrapTokenUpdated(_, PASSPHRASE_BOOTSTRAP_TOKEN)); 1506 OnBootstrapTokenUpdated(_, PASSPHRASE_BOOTSTRAP_TOKEN));
1507 EXPECT_CALL(encryption_observer_, OnPassphraseAccepted()); 1507 EXPECT_CALL(encryption_observer_, OnPassphraseAccepted());
1508 EXPECT_CALL(encryption_observer_, OnEncryptionComplete()); 1508 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
1509 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_)); 1509 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
1510 EXPECT_CALL(encryption_observer_, 1510 EXPECT_CALL(encryption_observer_,
1511 OnPassphraseStateChanged(CUSTOM_PASSPHRASE)); 1511 OnPassphraseStateChanged(CUSTOM_PASSPHRASE));
1512 sync_manager_.GetEncryptionHandler()->SetEncryptionPassphrase( 1512 sync_manager_.GetEncryptionHandler()->SetEncryptionPassphrase(
1513 "new_passphrase", true); 1513 "new_passphrase", true);
1514 EXPECT_TRUE(EncryptEverythingEnabledForTest()); 1514 EXPECT_TRUE(EncryptEverythingEnabledForTest());
1515 { 1515 {
1516 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1516 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1517 EXPECT_TRUE(GetEncryptedTypesWithTrans(&trans).Equals(ModelTypeSet::All())); 1517 EXPECT_TRUE(GetEncryptedTypesWithTrans(&trans).Equals(ModelTypeSet::All()));
1518 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest( 1518 EXPECT_TRUE(syncable::VerifyDataTypeEncryptionForTest(
1519 trans.GetWrappedTrans(), 1519 trans.GetWrappedTrans(),
1520 BOOKMARKS, 1520 BOOKMARKS,
1521 true /* is encrypted */)); 1521 true /* is encrypted */));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 EXPECT_EQ(IMPLICIT_PASSPHRASE, 1554 EXPECT_EQ(IMPLICIT_PASSPHRASE,
1555 sync_manager_.GetEncryptionHandler()->GetPassphraseState()); 1555 sync_manager_.GetEncryptionHandler()->GetPassphraseState());
1556 EXPECT_FALSE(EncryptEverythingEnabledForTest()); 1556 EXPECT_FALSE(EncryptEverythingEnabledForTest());
1557 { 1557 {
1558 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1558 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1559 ReadNode node(&trans); 1559 ReadNode node(&trans);
1560 EXPECT_EQ(BaseNode::INIT_OK, node.InitByTagLookup(kNigoriTag)); 1560 EXPECT_EQ(BaseNode::INIT_OK, node.InitByTagLookup(kNigoriTag));
1561 sync_pb::NigoriSpecifics nigori = node.GetNigoriSpecifics(); 1561 sync_pb::NigoriSpecifics nigori = node.GetNigoriSpecifics();
1562 Cryptographer* cryptographer = trans.GetCryptographer(); 1562 Cryptographer* cryptographer = trans.GetCryptographer();
1563 EXPECT_TRUE(cryptographer->is_ready()); 1563 EXPECT_TRUE(cryptographer->is_ready());
1564 EXPECT_TRUE(cryptographer->CanDecrypt(nigori.encrypted())); 1564 EXPECT_TRUE(cryptographer->CanDecrypt(nigori.encryption_keybag()));
1565 } 1565 }
1566 } 1566 }
1567 1567
1568 // Test that when there are no pending keys and we have on the old GAIA 1568 // Test that when there are no pending keys and we have on the old GAIA
1569 // password, we update and re-encrypt everything with the new GAIA password. 1569 // password, we update and re-encrypt everything with the new GAIA password.
1570 // (case 1 in SyncManager::SyncInternal::SetEncryptionPassphrase) 1570 // (case 1 in SyncManager::SyncInternal::SetEncryptionPassphrase)
1571 TEST_F(SyncManagerTest, UpdateGaiaPass) { 1571 TEST_F(SyncManagerTest, UpdateGaiaPass) {
1572 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION)); 1572 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION));
1573 Cryptographer verifier(&encryptor_); 1573 Cryptographer verifier(&encryptor_);
1574 { 1574 {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 cryptographer->GetBootstrapToken(&bootstrap_token); 1672 cryptographer->GetBootstrapToken(&bootstrap_token);
1673 other_cryptographer.Bootstrap(bootstrap_token); 1673 other_cryptographer.Bootstrap(bootstrap_token);
1674 1674
1675 // Now update the nigori to reflect the new keys, and update the 1675 // Now update the nigori to reflect the new keys, and update the
1676 // cryptographer to have pending keys. 1676 // cryptographer to have pending keys.
1677 KeyParams params = {"localhost", "dummy", "passphrase2"}; 1677 KeyParams params = {"localhost", "dummy", "passphrase2"};
1678 other_cryptographer.AddKey(params); 1678 other_cryptographer.AddKey(params);
1679 WriteNode node(&trans); 1679 WriteNode node(&trans);
1680 EXPECT_EQ(BaseNode::INIT_OK, node.InitByTagLookup(kNigoriTag)); 1680 EXPECT_EQ(BaseNode::INIT_OK, node.InitByTagLookup(kNigoriTag));
1681 sync_pb::NigoriSpecifics nigori; 1681 sync_pb::NigoriSpecifics nigori;
1682 other_cryptographer.GetKeys(nigori.mutable_encrypted()); 1682 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag());
1683 cryptographer->SetPendingKeys(nigori.encrypted()); 1683 cryptographer->SetPendingKeys(nigori.encryption_keybag());
1684 EXPECT_TRUE(cryptographer->has_pending_keys()); 1684 EXPECT_TRUE(cryptographer->has_pending_keys());
1685 node.SetNigoriSpecifics(nigori); 1685 node.SetNigoriSpecifics(nigori);
1686 } 1686 }
1687 EXPECT_CALL(encryption_observer_, 1687 EXPECT_CALL(encryption_observer_,
1688 OnBootstrapTokenUpdated(_, PASSPHRASE_BOOTSTRAP_TOKEN)); 1688 OnBootstrapTokenUpdated(_, PASSPHRASE_BOOTSTRAP_TOKEN));
1689 EXPECT_CALL(encryption_observer_, OnPassphraseAccepted()); 1689 EXPECT_CALL(encryption_observer_, OnPassphraseAccepted());
1690 EXPECT_CALL(encryption_observer_, OnEncryptionComplete()); 1690 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
1691 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_)); 1691 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
1692 sync_manager_.GetEncryptionHandler()->SetDecryptionPassphrase("passphrase2"); 1692 sync_manager_.GetEncryptionHandler()->SetDecryptionPassphrase("passphrase2");
1693 EXPECT_EQ(IMPLICIT_PASSPHRASE, 1693 EXPECT_EQ(IMPLICIT_PASSPHRASE,
(...skipping 26 matching lines...) Expand all
1720 cryptographer->GetBootstrapToken(&bootstrap_token); 1720 cryptographer->GetBootstrapToken(&bootstrap_token);
1721 other_cryptographer.Bootstrap(bootstrap_token); 1721 other_cryptographer.Bootstrap(bootstrap_token);
1722 1722
1723 // Now update the nigori to reflect the new keys, and update the 1723 // Now update the nigori to reflect the new keys, and update the
1724 // cryptographer to have pending keys. 1724 // cryptographer to have pending keys.
1725 KeyParams params = {"localhost", "dummy", "old_gaia"}; 1725 KeyParams params = {"localhost", "dummy", "old_gaia"};
1726 other_cryptographer.AddKey(params); 1726 other_cryptographer.AddKey(params);
1727 WriteNode node(&trans); 1727 WriteNode node(&trans);
1728 EXPECT_EQ(BaseNode::INIT_OK, node.InitByTagLookup(kNigoriTag)); 1728 EXPECT_EQ(BaseNode::INIT_OK, node.InitByTagLookup(kNigoriTag));
1729 sync_pb::NigoriSpecifics nigori; 1729 sync_pb::NigoriSpecifics nigori;
1730 other_cryptographer.GetKeys(nigori.mutable_encrypted()); 1730 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag());
1731 node.SetNigoriSpecifics(nigori); 1731 node.SetNigoriSpecifics(nigori);
1732 cryptographer->SetPendingKeys(nigori.encrypted()); 1732 cryptographer->SetPendingKeys(nigori.encryption_keybag());
1733 1733
1734 // other_cryptographer now contains all encryption keys, and is encrypting 1734 // other_cryptographer now contains all encryption keys, and is encrypting
1735 // with the newest gaia. 1735 // with the newest gaia.
1736 KeyParams new_params = {"localhost", "dummy", "new_gaia"}; 1736 KeyParams new_params = {"localhost", "dummy", "new_gaia"};
1737 other_cryptographer.AddKey(new_params); 1737 other_cryptographer.AddKey(new_params);
1738 } 1738 }
1739 // The bootstrap token should have been updated. Save it to ensure it's based 1739 // The bootstrap token should have been updated. Save it to ensure it's based
1740 // on the new GAIA password. 1740 // on the new GAIA password.
1741 std::string bootstrap_token; 1741 std::string bootstrap_token;
1742 EXPECT_CALL(encryption_observer_, 1742 EXPECT_CALL(encryption_observer_,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 cryptographer->GetBootstrapToken(&bootstrap_token); 1803 cryptographer->GetBootstrapToken(&bootstrap_token);
1804 other_cryptographer.Bootstrap(bootstrap_token); 1804 other_cryptographer.Bootstrap(bootstrap_token);
1805 1805
1806 // Now update the nigori to reflect the new keys, and update the 1806 // Now update the nigori to reflect the new keys, and update the
1807 // cryptographer to have pending keys. 1807 // cryptographer to have pending keys.
1808 KeyParams params = {"localhost", "dummy", "explicit"}; 1808 KeyParams params = {"localhost", "dummy", "explicit"};
1809 other_cryptographer.AddKey(params); 1809 other_cryptographer.AddKey(params);
1810 WriteNode node(&trans); 1810 WriteNode node(&trans);
1811 EXPECT_EQ(BaseNode::INIT_OK, node.InitByTagLookup(kNigoriTag)); 1811 EXPECT_EQ(BaseNode::INIT_OK, node.InitByTagLookup(kNigoriTag));
1812 sync_pb::NigoriSpecifics nigori; 1812 sync_pb::NigoriSpecifics nigori;
1813 other_cryptographer.GetKeys(nigori.mutable_encrypted()); 1813 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag());
1814 cryptographer->SetPendingKeys(nigori.encrypted()); 1814 cryptographer->SetPendingKeys(nigori.encryption_keybag());
1815 EXPECT_TRUE(cryptographer->has_pending_keys()); 1815 EXPECT_TRUE(cryptographer->has_pending_keys());
1816 nigori.set_using_explicit_passphrase(true); 1816 nigori.set_frozen_keybag(true);
1817 node.SetNigoriSpecifics(nigori); 1817 node.SetNigoriSpecifics(nigori);
1818 } 1818 }
1819 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
1820 EXPECT_CALL(encryption_observer_,
1821 OnPassphraseStateChanged(CUSTOM_PASSPHRASE));
1822 EXPECT_CALL(encryption_observer_, OnPassphraseRequired(_, _));
1823 EXPECT_CALL(encryption_observer_, OnEncryptedTypesChanged(_, false));
1824 sync_manager_.GetEncryptionHandler()->Init();
1819 EXPECT_CALL(encryption_observer_, 1825 EXPECT_CALL(encryption_observer_,
1820 OnBootstrapTokenUpdated(_, PASSPHRASE_BOOTSTRAP_TOKEN)); 1826 OnBootstrapTokenUpdated(_, PASSPHRASE_BOOTSTRAP_TOKEN));
1821 EXPECT_CALL(encryption_observer_, OnPassphraseAccepted()); 1827 EXPECT_CALL(encryption_observer_, OnPassphraseAccepted());
1822 EXPECT_CALL(encryption_observer_, OnEncryptionComplete()); 1828 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
1823 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_)); 1829 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
1824 EXPECT_CALL(encryption_observer_,
1825 OnPassphraseStateChanged(CUSTOM_PASSPHRASE));
1826 sync_manager_.GetEncryptionHandler()->SetDecryptionPassphrase("explicit"); 1830 sync_manager_.GetEncryptionHandler()->SetDecryptionPassphrase("explicit");
1827 EXPECT_EQ(CUSTOM_PASSPHRASE, 1831 EXPECT_EQ(CUSTOM_PASSPHRASE,
1828 sync_manager_.GetEncryptionHandler()->GetPassphraseState()); 1832 sync_manager_.GetEncryptionHandler()->GetPassphraseState());
1829 EXPECT_FALSE(EncryptEverythingEnabledForTest()); 1833 EXPECT_FALSE(EncryptEverythingEnabledForTest());
1830 { 1834 {
1831 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1835 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1832 Cryptographer* cryptographer = trans.GetCryptographer(); 1836 Cryptographer* cryptographer = trans.GetCryptographer();
1833 EXPECT_TRUE(cryptographer->is_ready()); 1837 EXPECT_TRUE(cryptographer->is_ready());
1834 // Verify we're encrypting with the new key. 1838 // Verify we're encrypting with the new key.
1835 sync_pb::EncryptedData encrypted; 1839 sync_pb::EncryptedData encrypted;
(...skipping 12 matching lines...) Expand all
1848 { 1852 {
1849 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 1853 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
1850 Cryptographer* cryptographer = trans.GetCryptographer(); 1854 Cryptographer* cryptographer = trans.GetCryptographer();
1851 // Now update the nigori to reflect the new keys, and update the 1855 // Now update the nigori to reflect the new keys, and update the
1852 // cryptographer to have pending keys. 1856 // cryptographer to have pending keys.
1853 KeyParams params = {"localhost", "dummy", "passphrase"}; 1857 KeyParams params = {"localhost", "dummy", "passphrase"};
1854 other_cryptographer.AddKey(params); 1858 other_cryptographer.AddKey(params);
1855 WriteNode node(&trans); 1859 WriteNode node(&trans);
1856 EXPECT_EQ(BaseNode::INIT_OK, node.InitByTagLookup(kNigoriTag)); 1860 EXPECT_EQ(BaseNode::INIT_OK, node.InitByTagLookup(kNigoriTag));
1857 sync_pb::NigoriSpecifics nigori; 1861 sync_pb::NigoriSpecifics nigori;
1858 other_cryptographer.GetKeys(nigori.mutable_encrypted()); 1862 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag());
1859 node.SetNigoriSpecifics(nigori); 1863 node.SetNigoriSpecifics(nigori);
1860 cryptographer->SetPendingKeys(nigori.encrypted()); 1864 cryptographer->SetPendingKeys(nigori.encryption_keybag());
1861 EXPECT_FALSE(cryptographer->is_ready()); 1865 EXPECT_FALSE(cryptographer->is_ready());
1862 } 1866 }
1863 EXPECT_CALL(encryption_observer_, 1867 EXPECT_CALL(encryption_observer_,
1864 OnBootstrapTokenUpdated(_, PASSPHRASE_BOOTSTRAP_TOKEN)); 1868 OnBootstrapTokenUpdated(_, PASSPHRASE_BOOTSTRAP_TOKEN));
1865 EXPECT_CALL(encryption_observer_, OnPassphraseAccepted()); 1869 EXPECT_CALL(encryption_observer_, OnPassphraseAccepted());
1866 EXPECT_CALL(encryption_observer_, OnEncryptionComplete()); 1870 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
1867 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_)); 1871 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
1868 sync_manager_.GetEncryptionHandler()->SetEncryptionPassphrase( 1872 sync_manager_.GetEncryptionHandler()->SetEncryptionPassphrase(
1869 "passphrase", 1873 "passphrase",
1870 false); 1874 false);
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after
2886 2890
2887 // Verify only the non-disabled types remain after cleanup. 2891 // Verify only the non-disabled types remain after cleanup.
2888 sync_manager_.PurgeDisabledTypes(enabled_types, new_enabled_types); 2892 sync_manager_.PurgeDisabledTypes(enabled_types, new_enabled_types);
2889 EXPECT_TRUE(new_enabled_types.Equals( 2893 EXPECT_TRUE(new_enabled_types.Equals(
2890 Union(sync_manager_.InitialSyncEndedTypes(), partial_enabled_types))); 2894 Union(sync_manager_.InitialSyncEndedTypes(), partial_enabled_types)));
2891 EXPECT_TRUE(disabled_types.Equals( 2895 EXPECT_TRUE(disabled_types.Equals(
2892 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All()))); 2896 sync_manager_.GetTypesWithEmptyProgressMarkerToken(ModelTypeSet::All())));
2893 } 2897 }
2894 2898
2895 } // namespace 2899 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698