blob: 198fe6f60012670d775f1c3f5414065e31def838 [file] [log] [blame]
// Copyright 2019 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 <string>
#include "base/component_export.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "chromeos/login/auth/stub_authenticator.h"
#include "chromeos/login/auth/user_context.h"
namespace chromeos {
// Helper class for creating a StubAuthenticator with certain configuration.
// Useful in tests for injecting StubAuthenticators to be used during user
// login.
class COMPONENT_EXPORT(CHROMEOS_LOGIN_AUTH) StubAuthenticatorBuilder {
explicit StubAuthenticatorBuilder(const UserContext& expected_user_context);
scoped_refptr<Authenticator> Create(AuthStatusConsumer* consumer);
// Sets up the stub Authenticator to report password changed.
// |old_password| - the expected old user password. The authenticator will use
// it to handle data migration requests (it will report failure if the
// provided old password does not match this one).
// |notifier| - can be empty. If set called when a user data recovery is
// attempted.
void SetUpPasswordChange(
const std::string& old_password,
const StubAuthenticator::DataRecoveryNotifier& notifier);
const UserContext expected_user_context_;
// Action to be performed on successful auth against expected user context..
StubAuthenticator::AuthAction auth_action_ =
// For kPasswordChange action, the old user password.
std::string old_password_;
// For kPasswordChange action, the callback to be called to report user data
// recovery result.
StubAuthenticator::DataRecoveryNotifier data_recovery_notifier_;
} // namespace chromeos