Commit 1c3fed29 authored by Vasilii Sukhanov's avatar Vasilii Sukhanov Committed by Commit Bot

Skeleton for BulkLeakCheck class.

Bug: 1049185
Change-Id: I423a56ae785d00d77f01b243d7fd91670ab4681c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2041607
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarJan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#739370}
parent dc836775
......@@ -612,6 +612,7 @@ source_set("unit_tests") {
"//components/password_manager/core/browser/form_parsing/fuzzer:unit_tests",
"//components/password_manager/core/browser/leak_detection",
"//components/password_manager/core/browser/leak_detection:leak_detection_interface_headers",
"//components/password_manager/core/browser/leak_detection:test_support",
"//components/password_manager/core/browser/leak_detection:unit_tests",
"//components/password_manager/core/common",
"//components/prefs:test_support",
......
......@@ -20,6 +20,7 @@
#include "components/password_manager/core/browser/android_affiliation/mock_affiliated_match_helper.h"
#include "components/password_manager/core/browser/leak_detection/leak_detection_check.h"
#include "components/password_manager/core/browser/leak_detection/leak_detection_check_factory.h"
#include "components/password_manager/core/browser/leak_detection/mock_leak_detection_check_factory.h"
#include "components/password_manager/core/browser/password_manager.h"
#include "components/password_manager/core/browser/stub_password_manager_client.h"
#include "components/password_manager/core/browser/test_password_store.h"
......@@ -53,15 +54,6 @@ class MockLeakDetectionCheck : public LeakDetectionCheck {
MOCK_METHOD3(Start, void(const GURL&, base::string16, base::string16));
};
class MockLeakDetectionCheckFactory : public LeakDetectionCheckFactory {
public:
MOCK_CONST_METHOD3(TryCreateLeakCheck,
std::unique_ptr<LeakDetectionCheck>(
LeakDetectionDelegateInterface*,
signin::IdentityManager*,
scoped_refptr<network::SharedURLLoaderFactory>));
};
class MockPasswordManagerClient : public StubPasswordManagerClient {
public:
MOCK_CONST_METHOD1(IsSavingAndFillingEnabled, bool(const GURL&));
......
......@@ -17,6 +17,7 @@ source_set("leak_detection_interface_headers") {
]
deps = [
"//base",
"//base/util/type_safety",
"//url",
]
}
......@@ -25,6 +26,9 @@ jumbo_source_set("leak_detection") {
sources = [
"authenticated_leak_check.cc",
"authenticated_leak_check.h",
"bulk_leak_check.h",
"bulk_leak_check_impl.cc",
"bulk_leak_check_impl.h",
"encryption_utils.cc",
"encryption_utils.h",
"leak_detection_check.h",
......@@ -59,6 +63,8 @@ jumbo_source_set("leak_detection") {
jumbo_source_set("test_support") {
testonly = true
sources = [
"mock_leak_detection_check_factory.cc",
"mock_leak_detection_check_factory.h",
"mock_leak_detection_delegate.cc",
"mock_leak_detection_delegate.h",
]
......@@ -74,6 +80,7 @@ jumbo_source_set("unit_tests") {
testonly = true
sources = [
"authenticated_leak_check_unittest.cc",
"bulk_leak_check_impl_unittest.cc",
"encryption_utils_unittest.cc",
"leak_detection_check_factory_impl_unittest.cc",
"leak_detection_request_unittest.cc",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_BULK_LEAK_CHECK_H_
#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_BULK_LEAK_CHECK_H_
#include <vector>
#include "base/strings/string16.h"
#include "base/supports_user_data.h"
namespace password_manager {
// A credential to be checked against the service. Caller can attach any data to
// it.
class LeakCheckCredential : public base::SupportsUserData {
public:
LeakCheckCredential(base::string16 username, base::string16 password);
// Movable.
LeakCheckCredential(LeakCheckCredential&&);
LeakCheckCredential& operator=(LeakCheckCredential&&);
~LeakCheckCredential() override;
// Not copyable.
LeakCheckCredential(const LeakCheckCredential&) = delete;
LeakCheckCredential& operator=(const LeakCheckCredential&) = delete;
const base::string16& username() const { return username_; }
const base::string16& password() const { return password_; }
private:
base::string16 username_;
base::string16 password_;
};
// The class checks a list of credentials against Google service of leaked
// passwords.
// The feature is available to sign-in users only.
class BulkLeakCheck {
public:
BulkLeakCheck() = default;
virtual ~BulkLeakCheck() = default;
// Not copyable or movable
BulkLeakCheck(const BulkLeakCheck&) = delete;
BulkLeakCheck& operator=(const BulkLeakCheck&) = delete;
BulkLeakCheck(BulkLeakCheck&&) = delete;
BulkLeakCheck& operator=(BulkLeakCheck&&) = delete;
// Appends |credentials| to the list of currently checked credentials. If
// necessary, starts the pipeline.
// The caller is responsible for deduplication of credentials if it wants to
// make it efficient.
virtual void CheckCredentials(
std::vector<LeakCheckCredential> credentials) = 0;
// Returns # of pending credentials to check.
virtual size_t GetPendingChecksCount() const = 0;
};
} // namespace password_manager
#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_BULK_LEAK_CHECK_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/password_manager/core/browser/leak_detection/bulk_leak_check_impl.h"
#include <utility>
#include "base/logging.h"
#include "components/password_manager/core/browser/leak_detection/leak_detection_delegate_interface.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
namespace password_manager {
LeakCheckCredential::LeakCheckCredential(base::string16 username,
base::string16 password)
: username_(std::move(username)), password_(std::move(password)) {}
LeakCheckCredential::LeakCheckCredential(LeakCheckCredential&&) = default;
LeakCheckCredential& LeakCheckCredential::operator=(LeakCheckCredential&&) =
default;
LeakCheckCredential::~LeakCheckCredential() = default;
BulkLeakCheckImpl::BulkLeakCheckImpl(
BulkLeakCheckDelegateInterface* delegate,
signin::IdentityManager* identity_manager,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory)
: delegate_(delegate),
identity_manager_(identity_manager),
url_loader_factory_(std::move(url_loader_factory)) {
DCHECK(delegate_);
DCHECK(identity_manager_);
DCHECK(url_loader_factory_);
}
BulkLeakCheckImpl::~BulkLeakCheckImpl() = default;
void BulkLeakCheckImpl::CheckCredentials(
std::vector<LeakCheckCredential> credentials) {
for (auto& c : credentials)
delegate_->OnFinishedCredential(std::move(c), IsLeaked(false));
}
size_t BulkLeakCheckImpl::GetPendingChecksCount() const {
return 0;
}
} // namespace password_manager
\ No newline at end of file
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_BULK_LEAK_CHECK_IMPL_H_
#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_BULK_LEAK_CHECK_IMPL_H_
#include "base/memory/scoped_refptr.h"
#include "components/password_manager/core/browser/leak_detection/bulk_leak_check.h"
namespace network {
class SharedURLLoaderFactory;
} // namespace network
namespace signin {
class IdentityManager;
} // namespace signin
namespace password_manager {
class BulkLeakCheckDelegateInterface;
// Implementation of the bulk leak check.
// Every credential in the list is processed consequitively:
// - prepare payload for the request.
// - get the access token.
// - make a network request.
// - decrypt the response.
// Encryption/decryption part is expensive and, therefore, done only on one
// background sequence.
class BulkLeakCheckImpl : public BulkLeakCheck {
public:
BulkLeakCheckImpl(
BulkLeakCheckDelegateInterface* delegate,
signin::IdentityManager* identity_manager,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory);
~BulkLeakCheckImpl() override;
// BulkLeakCheck:
void CheckCredentials(std::vector<LeakCheckCredential> credentials) override;
size_t GetPendingChecksCount() const override;
private:
// Delegate for the instance. Should outlive |this|.
BulkLeakCheckDelegateInterface* const delegate_;
// Identity manager for the profile.
signin::IdentityManager* const identity_manager_;
// URL loader factory required for the network request to the identity
// endpoint.
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_;
};
} // namespace password_manager
#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_BULK_LEAK_CHECK_IMPL_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/password_manager/core/browser/leak_detection/bulk_leak_check_impl.h"
#include "base/test/task_environment.h"
#include "components/password_manager/core/browser/leak_detection/leak_detection_delegate_interface.h"
#include "components/password_manager/core/browser/leak_detection/mock_leak_detection_delegate.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "services/network/test/test_shared_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace password_manager {
namespace {
class BulkLeakCheckTest : public testing::Test {
public:
BulkLeakCheckTest()
: bulk_check_(
&delegate_,
identity_test_env_.identity_manager(),
base::MakeRefCounted<network::TestSharedURLLoaderFactory>()) {}
MockBulkLeakCheckDelegateInterface& delegate() { return delegate_; }
private:
base::test::TaskEnvironment task_env_;
signin::IdentityTestEnvironment identity_test_env_;
::testing::StrictMock<MockBulkLeakCheckDelegateInterface> delegate_;
BulkLeakCheckImpl bulk_check_;
};
TEST_F(BulkLeakCheckTest, Create) {
EXPECT_CALL(delegate(), OnFinishedCredential).Times(0);
EXPECT_CALL(delegate(), OnError).Times(0);
// Destroying |leak_check_| doesn't trigger anything.
}
} // namespace
} // namespace password_manager
......@@ -19,6 +19,8 @@ class SharedURLLoaderFactory;
namespace password_manager {
class BulkLeakCheck;
class BulkLeakCheckDelegateInterface;
class LeakDetectionCheck;
class LeakDetectionDelegateInterface;
......@@ -36,8 +38,7 @@ class LeakDetectionCheckFactory {
LeakDetectionCheckFactory(LeakDetectionCheckFactory&&) = delete;
LeakDetectionCheckFactory& operator=(LeakDetectionCheckFactory&&) = delete;
// The leak check is available only for signed-in users and if the feature is
// available.
// The leak check is available only for signed-in users.
// |delegate| gets the results for the fetch.
// |identity_manager| is used to obtain the token.
// |url_loader_factory| does the actual network request.
......@@ -46,6 +47,17 @@ class LeakDetectionCheckFactory {
signin::IdentityManager* identity_manager,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory)
const = 0;
// The leak check is available only for signed-in users and if the feature is
// available.
// |delegate| gets the results for the fetch.
// |identity_manager| is used to obtain the token.
// |url_loader_factory| does the actual network request.
virtual std::unique_ptr<BulkLeakCheck> TryCreateBulkLeakCheck(
BulkLeakCheckDelegateInterface* delegate,
signin::IdentityManager* identity_manager,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory)
const = 0;
};
} // namespace password_manager
......
......@@ -7,6 +7,7 @@
#include <utility>
#include "components/password_manager/core/browser/leak_detection/authenticated_leak_check.h"
#include "components/password_manager/core/browser/leak_detection/bulk_leak_check_impl.h"
#include "components/password_manager/core/browser/leak_detection/leak_detection_delegate_interface.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
......@@ -30,4 +31,20 @@ LeakDetectionCheckFactoryImpl::TryCreateLeakCheck(
delegate, identity_manager, std::move(url_loader_factory));
}
std::unique_ptr<BulkLeakCheck>
LeakDetectionCheckFactoryImpl::TryCreateBulkLeakCheck(
BulkLeakCheckDelegateInterface* delegate,
signin::IdentityManager* identity_manager,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) const {
if (!base::FeatureList::IsEnabled(password_manager::features::kPasswordCheck))
return nullptr;
if (!AuthenticatedLeakCheck::HasAccountForRequest(identity_manager)) {
delegate->OnError(LeakDetectionError::kNotSignIn);
return nullptr;
}
return std::make_unique<BulkLeakCheckImpl>(delegate, identity_manager,
std::move(url_loader_factory));
}
} // namespace password_manager
......@@ -24,6 +24,12 @@ class LeakDetectionCheckFactoryImpl : public LeakDetectionCheckFactory {
signin::IdentityManager* identity_manager,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory)
const override;
std::unique_ptr<BulkLeakCheck> TryCreateBulkLeakCheck(
BulkLeakCheckDelegateInterface* delegate,
signin::IdentityManager* identity_manager,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory)
const override;
};
} // namespace password_manager
......
......@@ -29,6 +29,7 @@ class LeakDetectionCheckFactoryImplTest : public testing::Test {
signin::IdentityTestEnvironment& identity_env() { return identity_test_env_; }
MockLeakDetectionDelegateInterface& delegate() { return delegate_; }
MockBulkLeakCheckDelegateInterface& bulk_delegate() { return bulk_delegate_; }
const scoped_refptr<network::SharedURLLoaderFactory>& url_loader_factory() {
return url_loader_factory_;
}
......@@ -38,6 +39,7 @@ class LeakDetectionCheckFactoryImplTest : public testing::Test {
base::test::TaskEnvironment task_env_;
signin::IdentityTestEnvironment identity_test_env_;
StrictMock<MockLeakDetectionDelegateInterface> delegate_;
StrictMock<MockBulkLeakCheckDelegateInterface> bulk_delegate_;
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_ =
base::MakeRefCounted<network::TestSharedURLLoaderFactory>();
LeakDetectionCheckFactoryImpl request_factory_;
......@@ -51,6 +53,16 @@ TEST_F(LeakDetectionCheckFactoryImplTest, SignedOut) {
&delegate(), identity_env().identity_manager(), url_loader_factory()));
}
TEST_F(LeakDetectionCheckFactoryImplTest, BulkCheck_SignedOut) {
base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(password_manager::features::kPasswordCheck);
EXPECT_CALL(bulk_delegate(), OnError(LeakDetectionError::kNotSignIn));
EXPECT_FALSE(request_factory().TryCreateBulkLeakCheck(
&bulk_delegate(), identity_env().identity_manager(),
url_loader_factory()));
}
TEST_F(LeakDetectionCheckFactoryImplTest, SignedIn) {
AccountInfo info = identity_env().MakeAccountAvailable(kTestAccount);
identity_env().SetCookieAccounts({{info.email, info.gaia}});
......@@ -59,10 +71,39 @@ TEST_F(LeakDetectionCheckFactoryImplTest, SignedIn) {
&delegate(), identity_env().identity_manager(), url_loader_factory()));
}
TEST_F(LeakDetectionCheckFactoryImplTest, BulkCheck_SignedIn) {
base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(password_manager::features::kPasswordCheck);
AccountInfo info = identity_env().MakeAccountAvailable(kTestAccount);
identity_env().SetCookieAccounts({{info.email, info.gaia}});
identity_env().SetRefreshTokenForAccount(info.account_id);
EXPECT_TRUE(request_factory().TryCreateBulkLeakCheck(
&bulk_delegate(), identity_env().identity_manager(),
url_loader_factory()));
}
TEST_F(LeakDetectionCheckFactoryImplTest, SignedInAndSyncing) {
identity_env().SetPrimaryAccount(kTestAccount);
EXPECT_TRUE(request_factory().TryCreateLeakCheck(
&delegate(), identity_env().identity_manager(), url_loader_factory()));
}
TEST_F(LeakDetectionCheckFactoryImplTest, BulkCheck_SignedInAndSyncing) {
base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(password_manager::features::kPasswordCheck);
identity_env().SetPrimaryAccount(kTestAccount);
EXPECT_TRUE(request_factory().TryCreateBulkLeakCheck(
&bulk_delegate(), identity_env().identity_manager(),
url_loader_factory()));
}
TEST_F(LeakDetectionCheckFactoryImplTest, BulkCheck_FeatureOff) {
identity_env().SetPrimaryAccount(kTestAccount);
EXPECT_FALSE(request_factory().TryCreateBulkLeakCheck(
&bulk_delegate(), identity_env().identity_manager(),
url_loader_factory()));
}
} // namespace password_manager
......@@ -5,10 +5,13 @@
#ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_LEAK_DETECTION_DELEGATE_INTERFACE_H_
#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_LEAK_DETECTION_DELEGATE_INTERFACE_H_
#include "base/util/type_safety/strong_alias.h"
#include "url/gurl.h"
namespace password_manager {
class LeakCheckCredential;
enum class LeakDetectionError {
// The user isn't signed-in to Chrome.
kNotSignIn = 0,
......@@ -21,6 +24,8 @@ enum class LeakDetectionError {
kMaxValue = kInvalidServerResponse,
};
using IsLeaked = util::StrongAlias<class IsLeakedTag, bool>;
// Interface with callbacks for LeakDetectionCheck. Used to get the result of
// the check.
class LeakDetectionDelegateInterface {
......@@ -49,6 +54,31 @@ class LeakDetectionDelegateInterface {
virtual void OnError(LeakDetectionError error) = 0;
};
// Delegate for BulkLeakCheck. Gets the updates during processing the list.
class BulkLeakCheckDelegateInterface {
public:
BulkLeakCheckDelegateInterface() = default;
virtual ~BulkLeakCheckDelegateInterface() = default;
// Not copyable or movable
BulkLeakCheckDelegateInterface(const BulkLeakCheckDelegateInterface&) =
delete;
BulkLeakCheckDelegateInterface& operator=(
const BulkLeakCheckDelegateInterface&) = delete;
BulkLeakCheckDelegateInterface(BulkLeakCheckDelegateInterface&&) = delete;
BulkLeakCheckDelegateInterface& operator=(BulkLeakCheckDelegateInterface&&) =
delete;
// Called when |credential| was processed. |is_leaked| is true if it's leaked.
virtual void OnFinishedCredential(LeakCheckCredential credential,
IsLeaked is_leaked) = 0;
// Called when error occurred on one of the credentials. Other credentials are
// processed further.
// BulkLeakCheck can be deleted from this call safely.
virtual void OnError(LeakDetectionError error) = 0;
};
} // namespace password_manager
#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_LEAK_DETECTION_DELEGATE_INTERFACE_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/password_manager/core/browser/leak_detection/mock_leak_detection_check_factory.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
namespace password_manager {
MockLeakDetectionCheckFactory::MockLeakDetectionCheckFactory() = default;
MockLeakDetectionCheckFactory::~MockLeakDetectionCheckFactory() = default;
} // namespace password_manager
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_MOCK_LEAK_DETECTION_CHECK_FACTORY_H_
#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_MOCK_LEAK_DETECTION_CHECK_FACTORY_H_
#include "components/password_manager/core/browser/leak_detection/bulk_leak_check.h"
#include "components/password_manager/core/browser/leak_detection/leak_detection_check.h"
#include "components/password_manager/core/browser/leak_detection/leak_detection_check_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace password_manager {
class MockLeakDetectionCheckFactory : public LeakDetectionCheckFactory {
public:
MockLeakDetectionCheckFactory();
~MockLeakDetectionCheckFactory() override;
// LeakDetectionCheckFactory:
MOCK_CONST_METHOD3(TryCreateLeakCheck,
std::unique_ptr<LeakDetectionCheck>(
LeakDetectionDelegateInterface*,
signin::IdentityManager*,
scoped_refptr<network::SharedURLLoaderFactory>));
MOCK_CONST_METHOD3(TryCreateBulkLeakCheck,
std::unique_ptr<BulkLeakCheck>(
BulkLeakCheckDelegateInterface*,
signin::IdentityManager*,
scoped_refptr<network::SharedURLLoaderFactory>));
};
} // namespace password_manager
#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_MOCK_LEAK_DETECTION_CHECK_FACTORY_H_
......@@ -11,4 +11,9 @@ MockLeakDetectionDelegateInterface::MockLeakDetectionDelegateInterface() =
MockLeakDetectionDelegateInterface::~MockLeakDetectionDelegateInterface() =
default;
MockBulkLeakCheckDelegateInterface::MockBulkLeakCheckDelegateInterface() =
default;
MockBulkLeakCheckDelegateInterface::~MockBulkLeakCheckDelegateInterface() =
default;
} // namespace password_manager
......@@ -5,6 +5,7 @@
#ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_MOCK_LEAK_DETECTION_DELEGATE_H_
#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_MOCK_LEAK_DETECTION_DELEGATE_H_
#include "components/password_manager/core/browser/leak_detection/bulk_leak_check.h"
#include "components/password_manager/core/browser/leak_detection/leak_detection_delegate_interface.h"
#include "testing/gmock/include/gmock/gmock.h"
......@@ -22,6 +23,18 @@ class MockLeakDetectionDelegateInterface
MOCK_METHOD1(OnError, void(LeakDetectionError));
};
class MockBulkLeakCheckDelegateInterface
: public BulkLeakCheckDelegateInterface {
public:
MockBulkLeakCheckDelegateInterface();
~MockBulkLeakCheckDelegateInterface() override;
// BulkLeakCheckDelegateInterface:
MOCK_METHOD2(OnFinishedCredential,
void(LeakCheckCredential credential, IsLeaked is_leaked));
MOCK_METHOD1(OnError, void(LeakDetectionError));
};
} // namespace password_manager
#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LEAK_DETECTION_MOCK_LEAK_DETECTION_DELEGATE_H_
......@@ -11,6 +11,7 @@
#include "build/build_config.h"
#include "components/password_manager/core/browser/form_parsing/form_parser.h"
#include "components/password_manager/core/browser/leak_detection/leak_detection_check.h"
#include "components/password_manager/core/browser/leak_detection/mock_leak_detection_check_factory.h"
#include "components/password_manager/core/browser/leak_detection_delegate.h"
#include "components/password_manager/core/browser/mock_password_store.h"
#include "components/password_manager/core/browser/stub_password_manager_client.h"
......@@ -59,15 +60,6 @@ class MockLeakDetectionCheck : public LeakDetectionCheck {
MOCK_METHOD3(Start, void(const GURL&, base::string16, base::string16));
};
class MockLeakDetectionCheckFactory : public LeakDetectionCheckFactory {
public:
MOCK_CONST_METHOD3(TryCreateLeakCheck,
std::unique_ptr<LeakDetectionCheck>(
LeakDetectionDelegateInterface*,
signin::IdentityManager*,
scoped_refptr<network::SharedURLLoaderFactory>));
};
} // namespace
class LeakDetectionDelegateTest : public testing::Test {
......
......@@ -29,6 +29,7 @@
#include "components/password_manager/core/browser/form_fetcher_impl.h"
#include "components/password_manager/core/browser/leak_detection/leak_detection_check.h"
#include "components/password_manager/core/browser/leak_detection/leak_detection_check_factory.h"
#include "components/password_manager/core/browser/leak_detection/mock_leak_detection_check_factory.h"
#include "components/password_manager/core/browser/mock_password_store.h"
#include "components/password_manager/core/browser/password_autofill_manager.h"
#include "components/password_manager/core/browser/password_bubble_experiment.h"
......@@ -107,15 +108,6 @@ class MockLeakDetectionCheck : public LeakDetectionCheck {
MOCK_METHOD3(Start, void(const GURL&, base::string16, base::string16));
};
class MockLeakDetectionCheckFactory : public LeakDetectionCheckFactory {
public:
MOCK_CONST_METHOD3(TryCreateLeakCheck,
std::unique_ptr<LeakDetectionCheck>(
LeakDetectionDelegateInterface*,
signin::IdentityManager*,
scoped_refptr<network::SharedURLLoaderFactory>));
};
class MockStoreResultFilter : public StubCredentialsFilter {
public:
MOCK_CONST_METHOD1(ShouldSave, bool(const autofill::PasswordForm& form));
......
......@@ -170,6 +170,7 @@ source_set("unit_tests") {
"//components/password_manager/core/browser",
"//components/password_manager/core/browser:test_support",
"//components/password_manager/core/browser/leak_detection:leak_detection_interface_headers",
"//components/password_manager/core/browser/leak_detection:test_support",
"//components/password_manager/core/common",
"//components/password_manager/ios",
"//components/password_manager/ios:test_support",
......
......@@ -11,6 +11,7 @@
#include "base/strings/utf_string_conversions.h"
#include "components/password_manager/core/browser/leak_detection/leak_detection_check.h"
#include "components/password_manager/core/browser/leak_detection/leak_detection_check_factory.h"
#include "components/password_manager/core/browser/leak_detection/mock_leak_detection_check_factory.h"
#include "components/password_manager/core/browser/test_password_store.h"
#include "components/password_manager/ios/credential_manager_util.h"
#import "ios/chrome/browser/passwords/test/test_password_manager_client.h"
......@@ -56,16 +57,6 @@ class MockLeakDetectionCheck : public password_manager::LeakDetectionCheck {
MOCK_METHOD3(Start, void(const GURL&, base::string16, base::string16));
};
class MockLeakDetectionCheckFactory
: public password_manager::LeakDetectionCheckFactory {
public:
MOCK_CONST_METHOD3(TryCreateLeakCheck,
std::unique_ptr<password_manager::LeakDetectionCheck>(
password_manager::LeakDetectionDelegateInterface*,
signin::IdentityManager*,
scoped_refptr<network::SharedURLLoaderFactory>));
};
} // namespace
class CredentialManagerBaseTest
......@@ -175,8 +166,8 @@ class CredentialManagerTest : public CredentialManagerBaseTest {
// Tests storing a PasswordCredential.
TEST_F(CredentialManagerTest, StorePasswordCredential) {
auto mock_factory =
std::make_unique<testing::StrictMock<MockLeakDetectionCheckFactory>>();
auto mock_factory = std::make_unique<
testing::StrictMock<password_manager::MockLeakDetectionCheckFactory>>();
auto* weak_factory = mock_factory.get();
manager_->set_leak_factory(std::move(mock_factory));
......
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