Commit 047f81c7 authored by rogerta@chromium.org's avatar rogerta@chromium.org

Remove SigninManager::StartSignIn() since /ClientLogin is no longer used.

BUG=92948

Review URL: https://chromiumcodereview.appspot.com/23245003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221919 0039d316-1c4b-4281-b951-d872f2087c98
parent f115bd90
...@@ -43,13 +43,6 @@ FakeSigninManager::~FakeSigninManager() { ...@@ -43,13 +43,6 @@ FakeSigninManager::~FakeSigninManager() {
void FakeSigninManager::InitTokenService() { void FakeSigninManager::InitTokenService() {
} }
void FakeSigninManager::StartSignIn(const std::string& username,
const std::string& password,
const std::string& login_token,
const std::string& login_captcha) {
SetAuthenticatedUsername(username);
}
void FakeSigninManager::StartSignInWithCredentials( void FakeSigninManager::StartSignInWithCredentials(
const std::string& session_index, const std::string& session_index,
const std::string& username, const std::string& username,
......
...@@ -41,10 +41,6 @@ class FakeSigninManager : public SigninManager { ...@@ -41,10 +41,6 @@ class FakeSigninManager : public SigninManager {
virtual void SignOut() OVERRIDE; virtual void SignOut() OVERRIDE;
virtual void InitTokenService() OVERRIDE; virtual void InitTokenService() OVERRIDE;
virtual void StartSignIn(const std::string& username,
const std::string& password,
const std::string& login_token,
const std::string& login_captcha) OVERRIDE;
virtual void StartSignInWithCredentials( virtual void StartSignInWithCredentials(
const std::string& session_index, const std::string& session_index,
......
...@@ -130,8 +130,6 @@ std::string SigninManager::SigninTypeToString( ...@@ -130,8 +130,6 @@ std::string SigninManager::SigninTypeToString(
switch (type) { switch (type) {
case SIGNIN_TYPE_NONE: case SIGNIN_TYPE_NONE:
return "No Signin"; return "No Signin";
case SIGNIN_TYPE_CLIENT_LOGIN:
return "Client Login";
case SIGNIN_TYPE_WITH_CREDENTIALS: case SIGNIN_TYPE_WITH_CREDENTIALS:
return "Signin with credentials"; return "Signin with credentials";
} }
...@@ -168,47 +166,10 @@ bool SigninManager::PrepareForSignin(SigninType type, ...@@ -168,47 +166,10 @@ bool SigninManager::PrepareForSignin(SigninType type,
client_login_.reset(new GaiaAuthFetcher(this, client_login_.reset(new GaiaAuthFetcher(this,
GaiaConstants::kChromeSource, GaiaConstants::kChromeSource,
profile_->GetRequestContext())); profile_->GetRequestContext()));
NotifyDiagnosticsObservers(SIGNIN_TYPE, SigninTypeToString(type)); NotifyDiagnosticsObservers(SIGNIN_TYPE, SigninTypeToString(type));
return true; return true;
} }
// Users must always sign out before they sign in again.
void SigninManager::StartSignIn(const std::string& username,
const std::string& password,
const std::string& login_token,
const std::string& login_captcha) {
DCHECK(GetAuthenticatedUsername().empty() ||
gaia::AreEmailsSame(username, GetAuthenticatedUsername()));
if (!PrepareForSignin(SIGNIN_TYPE_CLIENT_LOGIN, username, password))
return;
client_login_->StartClientLogin(username,
password,
"",
login_token,
login_captcha,
GaiaAuthFetcher::HostedAccountsNotAllowed);
}
void SigninManager::ProvideSecondFactorAccessCode(
const std::string& access_code) {
DCHECK(!possibly_invalid_username_.empty() && !password_.empty() &&
last_result_.data.empty());
DCHECK(type_ == SIGNIN_TYPE_CLIENT_LOGIN);
client_login_.reset(new GaiaAuthFetcher(this,
GaiaConstants::kChromeSource,
profile_->GetRequestContext()));
client_login_->StartClientLogin(possibly_invalid_username_,
access_code,
"",
std::string(),
std::string(),
GaiaAuthFetcher::HostedAccountsNotAllowed);
}
void SigninManager::StartSignInWithCredentials( void SigninManager::StartSignInWithCredentials(
const std::string& session_index, const std::string& session_index,
const std::string& username, const std::string& username,
......
...@@ -75,20 +75,6 @@ class SigninManager : public SigninManagerBase, ...@@ -75,20 +75,6 @@ class SigninManager : public SigninManagerBase,
static bool IsUsernameAllowedByPolicy(const std::string& username, static bool IsUsernameAllowedByPolicy(const std::string& username,
const std::string& policy); const std::string& policy);
// Attempt to sign in this user with ClientLogin. If successful, set a
// preference indicating the signed in user and send out a notification,
// then start fetching tokens for the user.
// This is overridden for test subclasses that don't want to issue auth
// requests.
virtual void StartSignIn(const std::string& username,
const std::string& password,
const std::string& login_token,
const std::string& login_captcha);
// Used when a second factor access code was required to complete a signin
// attempt.
void ProvideSecondFactorAccessCode(const std::string& access_code);
// Attempt to sign in this user with existing credentials from the cookie jar. // Attempt to sign in this user with existing credentials from the cookie jar.
// |session_index| indicates which user account to use if the cookie jar // |session_index| indicates which user account to use if the cookie jar
// contains a multi-login session. Otherwise the end result of this call is // contains a multi-login session. Otherwise the end result of this call is
...@@ -197,14 +183,14 @@ class SigninManager : public SigninManagerBase, ...@@ -197,14 +183,14 @@ class SigninManager : public SigninManagerBase,
bool prohibit_signout_; bool prohibit_signout_;
private: private:
// TODO(guohui): Leaving the sign in type here because a follow up CL by
// Hui will add a new type. Hui: please remove this comment in your CL.
enum SigninType { enum SigninType {
SIGNIN_TYPE_NONE, SIGNIN_TYPE_NONE,
SIGNIN_TYPE_CLIENT_LOGIN,
SIGNIN_TYPE_WITH_CREDENTIALS, SIGNIN_TYPE_WITH_CREDENTIALS,
}; };
std::string SigninTypeToString(SigninType type); std::string SigninTypeToString(SigninType type);
friend class FakeSigninManager; friend class FakeSigninManager;
FRIEND_TEST_ALL_PREFIXES(SigninManagerTest, ClearTransientSigninData); FRIEND_TEST_ALL_PREFIXES(SigninManagerTest, ClearTransientSigninData);
FRIEND_TEST_ALL_PREFIXES(SigninManagerTest, ProvideSecondFactorSuccess); FRIEND_TEST_ALL_PREFIXES(SigninManagerTest, ProvideSecondFactorSuccess);
......
...@@ -209,40 +209,6 @@ class SigninManagerTest : public TokenServiceTestHarness { ...@@ -209,40 +209,6 @@ class SigninManagerTest : public TokenServiceTestHarness {
std::vector<std::string> cookies_; std::vector<std::string> cookies_;
}; };
// NOTE: ClientLogin's "StartSignin" is called after collecting credentials
// from the user.
TEST_F(SigninManagerTest, SignInClientLogin) {
manager_->Initialize(profile(), NULL);
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
manager_->StartSignIn(
"user@gmail.com", "password", std::string(), std::string());
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
SimulateValidResponseClientLogin(true);
EXPECT_FALSE(manager_->GetAuthenticatedUsername().empty());
// Should go into token service and stop.
EXPECT_EQ(1U, google_login_success_.size());
EXPECT_EQ(0U, google_login_failure_.size());
service()->OnIssueAuthTokenSuccess(
GaiaConstants::kGaiaOAuth2LoginRefreshToken,
"oauth2Token");
SimulateValidUberToken();
// Check that the login cookie has been sent.
ASSERT_NE(std::find(cookies_.begin(), cookies_.end(), "checkCookie = true"),
cookies_.end());
// Should persist across resets.
manager_->Shutdown();
manager_.reset(new SigninManager(
scoped_ptr<SigninManagerDelegate>(
new ChromeSigninManagerDelegate(profile()))));
manager_->Initialize(profile(), NULL);
EXPECT_EQ("user@gmail.com", manager_->GetAuthenticatedUsername());
}
TEST_F(SigninManagerTest, SignInWithCredentials) { TEST_F(SigninManagerTest, SignInWithCredentials) {
manager_->Initialize(profile(), NULL); manager_->Initialize(profile(), NULL);
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
...@@ -396,59 +362,13 @@ TEST_F(SigninManagerTest, SignInWithCredentialsCallbackCancel) { ...@@ -396,59 +362,13 @@ TEST_F(SigninManagerTest, SignInWithCredentialsCallbackCancel) {
EXPECT_EQ(oauth_tokens_fetched_[0], "rt1"); EXPECT_EQ(oauth_tokens_fetched_[0], "rt1");
} }
TEST_F(SigninManagerTest, SignInClientLoginNoGPlus) { TEST_F(SigninManagerTest, SignOut) {
manager_->Initialize(profile(), NULL);
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
manager_->StartSignIn("username", "password", std::string(), std::string());
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
SimulateValidResponseClientLogin(false);
EXPECT_FALSE(manager_->GetAuthenticatedUsername().empty());
}
TEST_F(SigninManagerTest, ClearTransientSigninData) {
manager_->Initialize(profile(), NULL);
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
manager_->StartSignIn("username", "password", std::string(), std::string());
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
SimulateValidResponseClientLogin(false);
// Should go into token service and stop.
EXPECT_EQ(1U, google_login_success_.size());
EXPECT_EQ(0U, google_login_failure_.size());
EXPECT_EQ("user@gmail.com", manager_->GetAuthenticatedUsername());
// Now clear the in memory data.
manager_->ClearTransientSigninData();
EXPECT_TRUE(manager_->last_result_.data.empty());
EXPECT_FALSE(manager_->GetAuthenticatedUsername().empty());
// Ensure preferences are not modified.
EXPECT_FALSE(
profile()->GetPrefs()->GetString(prefs::kGoogleServicesUsername).empty());
// On reset it should be regenerated.
manager_->Shutdown();
manager_.reset(new SigninManager(
scoped_ptr<SigninManagerDelegate>(
new ChromeSigninManagerDelegate(profile()))));
manager_->Initialize(profile(), NULL);
// Now make sure we have the right user name.
EXPECT_EQ("user@gmail.com", manager_->GetAuthenticatedUsername());
}
TEST_F(SigninManagerTest, SignOutClientLogin) {
manager_->Initialize(profile(), NULL); manager_->Initialize(profile(), NULL);
manager_->StartSignIn("username", "password", std::string(), std::string()); SigninManager::OAuthTokenFetchedCallback dummy;
SimulateValidResponseClientLogin(false); manager_->StartSignInWithCredentials("0", "user@gmail.com", "password",
manager_->OnClientLoginSuccess(credentials()); dummy);
ExpectSignInWithCredentialsSuccess();
EXPECT_EQ("user@gmail.com", manager_->GetAuthenticatedUsername());
manager_->SignOut(); manager_->SignOut();
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
// Should not be persisted anymore // Should not be persisted anymore
...@@ -460,79 +380,12 @@ TEST_F(SigninManagerTest, SignOutClientLogin) { ...@@ -460,79 +380,12 @@ TEST_F(SigninManagerTest, SignOutClientLogin) {
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
} }
TEST_F(SigninManagerTest, SignInFailureClientLogin) {
manager_->Initialize(profile(), NULL);
manager_->StartSignIn("username", "password", std::string(), std::string());
GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED);
manager_->OnClientLoginFailure(error);
EXPECT_EQ(0U, google_login_success_.size());
EXPECT_EQ(1U, google_login_failure_.size());
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
// Should not be persisted
manager_->Shutdown();
manager_.reset(new SigninManager(
scoped_ptr<SigninManagerDelegate>(
new ChromeSigninManagerDelegate(profile()))));
manager_->Initialize(profile(), NULL);
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
}
TEST_F(SigninManagerTest, ProvideSecondFactorSuccess) {
manager_->Initialize(profile(), NULL);
manager_->StartSignIn("username", "password", std::string(), std::string());
GoogleServiceAuthError error(GoogleServiceAuthError::TWO_FACTOR);
manager_->OnClientLoginFailure(error);
EXPECT_EQ(0U, google_login_success_.size());
EXPECT_EQ(1U, google_login_failure_.size());
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
EXPECT_FALSE(manager_->possibly_invalid_username_.empty());
manager_->ProvideSecondFactorAccessCode("access");
SimulateValidResponseClientLogin(false);
EXPECT_EQ(1U, google_login_success_.size());
EXPECT_EQ(1U, google_login_failure_.size());
}
TEST_F(SigninManagerTest, ProvideSecondFactorFailure) {
manager_->Initialize(profile(), NULL);
manager_->StartSignIn("username", "password", std::string(), std::string());
GoogleServiceAuthError error1(GoogleServiceAuthError::TWO_FACTOR);
manager_->OnClientLoginFailure(error1);
EXPECT_EQ(0U, google_login_success_.size());
EXPECT_EQ(1U, google_login_failure_.size());
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
EXPECT_FALSE(manager_->possibly_invalid_username_.empty());
manager_->ProvideSecondFactorAccessCode("badaccess");
GoogleServiceAuthError error2(
GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
manager_->OnClientLoginFailure(error2);
EXPECT_EQ(0U, google_login_success_.size());
EXPECT_EQ(2U, google_login_failure_.size());
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
manager_->ProvideSecondFactorAccessCode("badaccess");
GoogleServiceAuthError error3(GoogleServiceAuthError::CONNECTION_FAILED);
manager_->OnClientLoginFailure(error3);
EXPECT_EQ(0U, google_login_success_.size());
EXPECT_EQ(3U, google_login_failure_.size());
EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty());
}
TEST_F(SigninManagerTest, SignOutMidConnect) { TEST_F(SigninManagerTest, SignOutMidConnect) {
manager_->Initialize(profile(), NULL); manager_->Initialize(profile(), NULL);
manager_->StartSignIn("username", "password", std::string(), std::string()); SigninManager::OAuthTokenFetchedCallback dummy;
EXPECT_EQ("username", manager_->GetUsernameForAuthInProgress()); manager_->StartSignInWithCredentials("0", "user@gmail.com", "password",
dummy);
manager_->SignOut(); manager_->SignOut();
EXPECT_EQ(0U, google_login_success_.size()); EXPECT_EQ(0U, google_login_success_.size());
EXPECT_EQ(1U, google_login_failure_.size()); EXPECT_EQ(1U, google_login_failure_.size());
......
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