OLD | NEW |
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 #include "sync/internal_api/sync_encryption_handler_impl.h" | 5 #include "sync/internal_api/sync_encryption_handler_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 sync_pb::NigoriSpecifics nigori; | 416 sync_pb::NigoriSpecifics nigori; |
417 nigori.set_encrypt_everything(true); | 417 nigori.set_encrypt_everything(true); |
418 | 418 |
419 EXPECT_CALL(*observer(), | 419 EXPECT_CALL(*observer(), |
420 OnEncryptedTypesChanged( | 420 OnEncryptedTypesChanged( |
421 HasModelTypes(EncryptableUserTypes()), true)); | 421 HasModelTypes(EncryptableUserTypes()), true)); |
422 | 422 |
423 EXPECT_FALSE(encryption_handler()->EncryptEverythingEnabled()); | 423 EXPECT_FALSE(encryption_handler()->EncryptEverythingEnabled()); |
424 ModelTypeSet encrypted_types = | 424 ModelTypeSet encrypted_types = |
425 encryption_handler()->GetEncryptedTypesUnsafe(); | 425 encryption_handler()->GetEncryptedTypesUnsafe(); |
426 EXPECT_TRUE(encrypted_types.Equals(ModelTypeSet(PASSWORDS))); | 426 EXPECT_TRUE(encrypted_types.Equals( |
| 427 ModelTypeSet(PASSWORDS, WIFI_CREDENTIALS))); |
427 | 428 |
428 { | 429 { |
429 WriteTransaction trans(FROM_HERE, user_share()); | 430 WriteTransaction trans(FROM_HERE, user_share()); |
430 encryption_handler()->UpdateEncryptedTypesFromNigori( | 431 encryption_handler()->UpdateEncryptedTypesFromNigori( |
431 nigori, | 432 nigori, |
432 trans.GetWrappedTrans()); | 433 trans.GetWrappedTrans()); |
433 } | 434 } |
434 | 435 |
435 EXPECT_TRUE(encryption_handler()->EncryptEverythingEnabled()); | 436 EXPECT_TRUE(encryption_handler()->EncryptEverythingEnabled()); |
436 encrypted_types = encryption_handler()->GetEncryptedTypesUnsafe(); | 437 encrypted_types = encryption_handler()->GetEncryptedTypesUnsafe(); |
(...skipping 15 matching lines...) Expand all Loading... |
452 sync_pb::NigoriSpecifics nigori; | 453 sync_pb::NigoriSpecifics nigori; |
453 nigori.set_encrypt_bookmarks(true); // Non-passwords = encrypt everything | 454 nigori.set_encrypt_bookmarks(true); // Non-passwords = encrypt everything |
454 | 455 |
455 EXPECT_CALL(*observer(), | 456 EXPECT_CALL(*observer(), |
456 OnEncryptedTypesChanged( | 457 OnEncryptedTypesChanged( |
457 HasModelTypes(EncryptableUserTypes()), true)); | 458 HasModelTypes(EncryptableUserTypes()), true)); |
458 | 459 |
459 EXPECT_FALSE(encryption_handler()->EncryptEverythingEnabled()); | 460 EXPECT_FALSE(encryption_handler()->EncryptEverythingEnabled()); |
460 ModelTypeSet encrypted_types = | 461 ModelTypeSet encrypted_types = |
461 encryption_handler()->GetEncryptedTypesUnsafe(); | 462 encryption_handler()->GetEncryptedTypesUnsafe(); |
462 EXPECT_TRUE(encrypted_types.Equals(ModelTypeSet(PASSWORDS))); | 463 EXPECT_TRUE(encrypted_types.Equals( |
| 464 ModelTypeSet(PASSWORDS, WIFI_CREDENTIALS))); |
463 | 465 |
464 { | 466 { |
465 WriteTransaction trans(FROM_HERE, user_share()); | 467 WriteTransaction trans(FROM_HERE, user_share()); |
466 encryption_handler()->UpdateEncryptedTypesFromNigori( | 468 encryption_handler()->UpdateEncryptedTypesFromNigori( |
467 nigori, | 469 nigori, |
468 trans.GetWrappedTrans()); | 470 trans.GetWrappedTrans()); |
469 } | 471 } |
470 | 472 |
471 EXPECT_TRUE(encryption_handler()->EncryptEverythingEnabled()); | 473 EXPECT_TRUE(encryption_handler()->EncryptEverythingEnabled()); |
472 encrypted_types = encryption_handler()->GetEncryptedTypesUnsafe(); | 474 encrypted_types = encryption_handler()->GetEncryptedTypesUnsafe(); |
(...skipping 23 matching lines...) Expand all Loading... |
496 SyncEncryptionHandler::SensitiveTypes(); | 498 SyncEncryptionHandler::SensitiveTypes(); |
497 expected_encrypted_types.Put(BOOKMARKS); | 499 expected_encrypted_types.Put(BOOKMARKS); |
498 | 500 |
499 EXPECT_CALL(*observer(), | 501 EXPECT_CALL(*observer(), |
500 OnEncryptedTypesChanged( | 502 OnEncryptedTypesChanged( |
501 HasModelTypes(expected_encrypted_types), false)); | 503 HasModelTypes(expected_encrypted_types), false)); |
502 | 504 |
503 EXPECT_FALSE(encryption_handler()->EncryptEverythingEnabled()); | 505 EXPECT_FALSE(encryption_handler()->EncryptEverythingEnabled()); |
504 ModelTypeSet encrypted_types = | 506 ModelTypeSet encrypted_types = |
505 encryption_handler()->GetEncryptedTypesUnsafe(); | 507 encryption_handler()->GetEncryptedTypesUnsafe(); |
506 EXPECT_TRUE(encrypted_types.Equals(ModelTypeSet(PASSWORDS))); | 508 EXPECT_TRUE(encrypted_types.Equals( |
| 509 ModelTypeSet(PASSWORDS, WIFI_CREDENTIALS))); |
507 | 510 |
508 { | 511 { |
509 WriteTransaction trans(FROM_HERE, user_share()); | 512 WriteTransaction trans(FROM_HERE, user_share()); |
510 encryption_handler()->UpdateEncryptedTypesFromNigori( | 513 encryption_handler()->UpdateEncryptedTypesFromNigori( |
511 nigori, | 514 nigori, |
512 trans.GetWrappedTrans()); | 515 trans.GetWrappedTrans()); |
513 } | 516 } |
514 | 517 |
515 EXPECT_FALSE(encryption_handler()->EncryptEverythingEnabled()); | 518 EXPECT_FALSE(encryption_handler()->EncryptEverythingEnabled()); |
516 encrypted_types = encryption_handler()->GetEncryptedTypesUnsafe(); | 519 encrypted_types = encryption_handler()->GetEncryptedTypesUnsafe(); |
517 EXPECT_TRUE(encrypted_types.Equals(ModelTypeSet(BOOKMARKS, PASSWORDS))); | 520 EXPECT_TRUE(encrypted_types.Equals( |
| 521 ModelTypeSet(BOOKMARKS, PASSWORDS, WIFI_CREDENTIALS))); |
518 } | 522 } |
519 | 523 |
520 // Receive an old nigori with old encryption keys and encrypted types. We should | 524 // Receive an old nigori with old encryption keys and encrypted types. We should |
521 // not revert our default key or encrypted types, and should post a task to | 525 // not revert our default key or encrypted types, and should post a task to |
522 // overwrite the existing nigori with the correct data. | 526 // overwrite the existing nigori with the correct data. |
523 TEST_F(SyncEncryptionHandlerImplTest, ReceiveOldNigori) { | 527 TEST_F(SyncEncryptionHandlerImplTest, ReceiveOldNigori) { |
524 KeyParams old_key = {"localhost", "dummy", "old"}; | 528 KeyParams old_key = {"localhost", "dummy", "old"}; |
525 KeyParams current_key = {"localhost", "dummy", "cur"}; | 529 KeyParams current_key = {"localhost", "dummy", "cur"}; |
526 | 530 |
527 // Data for testing encryption/decryption. | 531 // Data for testing encryption/decryption. |
(...skipping 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2273 encryption_handler()->SetKeystoreKeys(keys, | 2277 encryption_handler()->SetKeystoreKeys(keys, |
2274 trans.GetWrappedTrans()); | 2278 trans.GetWrappedTrans()); |
2275 } | 2279 } |
2276 PumpLoop(); | 2280 PumpLoop(); |
2277 Mock::VerifyAndClearExpectations(observer()); | 2281 Mock::VerifyAndClearExpectations(observer()); |
2278 | 2282 |
2279 VerifyMigratedNigoriWithTimestamp(1, CUSTOM_PASSPHRASE, kCustomPass); | 2283 VerifyMigratedNigoriWithTimestamp(1, CUSTOM_PASSPHRASE, kCustomPass); |
2280 } | 2284 } |
2281 | 2285 |
2282 } // namespace syncer | 2286 } // namespace syncer |
OLD | NEW |