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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 } | 364 } |
365 EXPECT_TRUE(encrypted_types.Equals( | 365 EXPECT_TRUE(encrypted_types.Equals( |
366 encryption_handler()->GetEncryptedTypesUnsafe())); | 366 encryption_handler()->GetEncryptedTypesUnsafe())); |
367 EXPECT_TRUE(encrypted_types.Equals( | 367 EXPECT_TRUE(encrypted_types.Equals( |
368 handler2.GetEncryptedTypesUnsafe())); | 368 handler2.GetEncryptedTypesUnsafe())); |
369 | 369 |
370 Mock::VerifyAndClearExpectations(observer()); | 370 Mock::VerifyAndClearExpectations(observer()); |
371 Mock::VerifyAndClearExpectations(&observer2); | 371 Mock::VerifyAndClearExpectations(&observer2); |
372 | 372 |
373 ModelTypeSet encrypted_user_types = EncryptableUserTypes(); | 373 ModelTypeSet encrypted_user_types = EncryptableUserTypes(); |
374 // We never encrypt history delete directives. | |
375 encrypted_user_types.Remove(HISTORY_DELETE_DIRECTIVES); | |
376 | 374 |
377 EXPECT_CALL(*observer(), | 375 EXPECT_CALL(*observer(), |
378 OnEncryptedTypesChanged( | 376 OnEncryptedTypesChanged( |
379 HasModelTypes(encrypted_user_types), false)); | 377 HasModelTypes(encrypted_user_types), false)); |
380 EXPECT_CALL(observer2, | 378 EXPECT_CALL(observer2, |
381 OnEncryptedTypesChanged( | 379 OnEncryptedTypesChanged( |
382 HasModelTypes(encrypted_user_types), false)); | 380 HasModelTypes(encrypted_user_types), false)); |
383 | 381 |
384 // Set all encrypted types | 382 // Set all encrypted types |
385 encrypted_types = EncryptableUserTypes(); | 383 encrypted_types = EncryptableUserTypes(); |
386 { | 384 { |
387 WriteTransaction trans(FROM_HERE, user_share()); | 385 WriteTransaction trans(FROM_HERE, user_share()); |
388 encryption_handler()->MergeEncryptedTypes( | 386 encryption_handler()->MergeEncryptedTypes( |
389 encrypted_types, | 387 encrypted_types, |
390 trans.GetWrappedTrans()); | 388 trans.GetWrappedTrans()); |
391 encryption_handler()->UpdateNigoriFromEncryptedTypes( | 389 encryption_handler()->UpdateNigoriFromEncryptedTypes( |
392 &nigori, | 390 &nigori, |
393 trans.GetWrappedTrans()); | 391 trans.GetWrappedTrans()); |
394 handler2.UpdateEncryptedTypesFromNigori(nigori, trans.GetWrappedTrans()); | 392 handler2.UpdateEncryptedTypesFromNigori(nigori, trans.GetWrappedTrans()); |
395 } | 393 } |
396 EXPECT_TRUE(encrypted_types.Equals( | 394 EXPECT_TRUE(encrypted_types.Equals( |
397 encryption_handler()->GetEncryptedTypesUnsafe())); | 395 encryption_handler()->GetEncryptedTypesUnsafe())); |
398 //EXPECT_TRUE(encrypted_types.Equals(handler2.GetEncryptedTypesUnsafe())); | 396 EXPECT_TRUE(encrypted_types.Equals(handler2.GetEncryptedTypesUnsafe())); |
399 | 397 |
400 // Receiving an empty nigori should not reset any encrypted types or trigger | 398 // Receiving an empty nigori should not reset any encrypted types or trigger |
401 // an observer notification. | 399 // an observer notification. |
402 Mock::VerifyAndClearExpectations(observer()); | 400 Mock::VerifyAndClearExpectations(observer()); |
403 Mock::VerifyAndClearExpectations(&observer2); | 401 Mock::VerifyAndClearExpectations(&observer2); |
404 nigori = sync_pb::NigoriSpecifics(); | 402 nigori = sync_pb::NigoriSpecifics(); |
405 { | 403 { |
406 WriteTransaction trans(FROM_HERE, user_share()); | 404 WriteTransaction trans(FROM_HERE, user_share()); |
407 handler2.UpdateEncryptedTypesFromNigori(nigori, trans.GetWrappedTrans()); | 405 handler2.UpdateEncryptedTypesFromNigori(nigori, trans.GetWrappedTrans()); |
408 } | 406 } |
(...skipping 1833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2242 encryption_handler()->SetKeystoreKeys(keys, | 2240 encryption_handler()->SetKeystoreKeys(keys, |
2243 trans.GetWrappedTrans()); | 2241 trans.GetWrappedTrans()); |
2244 } | 2242 } |
2245 PumpLoop(); | 2243 PumpLoop(); |
2246 Mock::VerifyAndClearExpectations(observer()); | 2244 Mock::VerifyAndClearExpectations(observer()); |
2247 | 2245 |
2248 VerifyMigratedNigoriWithTimestamp(1, CUSTOM_PASSPHRASE, kCustomPass); | 2246 VerifyMigratedNigoriWithTimestamp(1, CUSTOM_PASSPHRASE, kCustomPass); |
2249 } | 2247 } |
2250 | 2248 |
2251 } // namespace syncer | 2249 } // namespace syncer |
OLD | NEW |