OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/browser/chromeos/login/mock_authenticator.h" | 5 #include "chrome/browser/chromeos/login/mock_authenticator.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/chromeos/login/user.h" | 8 #include "chrome/browser/chromeos/login/user.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 | 10 |
11 using content::BrowserThread; | 11 using content::BrowserThread; |
12 | 12 |
13 namespace chromeos { | 13 namespace chromeos { |
14 | 14 |
15 void MockAuthenticator::AuthenticateToLogin(Profile* profile, | 15 void MockAuthenticator::AuthenticateToLogin(Profile* profile, |
16 const UserContext& user_context, | 16 const UserContext& user_context) { |
17 const std::string& login_token, | |
18 const std::string& login_captcha) { | |
19 if (expected_username_ == user_context.username && | 17 if (expected_username_ == user_context.username && |
20 expected_password_ == user_context.password) { | 18 expected_password_ == user_context.password) { |
21 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 19 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
22 base::Bind(&MockAuthenticator::OnLoginSuccess, this, false)); | 20 base::Bind(&MockAuthenticator::OnLoginSuccess, this, false)); |
23 return; | 21 return; |
24 } | 22 } |
25 GoogleServiceAuthError error( | 23 GoogleServiceAuthError error( |
26 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 24 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
27 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 25 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
28 base::Bind(&MockAuthenticator::OnLoginFailure, this, | 26 base::Bind(&MockAuthenticator::OnLoginFailure, this, |
29 LoginFailure::FromNetworkAuthFailure(error))); | 27 LoginFailure::FromNetworkAuthFailure(error))); |
30 } | 28 } |
31 | 29 |
32 void MockAuthenticator::CompleteLogin(Profile* profile, | 30 void MockAuthenticator::CompleteLogin(Profile* profile, |
33 const UserContext& user_context) { | 31 const UserContext& user_context) { |
34 CHECK_EQ(expected_username_, user_context.username); | 32 CHECK_EQ(expected_username_, user_context.username); |
35 CHECK_EQ(expected_password_, user_context.password); | 33 CHECK_EQ(expected_password_, user_context.password); |
36 OnLoginSuccess(false); | 34 OnLoginSuccess(false); |
37 } | 35 } |
38 | 36 |
39 void MockAuthenticator::AuthenticateToUnlock( | 37 void MockAuthenticator::AuthenticateToUnlock( |
40 const UserContext& user_context) { | 38 const UserContext& user_context) { |
41 AuthenticateToLogin(NULL /* not used */, user_context, | 39 AuthenticateToLogin(NULL /* not used */, user_context); |
42 std::string(), std::string()); | |
43 } | 40 } |
44 | 41 |
45 void MockAuthenticator::LoginAsLocallyManagedUser( | 42 void MockAuthenticator::LoginAsLocallyManagedUser( |
46 const UserContext& user_context) { | 43 const UserContext& user_context) { |
47 consumer_->OnLoginSuccess(UserContext(expected_username_, | 44 consumer_->OnLoginSuccess(UserContext(expected_username_, |
48 std::string(), | 45 std::string(), |
49 std::string(), | 46 std::string(), |
50 user_context.username), // username_hash | 47 user_context.username), // username_hash |
51 false, | 48 false, |
52 false); | 49 false); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 } | 92 } |
96 | 93 |
97 void MockAuthenticator::SetExpectedCredentials( | 94 void MockAuthenticator::SetExpectedCredentials( |
98 const std::string& expected_username, | 95 const std::string& expected_username, |
99 const std::string& expected_password) { | 96 const std::string& expected_password) { |
100 expected_username_ = expected_username; | 97 expected_username_ = expected_username; |
101 expected_password_ = expected_password; | 98 expected_password_ = expected_password; |
102 } | 99 } |
103 | 100 |
104 } // namespace chromeos | 101 } // namespace chromeos |
OLD | NEW |