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

Side by Side Diff: sync/engine/apply_updates_command_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 #include <string> 5 #include <string>
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 .Equals(encrypted_types)); 529 .Equals(encrypted_types));
530 } 530 }
531 531
532 // Nigori node updates should update the Cryptographer. 532 // Nigori node updates should update the Cryptographer.
533 Cryptographer other_cryptographer(cryptographer->encryptor()); 533 Cryptographer other_cryptographer(cryptographer->encryptor());
534 KeyParams params = {"localhost", "dummy", "foobar"}; 534 KeyParams params = {"localhost", "dummy", "foobar"};
535 other_cryptographer.AddKey(params); 535 other_cryptographer.AddKey(params);
536 536
537 sync_pb::EntitySpecifics specifics; 537 sync_pb::EntitySpecifics specifics;
538 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); 538 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori();
539 other_cryptographer.GetKeys(nigori->mutable_encrypted()); 539 other_cryptographer.GetKeys(nigori->mutable_encryption_keybag());
540 nigori->set_encrypt_everything(true); 540 nigori->set_encrypt_everything(true);
541 entry_factory_->CreateUnappliedNewItem( 541 entry_factory_->CreateUnappliedNewItem(
542 ModelTypeToRootTag(NIGORI), specifics, true); 542 ModelTypeToRootTag(NIGORI), specifics, true);
543 EXPECT_FALSE(cryptographer->has_pending_keys()); 543 EXPECT_FALSE(cryptographer->has_pending_keys());
544 544
545 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); 545 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE);
546 apply_updates_command_.ExecuteImpl(session()); 546 apply_updates_command_.ExecuteImpl(session());
547 547
548 sessions::StatusController* status = session()->mutable_status_controller(); 548 sessions::StatusController* status = session()->mutable_status_controller();
549 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); 549 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE);
(...skipping 29 matching lines...) Expand all
579 .Equals(encrypted_types)); 579 .Equals(encrypted_types));
580 } 580 }
581 581
582 // Nigori node updates should update the Cryptographer. 582 // Nigori node updates should update the Cryptographer.
583 Cryptographer other_cryptographer(cryptographer->encryptor()); 583 Cryptographer other_cryptographer(cryptographer->encryptor());
584 KeyParams params = {"localhost", "dummy", "foobar"}; 584 KeyParams params = {"localhost", "dummy", "foobar"};
585 other_cryptographer.AddKey(params); 585 other_cryptographer.AddKey(params);
586 586
587 sync_pb::EntitySpecifics specifics; 587 sync_pb::EntitySpecifics specifics;
588 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); 588 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori();
589 other_cryptographer.GetKeys(nigori->mutable_encrypted()); 589 other_cryptographer.GetKeys(nigori->mutable_encryption_keybag());
590 nigori->set_encrypt_everything(true); 590 nigori->set_encrypt_everything(true);
591 entry_factory_->CreateUnappliedNewItem( 591 entry_factory_->CreateUnappliedNewItem(
592 ModelTypeToRootTag(NIGORI), specifics, true); 592 ModelTypeToRootTag(NIGORI), specifics, true);
593 EXPECT_FALSE(cryptographer->has_pending_keys()); 593 EXPECT_FALSE(cryptographer->has_pending_keys());
594 594
595 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE); 595 ExpectGroupToChange(apply_updates_command_, GROUP_PASSIVE);
596 apply_updates_command_.ExecuteImpl(session()); 596 apply_updates_command_.ExecuteImpl(session());
597 597
598 sessions::StatusController* status = session()->mutable_status_controller(); 598 sessions::StatusController* status = session()->mutable_status_controller();
599 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE); 599 sessions::ScopedModelSafeGroupRestriction r(status, GROUP_PASSIVE);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 entry_factory_->CreateUnsyncedItem( 659 entry_factory_->CreateUnsyncedItem(
660 id_factory_.NewLocalId(), id_factory_.root(), 660 id_factory_.NewLocalId(), id_factory_.root(),
661 base::StringPrintf("Item %"PRIuS"", i), false, 661 base::StringPrintf("Item %"PRIuS"", i), false,
662 BOOKMARKS, NULL); 662 BOOKMARKS, NULL);
663 } 663 }
664 664
665 KeyParams params = {"localhost", "dummy", "foobar"}; 665 KeyParams params = {"localhost", "dummy", "foobar"};
666 cryptographer->AddKey(params); 666 cryptographer->AddKey(params);
667 sync_pb::EntitySpecifics specifics; 667 sync_pb::EntitySpecifics specifics;
668 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); 668 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori();
669 cryptographer->GetKeys(nigori->mutable_encrypted()); 669 cryptographer->GetKeys(nigori->mutable_encryption_keybag());
670 nigori->set_encrypt_everything(true); 670 nigori->set_encrypt_everything(true);
671 encrypted_types.Put(BOOKMARKS); 671 encrypted_types.Put(BOOKMARKS);
672 entry_factory_->CreateUnappliedNewItem( 672 entry_factory_->CreateUnappliedNewItem(
673 ModelTypeToRootTag(NIGORI), specifics, true); 673 ModelTypeToRootTag(NIGORI), specifics, true);
674 EXPECT_FALSE(cryptographer->has_pending_keys()); 674 EXPECT_FALSE(cryptographer->has_pending_keys());
675 EXPECT_TRUE(cryptographer->is_ready()); 675 EXPECT_TRUE(cryptographer->is_ready());
676 676
677 { 677 {
678 // Ensure we have unsynced nodes that aren't properly encrypted. 678 // Ensure we have unsynced nodes that aren't properly encrypted.
679 syncable::ReadTransaction trans(FROM_HERE, directory()); 679 syncable::ReadTransaction trans(FROM_HERE, directory());
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 BOOKMARKS, NULL); 801 BOOKMARKS, NULL);
802 } 802 }
803 803
804 // We encrypt with new keys, triggering the local cryptographer to be unready 804 // We encrypt with new keys, triggering the local cryptographer to be unready
805 // and unable to decrypt data (once updated). 805 // and unable to decrypt data (once updated).
806 Cryptographer other_cryptographer(cryptographer->encryptor()); 806 Cryptographer other_cryptographer(cryptographer->encryptor());
807 KeyParams params = {"localhost", "dummy", "foobar"}; 807 KeyParams params = {"localhost", "dummy", "foobar"};
808 other_cryptographer.AddKey(params); 808 other_cryptographer.AddKey(params);
809 sync_pb::EntitySpecifics specifics; 809 sync_pb::EntitySpecifics specifics;
810 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori(); 810 sync_pb::NigoriSpecifics* nigori = specifics.mutable_nigori();
811 other_cryptographer.GetKeys(nigori->mutable_encrypted()); 811 other_cryptographer.GetKeys(nigori->mutable_encryption_keybag());
812 nigori->set_encrypt_everything(true); 812 nigori->set_encrypt_everything(true);
813 encrypted_types.Put(BOOKMARKS); 813 encrypted_types.Put(BOOKMARKS);
814 entry_factory_->CreateUnappliedNewItem( 814 entry_factory_->CreateUnappliedNewItem(
815 ModelTypeToRootTag(NIGORI), specifics, true); 815 ModelTypeToRootTag(NIGORI), specifics, true);
816 EXPECT_FALSE(cryptographer->has_pending_keys()); 816 EXPECT_FALSE(cryptographer->has_pending_keys());
817 817
818 { 818 {
819 // Ensure we have unsynced nodes that aren't properly encrypted. 819 // Ensure we have unsynced nodes that aren't properly encrypted.
820 syncable::ReadTransaction trans(FROM_HERE, directory()); 820 syncable::ReadTransaction trans(FROM_HERE, directory());
821 EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types)); 821 EXPECT_FALSE(VerifyUnsyncedChangesAreEncrypted(&trans, encrypted_types));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 EXPECT_FALSE(cryptographer->is_ready()); 854 EXPECT_FALSE(cryptographer->is_ready());
855 EXPECT_TRUE(cryptographer->has_pending_keys()); 855 EXPECT_TRUE(cryptographer->has_pending_keys());
856 856
857 Syncer::UnsyncedMetaHandles handles; 857 Syncer::UnsyncedMetaHandles handles;
858 GetUnsyncedEntries(&trans, &handles); 858 GetUnsyncedEntries(&trans, &handles);
859 EXPECT_EQ(2*batch_s+1, handles.size()); 859 EXPECT_EQ(2*batch_s+1, handles.size());
860 } 860 }
861 } 861 }
862 862
863 } // namespace syncer 863 } // namespace syncer
OLDNEW
« no previous file with comments | « no previous file | sync/engine/conflict_resolver.cc » ('j') | sync/internal_api/sync_encryption_handler_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698