Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1314 true /* is encrypted */)); | 1314 true /* is encrypted */)); |
| 1315 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), | 1315 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), |
| 1316 syncable::SESSIONS, | 1316 syncable::SESSIONS, |
| 1317 true /* is encrypted */)); | 1317 true /* is encrypted */)); |
| 1318 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), | 1318 EXPECT_TRUE(syncable::VerifyDataTypeEncryption(trans.GetWrappedTrans(), |
| 1319 syncable::THEMES, | 1319 syncable::THEMES, |
| 1320 false /* not encrypted */)); | 1320 false /* not encrypted */)); |
| 1321 } | 1321 } |
| 1322 } | 1322 } |
| 1323 | 1323 |
| 1324 TEST_F(SyncManagerTest, SetPassphraseWithPassword) { | |
| 1325 EXPECT_TRUE(SetUpEncryption()); | |
| 1326 { | |
| 1327 WriteTransaction trans(sync_manager_.GetUserShare()); | |
| 1328 ReadNode root_node(&trans); | |
| 1329 root_node.InitByRootLookup(); | |
| 1330 | |
| 1331 WriteNode password_node(&trans); | |
| 1332 EXPECT_TRUE(password_node.InitUniqueByCreation(syncable::PASSWORDS, | |
| 1333 root_node, "foo")); | |
| 1334 sync_pb::PasswordSpecificsData data; | |
| 1335 data.set_password_value("secret"); | |
| 1336 password_node.SetPasswordSpecifics(data); | |
| 1337 } | |
| 1338 EXPECT_CALL(observer_, OnPassphraseAccepted(_)); | |
| 1339 EXPECT_CALL(observer_, OnEncryptionComplete(_)); | |
| 1340 sync_manager_.SetPassphrase("new_passphrase", true); | |
| 1341 { | |
| 1342 ReadTransaction trans(sync_manager_.GetUserShare()); | |
| 1343 ReadNode root_node(&trans); | |
| 1344 root_node.InitByRootLookup(); | |
| 1345 | |
| 1346 ReadNode password_node(&trans); | |
| 1347 EXPECT_TRUE(password_node.InitByClientTagLookup(syncable::PASSWORDS, | |
| 1348 "foo")); | |
| 1349 const sync_pb::PasswordSpecificsData& data = | |
| 1350 password_node.GetPasswordSpecifics(); | |
| 1351 EXPECT_EQ("secret", data.password_value()); | |
| 1352 } | |
| 1353 } | |
| 1354 | |
| 1355 TEST_F(SyncManagerTest, SetPassphraseWithEmptyPasswordNode) { | |
| 1356 EXPECT_TRUE(SetUpEncryption()); | |
| 1357 int64 node_id = 0; | |
| 1358 std::string tag = "foo"; | |
| 1359 { | |
| 1360 WriteTransaction trans(sync_manager_.GetUserShare()); | |
| 1361 ReadNode root_node(&trans); | |
| 1362 root_node.InitByRootLookup(); | |
| 1363 | |
| 1364 WriteNode password_node(&trans); | |
| 1365 EXPECT_TRUE(password_node.InitUniqueByCreation(syncable::PASSWORDS, | |
| 1366 root_node, tag)); | |
| 1367 sync_pb::PasswordSpecificsData data; | |
| 1368 password_node.SetPasswordSpecifics(data); | |
|
tim (not reviewing)
2011/06/13 17:43:22
Is this legal?
Nicolas Zea
2011/06/13 18:38:22
Not really, but I primarily want to test that SetP
| |
| 1369 node_id = password_node.GetId(); | |
| 1370 } | |
| 1371 EXPECT_CALL(observer_, OnPassphraseAccepted(_)); | |
| 1372 EXPECT_CALL(observer_, OnEncryptionComplete(_)); | |
| 1373 sync_manager_.SetPassphrase("new_passphrase", true); | |
| 1374 { | |
| 1375 ReadTransaction trans(sync_manager_.GetUserShare()); | |
| 1376 ReadNode root_node(&trans); | |
| 1377 root_node.InitByRootLookup(); | |
| 1378 | |
| 1379 ReadNode password_node(&trans); | |
| 1380 EXPECT_FALSE(password_node.InitByClientTagLookup(syncable::PASSWORDS, | |
| 1381 tag)); | |
| 1382 } | |
| 1383 { | |
| 1384 ReadTransaction trans(sync_manager_.GetUserShare()); | |
| 1385 ReadNode root_node(&trans); | |
| 1386 root_node.InitByRootLookup(); | |
| 1387 | |
| 1388 ReadNode password_node(&trans); | |
| 1389 EXPECT_FALSE(password_node.InitByIdLookup(node_id)); | |
| 1390 } | |
| 1391 } | |
| 1392 | |
| 1324 } // namespace | 1393 } // namespace |
| 1325 | 1394 |
| 1326 } // namespace browser_sync | 1395 } // namespace browser_sync |
| OLD | NEW |