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

Side by Side Diff: components/sync/core_impl/sync_manager_impl_unittest.cc

Issue 2294913009: Fill the un-encrypted metadata field in password specifics. (Closed)
Patch Set: additional test Created 4 years, 2 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
OLDNEW
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 // 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 "components/sync/core_impl/sync_manager_impl.h" 9 #include "components/sync/core_impl/sync_manager_impl.h"
10 10
11 #include <stdint.h> 11 #include <stdint.h>
12 12
13 #include <cstddef> 13 #include <cstddef>
14 #include <map> 14 #include <map>
15 #include <memory> 15 #include <memory>
16 #include <utility> 16 #include <utility>
17 17
18 #include "base/callback.h" 18 #include "base/callback.h"
19 #include "base/compiler_specific.h" 19 #include "base/compiler_specific.h"
20 #include "base/files/scoped_temp_dir.h" 20 #include "base/files/scoped_temp_dir.h"
21 #include "base/format_macros.h" 21 #include "base/format_macros.h"
22 #include "base/location.h" 22 #include "base/location.h"
23 #include "base/metrics/field_trial.h"
23 #include "base/run_loop.h" 24 #include "base/run_loop.h"
24 #include "base/strings/string_number_conversions.h" 25 #include "base/strings/string_number_conversions.h"
25 #include "base/strings/stringprintf.h" 26 #include "base/strings/stringprintf.h"
26 #include "base/strings/utf_string_conversions.h" 27 #include "base/strings/utf_string_conversions.h"
27 #include "base/test/values_test_util.h" 28 #include "base/test/values_test_util.h"
28 #include "base/values.h" 29 #include "base/values.h"
29 #include "components/sync/base/attachment_id_proto.h" 30 #include "components/sync/base/attachment_id_proto.h"
30 #include "components/sync/base/cancelation_signal.h" 31 #include "components/sync/base/cancelation_signal.h"
31 #include "components/sync/base/cryptographer.h" 32 #include "components/sync/base/cryptographer.h"
32 #include "components/sync/base/extensions_activity.h" 33 #include "components/sync/base/extensions_activity.h"
33 #include "components/sync/base/fake_encryptor.h" 34 #include "components/sync/base/fake_encryptor.h"
34 #include "components/sync/base/mock_unrecoverable_error_handler.h" 35 #include "components/sync/base/mock_unrecoverable_error_handler.h"
35 #include "components/sync/base/model_type_test_util.h" 36 #include "components/sync/base/model_type_test_util.h"
36 #include "components/sync/base/time.h" 37 #include "components/sync/base/time.h"
37 #include "components/sync/core/change_record.h" 38 #include "components/sync/core/change_record.h"
38 #include "components/sync/core/http_post_provider_factory.h" 39 #include "components/sync/core/http_post_provider_factory.h"
39 #include "components/sync/core/http_post_provider_interface.h" 40 #include "components/sync/core/http_post_provider_interface.h"
40 #include "components/sync/core/read_node.h" 41 #include "components/sync/core/read_node.h"
41 #include "components/sync/core/read_transaction.h" 42 #include "components/sync/core/read_transaction.h"
43 #include "components/sync/core/sync_features.h"
42 #include "components/sync/core/test/test_entry_factory.h" 44 #include "components/sync/core/test/test_entry_factory.h"
43 #include "components/sync/core/test/test_internal_components_factory.h" 45 #include "components/sync/core/test/test_internal_components_factory.h"
44 #include "components/sync/core/test/test_user_share.h" 46 #include "components/sync/core/test/test_user_share.h"
45 #include "components/sync/core/write_node.h" 47 #include "components/sync/core/write_node.h"
46 #include "components/sync/core/write_transaction.h" 48 #include "components/sync/core/write_transaction.h"
47 #include "components/sync/core_impl/sync_encryption_handler_impl.h" 49 #include "components/sync/core_impl/sync_encryption_handler_impl.h"
48 #include "components/sync/core_impl/syncapi_internal.h" 50 #include "components/sync/core_impl/syncapi_internal.h"
49 #include "components/sync/engine/events/protocol_event.h" 51 #include "components/sync/engine/events/protocol_event.h"
50 #include "components/sync/engine/model_safe_worker.h" 52 #include "components/sync/engine/model_safe_worker.h"
51 #include "components/sync/engine/polling_constants.h" 53 #include "components/sync/engine/polling_constants.h"
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 ReadNode node(&trans); 505 ReadNode node(&trans);
504 EXPECT_EQ(BaseNode::INIT_OK, 506 EXPECT_EQ(BaseNode::INIT_OK,
505 node.InitByClientTagLookup(BOOKMARKS, "testtag")); 507 node.InitByClientTagLookup(BOOKMARKS, "testtag"));
506 EXPECT_EQ(node.GetTitle(), test_title); 508 EXPECT_EQ(node.GetTitle(), test_title);
507 EXPECT_EQ(node.GetModelType(), BOOKMARKS); 509 EXPECT_EQ(node.GetModelType(), BOOKMARKS);
508 } 510 }
509 } 511 }
510 512
511 TEST_F(SyncApiTest, WriteAndReadPassword) { 513 TEST_F(SyncApiTest, WriteAndReadPassword) {
512 KeyParams params = {"localhost", "username", "passphrase"}; 514 KeyParams params = {"localhost", "username", "passphrase"};
515 base::FeatureList::ClearInstanceForTesting();
516 EXPECT_FALSE(base::FeatureList::IsEnabled(kFillPasswordMetadata));
517
513 { 518 {
514 ReadTransaction trans(FROM_HERE, user_share()); 519 ReadTransaction trans(FROM_HERE, user_share());
515 trans.GetCryptographer()->AddKey(params); 520 trans.GetCryptographer()->AddKey(params);
516 } 521 }
522
517 { 523 {
518 WriteTransaction trans(FROM_HERE, user_share()); 524 WriteTransaction trans(FROM_HERE, user_share());
519 ReadNode root_node(&trans); 525 ReadNode root_node(&trans);
520 root_node.InitByRootLookup(); 526 root_node.InitByRootLookup();
521 527
522 WriteNode password_node(&trans); 528 WriteNode password_node(&trans);
523 WriteNode::InitUniqueByCreationResult result = 529 WriteNode::InitUniqueByCreationResult result =
524 password_node.InitUniqueByCreation(PASSWORDS, root_node, kClientTag); 530 password_node.InitUniqueByCreation(PASSWORDS, root_node, kClientTag);
525 EXPECT_EQ(WriteNode::INIT_SUCCESS, result); 531 EXPECT_EQ(WriteNode::INIT_SUCCESS, result);
526 sync_pb::PasswordSpecificsData data; 532 sync_pb::PasswordSpecificsData data;
527 data.set_password_value(kPasswordValue); 533 data.set_password_value(kPasswordValue);
528 password_node.SetPasswordSpecifics(data); 534 password_node.SetPasswordSpecifics(data);
529 } 535 }
530 { 536 {
531 ReadTransaction trans(FROM_HERE, user_share()); 537 ReadTransaction trans(FROM_HERE, user_share());
532 538
533 ReadNode password_node(&trans); 539 ReadNode password_node(&trans);
534 EXPECT_EQ(BaseNode::INIT_OK, 540 EXPECT_EQ(BaseNode::INIT_OK,
535 password_node.InitByClientTagLookup(PASSWORDS, kClientTag)); 541 password_node.InitByClientTagLookup(PASSWORDS, kClientTag));
536 const sync_pb::PasswordSpecificsData& data = 542 const sync_pb::PasswordSpecificsData& data =
537 password_node.GetPasswordSpecifics(); 543 password_node.GetPasswordSpecifics();
538 EXPECT_EQ(kPasswordValue, data.password_value()); 544 EXPECT_EQ(kPasswordValue, data.password_value());
539 // Check that nothing has appeared in the unencrypted field. 545 // Check that when feature is disabled nothing appears in the unencrypted
546 // field.
540 EXPECT_FALSE(password_node.GetEntitySpecifics() 547 EXPECT_FALSE(password_node.GetEntitySpecifics()
541 .password() 548 .password()
542 .has_unencrypted_metadata()); 549 .has_unencrypted_metadata());
543 } 550 }
544 } 551 }
545 552
553 TEST_F(SyncApiTest, WritePasswordAndCheckMetadata) {
554 KeyParams params = {"localhost", "username", "passphrase"};
555 {
556 ReadTransaction trans(FROM_HERE, user_share());
557 trans.GetCryptographer()->AddKey(params);
558 }
559
560 base::FeatureList::ClearInstanceForTesting();
561 base::FieldTrialList field_trial_list(nullptr);
562 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
563 feature_list->InitializeFromCommandLine(kFillPasswordMetadata.name,
564 std::string());
565 base::FeatureList::SetInstance(std::move(feature_list));
566
567 EXPECT_TRUE(base::FeatureList::IsEnabled(kFillPasswordMetadata));
568 {
569 WriteTransaction trans(FROM_HERE, user_share());
570 ReadNode root_node(&trans);
571 root_node.InitByRootLookup();
572
573 WriteNode password_node(&trans);
574 WriteNode::InitUniqueByCreationResult result =
575 password_node.InitUniqueByCreation(PASSWORDS, root_node, kClientTag);
576 EXPECT_EQ(WriteNode::INIT_SUCCESS, result);
577 sync_pb::PasswordSpecificsData data;
578 data.set_password_value(kPasswordValue);
579 data.set_signon_realm(kUrl);
580 password_node.SetPasswordSpecifics(data);
581 }
582 {
583 ReadTransaction trans(FROM_HERE, user_share());
584
585 ReadNode password_node(&trans);
586 EXPECT_EQ(BaseNode::INIT_OK,
587 password_node.InitByClientTagLookup(PASSWORDS, kClientTag));
588 const sync_pb::PasswordSpecificsData& data =
589 password_node.GetPasswordSpecifics();
590 EXPECT_EQ(kPasswordValue, data.password_value());
591 EXPECT_EQ(kUrl, password_node.GetEntitySpecifics()
592 .password()
593 .unencrypted_metadata()
594 .url());
595 }
596 }
597
546 TEST_F(SyncApiTest, WriteEncryptedTitle) { 598 TEST_F(SyncApiTest, WriteEncryptedTitle) {
547 KeyParams params = {"localhost", "username", "passphrase"}; 599 KeyParams params = {"localhost", "username", "passphrase"};
548 { 600 {
549 ReadTransaction trans(FROM_HERE, user_share()); 601 ReadTransaction trans(FROM_HERE, user_share());
550 trans.GetCryptographer()->AddKey(params); 602 trans.GetCryptographer()->AddKey(params);
551 } 603 }
552 encryption_handler()->EnableEncryptEverything(); 604 encryption_handler()->EnableEncryptEverything();
553 int bookmark_id; 605 int bookmark_id;
554 { 606 {
555 WriteTransaction trans(FROM_HERE, user_share()); 607 WriteTransaction trans(FROM_HERE, user_share());
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after
2048 const syncable::Entry* node_entry = node.GetEntry(); 2100 const syncable::Entry* node_entry = node.GetEntry();
2049 EXPECT_TRUE(node_entry->GetIsUnsynced()); 2101 EXPECT_TRUE(node_entry->GetIsUnsynced());
2050 } 2102 }
2051 } 2103 }
2052 2104
2053 // Passwords have their own handling for encryption. Verify setting a new 2105 // Passwords have their own handling for encryption. Verify setting a new
2054 // passphrase updates the data and clears the unencrypted metadta for passwords. 2106 // passphrase updates the data and clears the unencrypted metadta for passwords.
2055 TEST_F(SyncManagerTest, UpdatePasswordNewPassphrase) { 2107 TEST_F(SyncManagerTest, UpdatePasswordNewPassphrase) {
2056 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION)); 2108 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION));
2057 sync_pb::EntitySpecifics entity_specifics; 2109 sync_pb::EntitySpecifics entity_specifics;
2110 base::FeatureList::ClearInstanceForTesting();
2111 base::FieldTrialList field_trial_list(nullptr);
2112 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
2113 feature_list->InitializeFromCommandLine(kFillPasswordMetadata.name,
2114 std::string());
2115 base::FeatureList::SetInstance(std::move(feature_list));
2058 { 2116 {
2059 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 2117 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2060 Cryptographer* cryptographer = trans.GetCryptographer(); 2118 Cryptographer* cryptographer = trans.GetCryptographer();
2061 sync_pb::PasswordSpecificsData data; 2119 sync_pb::PasswordSpecificsData data;
2062 data.set_password_value(kPasswordValue); 2120 data.set_password_value(kPasswordValue);
2063 entity_specifics.mutable_password() 2121 entity_specifics.mutable_password()
2064 ->mutable_unencrypted_metadata() 2122 ->mutable_unencrypted_metadata()
2065 ->set_url(kUrl); 2123 ->set_url(kUrl);
2066 cryptographer->Encrypt( 2124 cryptographer->Encrypt(
2067 data, entity_specifics.mutable_password()->mutable_encrypted()); 2125 data, entity_specifics.mutable_password()->mutable_encrypted());
(...skipping 19 matching lines...) Expand all
2087 EXPECT_EQ(BaseNode::INIT_OK, 2145 EXPECT_EQ(BaseNode::INIT_OK,
2088 password_node.InitByClientTagLookup(PASSWORDS, kClientTag)); 2146 password_node.InitByClientTagLookup(PASSWORDS, kClientTag));
2089 const sync_pb::PasswordSpecificsData& data = 2147 const sync_pb::PasswordSpecificsData& data =
2090 password_node.GetPasswordSpecifics(); 2148 password_node.GetPasswordSpecifics();
2091 EXPECT_EQ(kPasswordValue, data.password_value()); 2149 EXPECT_EQ(kPasswordValue, data.password_value());
2092 EXPECT_FALSE(password_node.GetEntitySpecifics() 2150 EXPECT_FALSE(password_node.GetEntitySpecifics()
2093 .password() 2151 .password()
2094 .has_unencrypted_metadata()); 2152 .has_unencrypted_metadata());
2095 } 2153 }
2096 EXPECT_TRUE(ResetUnsyncedEntry(PASSWORDS, kClientTag)); 2154 EXPECT_TRUE(ResetUnsyncedEntry(PASSWORDS, kClientTag));
2155 // Check that writing new password doesn't set the metadata.
Nicolas Zea 2016/10/04 20:58:11 nit: newline above
melandory 2016/10/18 08:35:20 Done.
2156 const std::string tag = "newpassentity";
2157 {
2158 WriteTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2159 ReadNode root_node(&trans);
2160 root_node.InitByRootLookup();
2161
2162 WriteNode password_node(&trans);
2163 WriteNode::InitUniqueByCreationResult result =
2164 password_node.InitUniqueByCreation(PASSWORDS, root_node, tag);
2165 EXPECT_EQ(WriteNode::INIT_SUCCESS, result);
2166 sync_pb::PasswordSpecificsData data;
2167 data.set_password_value(kPasswordValue);
2168 data.set_signon_realm(kUrl);
2169 password_node.SetPasswordSpecifics(data);
2170 }
2171 {
2172 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2173 Cryptographer* cryptographer = trans.GetCryptographer();
2174 EXPECT_TRUE(cryptographer->is_ready());
2175 ReadNode password_node(&trans);
2176 EXPECT_EQ(BaseNode::INIT_OK,
2177 password_node.InitByClientTagLookup(PASSWORDS, tag));
2178 const sync_pb::PasswordSpecificsData& data =
2179 password_node.GetPasswordSpecifics();
2180 EXPECT_EQ(kPasswordValue, data.password_value());
2181 EXPECT_FALSE(password_node.GetEntitySpecifics()
2182 .password()
2183 .has_unencrypted_metadata());
2184 }
2097 } 2185 }
2098 2186
2099 // Passwords have their own handling for encryption. Verify it does not result 2187 // Passwords have their own handling for encryption. Verify it does not result
2100 // in unnecessary writes via ReencryptEverything. 2188 // in unnecessary writes via ReencryptEverything.
2101 TEST_F(SyncManagerTest, UpdatePasswordReencryptEverything) { 2189 TEST_F(SyncManagerTest, UpdatePasswordReencryptEverything) {
2102 std::string client_tag = "title"; 2190 base::FeatureList::ClearInstanceForTesting();
2191 EXPECT_FALSE(base::FeatureList::IsEnabled(kFillPasswordMetadata));
2192
2103 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION)); 2193 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION));
2104 sync_pb::EntitySpecifics entity_specifics; 2194 sync_pb::EntitySpecifics entity_specifics;
2105 { 2195 {
2106 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare()); 2196 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2107 Cryptographer* cryptographer = trans.GetCryptographer(); 2197 Cryptographer* cryptographer = trans.GetCryptographer();
2108 sync_pb::PasswordSpecificsData data; 2198 sync_pb::PasswordSpecificsData data;
2109 data.set_password_value("secret"); 2199 data.set_password_value("secret");
2110 cryptographer->Encrypt( 2200 cryptographer->Encrypt(
2111 data, entity_specifics.mutable_password()->mutable_encrypted()); 2201 data, entity_specifics.mutable_password()->mutable_encrypted());
2112 } 2202 }
2113 MakeServerNode(sync_manager_.GetUserShare(), PASSWORDS, client_tag, 2203 MakeServerNode(sync_manager_.GetUserShare(), PASSWORDS, kClientTag,
2114 syncable::GenerateSyncableHash(PASSWORDS, client_tag), 2204 syncable::GenerateSyncableHash(PASSWORDS, kClientTag),
2115 entity_specifics); 2205 entity_specifics);
2116 // New node shouldn't start off unsynced. 2206 // New node shouldn't start off unsynced.
2117 EXPECT_FALSE(ResetUnsyncedEntry(PASSWORDS, client_tag)); 2207 EXPECT_FALSE(ResetUnsyncedEntry(PASSWORDS, kClientTag));
2118 2208
2119 // Force a re-encrypt everything. Should not set is_unsynced. 2209 // Force a re-encrypt everything. Should not set is_unsynced.
2120 testing::Mock::VerifyAndClearExpectations(&encryption_observer_); 2210 testing::Mock::VerifyAndClearExpectations(&encryption_observer_);
2121 EXPECT_CALL(encryption_observer_, OnEncryptionComplete()); 2211 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
2122 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_)); 2212 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
2123 EXPECT_CALL(encryption_observer_, OnEncryptedTypesChanged(_, false)); 2213 EXPECT_CALL(encryption_observer_, OnEncryptedTypesChanged(_, false));
2124 sync_manager_.GetEncryptionHandler()->Init(); 2214 sync_manager_.GetEncryptionHandler()->Init();
2125 PumpLoop(); 2215 PumpLoop();
2126 EXPECT_FALSE(ResetUnsyncedEntry(PASSWORDS, client_tag)); 2216 EXPECT_FALSE(ResetUnsyncedEntry(PASSWORDS, kClientTag));
2217 }
2218
2219 // Metadata filling can happen during ReencryptEverything, check that data is
2220 // written when it's applicable, namely that password specifics entity is marked
2221 // unsynced, when data was written to the unencrypted metadata field.
2222 TEST_F(SyncManagerTest, UpdatePasswordReencryptEverythingFillMetadata) {
2223 base::FeatureList::ClearInstanceForTesting();
2224 base::FieldTrialList field_trial_list(nullptr);
2225 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
2226 feature_list->InitializeFromCommandLine(kFillPasswordMetadata.name,
2227 std::string());
2228 base::FeatureList::SetInstance(std::move(feature_list));
2229 EXPECT_TRUE(base::FeatureList::IsEnabled(kFillPasswordMetadata));
2230
2231 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION));
2232 sync_pb::EntitySpecifics entity_specifics;
2233 {
2234 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2235 Cryptographer* cryptographer = trans.GetCryptographer();
2236 sync_pb::PasswordSpecificsData data;
2237 data.set_password_value("secret");
2238 data.set_signon_realm(kUrl);
2239 cryptographer->Encrypt(
2240 data, entity_specifics.mutable_password()->mutable_encrypted());
2241 }
2242 MakeServerNode(sync_manager_.GetUserShare(), PASSWORDS, kClientTag,
2243 syncable::GenerateSyncableHash(PASSWORDS, kClientTag),
2244 entity_specifics);
2245 // New node shouldn't start off unsynced.
2246 EXPECT_FALSE(ResetUnsyncedEntry(PASSWORDS, kClientTag));
2247
2248 // Force a re-encrypt everything. Should set is_unsynced.
2249 testing::Mock::VerifyAndClearExpectations(&encryption_observer_);
2250 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
2251 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
2252 EXPECT_CALL(encryption_observer_, OnEncryptedTypesChanged(_, false));
2253 sync_manager_.GetEncryptionHandler()->Init();
2254 PumpLoop();
2255 // Check that unencrypted metadata field was set.
2256 {
2257 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2258 Cryptographer* cryptographer = trans.GetCryptographer();
2259 EXPECT_TRUE(cryptographer->is_ready());
2260 ReadNode password_node(&trans);
2261 EXPECT_EQ(BaseNode::INIT_OK,
2262 password_node.InitByClientTagLookup(PASSWORDS, kClientTag));
2263 EXPECT_EQ(kUrl, password_node.GetEntitySpecifics()
2264 .password()
2265 .unencrypted_metadata()
2266 .url());
2267 }
2268
2269 EXPECT_TRUE(ResetUnsyncedEntry(PASSWORDS, kClientTag));
2270 }
2271
2272 // Check that when the data in PasswordSpecifics hasn't changed during
2273 // ReEncryption, entity is not marked as unsynced.
2274 TEST_F(SyncManagerTest,
2275 UpdatePasswordReencryptEverythingDontMarkUnsyncWhenNotNeeded) {
2276 base::FeatureList::ClearInstanceForTesting();
2277 base::FieldTrialList field_trial_list(nullptr);
2278 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
2279 feature_list->InitializeFromCommandLine(kFillPasswordMetadata.name,
2280 std::string());
2281 base::FeatureList::SetInstance(std::move(feature_list));
2282 EXPECT_TRUE(base::FeatureList::IsEnabled(kFillPasswordMetadata));
2283
2284 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION));
2285 sync_pb::EntitySpecifics entity_specifics;
2286 {
2287 ReadTransaction trans(FROM_HERE, sync_manager_.GetUserShare());
2288 Cryptographer* cryptographer = trans.GetCryptographer();
2289 sync_pb::PasswordSpecificsData data;
2290 data.set_password_value("secret");
2291 data.set_signon_realm(kUrl);
2292 cryptographer->Encrypt(
2293 data, entity_specifics.mutable_password()->mutable_encrypted());
2294 }
2295 entity_specifics.mutable_password()->mutable_unencrypted_metadata()->set_url(
2296 kUrl);
2297 MakeServerNode(sync_manager_.GetUserShare(), PASSWORDS, kClientTag,
2298 syncable::GenerateSyncableHash(PASSWORDS, kClientTag),
2299 entity_specifics);
2300 // New node shouldn't start off unsynced.
2301 EXPECT_FALSE(ResetUnsyncedEntry(PASSWORDS, kClientTag));
2302
2303 // Force a re-encrypt everything. Should not set is_unsynced.
2304 testing::Mock::VerifyAndClearExpectations(&encryption_observer_);
2305 EXPECT_CALL(encryption_observer_, OnEncryptionComplete());
2306 EXPECT_CALL(encryption_observer_, OnCryptographerStateChanged(_));
2307 EXPECT_CALL(encryption_observer_, OnEncryptedTypesChanged(_, false));
2308 sync_manager_.GetEncryptionHandler()->Init();
2309 PumpLoop();
2310 EXPECT_FALSE(ResetUnsyncedEntry(PASSWORDS, kClientTag));
2127 } 2311 }
2128 2312
2129 // Test that attempting to start up with corrupted password data triggers 2313 // Test that attempting to start up with corrupted password data triggers
2130 // an unrecoverable error (rather than crashing). 2314 // an unrecoverable error (rather than crashing).
2131 TEST_F(SyncManagerTest, ReencryptEverythingWithUnrecoverableErrorPasswords) { 2315 TEST_F(SyncManagerTest, ReencryptEverythingWithUnrecoverableErrorPasswords) {
2132 const char kClientTag[] = "client_tag"; 2316 const char kClientTag[] = "client_tag";
2133 2317
2134 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION)); 2318 EXPECT_TRUE(SetUpEncryption(WRITE_TO_NIGORI, DEFAULT_ENCRYPTION));
2135 sync_pb::EntitySpecifics entity_specifics; 2319 sync_pb::EntitySpecifics entity_specifics;
2136 { 2320 {
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
3359 // SyncManagerInitInvalidStorageTest::GetFactory will return 3543 // SyncManagerInitInvalidStorageTest::GetFactory will return
3360 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails. 3544 // DirectoryBackingStore that ensures that SyncManagerImpl::OpenDirectory fails.
3361 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's 3545 // SyncManagerImpl initialization is done in SyncManagerTest::SetUp. This test's
3362 // task is to ensure that SyncManagerImpl reported initialization failure in 3546 // task is to ensure that SyncManagerImpl reported initialization failure in
3363 // OnInitializationComplete callback. 3547 // OnInitializationComplete callback.
3364 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) { 3548 TEST_F(SyncManagerInitInvalidStorageTest, FailToOpenDatabase) {
3365 EXPECT_FALSE(initialization_succeeded_); 3549 EXPECT_FALSE(initialization_succeeded_);
3366 } 3550 }
3367 3551
3368 } // namespace syncer 3552 } // namespace syncer
OLDNEW
« components/sync/core/sync_features.cc ('K') | « components/sync/core/write_node.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698