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

Side by Side Diff: chrome/browser/sync/internal_api/syncapi_unittest.cc

Issue 7878005: [Sync] Fix encrypting of sync titles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and add comment Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 using browser_sync::JsEventHandler; 61 using browser_sync::JsEventHandler;
62 using browser_sync::JsReplyHandler; 62 using browser_sync::JsReplyHandler;
63 using browser_sync::MockJsEventHandler; 63 using browser_sync::MockJsEventHandler;
64 using browser_sync::MockJsReplyHandler; 64 using browser_sync::MockJsReplyHandler;
65 using browser_sync::ModelSafeRoutingInfo; 65 using browser_sync::ModelSafeRoutingInfo;
66 using browser_sync::ModelSafeWorker; 66 using browser_sync::ModelSafeWorker;
67 using browser_sync::ModelSafeWorkerRegistrar; 67 using browser_sync::ModelSafeWorkerRegistrar;
68 using browser_sync::sessions::SyncSessionSnapshot; 68 using browser_sync::sessions::SyncSessionSnapshot;
69 using browser_sync::WeakHandle; 69 using browser_sync::WeakHandle;
70 using syncable::GetAllRealModelTypes; 70 using syncable::GetAllRealModelTypes;
71 using syncable::kEncryptedString;
71 using syncable::ModelType; 72 using syncable::ModelType;
72 using syncable::ModelTypeSet; 73 using syncable::ModelTypeSet;
73 using test::ExpectDictDictionaryValue; 74 using test::ExpectDictDictionaryValue;
74 using test::ExpectDictStringValue; 75 using test::ExpectDictStringValue;
75 using testing::_; 76 using testing::_;
76 using testing::AnyNumber; 77 using testing::AnyNumber;
77 using testing::AtLeast; 78 using testing::AtLeast;
78 using testing::InSequence; 79 using testing::InSequence;
79 using testing::Invoke; 80 using testing::Invoke;
80 using testing::SaveArg; 81 using testing::SaveArg;
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 396
396 ReadNode password_node(&trans); 397 ReadNode password_node(&trans);
397 EXPECT_TRUE(password_node.InitByClientTagLookup(syncable::PASSWORDS, 398 EXPECT_TRUE(password_node.InitByClientTagLookup(syncable::PASSWORDS,
398 "foo")); 399 "foo"));
399 const sync_pb::PasswordSpecificsData& data = 400 const sync_pb::PasswordSpecificsData& data =
400 password_node.GetPasswordSpecifics(); 401 password_node.GetPasswordSpecifics();
401 EXPECT_EQ("secret", data.password_value()); 402 EXPECT_EQ("secret", data.password_value());
402 } 403 }
403 } 404 }
404 405
406 TEST_F(SyncApiTest, WriteEncryptedTitle) {
407 KeyParams params = {"localhost", "username", "passphrase"};
408 {
409 ReadTransaction trans(FROM_HERE, test_user_share_.user_share());
410 trans.GetCryptographer()->AddKey(params);
411 trans.GetCryptographer()->set_encrypt_everything();
412 }
413 {
414 WriteTransaction trans(FROM_HERE, test_user_share_.user_share());
415 ReadNode root_node(&trans);
416 root_node.InitByRootLookup();
417
418 WriteNode bookmark_node(&trans);
419 EXPECT_TRUE(bookmark_node.InitUniqueByCreation(syncable::BOOKMARKS,
420 root_node, "foo"));
421 bookmark_node.SetTitle(UTF8ToWide("foo"));
422
423 WriteNode pref_node(&trans);
424 EXPECT_TRUE(pref_node.InitUniqueByCreation(syncable::PREFERENCES,
425 root_node, "bar"));
426 pref_node.SetTitle(UTF8ToWide("bar"));
427 }
428 {
429 ReadTransaction trans(FROM_HERE, test_user_share_.user_share());
430 ReadNode root_node(&trans);
431 root_node.InitByRootLookup();
432
433 ReadNode bookmark_node(&trans);
434 EXPECT_TRUE(bookmark_node.InitByClientTagLookup(syncable::BOOKMARKS,
435 "foo"));
436 EXPECT_EQ("foo", bookmark_node.GetTitle());
437 EXPECT_EQ(kEncryptedString,
438 bookmark_node.GetEntry()->Get(syncable::NON_UNIQUE_NAME));
439
440 ReadNode pref_node(&trans);
441 EXPECT_TRUE(pref_node.InitByClientTagLookup(syncable::PREFERENCES,
442 "bar"));
443 EXPECT_EQ(kEncryptedString, pref_node.GetTitle());
444 }
445 }
446
405 TEST_F(SyncApiTest, BaseNodeSetSpecifics) { 447 TEST_F(SyncApiTest, BaseNodeSetSpecifics) {
406 int64 child_id = MakeNode(test_user_share_.user_share(), 448 int64 child_id = MakeNode(test_user_share_.user_share(),
407 syncable::BOOKMARKS, "testtag"); 449 syncable::BOOKMARKS, "testtag");
408 WriteTransaction trans(FROM_HERE, test_user_share_.user_share()); 450 WriteTransaction trans(FROM_HERE, test_user_share_.user_share());
409 WriteNode node(&trans); 451 WriteNode node(&trans);
410 EXPECT_TRUE(node.InitByIdLookup(child_id)); 452 EXPECT_TRUE(node.InitByIdLookup(child_id));
411 453
412 sync_pb::EntitySpecifics entity_specifics; 454 sync_pb::EntitySpecifics entity_specifics;
413 entity_specifics.MutableExtension(sync_pb::bookmark)-> 455 entity_specifics.MutableExtension(sync_pb::bookmark)->
414 set_url("http://www.google.com"); 456 set_url("http://www.google.com");
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1507 ReadNode node(&trans); 1549 ReadNode node(&trans);
1508 EXPECT_TRUE(node.InitByIdLookup(node1)); 1550 EXPECT_TRUE(node.InitByIdLookup(node1));
1509 EXPECT_EQ(syncable::BOOKMARKS, node.GetModelType()); 1551 EXPECT_EQ(syncable::BOOKMARKS, node.GetModelType());
1510 EXPECT_EQ(title, node.GetTitle()); 1552 EXPECT_EQ(title, node.GetTitle());
1511 EXPECT_EQ(title, node.GetBookmarkSpecifics().title()); 1553 EXPECT_EQ(title, node.GetBookmarkSpecifics().title());
1512 EXPECT_EQ(url, node.GetBookmarkSpecifics().url()); 1554 EXPECT_EQ(url, node.GetBookmarkSpecifics().url());
1513 } 1555 }
1514 } 1556 }
1515 1557
1516 } // namespace browser_sync 1558 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncer_unittest.cc ('k') | chrome/browser/sync/internal_api/write_node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698