| 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/signin/signin_manager.h" | 5 #include "chrome/browser/signin/signin_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 scoped_ptr<content::TestBrowserThread> io_thread_; | 301 scoped_ptr<content::TestBrowserThread> io_thread_; |
| 302 std::vector<std::string> cookies_; | 302 std::vector<std::string> cookies_; |
| 303 }; | 303 }; |
| 304 | 304 |
| 305 // NOTE: ClientLogin's "StartSignin" is called after collecting credentials | 305 // NOTE: ClientLogin's "StartSignin" is called after collecting credentials |
| 306 // from the user. | 306 // from the user. |
| 307 TEST_F(SigninManagerTest, SignInClientLogin) { | 307 TEST_F(SigninManagerTest, SignInClientLogin) { |
| 308 manager_->Initialize(profile_.get()); | 308 manager_->Initialize(profile_.get()); |
| 309 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); | 309 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); |
| 310 | 310 |
| 311 manager_->StartSignIn("user@gmail.com", "password", "", ""); | 311 manager_->StartSignIn( |
| 312 "user@gmail.com", "password", std::string(), std::string()); |
| 312 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); | 313 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); |
| 313 | 314 |
| 314 SimulateValidResponseClientLogin(true); | 315 SimulateValidResponseClientLogin(true); |
| 315 EXPECT_FALSE(manager_->GetAuthenticatedUsername().empty()); | 316 EXPECT_FALSE(manager_->GetAuthenticatedUsername().empty()); |
| 316 | 317 |
| 317 // Should go into token service and stop. | 318 // Should go into token service and stop. |
| 318 EXPECT_EQ(1U, google_login_success_.size()); | 319 EXPECT_EQ(1U, google_login_success_.size()); |
| 319 EXPECT_EQ(0U, google_login_failure_.size()); | 320 EXPECT_EQ(0U, google_login_failure_.size()); |
| 320 | 321 |
| 321 service_->OnIssueAuthTokenSuccess(GaiaConstants::kGaiaOAuth2LoginRefreshToken, | 322 service_->OnIssueAuthTokenSuccess(GaiaConstants::kGaiaOAuth2LoginRefreshToken, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 333 } | 334 } |
| 334 | 335 |
| 335 TEST_F(SigninManagerTest, Prohibited) { | 336 TEST_F(SigninManagerTest, Prohibited) { |
| 336 g_browser_process->local_state()->SetString( | 337 g_browser_process->local_state()->SetString( |
| 337 prefs::kGoogleServicesUsernamePattern, ".*@google.com"); | 338 prefs::kGoogleServicesUsernamePattern, ".*@google.com"); |
| 338 manager_->Initialize(profile_.get()); | 339 manager_->Initialize(profile_.get()); |
| 339 EXPECT_TRUE(manager_->IsAllowedUsername("test@google.com")); | 340 EXPECT_TRUE(manager_->IsAllowedUsername("test@google.com")); |
| 340 EXPECT_TRUE(manager_->IsAllowedUsername("happy@google.com")); | 341 EXPECT_TRUE(manager_->IsAllowedUsername("happy@google.com")); |
| 341 EXPECT_FALSE(manager_->IsAllowedUsername("test@invalid.com")); | 342 EXPECT_FALSE(manager_->IsAllowedUsername("test@invalid.com")); |
| 342 EXPECT_FALSE(manager_->IsAllowedUsername("test@notgoogle.com")); | 343 EXPECT_FALSE(manager_->IsAllowedUsername("test@notgoogle.com")); |
| 343 EXPECT_FALSE(manager_->IsAllowedUsername("")); | 344 EXPECT_FALSE(manager_->IsAllowedUsername(std::string())); |
| 344 } | 345 } |
| 345 | 346 |
| 346 TEST_F(SigninManagerTest, TestAlternateWildcard) { | 347 TEST_F(SigninManagerTest, TestAlternateWildcard) { |
| 347 // Test to make sure we accept "*@google.com" as a pattern (treat it as if | 348 // Test to make sure we accept "*@google.com" as a pattern (treat it as if |
| 348 // the admin entered ".*@google.com"). | 349 // the admin entered ".*@google.com"). |
| 349 g_browser_process->local_state()->SetString( | 350 g_browser_process->local_state()->SetString( |
| 350 prefs::kGoogleServicesUsernamePattern, "*@google.com"); | 351 prefs::kGoogleServicesUsernamePattern, "*@google.com"); |
| 351 manager_->Initialize(profile_.get()); | 352 manager_->Initialize(profile_.get()); |
| 352 EXPECT_TRUE(manager_->IsAllowedUsername("test@google.com")); | 353 EXPECT_TRUE(manager_->IsAllowedUsername("test@google.com")); |
| 353 EXPECT_TRUE(manager_->IsAllowedUsername("happy@google.com")); | 354 EXPECT_TRUE(manager_->IsAllowedUsername("happy@google.com")); |
| 354 EXPECT_FALSE(manager_->IsAllowedUsername("test@invalid.com")); | 355 EXPECT_FALSE(manager_->IsAllowedUsername("test@invalid.com")); |
| 355 EXPECT_FALSE(manager_->IsAllowedUsername("test@notgoogle.com")); | 356 EXPECT_FALSE(manager_->IsAllowedUsername("test@notgoogle.com")); |
| 356 EXPECT_FALSE(manager_->IsAllowedUsername("")); | 357 EXPECT_FALSE(manager_->IsAllowedUsername(std::string())); |
| 357 } | 358 } |
| 358 | 359 |
| 359 TEST_F(SigninManagerTest, ProhibitedAtStartup) { | 360 TEST_F(SigninManagerTest, ProhibitedAtStartup) { |
| 360 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, | 361 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, |
| 361 "monkey@invalid.com"); | 362 "monkey@invalid.com"); |
| 362 g_browser_process->local_state()->SetString( | 363 g_browser_process->local_state()->SetString( |
| 363 prefs::kGoogleServicesUsernamePattern, ".*@google.com"); | 364 prefs::kGoogleServicesUsernamePattern, ".*@google.com"); |
| 364 manager_->Initialize(profile_.get()); | 365 manager_->Initialize(profile_.get()); |
| 365 // Currently signed in user is prohibited by policy, so should be signed out. | 366 // Currently signed in user is prohibited by policy, so should be signed out. |
| 366 EXPECT_EQ("", manager_->GetAuthenticatedUsername()); | 367 EXPECT_EQ("", manager_->GetAuthenticatedUsername()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 scoped_refptr<net::CookieMonster> cookie_monster = | 415 scoped_refptr<net::CookieMonster> cookie_monster = |
| 415 profile_->GetCookieMonster(); | 416 profile_->GetCookieMonster(); |
| 416 net::CookieOptions options; | 417 net::CookieOptions options; |
| 417 options.set_include_httponly(); | 418 options.set_include_httponly(); |
| 418 cookie_monster->SetCookieWithOptionsAsync( | 419 cookie_monster->SetCookieWithOptionsAsync( |
| 419 GURL("https://accounts.google.com"), | 420 GURL("https://accounts.google.com"), |
| 420 "LSID=1234; secure; httponly", options, | 421 "LSID=1234; secure; httponly", options, |
| 421 net::CookieMonster::SetCookiesCallback()); | 422 net::CookieMonster::SetCookiesCallback()); |
| 422 | 423 |
| 423 // Since the password is empty, will verify the gaia cookies first. | 424 // Since the password is empty, will verify the gaia cookies first. |
| 424 manager_->StartSignInWithCredentials("0", "user@gmail.com", ""); | 425 manager_->StartSignInWithCredentials("0", "user@gmail.com", std::string()); |
| 425 | 426 |
| 426 WaitUntilUIDone(); | 427 WaitUntilUIDone(); |
| 427 | 428 |
| 428 // Verification should succeed and continue with auto signin. | 429 // Verification should succeed and continue with auto signin. |
| 429 ExpectSignInWithCredentialsSuccess(); | 430 ExpectSignInWithCredentialsSuccess(); |
| 430 } | 431 } |
| 431 | 432 |
| 432 TEST_F(SigninManagerTest, SignInWithCredentialsEmptyPasswordNoValidCookie) { | 433 TEST_F(SigninManagerTest, SignInWithCredentialsEmptyPasswordNoValidCookie) { |
| 433 manager_->Initialize(profile_.get()); | 434 manager_->Initialize(profile_.get()); |
| 434 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); | 435 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); |
| 435 | 436 |
| 436 // Since the password is empty, will verify the gaia cookies first. | 437 // Since the password is empty, will verify the gaia cookies first. |
| 437 manager_->StartSignInWithCredentials("0", "user@gmail.com", ""); | 438 manager_->StartSignInWithCredentials("0", "user@gmail.com", std::string()); |
| 438 | 439 |
| 439 WaitUntilUIDone(); | 440 WaitUntilUIDone(); |
| 440 | 441 |
| 441 // Since the test cookie store is empty, verification should fail and throws | 442 // Since the test cookie store is empty, verification should fail and throws |
| 442 // a login error. | 443 // a login error. |
| 443 ExpectSignInWithCredentialsFail(false /* requestSent */); | 444 ExpectSignInWithCredentialsFail(false /* requestSent */); |
| 444 } | 445 } |
| 445 | 446 |
| 446 TEST_F(SigninManagerTest, SignInWithCredentialsEmptyPasswordInValidCookie) { | 447 TEST_F(SigninManagerTest, SignInWithCredentialsEmptyPasswordInValidCookie) { |
| 447 manager_->Initialize(profile_.get()); | 448 manager_->Initialize(profile_.get()); |
| 448 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); | 449 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); |
| 449 | 450 |
| 450 // Set an invalid LSID cookie in the test cookie store. | 451 // Set an invalid LSID cookie in the test cookie store. |
| 451 scoped_refptr<net::CookieMonster> cookie_monster = | 452 scoped_refptr<net::CookieMonster> cookie_monster = |
| 452 profile_->GetCookieMonster(); | 453 profile_->GetCookieMonster(); |
| 453 net::CookieOptions options; | 454 net::CookieOptions options; |
| 454 options.set_include_httponly(); | 455 options.set_include_httponly(); |
| 455 cookie_monster->SetCookieWithOptionsAsync( | 456 cookie_monster->SetCookieWithOptionsAsync( |
| 456 GURL("https://accounts.google.com"), | 457 GURL("https://accounts.google.com"), |
| 457 "LSID=1234; domain=google.com; secure; httponly", options, | 458 "LSID=1234; domain=google.com; secure; httponly", options, |
| 458 net::CookieMonster::SetCookiesCallback()); | 459 net::CookieMonster::SetCookiesCallback()); |
| 459 | 460 |
| 460 // Since the password is empty, must verify the gaia cookies first. | 461 // Since the password is empty, must verify the gaia cookies first. |
| 461 manager_->StartSignInWithCredentials("0", "user@gmail.com", ""); | 462 manager_->StartSignInWithCredentials("0", "user@gmail.com", std::string()); |
| 462 | 463 |
| 463 WaitUntilUIDone(); | 464 WaitUntilUIDone(); |
| 464 | 465 |
| 465 // Since the LSID cookie is invalid, verification should fail and throws | 466 // Since the LSID cookie is invalid, verification should fail and throws |
| 466 // a login error. | 467 // a login error. |
| 467 ExpectSignInWithCredentialsFail(false /* requestSent */); | 468 ExpectSignInWithCredentialsFail(false /* requestSent */); |
| 468 } | 469 } |
| 469 | 470 |
| 470 TEST_F(SigninManagerTest, SignInClientLoginNoGPlus) { | 471 TEST_F(SigninManagerTest, SignInClientLoginNoGPlus) { |
| 471 manager_->Initialize(profile_.get()); | 472 manager_->Initialize(profile_.get()); |
| 472 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); | 473 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); |
| 473 | 474 |
| 474 manager_->StartSignIn("username", "password", "", ""); | 475 manager_->StartSignIn("username", "password", std::string(), std::string()); |
| 475 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); | 476 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); |
| 476 | 477 |
| 477 SimulateValidResponseClientLogin(false); | 478 SimulateValidResponseClientLogin(false); |
| 478 EXPECT_FALSE(manager_->GetAuthenticatedUsername().empty()); | 479 EXPECT_FALSE(manager_->GetAuthenticatedUsername().empty()); |
| 479 } | 480 } |
| 480 | 481 |
| 481 TEST_F(SigninManagerTest, ClearTransientSigninData) { | 482 TEST_F(SigninManagerTest, ClearTransientSigninData) { |
| 482 manager_->Initialize(profile_.get()); | 483 manager_->Initialize(profile_.get()); |
| 483 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); | 484 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); |
| 484 | 485 |
| 485 manager_->StartSignIn("username", "password", "", ""); | 486 manager_->StartSignIn("username", "password", std::string(), std::string()); |
| 486 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); | 487 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); |
| 487 | 488 |
| 488 SimulateValidResponseClientLogin(false); | 489 SimulateValidResponseClientLogin(false); |
| 489 | 490 |
| 490 // Should go into token service and stop. | 491 // Should go into token service and stop. |
| 491 EXPECT_EQ(1U, google_login_success_.size()); | 492 EXPECT_EQ(1U, google_login_success_.size()); |
| 492 EXPECT_EQ(0U, google_login_failure_.size()); | 493 EXPECT_EQ(0U, google_login_failure_.size()); |
| 493 | 494 |
| 494 EXPECT_EQ("user@gmail.com", manager_->GetAuthenticatedUsername()); | 495 EXPECT_EQ("user@gmail.com", manager_->GetAuthenticatedUsername()); |
| 495 | 496 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 506 manager_->Shutdown(); | 507 manager_->Shutdown(); |
| 507 manager_.reset(new SigninManager()); | 508 manager_.reset(new SigninManager()); |
| 508 manager_->Initialize(profile_.get()); | 509 manager_->Initialize(profile_.get()); |
| 509 | 510 |
| 510 // Now make sure we have the right user name. | 511 // Now make sure we have the right user name. |
| 511 EXPECT_EQ("user@gmail.com", manager_->GetAuthenticatedUsername()); | 512 EXPECT_EQ("user@gmail.com", manager_->GetAuthenticatedUsername()); |
| 512 } | 513 } |
| 513 | 514 |
| 514 TEST_F(SigninManagerTest, SignOutClientLogin) { | 515 TEST_F(SigninManagerTest, SignOutClientLogin) { |
| 515 manager_->Initialize(profile_.get()); | 516 manager_->Initialize(profile_.get()); |
| 516 manager_->StartSignIn("username", "password", "", ""); | 517 manager_->StartSignIn("username", "password", std::string(), std::string()); |
| 517 SimulateValidResponseClientLogin(false); | 518 SimulateValidResponseClientLogin(false); |
| 518 manager_->OnClientLoginSuccess(credentials_); | 519 manager_->OnClientLoginSuccess(credentials_); |
| 519 | 520 |
| 520 EXPECT_EQ("user@gmail.com", manager_->GetAuthenticatedUsername()); | 521 EXPECT_EQ("user@gmail.com", manager_->GetAuthenticatedUsername()); |
| 521 manager_->SignOut(); | 522 manager_->SignOut(); |
| 522 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); | 523 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); |
| 523 // Should not be persisted anymore | 524 // Should not be persisted anymore |
| 524 manager_->Shutdown(); | 525 manager_->Shutdown(); |
| 525 manager_.reset(new SigninManager()); | 526 manager_.reset(new SigninManager()); |
| 526 manager_->Initialize(profile_.get()); | 527 manager_->Initialize(profile_.get()); |
| 527 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); | 528 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); |
| 528 } | 529 } |
| 529 | 530 |
| 530 TEST_F(SigninManagerTest, SignInFailureClientLogin) { | 531 TEST_F(SigninManagerTest, SignInFailureClientLogin) { |
| 531 manager_->Initialize(profile_.get()); | 532 manager_->Initialize(profile_.get()); |
| 532 manager_->StartSignIn("username", "password", "", ""); | 533 manager_->StartSignIn("username", "password", std::string(), std::string()); |
| 533 GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED); | 534 GoogleServiceAuthError error(GoogleServiceAuthError::REQUEST_CANCELED); |
| 534 manager_->OnClientLoginFailure(error); | 535 manager_->OnClientLoginFailure(error); |
| 535 | 536 |
| 536 EXPECT_EQ(0U, google_login_success_.size()); | 537 EXPECT_EQ(0U, google_login_success_.size()); |
| 537 EXPECT_EQ(1U, google_login_failure_.size()); | 538 EXPECT_EQ(1U, google_login_failure_.size()); |
| 538 | 539 |
| 539 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); | 540 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); |
| 540 | 541 |
| 541 // Should not be persisted | 542 // Should not be persisted |
| 542 manager_->Shutdown(); | 543 manager_->Shutdown(); |
| 543 manager_.reset(new SigninManager()); | 544 manager_.reset(new SigninManager()); |
| 544 manager_->Initialize(profile_.get()); | 545 manager_->Initialize(profile_.get()); |
| 545 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); | 546 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); |
| 546 } | 547 } |
| 547 | 548 |
| 548 TEST_F(SigninManagerTest, ProvideSecondFactorSuccess) { | 549 TEST_F(SigninManagerTest, ProvideSecondFactorSuccess) { |
| 549 manager_->Initialize(profile_.get()); | 550 manager_->Initialize(profile_.get()); |
| 550 manager_->StartSignIn("username", "password", "", ""); | 551 manager_->StartSignIn("username", "password", std::string(), std::string()); |
| 551 GoogleServiceAuthError error(GoogleServiceAuthError::TWO_FACTOR); | 552 GoogleServiceAuthError error(GoogleServiceAuthError::TWO_FACTOR); |
| 552 manager_->OnClientLoginFailure(error); | 553 manager_->OnClientLoginFailure(error); |
| 553 | 554 |
| 554 EXPECT_EQ(0U, google_login_success_.size()); | 555 EXPECT_EQ(0U, google_login_success_.size()); |
| 555 EXPECT_EQ(1U, google_login_failure_.size()); | 556 EXPECT_EQ(1U, google_login_failure_.size()); |
| 556 | 557 |
| 557 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); | 558 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); |
| 558 EXPECT_FALSE(manager_->possibly_invalid_username_.empty()); | 559 EXPECT_FALSE(manager_->possibly_invalid_username_.empty()); |
| 559 | 560 |
| 560 manager_->ProvideSecondFactorAccessCode("access"); | 561 manager_->ProvideSecondFactorAccessCode("access"); |
| 561 SimulateValidResponseClientLogin(false); | 562 SimulateValidResponseClientLogin(false); |
| 562 | 563 |
| 563 EXPECT_EQ(1U, google_login_success_.size()); | 564 EXPECT_EQ(1U, google_login_success_.size()); |
| 564 EXPECT_EQ(1U, google_login_failure_.size()); | 565 EXPECT_EQ(1U, google_login_failure_.size()); |
| 565 } | 566 } |
| 566 | 567 |
| 567 TEST_F(SigninManagerTest, ProvideSecondFactorFailure) { | 568 TEST_F(SigninManagerTest, ProvideSecondFactorFailure) { |
| 568 manager_->Initialize(profile_.get()); | 569 manager_->Initialize(profile_.get()); |
| 569 manager_->StartSignIn("username", "password", "", ""); | 570 manager_->StartSignIn("username", "password", std::string(), std::string()); |
| 570 GoogleServiceAuthError error1(GoogleServiceAuthError::TWO_FACTOR); | 571 GoogleServiceAuthError error1(GoogleServiceAuthError::TWO_FACTOR); |
| 571 manager_->OnClientLoginFailure(error1); | 572 manager_->OnClientLoginFailure(error1); |
| 572 | 573 |
| 573 EXPECT_EQ(0U, google_login_success_.size()); | 574 EXPECT_EQ(0U, google_login_success_.size()); |
| 574 EXPECT_EQ(1U, google_login_failure_.size()); | 575 EXPECT_EQ(1U, google_login_failure_.size()); |
| 575 | 576 |
| 576 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); | 577 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); |
| 577 EXPECT_FALSE(manager_->possibly_invalid_username_.empty()); | 578 EXPECT_FALSE(manager_->possibly_invalid_username_.empty()); |
| 578 | 579 |
| 579 manager_->ProvideSecondFactorAccessCode("badaccess"); | 580 manager_->ProvideSecondFactorAccessCode("badaccess"); |
| 580 GoogleServiceAuthError error2( | 581 GoogleServiceAuthError error2( |
| 581 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); | 582 GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); |
| 582 manager_->OnClientLoginFailure(error2); | 583 manager_->OnClientLoginFailure(error2); |
| 583 | 584 |
| 584 EXPECT_EQ(0U, google_login_success_.size()); | 585 EXPECT_EQ(0U, google_login_success_.size()); |
| 585 EXPECT_EQ(2U, google_login_failure_.size()); | 586 EXPECT_EQ(2U, google_login_failure_.size()); |
| 586 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); | 587 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); |
| 587 | 588 |
| 588 manager_->ProvideSecondFactorAccessCode("badaccess"); | 589 manager_->ProvideSecondFactorAccessCode("badaccess"); |
| 589 GoogleServiceAuthError error3(GoogleServiceAuthError::CONNECTION_FAILED); | 590 GoogleServiceAuthError error3(GoogleServiceAuthError::CONNECTION_FAILED); |
| 590 manager_->OnClientLoginFailure(error3); | 591 manager_->OnClientLoginFailure(error3); |
| 591 | 592 |
| 592 EXPECT_EQ(0U, google_login_success_.size()); | 593 EXPECT_EQ(0U, google_login_success_.size()); |
| 593 EXPECT_EQ(3U, google_login_failure_.size()); | 594 EXPECT_EQ(3U, google_login_failure_.size()); |
| 594 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); | 595 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); |
| 595 } | 596 } |
| 596 | 597 |
| 597 TEST_F(SigninManagerTest, SignOutMidConnect) { | 598 TEST_F(SigninManagerTest, SignOutMidConnect) { |
| 598 manager_->Initialize(profile_.get()); | 599 manager_->Initialize(profile_.get()); |
| 599 manager_->StartSignIn("username", "password", "", ""); | 600 manager_->StartSignIn("username", "password", std::string(), std::string()); |
| 600 manager_->SignOut(); | 601 manager_->SignOut(); |
| 601 EXPECT_EQ(0U, google_login_success_.size()); | 602 EXPECT_EQ(0U, google_login_success_.size()); |
| 602 EXPECT_EQ(0U, google_login_failure_.size()); | 603 EXPECT_EQ(0U, google_login_failure_.size()); |
| 603 | 604 |
| 604 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); | 605 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); |
| 605 } | 606 } |
| 606 | 607 |
| 607 TEST_F(SigninManagerTest, SignInWithOAuth) { | 608 TEST_F(SigninManagerTest, SignInWithOAuth) { |
| 608 manager_->Initialize(profile_.get()); | 609 manager_->Initialize(profile_.get()); |
| 609 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); | 610 EXPECT_TRUE(manager_->GetAuthenticatedUsername().empty()); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 GURL("http://accounts.google.com/ServiceLogin?service=chromiumsync"))); | 677 GURL("http://accounts.google.com/ServiceLogin?service=chromiumsync"))); |
| 677 // http, not https, should not be treated as web based signin. | 678 // http, not https, should not be treated as web based signin. |
| 678 EXPECT_FALSE(SigninManager::IsWebBasedSigninFlowURL( | 679 EXPECT_FALSE(SigninManager::IsWebBasedSigninFlowURL( |
| 679 GURL("http://accounts.google.com/ServiceLogin?service=googlemail"))); | 680 GURL("http://accounts.google.com/ServiceLogin?service=googlemail"))); |
| 680 // chromiumsync is double-embedded in a continue query param. | 681 // chromiumsync is double-embedded in a continue query param. |
| 681 EXPECT_TRUE(SigninManager::IsWebBasedSigninFlowURL( | 682 EXPECT_TRUE(SigninManager::IsWebBasedSigninFlowURL( |
| 682 GURL("https://accounts.google.com/CheckCookie?" | 683 GURL("https://accounts.google.com/CheckCookie?" |
| 683 "continue=https%3A%2F%2Fwww.google.com%2Fintl%2Fen-US%2Fchrome" | 684 "continue=https%3A%2F%2Fwww.google.com%2Fintl%2Fen-US%2Fchrome" |
| 684 "%2Fblank.html%3Fsource%3D3%26nonadv%3D1&service=chromiumsync"))); | 685 "%2Fblank.html%3Fsource%3D3%26nonadv%3D1&service=chromiumsync"))); |
| 685 } | 686 } |
| OLD | NEW |