Commit a83ea268 authored by Maksim Moskvitin's avatar Maksim Moskvitin Committed by Commit Bot

Remove DirectoryCryptographer usages in USS tests

DirectoryCryptographer is subject to remove and its usages should be
replaced with CryptographerImpl or removed. This CL does it for all
remaining USS tests.

Bug: 1083924
Change-Id: Iedd4f6c039407cce0dfb502a4070ac42f4336c80
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2226753
Commit-Queue: Maksim Moskvitin <mmoskvitin@google.com>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774562}
parent 9f52f0c2
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "components/sync/engine/sync_string_conversions.h" #include "components/sync/engine/sync_string_conversions.h"
#include "components/sync/js/js_event_details.h" #include "components/sync/js/js_event_details.h"
#include "components/sync/js/js_test_util.h" #include "components/sync/js/js_test_util.h"
#include "components/sync/syncable/directory_cryptographer.h" #include "components/sync/nigori/cryptographer_impl.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace syncer { namespace syncer {
...@@ -134,9 +134,10 @@ TEST_F(JsSyncEncryptionHandlerObserverTest, OnCryptographerStateChanged) { ...@@ -134,9 +134,10 @@ TEST_F(JsSyncEncryptionHandlerObserverTest, OnCryptographerStateChanged) {
HandleJsEvent("onCryptographerStateChanged", HandleJsEvent("onCryptographerStateChanged",
HasDetailsAsDictionary(expected_details))); HasDetailsAsDictionary(expected_details)));
DirectoryCryptographer cryptographer; std::unique_ptr<CryptographerImpl> cryptographer =
CryptographerImpl::CreateEmpty();
js_sync_encryption_handler_observer_.OnCryptographerStateChanged( js_sync_encryption_handler_observer_.OnCryptographerStateChanged(
&cryptographer, /*has_pending_keys=*/false); cryptographer.get(), /*has_pending_keys=*/false);
PumpLoop(); PumpLoop();
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "components/sync/base/client_tag_hash.h" #include "components/sync/base/client_tag_hash.h"
#include "components/sync/base/model_type.h" #include "components/sync/base/model_type.h"
#include "components/sync/base/unique_position.h" #include "components/sync/base/unique_position.h"
#include "components/sync/syncable/directory_cryptographer.h" #include "components/sync/nigori/cryptographer_impl.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace syncer { namespace syncer {
...@@ -169,16 +169,17 @@ TEST(NonBlockingTypeCommitContributionTest, ...@@ -169,16 +169,17 @@ TEST(NonBlockingTypeCommitContributionTest,
base::ObserverList<TypeDebugInfoObserver>::Unchecked observers; base::ObserverList<TypeDebugInfoObserver>::Unchecked observers;
DataTypeDebugInfoEmitter debug_info_emitter(PASSWORDS, &observers); DataTypeDebugInfoEmitter debug_info_emitter(PASSWORDS, &observers);
DirectoryCryptographer cryptographer; std::unique_ptr<CryptographerImpl> cryptographer =
cryptographer.AddKey({KeyDerivationParams::CreateForPbkdf2(), "dummy"}); CryptographerImpl::FromSingleKeyForTesting("dummy");
CommitRequestDataList requests_data; CommitRequestDataList requests_data;
requests_data.push_back(std::move(request_data)); requests_data.push_back(std::move(request_data));
NonBlockingTypeCommitContribution contribution( NonBlockingTypeCommitContribution contribution(
PASSWORDS, sync_pb::DataTypeContext(), std::move(requests_data), PASSWORDS, sync_pb::DataTypeContext(), std::move(requests_data),
/*on_commit_response_callback=*/base::NullCallback(), /*on_commit_response_callback=*/base::NullCallback(),
/*on_full_commit_failure_callback=*/base::NullCallback(), &cryptographer, /*on_full_commit_failure_callback=*/base::NullCallback(),
PassphraseType::kImplicitPassphrase, &debug_info_emitter, cryptographer.get(), PassphraseType::kImplicitPassphrase,
&debug_info_emitter,
/*only_commit_specifics=*/false); /*only_commit_specifics=*/false);
sync_pb::ClientToServerMessage msg; sync_pb::ClientToServerMessage msg;
...@@ -235,16 +236,17 @@ TEST(NonBlockingTypeCommitContributionTest, ...@@ -235,16 +236,17 @@ TEST(NonBlockingTypeCommitContributionTest,
base::ObserverList<TypeDebugInfoObserver>::Unchecked observers; base::ObserverList<TypeDebugInfoObserver>::Unchecked observers;
DataTypeDebugInfoEmitter debug_info_emitter(PASSWORDS, &observers); DataTypeDebugInfoEmitter debug_info_emitter(PASSWORDS, &observers);
DirectoryCryptographer cryptographer; std::unique_ptr<CryptographerImpl> cryptographer =
cryptographer.AddKey({KeyDerivationParams::CreateForPbkdf2(), "dummy"}); CryptographerImpl::FromSingleKeyForTesting("dummy");
CommitRequestDataList requests_data; CommitRequestDataList requests_data;
requests_data.push_back(std::move(request_data)); requests_data.push_back(std::move(request_data));
NonBlockingTypeCommitContribution contribution( NonBlockingTypeCommitContribution contribution(
PASSWORDS, sync_pb::DataTypeContext(), std::move(requests_data), PASSWORDS, sync_pb::DataTypeContext(), std::move(requests_data),
/*on_commit_response_callback=*/base::NullCallback(), /*on_commit_response_callback=*/base::NullCallback(),
/*on_full_commit_failure_callback=*/base::NullCallback(), &cryptographer, /*on_full_commit_failure_callback=*/base::NullCallback(),
PassphraseType::kCustomPassphrase, &debug_info_emitter, cryptographer.get(), PassphraseType::kCustomPassphrase,
&debug_info_emitter,
/*only_commit_specifics=*/false); /*only_commit_specifics=*/false);
sync_pb::ClientToServerMessage msg; sync_pb::ClientToServerMessage msg;
...@@ -281,7 +283,8 @@ TEST(NonBlockingTypeCommitContributionTest, ...@@ -281,7 +283,8 @@ TEST(NonBlockingTypeCommitContributionTest,
base::ObserverList<TypeDebugInfoObserver>::Unchecked observers; base::ObserverList<TypeDebugInfoObserver>::Unchecked observers;
DataTypeDebugInfoEmitter debug_info_emitter(PASSWORDS, &observers); DataTypeDebugInfoEmitter debug_info_emitter(PASSWORDS, &observers);
DirectoryCryptographer cryptographer; std::unique_ptr<CryptographerImpl> cryptographer =
CryptographerImpl::CreateEmpty();
FailedCommitResponseDataList actual_error_response_list; FailedCommitResponseDataList actual_error_response_list;
...@@ -298,8 +301,9 @@ TEST(NonBlockingTypeCommitContributionTest, ...@@ -298,8 +301,9 @@ TEST(NonBlockingTypeCommitContributionTest,
NonBlockingTypeCommitContribution contribution( NonBlockingTypeCommitContribution contribution(
PASSWORDS, sync_pb::DataTypeContext(), std::move(requests_data), PASSWORDS, sync_pb::DataTypeContext(), std::move(requests_data),
std::move(on_commit_response_callback), std::move(on_commit_response_callback),
/*on_full_commit_failure_callback=*/base::NullCallback(), &cryptographer, /*on_full_commit_failure_callback=*/base::NullCallback(),
PassphraseType::kCustomPassphrase, &debug_info_emitter, cryptographer.get(), PassphraseType::kCustomPassphrase,
&debug_info_emitter,
/*only_commit_specifics=*/false); /*only_commit_specifics=*/false);
sync_pb::ClientToServerMessage msg; sync_pb::ClientToServerMessage msg;
...@@ -333,19 +337,18 @@ TEST(NonBlockingTypeCommitContributionTest, ...@@ -333,19 +337,18 @@ TEST(NonBlockingTypeCommitContributionTest,
} }
TEST(NonBlockingTypeCommitContributionTest, ShouldPropagateFullCommitFailure) { TEST(NonBlockingTypeCommitContributionTest, ShouldPropagateFullCommitFailure) {
DirectoryCryptographer cryptographer;
base::ObserverList<TypeDebugInfoObserver>::Unchecked observers; base::ObserverList<TypeDebugInfoObserver>::Unchecked observers;
DataTypeDebugInfoEmitter debug_info_emitter(PASSWORDS, &observers); DataTypeDebugInfoEmitter debug_info_emitter(BOOKMARKS, &observers);
base::MockOnceCallback<void(SyncCommitError commit_error)> base::MockOnceCallback<void(SyncCommitError commit_error)>
on_commit_failure_callback; on_commit_failure_callback;
EXPECT_CALL(on_commit_failure_callback, Run(SyncCommitError::kNetworkError)); EXPECT_CALL(on_commit_failure_callback, Run(SyncCommitError::kNetworkError));
NonBlockingTypeCommitContribution contribution( NonBlockingTypeCommitContribution contribution(
PASSWORDS, sync_pb::DataTypeContext(), CommitRequestDataList(), BOOKMARKS, sync_pb::DataTypeContext(), CommitRequestDataList(),
/*on_commit_response_callback=*/base::NullCallback(), /*on_commit_response_callback=*/base::NullCallback(),
on_commit_failure_callback.Get(), &cryptographer, on_commit_failure_callback.Get(), /*cryptographer=*/nullptr,
PassphraseType::kCustomPassphrase, &debug_info_emitter, PassphraseType::kKeystorePassphrase, &debug_info_emitter,
/*only_commit_specifics=*/false); /*only_commit_specifics=*/false);
contribution.ProcessCommitFailure(SyncCommitError::kNetworkError); contribution.ProcessCommitFailure(SyncCommitError::kNetworkError);
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "components/sync/syncable/nigori_handler_proxy.h" #include "components/sync/syncable/nigori_handler_proxy.h"
#include "components/sync/base/model_type.h" #include "components/sync/base/model_type.h"
#include "components/sync/syncable/directory_cryptographer.h" #include "components/sync/nigori/cryptographer_impl.h"
#include "components/sync/syncable/syncable_base_transaction.h" #include "components/sync/syncable/syncable_base_transaction.h"
#include "components/sync/syncable/user_share.h" #include "components/sync/syncable/user_share.h"
#include "components/sync/syncable/write_transaction.h" #include "components/sync/syncable/write_transaction.h"
...@@ -16,7 +16,7 @@ namespace syncable { ...@@ -16,7 +16,7 @@ namespace syncable {
NigoriHandlerProxy::NigoriHandlerProxy(UserShare* user_share) NigoriHandlerProxy::NigoriHandlerProxy(UserShare* user_share)
: user_share_(user_share), : user_share_(user_share),
cryptographer_(std::make_unique<DirectoryCryptographer>()), cryptographer_(CryptographerImpl::CreateEmpty()),
encrypted_types_(AlwaysEncryptedUserTypes()), encrypted_types_(AlwaysEncryptedUserTypes()),
passphrase_type_(SyncEncryptionHandler::kInitialPassphraseType) { passphrase_type_(SyncEncryptionHandler::kInitialPassphraseType) {
DCHECK(user_share); DCHECK(user_share);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment