OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/sync/util/cryptographer.h" | |
6 #include "chrome/browser/sync/syncable/nigori_util.h" | |
7 #include "testing/gtest/include/gtest/gtest.h" | |
8 | |
9 namespace syncable { | |
10 | |
11 typedef testing::Test NigoriUtilTest; | |
12 | |
13 TEST_F(NigoriUtilTest, NigoriEncryptionTypes) { | |
14 browser_sync::Cryptographer cryptographer; | |
15 sync_pb::NigoriSpecifics nigori; | |
16 ModelTypeSet encrypted_types; | |
17 encrypted_types.insert(syncable::PASSWORDS); | |
18 FillNigoriEncryptedTypes(encrypted_types, &nigori); | |
19 cryptographer.SetEncryptedTypes(nigori); | |
20 ModelTypeSet test_types = cryptographer.GetEncryptedTypes(); | |
21 EXPECT_EQ(encrypted_types, test_types); | |
22 | |
23 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { | |
24 encrypted_types.insert(ModelTypeFromInt(i)); | |
25 } | |
26 FillNigoriEncryptedTypes(encrypted_types, &nigori); | |
27 cryptographer.SetEncryptedTypes(nigori); | |
28 test_types = cryptographer.GetEncryptedTypes(); | |
29 encrypted_types.erase(syncable::NIGORI); // Should not get set. | |
30 EXPECT_EQ(encrypted_types, test_types); | |
31 | |
32 encrypted_types.erase(syncable::BOOKMARKS); | |
33 encrypted_types.erase(syncable::SESSIONS); | |
34 FillNigoriEncryptedTypes(encrypted_types, &nigori); | |
35 cryptographer.SetEncryptedTypes(nigori); | |
36 test_types = cryptographer.GetEncryptedTypes(); | |
37 EXPECT_EQ(encrypted_types, test_types); | |
38 } | |
39 | |
40 // ProcessUnsyncedChangesForEncryption and other methods that rely on the syncer | |
41 // are tested in apply_updates_command_unittest.cc | |
42 | |
43 } // namespace syncable | |
OLD | NEW |