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

Side by Side Diff: chrome/browser/sync/syncable/nigori_util_unittest.cc

Issue 7806005: Revert 98770 - Merge 98758 - [Sync] Gracefully handle writing to a node when the cryptographer is... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/835/src/
Patch Set: 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
« no previous file with comments | « chrome/browser/sync/syncable/nigori_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/sync/protocol/bookmark_specifics.pb.h"
6 #include "chrome/browser/sync/util/cryptographer.h" 5 #include "chrome/browser/sync/util/cryptographer.h"
7 #include "chrome/browser/sync/syncable/nigori_util.h" 6 #include "chrome/browser/sync/syncable/nigori_util.h"
8 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
9 8
10 namespace syncable { 9 namespace syncable {
11 10
12 typedef testing::Test NigoriUtilTest; 11 typedef testing::Test NigoriUtilTest;
13 12
14 TEST_F(NigoriUtilTest, NigoriEncryptionTypes) { 13 TEST_F(NigoriUtilTest, NigoriEncryptionTypes) {
15 browser_sync::Cryptographer cryptographer; 14 browser_sync::Cryptographer cryptographer;
(...skipping 15 matching lines...) Expand all
31 EXPECT_EQ(encrypted_types, test_types); 30 EXPECT_EQ(encrypted_types, test_types);
32 31
33 encrypted_types.erase(syncable::BOOKMARKS); 32 encrypted_types.erase(syncable::BOOKMARKS);
34 encrypted_types.erase(syncable::SESSIONS); 33 encrypted_types.erase(syncable::SESSIONS);
35 FillNigoriEncryptedTypes(encrypted_types, &nigori); 34 FillNigoriEncryptedTypes(encrypted_types, &nigori);
36 cryptographer.SetEncryptedTypes(nigori); 35 cryptographer.SetEncryptedTypes(nigori);
37 test_types = cryptographer.GetEncryptedTypes(); 36 test_types = cryptographer.GetEncryptedTypes();
38 EXPECT_EQ(encrypted_types, test_types); 37 EXPECT_EQ(encrypted_types, test_types);
39 } 38 }
40 39
41 TEST(NigoriUtilTest, SpecificsNeedsEncryption) {
42 ModelTypeSet encrypted_types;
43 encrypted_types.insert(BOOKMARKS);
44 encrypted_types.insert(PASSWORDS);
45
46 sync_pb::EntitySpecifics specifics;
47 EXPECT_FALSE(SpecificsNeedsEncryption(ModelTypeSet(), specifics));
48 EXPECT_FALSE(SpecificsNeedsEncryption(encrypted_types, specifics));
49
50 AddDefaultExtensionValue(PREFERENCES, &specifics);
51 EXPECT_FALSE(SpecificsNeedsEncryption(encrypted_types, specifics));
52
53 sync_pb::EntitySpecifics bookmark_specifics;
54 AddDefaultExtensionValue(BOOKMARKS, &bookmark_specifics);
55 EXPECT_TRUE(SpecificsNeedsEncryption(encrypted_types, bookmark_specifics));
56
57 bookmark_specifics.MutableExtension(sync_pb::bookmark)->set_title("title");
58 bookmark_specifics.MutableExtension(sync_pb::bookmark)->set_url("url");
59 EXPECT_TRUE(SpecificsNeedsEncryption(encrypted_types, bookmark_specifics));
60 EXPECT_FALSE(SpecificsNeedsEncryption(ModelTypeSet(), bookmark_specifics));
61
62 bookmark_specifics.mutable_encrypted();
63 EXPECT_FALSE(SpecificsNeedsEncryption(encrypted_types, bookmark_specifics));
64 EXPECT_FALSE(SpecificsNeedsEncryption(ModelTypeSet(), bookmark_specifics));
65
66 sync_pb::EntitySpecifics password_specifics;
67 AddDefaultExtensionValue(PASSWORDS, &password_specifics);
68 EXPECT_FALSE(SpecificsNeedsEncryption(encrypted_types, password_specifics));
69 }
70
71 // ProcessUnsyncedChangesForEncryption and other methods that rely on the syncer 40 // ProcessUnsyncedChangesForEncryption and other methods that rely on the syncer
72 // are tested in apply_updates_command_unittest.cc 41 // are tested in apply_updates_command_unittest.cc
73 42
74 } // namespace syncable 43 } // namespace syncable
OLDNEW
« no previous file with comments | « chrome/browser/sync/syncable/nigori_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698