Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(802)

Side by Side Diff: chrome/browser/chromeos/login/login_utils_browsertest.cc

Issue 12704002: Support for auth code based authentication flow for both app and web UI driven flow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase4 Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/login_utils.h" 5 #include "chrome/browser/chromeos/login/login_utils.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 #if defined(ENABLE_RLZ) 379 #if defined(ENABLE_RLZ)
380 virtual void OnRlzInitialized(Profile* profile) OVERRIDE { 380 virtual void OnRlzInitialized(Profile* profile) OVERRIDE {
381 rlz_initialized_cb_.Run(); 381 rlz_initialized_cb_.Run();
382 } 382 }
383 #endif 383 #endif
384 384
385 virtual void OnLoginFailure(const LoginFailure& error) OVERRIDE { 385 virtual void OnLoginFailure(const LoginFailure& error) OVERRIDE {
386 FAIL() << "OnLoginFailure not expected"; 386 FAIL() << "OnLoginFailure not expected";
387 } 387 }
388 388
389 virtual void OnLoginSuccess(const std::string& username, 389 virtual void OnLoginSuccess(const UserCredentials& credentials,
390 const std::string& password,
391 bool pending_requests, 390 bool pending_requests,
392 bool using_oauth) OVERRIDE { 391 bool using_oauth) OVERRIDE {
393 FAIL() << "OnLoginSuccess not expected"; 392 FAIL() << "OnLoginSuccess not expected";
394 } 393 }
395 394
396 void EnrollDevice(const std::string& username) { 395 void EnrollDevice(const std::string& username) {
397 EXPECT_CALL(*cryptohome_, InstallAttributesIsFirstInstall()) 396 EXPECT_CALL(*cryptohome_, InstallAttributesIsFirstInstall())
398 .WillOnce(Return(true)) 397 .WillOnce(Return(true))
399 .WillRepeatedly(Return(false)); 398 .WillRepeatedly(Return(false));
400 EXPECT_EQ(policy::EnterpriseInstallAttributes::LOCK_SUCCESS, 399 EXPECT_EQ(policy::EnterpriseInstallAttributes::LOCK_SUCCESS,
401 connector_->GetInstallAttributes()->LockDevice( 400 connector_->GetInstallAttributes()->LockDevice(
402 username, policy::DEVICE_MODE_ENTERPRISE, kDeviceId)); 401 username, policy::DEVICE_MODE_ENTERPRISE, kDeviceId));
403 RunUntilIdle(); 402 RunUntilIdle();
404 } 403 }
405 404
406 void PrepareProfile(const std::string& username) { 405 void PrepareProfile(const std::string& username) {
407 ScopedDeviceSettingsTestHelper device_settings_test_helper; 406 ScopedDeviceSettingsTestHelper device_settings_test_helper;
408 MockSessionManagerClient* session_manager_client = 407 MockSessionManagerClient* session_manager_client =
409 mock_dbus_thread_manager_.mock_session_manager_client(); 408 mock_dbus_thread_manager_.mock_session_manager_client();
410 EXPECT_CALL(*session_manager_client, StartSession(_)); 409 EXPECT_CALL(*session_manager_client, StartSession(_));
411 EXPECT_CALL(*cryptohome_, GetSystemSalt()) 410 EXPECT_CALL(*cryptohome_, GetSystemSalt())
412 .WillRepeatedly(Return(std::string("stub_system_salt"))); 411 .WillRepeatedly(Return(std::string("stub_system_salt")));
413 EXPECT_CALL(*mock_async_method_caller_, AsyncMount(_, _, _, _)) 412 EXPECT_CALL(*mock_async_method_caller_, AsyncMount(_, _, _, _))
414 .WillRepeatedly(Return()); 413 .WillRepeatedly(Return());
415 414
416 scoped_refptr<Authenticator> authenticator = 415 scoped_refptr<Authenticator> authenticator =
417 LoginUtils::Get()->CreateAuthenticator(this); 416 LoginUtils::Get()->CreateAuthenticator(this);
418 authenticator->CompleteLogin(ProfileManager::GetDefaultProfile(), 417 authenticator->CompleteLogin(ProfileManager::GetDefaultProfile(),
419 username, 418 UserCredentials(username,
420 "password"); 419 "password",
420 ""));
421 421
422 const bool kUsingOAuth = true; 422 const bool kUsingOAuth = true;
423 // Setting |kHasCookies| to false prevents ProfileAuthData::Transfer from 423 // Setting |kHasCookies| to false prevents ProfileAuthData::Transfer from
424 // waiting for an IO task before proceeding. 424 // waiting for an IO task before proceeding.
425 const bool kHasCookies = false; 425 const bool kHasCookies = false;
426 LoginUtils::Get()->PrepareProfile(username, std::string(), "password", 426 LoginUtils::Get()->PrepareProfile(
427 kUsingOAuth, kHasCookies, this); 427 UserCredentials(username, "password", std::string()),
428 std::string(), kUsingOAuth, kHasCookies, this);
428 device_settings_test_helper.Flush(); 429 device_settings_test_helper.Flush();
429 RunUntilIdle(); 430 RunUntilIdle();
430 } 431 }
431 432
432 net::TestURLFetcher* PrepareOAuthFetcher(const std::string& expected_url) { 433 net::TestURLFetcher* PrepareOAuthFetcher(const std::string& expected_url) {
433 net::TestURLFetcher* fetcher = test_url_fetcher_factory_.GetFetcherByID(0); 434 net::TestURLFetcher* fetcher = test_url_fetcher_factory_.GetFetcherByID(0);
434 EXPECT_TRUE(fetcher); 435 EXPECT_TRUE(fetcher);
435 if (!fetcher) 436 if (!fetcher)
436 return NULL; 437 return NULL;
437 EXPECT_TRUE(fetcher->delegate()); 438 EXPECT_TRUE(fetcher->delegate());
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 } 698 }
698 699
699 INSTANTIATE_TEST_CASE_P( 700 INSTANTIATE_TEST_CASE_P(
700 LoginUtilsBlockingLoginTestInstance, 701 LoginUtilsBlockingLoginTestInstance,
701 LoginUtilsBlockingLoginTest, 702 LoginUtilsBlockingLoginTest,
702 testing::Values(0, 1, 2, 3, 4, 5)); 703 testing::Values(0, 1, 2, 3, 4, 5));
703 704
704 } // namespace 705 } // namespace
705 706
706 } 707 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698