Index: chromeos/login/auth/stub_authenticator.cc |
diff --git a/chromeos/login/auth/mock_authenticator.cc b/chromeos/login/auth/stub_authenticator.cc |
similarity index 52% |
rename from chromeos/login/auth/mock_authenticator.cc |
rename to chromeos/login/auth/stub_authenticator.cc |
index fdd942911a4ac150e125fac185dc2e87c332de57..8a3e30f263d0e6bbe8eae274dac6d297f7132972 100644 |
--- a/chromeos/login/auth/mock_authenticator.cc |
+++ b/chromeos/login/auth/stub_authenticator.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chromeos/login/auth/mock_authenticator.h" |
+#include "chromeos/login/auth/stub_authenticator.h" |
#include "base/bind.h" |
#include "base/location.h" |
@@ -10,87 +10,99 @@ |
namespace chromeos { |
-MockAuthenticator::MockAuthenticator(AuthStatusConsumer* consumer, |
+namespace { |
+ |
+// As defined in /chromeos/dbus/cryptohome_client.cc. |
+static const char kUserIdHashSuffix[] = "-hash"; |
+ |
+} // anonymous namespace |
+ |
+StubAuthenticator::StubAuthenticator(AuthStatusConsumer* consumer, |
const UserContext& expected_user_context) |
: Authenticator(consumer), |
expected_user_context_(expected_user_context), |
message_loop_(base::MessageLoopProxy::current()) { |
} |
-void MockAuthenticator::CompleteLogin(content::BrowserContext* ignored, |
+void StubAuthenticator::CompleteLogin(content::BrowserContext* context, |
const UserContext& user_context) { |
+ authentication_context_ = context; |
if (expected_user_context_ != user_context) |
NOTREACHED(); |
OnAuthSuccess(); |
} |
-void MockAuthenticator::AuthenticateToLogin(content::BrowserContext* ignored, |
+void StubAuthenticator::AuthenticateToLogin(content::BrowserContext* context, |
const UserContext& user_context) { |
+ authentication_context_ = context; |
if (user_context == expected_user_context_) { |
message_loop_->PostTask( |
- FROM_HERE, base::Bind(&MockAuthenticator::OnAuthSuccess, this)); |
+ FROM_HERE, base::Bind(&StubAuthenticator::OnAuthSuccess, this)); |
return; |
} |
GoogleServiceAuthError error( |
GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
message_loop_->PostTask( |
- FROM_HERE, |
- base::Bind(&MockAuthenticator::OnAuthFailure, |
- this, |
- AuthFailure::FromNetworkAuthFailure(error))); |
+ FROM_HERE, base::Bind(&StubAuthenticator::OnAuthFailure, this, |
+ AuthFailure::FromNetworkAuthFailure(error))); |
} |
-void MockAuthenticator::AuthenticateToUnlock(const UserContext& user_context) { |
+void StubAuthenticator::AuthenticateToUnlock(const UserContext& user_context) { |
AuthenticateToLogin(NULL /* not used */, user_context); |
} |
-void MockAuthenticator::LoginAsSupervisedUser(const UserContext& user_context) { |
+void StubAuthenticator::LoginAsSupervisedUser(const UserContext& user_context) { |
UserContext new_user_context = user_context; |
- new_user_context.SetUserIDHash(user_context.GetUserID()); |
+ new_user_context.SetUserIDHash(user_context.GetUserID() + kUserIdHashSuffix); |
consumer_->OnAuthSuccess(new_user_context); |
} |
-void MockAuthenticator::LoginOffTheRecord() { |
+void StubAuthenticator::LoginOffTheRecord() { |
consumer_->OnOffTheRecordAuthSuccess(); |
} |
-void MockAuthenticator::LoginAsPublicSession(const UserContext& user_context) { |
+void StubAuthenticator::LoginAsPublicSession(const UserContext& user_context) { |
UserContext logged_in_user_context = user_context; |
- logged_in_user_context.SetUserIDHash(logged_in_user_context.GetUserID()); |
+ logged_in_user_context.SetIsUsingOAuth(false); |
+ logged_in_user_context.SetUserIDHash(logged_in_user_context.GetUserID() + |
+ kUserIdHashSuffix); |
consumer_->OnAuthSuccess(logged_in_user_context); |
} |
-void MockAuthenticator::LoginAsKioskAccount(const std::string& app_user_id, |
+void StubAuthenticator::LoginAsKioskAccount(const std::string& app_user_id, |
bool use_guest_mount) { |
UserContext user_context(expected_user_context_.GetUserID()); |
- user_context.SetUserIDHash(expected_user_context_.GetUserID()); |
+ user_context.SetIsUsingOAuth(false); |
+ user_context.SetUserIDHash(expected_user_context_.GetUserID() + |
+ kUserIdHashSuffix); |
consumer_->OnAuthSuccess(user_context); |
} |
-void MockAuthenticator::OnAuthSuccess() { |
+void StubAuthenticator::OnAuthSuccess() { |
// If we want to be more like the real thing, we could save the user ID |
// in AuthenticateToLogin, but there's not much of a point. |
UserContext user_context(expected_user_context_); |
- user_context.SetUserIDHash(expected_user_context_.GetUserID()); |
+ user_context.SetUserIDHash(expected_user_context_.GetUserID() + |
+ kUserIdHashSuffix); |
consumer_->OnAuthSuccess(user_context); |
} |
-void MockAuthenticator::OnAuthFailure(const AuthFailure& failure) { |
+void StubAuthenticator::OnAuthFailure(const AuthFailure& failure) { |
consumer_->OnAuthFailure(failure); |
} |
-void MockAuthenticator::RecoverEncryptedData(const std::string& old_password) { |
+void StubAuthenticator::RecoverEncryptedData(const std::string& old_password) { |
} |
-void MockAuthenticator::ResyncEncryptedData() { |
+void StubAuthenticator::ResyncEncryptedData() { |
} |
-void MockAuthenticator::SetExpectedCredentials( |
+void StubAuthenticator::SetExpectedCredentials( |
const UserContext& user_context) { |
expected_user_context_ = user_context; |
} |
-MockAuthenticator::~MockAuthenticator() { |
+StubAuthenticator::~StubAuthenticator() { |
} |
} // namespace chromeos |