OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "sync/engine/apply_control_data_updates.h" | 5 #include "sync/engine/apply_control_data_updates.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include <string> | 10 #include <string> |
8 | 11 |
9 #include "base/format_macros.h" | 12 #include "base/format_macros.h" |
10 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
12 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
13 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
14 #include "sync/engine/syncer.h" | 18 #include "sync/engine/syncer.h" |
15 #include "sync/engine/syncer_util.h" | 19 #include "sync/engine/syncer_util.h" |
16 #include "sync/internal_api/public/test/test_entry_factory.h" | 20 #include "sync/internal_api/public/test/test_entry_factory.h" |
17 #include "sync/protocol/nigori_specifics.pb.h" | 21 #include "sync/protocol/nigori_specifics.pb.h" |
18 #include "sync/syncable/directory.h" | 22 #include "sync/syncable/directory.h" |
19 #include "sync/syncable/mutable_entry.h" | 23 #include "sync/syncable/mutable_entry.h" |
20 #include "sync/syncable/nigori_util.h" | 24 #include "sync/syncable/nigori_util.h" |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 Cryptographer other_cryptographer(cryptographer->encryptor()); | 327 Cryptographer other_cryptographer(cryptographer->encryptor()); |
324 other_cryptographer.AddKey(other_params); | 328 other_cryptographer.AddKey(other_params); |
325 | 329 |
326 // Create server specifics with pending keys, new encrypted types, | 330 // Create server specifics with pending keys, new encrypted types, |
327 // and a custom passphrase (unmigrated). | 331 // and a custom passphrase (unmigrated). |
328 sync_pb::EntitySpecifics server_specifics; | 332 sync_pb::EntitySpecifics server_specifics; |
329 sync_pb::NigoriSpecifics* server_nigori = server_specifics.mutable_nigori(); | 333 sync_pb::NigoriSpecifics* server_nigori = server_specifics.mutable_nigori(); |
330 other_cryptographer.GetKeys(server_nigori->mutable_encryption_keybag()); | 334 other_cryptographer.GetKeys(server_nigori->mutable_encryption_keybag()); |
331 server_nigori->set_encrypt_everything(true); | 335 server_nigori->set_encrypt_everything(true); |
332 server_nigori->set_keybag_is_frozen(true); | 336 server_nigori->set_keybag_is_frozen(true); |
333 int64 nigori_handle = | 337 int64_t nigori_handle = entry_factory_->CreateUnappliedNewItem( |
334 entry_factory_->CreateUnappliedNewItem(kNigoriTag, | 338 kNigoriTag, server_specifics, true); |
335 server_specifics, | |
336 true); | |
337 | 339 |
338 // Initialize the local cryptographer with the local keys. | 340 // Initialize the local cryptographer with the local keys. |
339 cryptographer->AddKey(local_params); | 341 cryptographer->AddKey(local_params); |
340 EXPECT_TRUE(cryptographer->is_ready()); | 342 EXPECT_TRUE(cryptographer->is_ready()); |
341 | 343 |
342 // Set up a local nigori with the local encryption keys and default encrypted | 344 // Set up a local nigori with the local encryption keys and default encrypted |
343 // types. | 345 // types. |
344 sync_pb::EntitySpecifics local_specifics; | 346 sync_pb::EntitySpecifics local_specifics; |
345 sync_pb::NigoriSpecifics* local_nigori = local_specifics.mutable_nigori(); | 347 sync_pb::NigoriSpecifics* local_nigori = local_specifics.mutable_nigori(); |
346 cryptographer->GetKeys(local_nigori->mutable_encryption_keybag()); | 348 cryptographer->GetKeys(local_nigori->mutable_encryption_keybag()); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 Cryptographer other_cryptographer(cryptographer->encryptor()); | 403 Cryptographer other_cryptographer(cryptographer->encryptor()); |
402 other_cryptographer.AddKey(other_params); | 404 other_cryptographer.AddKey(other_params); |
403 | 405 |
404 // Create server specifics with pending keys, new encrypted types, | 406 // Create server specifics with pending keys, new encrypted types, |
405 // and a custom passphrase (unmigrated). | 407 // and a custom passphrase (unmigrated). |
406 sync_pb::EntitySpecifics server_specifics; | 408 sync_pb::EntitySpecifics server_specifics; |
407 sync_pb::NigoriSpecifics* server_nigori = server_specifics.mutable_nigori(); | 409 sync_pb::NigoriSpecifics* server_nigori = server_specifics.mutable_nigori(); |
408 other_cryptographer.GetKeys(server_nigori->mutable_encryption_keybag()); | 410 other_cryptographer.GetKeys(server_nigori->mutable_encryption_keybag()); |
409 server_nigori->set_encrypt_everything(false); | 411 server_nigori->set_encrypt_everything(false); |
410 server_nigori->set_keybag_is_frozen(false); | 412 server_nigori->set_keybag_is_frozen(false); |
411 int64 nigori_handle = | 413 int64_t nigori_handle = entry_factory_->CreateUnappliedNewItem( |
412 entry_factory_->CreateUnappliedNewItem(kNigoriTag, | 414 kNigoriTag, server_specifics, true); |
413 server_specifics, | |
414 true); | |
415 | 415 |
416 // Initialize the local cryptographer with the local keys. | 416 // Initialize the local cryptographer with the local keys. |
417 cryptographer->AddKey(local_params); | 417 cryptographer->AddKey(local_params); |
418 EXPECT_TRUE(cryptographer->is_ready()); | 418 EXPECT_TRUE(cryptographer->is_ready()); |
419 | 419 |
420 // Set up a local nigori with the local encryption keys and default encrypted | 420 // Set up a local nigori with the local encryption keys and default encrypted |
421 // types. | 421 // types. |
422 sync_pb::EntitySpecifics local_specifics; | 422 sync_pb::EntitySpecifics local_specifics; |
423 sync_pb::NigoriSpecifics* local_nigori = local_specifics.mutable_nigori(); | 423 sync_pb::NigoriSpecifics* local_nigori = local_specifics.mutable_nigori(); |
424 cryptographer->GetKeys(local_nigori->mutable_encryption_keybag()); | 424 cryptographer->GetKeys(local_nigori->mutable_encryption_keybag()); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 } | 476 } |
477 | 477 |
478 // Set up the cryptographer with old keys | 478 // Set up the cryptographer with old keys |
479 cryptographer->AddKey(old_params); | 479 cryptographer->AddKey(old_params); |
480 | 480 |
481 // Create server specifics with old keys and new encrypted types. | 481 // Create server specifics with old keys and new encrypted types. |
482 sync_pb::EntitySpecifics server_specifics; | 482 sync_pb::EntitySpecifics server_specifics; |
483 sync_pb::NigoriSpecifics* server_nigori = server_specifics.mutable_nigori(); | 483 sync_pb::NigoriSpecifics* server_nigori = server_specifics.mutable_nigori(); |
484 cryptographer->GetKeys(server_nigori->mutable_encryption_keybag()); | 484 cryptographer->GetKeys(server_nigori->mutable_encryption_keybag()); |
485 server_nigori->set_encrypt_everything(true); | 485 server_nigori->set_encrypt_everything(true); |
486 int64 nigori_handle = | 486 int64_t nigori_handle = entry_factory_->CreateUnappliedNewItem( |
487 entry_factory_->CreateUnappliedNewItem(kNigoriTag, | 487 kNigoriTag, server_specifics, true); |
488 server_specifics, | |
489 true); | |
490 | 488 |
491 // Add the new keys to the cryptogrpaher | 489 // Add the new keys to the cryptogrpaher |
492 cryptographer->AddKey(new_params); | 490 cryptographer->AddKey(new_params); |
493 EXPECT_TRUE(cryptographer->is_ready()); | 491 EXPECT_TRUE(cryptographer->is_ready()); |
494 | 492 |
495 // Set up a local nigori with the superset of keys. | 493 // Set up a local nigori with the superset of keys. |
496 sync_pb::EntitySpecifics local_specifics; | 494 sync_pb::EntitySpecifics local_specifics; |
497 sync_pb::NigoriSpecifics* local_nigori = local_specifics.mutable_nigori(); | 495 sync_pb::NigoriSpecifics* local_nigori = local_specifics.mutable_nigori(); |
498 cryptographer->GetKeys(local_nigori->mutable_encryption_keybag()); | 496 cryptographer->GetKeys(local_nigori->mutable_encryption_keybag()); |
499 local_nigori->set_encrypt_everything(false); | 497 local_nigori->set_encrypt_everything(false); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 | 549 |
552 // Create server specifics with a migrated keystore passphrase type. | 550 // Create server specifics with a migrated keystore passphrase type. |
553 sync_pb::EntitySpecifics server_specifics; | 551 sync_pb::EntitySpecifics server_specifics; |
554 sync_pb::NigoriSpecifics* server_nigori = server_specifics.mutable_nigori(); | 552 sync_pb::NigoriSpecifics* server_nigori = server_specifics.mutable_nigori(); |
555 other_cryptographer.GetKeys(server_nigori->mutable_encryption_keybag()); | 553 other_cryptographer.GetKeys(server_nigori->mutable_encryption_keybag()); |
556 server_nigori->set_encrypt_everything(false); | 554 server_nigori->set_encrypt_everything(false); |
557 server_nigori->set_keybag_is_frozen(true); | 555 server_nigori->set_keybag_is_frozen(true); |
558 server_nigori->set_passphrase_type( | 556 server_nigori->set_passphrase_type( |
559 sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE); | 557 sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE); |
560 server_nigori->mutable_keystore_decryptor_token(); | 558 server_nigori->mutable_keystore_decryptor_token(); |
561 int64 nigori_handle = | 559 int64_t nigori_handle = entry_factory_->CreateUnappliedNewItem( |
562 entry_factory_->CreateUnappliedNewItem(kNigoriTag, | 560 kNigoriTag, server_specifics, true); |
563 server_specifics, | |
564 true); | |
565 | 561 |
566 // Add the new keys to the cryptographer. | 562 // Add the new keys to the cryptographer. |
567 cryptographer->AddKey(old_params); | 563 cryptographer->AddKey(old_params); |
568 cryptographer->AddKey(new_params); | 564 cryptographer->AddKey(new_params); |
569 EXPECT_TRUE(cryptographer->is_ready()); | 565 EXPECT_TRUE(cryptographer->is_ready()); |
570 | 566 |
571 // Set up a local nigori with a migrated custom passphrase type | 567 // Set up a local nigori with a migrated custom passphrase type |
572 sync_pb::EntitySpecifics local_specifics; | 568 sync_pb::EntitySpecifics local_specifics; |
573 sync_pb::NigoriSpecifics* local_nigori = local_specifics.mutable_nigori(); | 569 sync_pb::NigoriSpecifics* local_nigori = local_specifics.mutable_nigori(); |
574 cryptographer->GetKeys(local_nigori->mutable_encryption_keybag()); | 570 cryptographer->GetKeys(local_nigori->mutable_encryption_keybag()); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 other_cryptographer.AddKey(new_params); | 629 other_cryptographer.AddKey(new_params); |
634 | 630 |
635 // Create server specifics with a migrated custom passphrase type. | 631 // Create server specifics with a migrated custom passphrase type. |
636 sync_pb::EntitySpecifics server_specifics; | 632 sync_pb::EntitySpecifics server_specifics; |
637 sync_pb::NigoriSpecifics* server_nigori = server_specifics.mutable_nigori(); | 633 sync_pb::NigoriSpecifics* server_nigori = server_specifics.mutable_nigori(); |
638 other_cryptographer.GetKeys(server_nigori->mutable_encryption_keybag()); | 634 other_cryptographer.GetKeys(server_nigori->mutable_encryption_keybag()); |
639 server_nigori->set_encrypt_everything(true); | 635 server_nigori->set_encrypt_everything(true); |
640 server_nigori->set_keybag_is_frozen(true); | 636 server_nigori->set_keybag_is_frozen(true); |
641 server_nigori->set_passphrase_type( | 637 server_nigori->set_passphrase_type( |
642 sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE); | 638 sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE); |
643 int64 nigori_handle = | 639 int64_t nigori_handle = entry_factory_->CreateUnappliedNewItem( |
644 entry_factory_->CreateUnappliedNewItem(kNigoriTag, | 640 kNigoriTag, server_specifics, true); |
645 server_specifics, | |
646 true); | |
647 | 641 |
648 // Add the old keys to the cryptographer. | 642 // Add the old keys to the cryptographer. |
649 cryptographer->AddKey(old_params); | 643 cryptographer->AddKey(old_params); |
650 EXPECT_TRUE(cryptographer->is_ready()); | 644 EXPECT_TRUE(cryptographer->is_ready()); |
651 | 645 |
652 // Set up a local nigori with a migrated keystore passphrase type | 646 // Set up a local nigori with a migrated keystore passphrase type |
653 sync_pb::EntitySpecifics local_specifics; | 647 sync_pb::EntitySpecifics local_specifics; |
654 sync_pb::NigoriSpecifics* local_nigori = local_specifics.mutable_nigori(); | 648 sync_pb::NigoriSpecifics* local_nigori = local_specifics.mutable_nigori(); |
655 cryptographer->GetKeys(local_nigori->mutable_encryption_keybag()); | 649 cryptographer->GetKeys(local_nigori->mutable_encryption_keybag()); |
656 local_nigori->set_encrypt_everything(false); | 650 local_nigori->set_encrypt_everything(false); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 // Set up the cryptographer with both new keys and old keys. | 707 // Set up the cryptographer with both new keys and old keys. |
714 Cryptographer other_cryptographer(cryptographer->encryptor()); | 708 Cryptographer other_cryptographer(cryptographer->encryptor()); |
715 other_cryptographer.AddKey(old_params); | 709 other_cryptographer.AddKey(old_params); |
716 | 710 |
717 // Create server specifics with an unmigrated implicit passphrase type. | 711 // Create server specifics with an unmigrated implicit passphrase type. |
718 sync_pb::EntitySpecifics server_specifics; | 712 sync_pb::EntitySpecifics server_specifics; |
719 sync_pb::NigoriSpecifics* server_nigori = server_specifics.mutable_nigori(); | 713 sync_pb::NigoriSpecifics* server_nigori = server_specifics.mutable_nigori(); |
720 other_cryptographer.GetKeys(server_nigori->mutable_encryption_keybag()); | 714 other_cryptographer.GetKeys(server_nigori->mutable_encryption_keybag()); |
721 server_nigori->set_encrypt_everything(true); | 715 server_nigori->set_encrypt_everything(true); |
722 server_nigori->set_keybag_is_frozen(false); | 716 server_nigori->set_keybag_is_frozen(false); |
723 int64 nigori_handle = | 717 int64_t nigori_handle = entry_factory_->CreateUnappliedNewItem( |
724 entry_factory_->CreateUnappliedNewItem(kNigoriTag, | 718 kNigoriTag, server_specifics, true); |
725 server_specifics, | |
726 true); | |
727 | 719 |
728 // Add the old keys to the cryptographer. | 720 // Add the old keys to the cryptographer. |
729 cryptographer->AddKey(old_params); | 721 cryptographer->AddKey(old_params); |
730 cryptographer->AddKey(new_params); | 722 cryptographer->AddKey(new_params); |
731 EXPECT_TRUE(cryptographer->is_ready()); | 723 EXPECT_TRUE(cryptographer->is_ready()); |
732 | 724 |
733 // Set up a local nigori with a migrated custom passphrase type | 725 // Set up a local nigori with a migrated custom passphrase type |
734 sync_pb::EntitySpecifics local_specifics; | 726 sync_pb::EntitySpecifics local_specifics; |
735 sync_pb::NigoriSpecifics* local_nigori = local_specifics.mutable_nigori(); | 727 sync_pb::NigoriSpecifics* local_nigori = local_specifics.mutable_nigori(); |
736 cryptographer->GetKeys(local_nigori->mutable_encryption_keybag()); | 728 cryptographer->GetKeys(local_nigori->mutable_encryption_keybag()); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 | 787 |
796 // Create server specifics with an migrated keystore passphrase type. | 788 // Create server specifics with an migrated keystore passphrase type. |
797 sync_pb::EntitySpecifics server_specifics; | 789 sync_pb::EntitySpecifics server_specifics; |
798 sync_pb::NigoriSpecifics* server_nigori = server_specifics.mutable_nigori(); | 790 sync_pb::NigoriSpecifics* server_nigori = server_specifics.mutable_nigori(); |
799 other_cryptographer.GetKeys(server_nigori->mutable_encryption_keybag()); | 791 other_cryptographer.GetKeys(server_nigori->mutable_encryption_keybag()); |
800 server_nigori->set_encrypt_everything(false); | 792 server_nigori->set_encrypt_everything(false); |
801 server_nigori->set_keybag_is_frozen(true); | 793 server_nigori->set_keybag_is_frozen(true); |
802 server_nigori->set_passphrase_type( | 794 server_nigori->set_passphrase_type( |
803 sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE); | 795 sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE); |
804 server_nigori->mutable_keystore_decryptor_token(); | 796 server_nigori->mutable_keystore_decryptor_token(); |
805 int64 nigori_handle = | 797 int64_t nigori_handle = entry_factory_->CreateUnappliedNewItem( |
806 entry_factory_->CreateUnappliedNewItem(kNigoriTag, | 798 kNigoriTag, server_specifics, true); |
807 server_specifics, | |
808 true); | |
809 | 799 |
810 // Add the old keys to the cryptographer. | 800 // Add the old keys to the cryptographer. |
811 cryptographer->AddKey(old_params); | 801 cryptographer->AddKey(old_params); |
812 cryptographer->AddKey(new_params); | 802 cryptographer->AddKey(new_params); |
813 EXPECT_TRUE(cryptographer->is_ready()); | 803 EXPECT_TRUE(cryptographer->is_ready()); |
814 | 804 |
815 // Set up a local nigori with a migrated custom passphrase type | 805 // Set up a local nigori with a migrated custom passphrase type |
816 sync_pb::EntitySpecifics local_specifics; | 806 sync_pb::EntitySpecifics local_specifics; |
817 sync_pb::NigoriSpecifics* local_nigori = local_specifics.mutable_nigori(); | 807 sync_pb::NigoriSpecifics* local_nigori = local_specifics.mutable_nigori(); |
818 cryptographer->GetKeys(local_nigori->mutable_encryption_keybag()); | 808 cryptographer->GetKeys(local_nigori->mutable_encryption_keybag()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 syncable::ReadTransaction trans(FROM_HERE, directory()); | 847 syncable::ReadTransaction trans(FROM_HERE, directory()); |
858 } | 848 } |
859 } | 849 } |
860 | 850 |
861 // Check that we can apply a simple control datatype node successfully. | 851 // Check that we can apply a simple control datatype node successfully. |
862 TEST_F(ApplyControlDataUpdatesTest, ControlApply) { | 852 TEST_F(ApplyControlDataUpdatesTest, ControlApply) { |
863 std::string experiment_id = "experiment"; | 853 std::string experiment_id = "experiment"; |
864 sync_pb::EntitySpecifics specifics; | 854 sync_pb::EntitySpecifics specifics; |
865 specifics.mutable_experiments()->mutable_keystore_encryption()-> | 855 specifics.mutable_experiments()->mutable_keystore_encryption()-> |
866 set_enabled(true); | 856 set_enabled(true); |
867 int64 experiment_handle = entry_factory_->CreateUnappliedNewItem( | 857 int64_t experiment_handle = |
868 experiment_id, specifics, false); | 858 entry_factory_->CreateUnappliedNewItem(experiment_id, specifics, false); |
869 ApplyControlDataUpdates(directory()); | 859 ApplyControlDataUpdates(directory()); |
870 | 860 |
871 EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(experiment_handle)); | 861 EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(experiment_handle)); |
872 EXPECT_TRUE( | 862 EXPECT_TRUE( |
873 entry_factory_->GetLocalSpecificsForItem(experiment_handle). | 863 entry_factory_->GetLocalSpecificsForItem(experiment_handle). |
874 experiments().keystore_encryption().enabled()); | 864 experiments().keystore_encryption().enabled()); |
875 } | 865 } |
876 | 866 |
877 // Verify that we apply top level folders before their children. | 867 // Verify that we apply top level folders before their children. |
878 TEST_F(ApplyControlDataUpdatesTest, ControlApplyParentBeforeChild) { | 868 TEST_F(ApplyControlDataUpdatesTest, ControlApplyParentBeforeChild) { |
879 std::string parent_id = "parent"; | 869 std::string parent_id = "parent"; |
880 std::string experiment_id = "experiment"; | 870 std::string experiment_id = "experiment"; |
881 sync_pb::EntitySpecifics specifics; | 871 sync_pb::EntitySpecifics specifics; |
882 specifics.mutable_experiments()->mutable_keystore_encryption()-> | 872 specifics.mutable_experiments()->mutable_keystore_encryption()-> |
883 set_enabled(true); | 873 set_enabled(true); |
884 int64 experiment_handle = entry_factory_->CreateUnappliedNewItemWithParent( | 874 int64_t experiment_handle = entry_factory_->CreateUnappliedNewItemWithParent( |
885 experiment_id, specifics, parent_id); | 875 experiment_id, specifics, parent_id); |
886 int64 parent_handle = entry_factory_->CreateUnappliedNewItem( | 876 int64_t parent_handle = |
887 parent_id, specifics, true); | 877 entry_factory_->CreateUnappliedNewItem(parent_id, specifics, true); |
888 ApplyControlDataUpdates(directory()); | 878 ApplyControlDataUpdates(directory()); |
889 | 879 |
890 EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(parent_handle)); | 880 EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(parent_handle)); |
891 EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(experiment_handle)); | 881 EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(experiment_handle)); |
892 EXPECT_TRUE( | 882 EXPECT_TRUE( |
893 entry_factory_->GetLocalSpecificsForItem(experiment_handle). | 883 entry_factory_->GetLocalSpecificsForItem(experiment_handle). |
894 experiments().keystore_encryption().enabled()); | 884 experiments().keystore_encryption().enabled()); |
895 } | 885 } |
896 | 886 |
897 // Verify that we handle control datatype conflicts by preserving the server | 887 // Verify that we handle control datatype conflicts by preserving the server |
898 // data. | 888 // data. |
899 TEST_F(ApplyControlDataUpdatesTest, ControlConflict) { | 889 TEST_F(ApplyControlDataUpdatesTest, ControlConflict) { |
900 std::string experiment_id = "experiment"; | 890 std::string experiment_id = "experiment"; |
901 sync_pb::EntitySpecifics local_specifics, server_specifics; | 891 sync_pb::EntitySpecifics local_specifics, server_specifics; |
902 server_specifics.mutable_experiments()->mutable_keystore_encryption()-> | 892 server_specifics.mutable_experiments()->mutable_keystore_encryption()-> |
903 set_enabled(true); | 893 set_enabled(true); |
904 local_specifics.mutable_experiments()->mutable_keystore_encryption()-> | 894 local_specifics.mutable_experiments()->mutable_keystore_encryption()-> |
905 set_enabled(false); | 895 set_enabled(false); |
906 int64 experiment_handle = entry_factory_->CreateSyncedItem( | 896 int64_t experiment_handle = |
907 experiment_id, EXPERIMENTS, false); | 897 entry_factory_->CreateSyncedItem(experiment_id, EXPERIMENTS, false); |
908 entry_factory_->SetServerSpecificsForItem(experiment_handle, | 898 entry_factory_->SetServerSpecificsForItem(experiment_handle, |
909 server_specifics); | 899 server_specifics); |
910 entry_factory_->SetLocalSpecificsForItem(experiment_handle, | 900 entry_factory_->SetLocalSpecificsForItem(experiment_handle, |
911 local_specifics); | 901 local_specifics); |
912 ApplyControlDataUpdates(directory()); | 902 ApplyControlDataUpdates(directory()); |
913 | 903 |
914 EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(experiment_handle)); | 904 EXPECT_FALSE(entry_factory_->GetIsUnappliedForItem(experiment_handle)); |
915 EXPECT_TRUE( | 905 EXPECT_TRUE( |
916 entry_factory_->GetLocalSpecificsForItem(experiment_handle). | 906 entry_factory_->GetLocalSpecificsForItem(experiment_handle). |
917 experiments().keystore_encryption().enabled()); | 907 experiments().keystore_encryption().enabled()); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 ApplyControlDataUpdates(directory()); | 964 ApplyControlDataUpdates(directory()); |
975 | 965 |
976 // After applying the updates NIGORI should be marked as having its | 966 // After applying the updates NIGORI should be marked as having its |
977 // initial sync completed. | 967 // initial sync completed. |
978 EXPECT_TRUE(directory()->InitialSyncEndedForType(NIGORI)); | 968 EXPECT_TRUE(directory()->InitialSyncEndedForType(NIGORI)); |
979 // Verify that there is no side effect on another control type. | 969 // Verify that there is no side effect on another control type. |
980 EXPECT_FALSE(directory()->InitialSyncEndedForType(EXPERIMENTS)); | 970 EXPECT_FALSE(directory()->InitialSyncEndedForType(EXPERIMENTS)); |
981 } | 971 } |
982 | 972 |
983 } // namespace syncer | 973 } // namespace syncer |
OLD | NEW |