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

Side by Side Diff: sync/internal_api/sync_encryption_handler_impl_unittest.cc

Issue 1250503002: [Sync] Don't require keystore migration time to be set in nigori node (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comment Created 5 years, 5 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
« no previous file with comments | « sync/internal_api/sync_encryption_handler_impl.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 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 2433 matching lines...) Expand 10 before | Expand all | Expand 10 after
2444 // We need the passphrase bootstrap token, but OnBootstrapTokenUpdated(_, 2444 // We need the passphrase bootstrap token, but OnBootstrapTokenUpdated(_,
2445 // PASSPHRASE_BOOTSTRAP_TOKEN) has not been invoked (because it was invoked 2445 // PASSPHRASE_BOOTSTRAP_TOKEN) has not been invoked (because it was invoked
2446 // during a previous instance) so get it from the Cryptographer. 2446 // during a previous instance) so get it from the Cryptographer.
2447 std::string passphrase_bootstrap_token; 2447 std::string passphrase_bootstrap_token;
2448 GetCryptographer()->GetBootstrapToken(&passphrase_bootstrap_token); 2448 GetCryptographer()->GetBootstrapToken(&passphrase_bootstrap_token);
2449 VerifyRestoreAfterCustomPassphrase(migration_time, kCustomPass, 2449 VerifyRestoreAfterCustomPassphrase(migration_time, kCustomPass,
2450 passphrase_bootstrap_token, 2450 passphrase_bootstrap_token,
2451 captured_nigori_state, CUSTOM_PASSPHRASE); 2451 captured_nigori_state, CUSTOM_PASSPHRASE);
2452 } 2452 }
2453 2453
2454 // Verify that the client can gracefully handle a nigori node that is missing
2455 // the keystore migration time field.
2456 TEST_F(SyncEncryptionHandlerImplTest, MissingKeystoreMigrationTime) {
2457 EXPECT_CALL(*observer(),
2458 OnCryptographerStateChanged(_)).Times(AnyNumber());
2459 EXPECT_CALL(*observer(),
2460 OnPassphraseRequired(_, _));
2461 EXPECT_CALL(*observer(),
2462 OnEncryptedTypesChanged(_, false));
2463 encryption_handler()->Init();
2464 Mock::VerifyAndClearExpectations(observer());
2465
2466 // Now simulate downloading a nigori node that that is missing the keystore
2467 // migration time. It should be interpreted properly, and the passphrase type
2468 // should switch to keystore passphrase.
2469 EXPECT_CALL(*observer(),
2470 OnCryptographerStateChanged(_)).Times(AnyNumber());
2471 EXPECT_CALL(*observer(),
2472 OnPassphraseRequired(_, _));
2473 EXPECT_CALL(*observer(),
2474 OnPassphraseTypeChanged(KEYSTORE_PASSPHRASE, _));
2475 {
2476 sync_pb::NigoriSpecifics nigori = BuildMigratedNigori(
2477 KEYSTORE_PASSPHRASE,
2478 1,
2479 kKeystoreKey,
2480 kKeystoreKey);
2481 nigori.clear_keystore_migration_time();
2482 // Update the encryption handler.
2483 WriteTransaction trans(FROM_HERE, user_share());
2484 encryption_handler()->ApplyNigoriUpdate(
2485 nigori,
2486 trans.GetWrappedTrans());
2487 }
2488 Mock::VerifyAndClearExpectations(observer());
2489
2490 // Now provide the keystore key to fully initialize the cryptographer.
2491 EXPECT_CALL(*observer(),
2492 OnCryptographerStateChanged(_)).Times(AnyNumber());
2493 EXPECT_CALL(*observer(),
2494 OnBootstrapTokenUpdated(_, KEYSTORE_BOOTSTRAP_TOKEN));
2495 {
2496 ReadTransaction trans(FROM_HERE, user_share());
2497 encryption_handler()->SetKeystoreKeys(BuildEncryptionKeyProto(
2498 kRawKeystoreKey),
2499 trans.GetWrappedTrans());
2500
2501 }
2502 }
2503
2454 } // namespace syncer 2504 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/sync_encryption_handler_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698