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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 content::RunAllPendingInMessageLoop(); | 98 content::RunAllPendingInMessageLoop(); |
99 break; | 99 break; |
100 } | 100 } |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 } // namespace | 104 } // namespace |
105 | 105 |
106 class ExistingUserControllerTest : public policy::DevicePolicyCrosBrowserTest { | 106 class ExistingUserControllerTest : public policy::DevicePolicyCrosBrowserTest { |
107 protected: | 107 protected: |
108 ExistingUserControllerTest() : mock_login_display_(NULL) {} | 108 ExistingUserControllerTest() |
109 : mock_login_display_(NULL), | |
achuithb
2015/10/23 00:08:49
in-class member initialization
Alexander Alekseev
2015/10/23 09:11:21
Done.
| |
110 account_id_(AccountId::FromUserEmail(kUsername)) {} | |
109 | 111 |
110 ExistingUserController* existing_user_controller() { | 112 ExistingUserController* existing_user_controller() { |
111 return ExistingUserController::current_controller(); | 113 return ExistingUserController::current_controller(); |
112 } | 114 } |
113 | 115 |
114 const ExistingUserController* existing_user_controller() const { | 116 const ExistingUserController* existing_user_controller() const { |
115 return ExistingUserController::current_controller(); | 117 return ExistingUserController::current_controller(); |
116 } | 118 } |
117 | 119 |
118 void SetUpInProcessBrowserTestFixture() override { | 120 void SetUpInProcessBrowserTestFixture() override { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 ListPrefUpdate users_pref(g_browser_process->local_state(), | 191 ListPrefUpdate users_pref(g_browser_process->local_state(), |
190 "LoggedInUsers"); | 192 "LoggedInUsers"); |
191 users_pref->AppendIfNotPresent(new base::StringValue(user_id)); | 193 users_pref->AppendIfNotPresent(new base::StringValue(user_id)); |
192 } | 194 } |
193 | 195 |
194 // ExistingUserController private member accessors. | 196 // ExistingUserController private member accessors. |
195 base::OneShotTimer* auto_login_timer() { | 197 base::OneShotTimer* auto_login_timer() { |
196 return existing_user_controller()->auto_login_timer_.get(); | 198 return existing_user_controller()->auto_login_timer_.get(); |
197 } | 199 } |
198 | 200 |
199 const std::string& auto_login_username() const { | 201 const AccountId auto_login_account_id() const { |
achuithb
2015/10/23 00:08:49
Return AccountId not const AccountId
Alexander Alekseev
2015/10/23 09:11:21
Done.
| |
200 return existing_user_controller()->public_session_auto_login_username_; | 202 return AccountId::FromUserEmail( |
203 existing_user_controller()->public_session_auto_login_username_); | |
201 } | 204 } |
202 | 205 |
203 int auto_login_delay() const { | 206 int auto_login_delay() const { |
204 return existing_user_controller()->public_session_auto_login_delay_; | 207 return existing_user_controller()->public_session_auto_login_delay_; |
205 } | 208 } |
206 | 209 |
207 bool is_login_in_progress() const { | 210 bool is_login_in_progress() const { |
208 return existing_user_controller()->is_login_in_progress_; | 211 return existing_user_controller()->is_login_in_progress_; |
209 } | 212 } |
210 | 213 |
211 scoped_ptr<ExistingUserController> existing_user_controller_; | 214 scoped_ptr<ExistingUserController> existing_user_controller_; |
212 | 215 |
213 // |mock_login_display_| is owned by the ExistingUserController, which calls | 216 // |mock_login_display_| is owned by the ExistingUserController, which calls |
214 // CreateLoginDisplay() on the |mock_login_display_host_| to get it. | 217 // CreateLoginDisplay() on the |mock_login_display_host_| to get it. |
215 MockLoginDisplay* mock_login_display_; | 218 MockLoginDisplay* mock_login_display_; |
216 scoped_ptr<MockLoginDisplayHost> mock_login_display_host_; | 219 scoped_ptr<MockLoginDisplayHost> mock_login_display_host_; |
217 | 220 |
218 // Mock URLFetcher. | 221 // Mock URLFetcher. |
219 MockURLFetcherFactory<SuccessFetcher> factory_; | 222 MockURLFetcherFactory<SuccessFetcher> factory_; |
220 | 223 |
224 const AccountId account_id_; | |
225 | |
221 private: | 226 private: |
222 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerTest); | 227 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerTest); |
223 }; | 228 }; |
224 | 229 |
225 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, PRE_ExistingUserLogin) { | 230 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, PRE_ExistingUserLogin) { |
226 RegisterUser(kUsername); | 231 RegisterUser(account_id_.GetUserEmail()); |
227 } | 232 } |
228 | 233 |
229 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) { | 234 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) { |
230 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 235 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
231 .Times(2); | 236 .Times(2); |
232 UserContext user_context(kUsername); | 237 UserContext user_context(account_id_); |
233 user_context.SetGaiaID(kGaiaID); | 238 user_context.SetGaiaID(kGaiaID); |
234 user_context.SetKey(Key(kPassword)); | 239 user_context.SetKey(Key(kPassword)); |
235 user_context.SetUserIDHash(kUsername); | 240 user_context.SetUserIDHash(account_id_.GetUserEmail()); |
236 test::UserSessionManagerTestApi session_manager_test_api( | 241 test::UserSessionManagerTestApi session_manager_test_api( |
237 UserSessionManager::GetInstance()); | 242 UserSessionManager::GetInstance()); |
238 session_manager_test_api.InjectStubUserContext(user_context); | 243 session_manager_test_api.InjectStubUserContext(user_context); |
239 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) | 244 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) |
240 .Times(1); | 245 .Times(1); |
241 EXPECT_CALL(*mock_login_display_host_, | 246 EXPECT_CALL(*mock_login_display_host_, |
242 StartWizard(WizardController::kTermsOfServiceScreenName)) | 247 StartWizard(WizardController::kTermsOfServiceScreenName)) |
243 .Times(0); | 248 .Times(0); |
244 | 249 |
245 content::WindowedNotificationObserver profile_prepared_observer( | 250 content::WindowedNotificationObserver profile_prepared_observer( |
(...skipping 27 matching lines...) Expand all Loading... | |
273 | 278 |
274 ExpectLoginFailure(); | 279 ExpectLoginFailure(); |
275 } | 280 } |
276 | 281 |
277 void ExistingUserControllerUntrustedTest::SetUpSessionManager() { | 282 void ExistingUserControllerUntrustedTest::SetUpSessionManager() { |
278 InstallOwnerKey(); | 283 InstallOwnerKey(); |
279 } | 284 } |
280 | 285 |
281 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 286 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
282 ExistingUserLoginForbidden) { | 287 ExistingUserLoginForbidden) { |
283 UserContext user_context(kUsername); | 288 UserContext user_context(account_id_); |
284 user_context.SetGaiaID(kGaiaID); | 289 user_context.SetGaiaID(kGaiaID); |
285 user_context.SetKey(Key(kPassword)); | 290 user_context.SetKey(Key(kPassword)); |
286 user_context.SetUserIDHash(kUsername); | 291 user_context.SetUserIDHash(account_id_.GetUserEmail()); |
287 existing_user_controller()->Login(user_context, SigninSpecifics()); | 292 existing_user_controller()->Login(user_context, SigninSpecifics()); |
288 } | 293 } |
289 | 294 |
290 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 295 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
291 NewUserLoginForbidden) { | 296 NewUserLoginForbidden) { |
292 UserContext user_context(kUsername); | 297 UserContext user_context(account_id_); |
293 user_context.SetGaiaID(kGaiaID); | 298 user_context.SetGaiaID(kGaiaID); |
294 user_context.SetKey(Key(kPassword)); | 299 user_context.SetKey(Key(kPassword)); |
295 user_context.SetUserIDHash(kUsername); | 300 user_context.SetUserIDHash(account_id_.GetUserEmail()); |
296 existing_user_controller()->CompleteLogin(user_context); | 301 existing_user_controller()->CompleteLogin(user_context); |
297 } | 302 } |
298 | 303 |
299 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 304 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
300 GuestLoginForbidden) { | 305 GuestLoginForbidden) { |
301 existing_user_controller()->Login( | 306 existing_user_controller()->Login( |
302 UserContext(user_manager::USER_TYPE_GUEST, std::string()), | 307 UserContext(user_manager::USER_TYPE_GUEST, std::string()), |
303 SigninSpecifics()); | 308 SigninSpecifics()); |
304 } | 309 } |
305 | 310 |
306 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 311 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
307 SupervisedUserLoginForbidden) { | 312 SupervisedUserLoginForbidden) { |
308 UserContext user_context(kSupervisedUserID); | 313 UserContext user_context(AccountId::FromUserEmail(kSupervisedUserID)); |
309 user_context.SetKey(Key(kPassword)); | 314 user_context.SetKey(Key(kPassword)); |
310 user_context.SetUserIDHash(kUsername); | 315 user_context.SetUserIDHash(account_id_.GetUserEmail()); |
311 existing_user_controller()->Login(user_context, SigninSpecifics()); | 316 existing_user_controller()->Login(user_context, SigninSpecifics()); |
312 } | 317 } |
313 | 318 |
314 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 319 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
315 SupervisedUserCreationForbidden) { | 320 SupervisedUserCreationForbidden) { |
316 MockBaseScreenDelegate mock_base_screen_delegate; | 321 MockBaseScreenDelegate mock_base_screen_delegate; |
317 SupervisedUserCreationScreenHandler supervised_user_creation_screen_handler; | 322 SupervisedUserCreationScreenHandler supervised_user_creation_screen_handler; |
318 SupervisedUserCreationScreen supervised_user_creation_screen( | 323 SupervisedUserCreationScreen supervised_user_creation_screen( |
319 &mock_base_screen_delegate, &supervised_user_creation_screen_handler); | 324 &mock_base_screen_delegate, &supervised_user_creation_screen_handler); |
320 | 325 |
321 supervised_user_creation_screen.AuthenticateManager(kUsername, kPassword); | 326 supervised_user_creation_screen.AuthenticateManager( |
327 account_id_.GetUserEmail(), kPassword); | |
322 } | 328 } |
323 | 329 |
324 MATCHER_P(HasDetails, expected, "") { | 330 MATCHER_P(HasDetails, expected, "") { |
325 return expected == *content::Details<const std::string>(arg).ptr(); | 331 return expected == *content::Details<const std::string>(arg).ptr(); |
326 } | 332 } |
327 | 333 |
328 class ExistingUserControllerPublicSessionTest | 334 class ExistingUserControllerPublicSessionTest |
329 : public ExistingUserControllerTest { | 335 : public ExistingUserControllerTest { |
330 protected: | 336 protected: |
331 ExistingUserControllerPublicSessionTest() | 337 ExistingUserControllerPublicSessionTest() |
332 : public_session_user_id_(policy::GenerateDeviceLocalAccountUserId( | 338 : public_session_user_id_( |
333 kPublicSessionAccountId, | 339 AccountId::FromUserEmail(policy::GenerateDeviceLocalAccountUserId( |
334 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION)) { | 340 kPublicSessionAccountId, |
335 } | 341 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION))) {} |
336 | 342 |
337 void SetUpOnMainThread() override { | 343 void SetUpOnMainThread() override { |
338 ExistingUserControllerTest::SetUpOnMainThread(); | 344 ExistingUserControllerTest::SetUpOnMainThread(); |
339 | 345 |
340 // Wait for the public session user to be created. | 346 // Wait for the public session user to be created. |
341 if (!user_manager::UserManager::Get()->IsKnownUser( | 347 if (!user_manager::UserManager::Get()->IsKnownUser( |
342 public_session_user_id_)) { | 348 public_session_user_id_)) { |
343 content::WindowedNotificationObserver( | 349 content::WindowedNotificationObserver( |
344 chrome::NOTIFICATION_USER_LIST_CHANGED, | 350 chrome::NOTIFICATION_USER_LIST_CHANGED, |
345 base::Bind(&user_manager::UserManager::IsKnownUser, | 351 base::Bind(&user_manager::UserManager::IsKnownUser, |
346 base::Unretained(user_manager::UserManager::Get()), | 352 base::Unretained(user_manager::UserManager::Get()), |
347 public_session_user_id_)).Wait(); | 353 public_session_user_id_)).Wait(); |
348 } | 354 } |
349 | 355 |
350 // Wait for the device local account policy to be installed. | 356 // Wait for the device local account policy to be installed. |
351 policy::CloudPolicyStore* store = | 357 policy::CloudPolicyStore* store = |
352 TestingBrowserProcess::GetGlobal() | 358 TestingBrowserProcess::GetGlobal() |
353 ->platform_part() | 359 ->platform_part() |
354 ->browser_policy_connector_chromeos() | 360 ->browser_policy_connector_chromeos() |
355 ->GetDeviceLocalAccountPolicyService() | 361 ->GetDeviceLocalAccountPolicyService() |
356 ->GetBrokerForUser(public_session_user_id_) | 362 ->GetBrokerForUser(public_session_user_id_.GetUserEmail()) |
357 ->core() | 363 ->core() |
358 ->store(); | 364 ->store(); |
359 if (!store->has_policy()) { | 365 if (!store->has_policy()) { |
360 policy::MockCloudPolicyStoreObserver observer; | 366 policy::MockCloudPolicyStoreObserver observer; |
361 | 367 |
362 base::RunLoop loop; | 368 base::RunLoop loop; |
363 store->AddObserver(&observer); | 369 store->AddObserver(&observer); |
364 EXPECT_CALL(observer, OnStoreLoaded(store)) | 370 EXPECT_CALL(observer, OnStoreLoaded(store)) |
365 .Times(1) | 371 .Times(1) |
366 .WillOnce(InvokeWithoutArgs(&loop, &base::RunLoop::Quit)); | 372 .WillOnce(InvokeWithoutArgs(&loop, &base::RunLoop::Quit)); |
367 loop.Run(); | 373 loop.Run(); |
368 store->RemoveObserver(&observer); | 374 store->RemoveObserver(&observer); |
369 } | 375 } |
370 } | 376 } |
371 | 377 |
372 void SetUpSessionManager() override { | 378 void SetUpSessionManager() override { |
373 InstallOwnerKey(); | 379 InstallOwnerKey(); |
374 | 380 |
375 // Setup the device policy. | 381 // Setup the device policy. |
376 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); | 382 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); |
377 em::DeviceLocalAccountInfoProto* account = | 383 em::DeviceLocalAccountInfoProto* account = |
378 proto.mutable_device_local_accounts()->add_account(); | 384 proto.mutable_device_local_accounts()->add_account(); |
379 account->set_account_id(kPublicSessionAccountId); | 385 account->set_account_id(kPublicSessionAccountId); |
achuithb
2015/10/23 00:08:49
This is still correct, right? We don't store the a
Alexander Alekseev
2015/10/23 09:11:21
AFAIK, this is not admin email. This is local acco
| |
380 account->set_type( | 386 account->set_type( |
381 em::DeviceLocalAccountInfoProto::ACCOUNT_TYPE_PUBLIC_SESSION); | 387 em::DeviceLocalAccountInfoProto::ACCOUNT_TYPE_PUBLIC_SESSION); |
382 RefreshDevicePolicy(); | 388 RefreshDevicePolicy(); |
383 | 389 |
384 // Setup the device local account policy. | 390 // Setup the device local account policy. |
385 policy::UserPolicyBuilder device_local_account_policy; | 391 policy::UserPolicyBuilder device_local_account_policy; |
386 device_local_account_policy.policy_data().set_username( | 392 device_local_account_policy.policy_data().set_username( |
387 kPublicSessionAccountId); | 393 kPublicSessionAccountId); |
388 device_local_account_policy.policy_data().set_policy_type( | 394 device_local_account_policy.policy_data().set_policy_type( |
389 policy::dm_protocol::kChromePublicAccountPolicyType); | 395 policy::dm_protocol::kChromePublicAccountPolicyType); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
484 void MakeCrosSettingsPermanentlyUntrusted() { | 490 void MakeCrosSettingsPermanentlyUntrusted() { |
485 device_policy()->policy().set_policy_data_signature("bad signature"); | 491 device_policy()->policy().set_policy_data_signature("bad signature"); |
486 session_manager_client()->set_device_policy(device_policy()->GetBlob()); | 492 session_manager_client()->set_device_policy(device_policy()->GetBlob()); |
487 session_manager_client()->OnPropertyChangeComplete(true); | 493 session_manager_client()->OnPropertyChangeComplete(true); |
488 | 494 |
489 base::RunLoop run_loop; | 495 base::RunLoop run_loop; |
490 WaitForPermanentlyUntrustedStatusAndRun(run_loop.QuitClosure()); | 496 WaitForPermanentlyUntrustedStatusAndRun(run_loop.QuitClosure()); |
491 run_loop.Run(); | 497 run_loop.Run(); |
492 } | 498 } |
493 | 499 |
494 const std::string public_session_user_id_; | 500 const AccountId public_session_user_id_; |
495 | 501 |
496 private: | 502 private: |
497 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerPublicSessionTest); | 503 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerPublicSessionTest); |
498 }; | 504 }; |
499 | 505 |
500 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 506 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
501 ConfigureAutoLoginUsingPolicy) { | 507 ConfigureAutoLoginUsingPolicy) { |
502 existing_user_controller()->OnSigninScreenReady(); | 508 existing_user_controller()->OnSigninScreenReady(); |
503 EXPECT_EQ("", auto_login_username()); | 509 EXPECT_TRUE(auto_login_account_id().empty()); |
504 EXPECT_EQ(0, auto_login_delay()); | 510 EXPECT_EQ(0, auto_login_delay()); |
505 EXPECT_FALSE(auto_login_timer()); | 511 EXPECT_FALSE(auto_login_timer()); |
506 | 512 |
507 // Set the policy. | 513 // Set the policy. |
508 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 514 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
509 EXPECT_EQ(public_session_user_id_, auto_login_username()); | 515 EXPECT_EQ(public_session_user_id_, auto_login_account_id()); |
510 EXPECT_EQ(kAutoLoginLongDelay, auto_login_delay()); | 516 EXPECT_EQ(kAutoLoginLongDelay, auto_login_delay()); |
511 ASSERT_TRUE(auto_login_timer()); | 517 ASSERT_TRUE(auto_login_timer()); |
512 EXPECT_TRUE(auto_login_timer()->IsRunning()); | 518 EXPECT_TRUE(auto_login_timer()->IsRunning()); |
513 | 519 |
514 // Unset the policy. | 520 // Unset the policy. |
515 SetAutoLoginPolicy("", 0); | 521 SetAutoLoginPolicy("", 0); |
516 EXPECT_EQ("", auto_login_username()); | 522 EXPECT_TRUE(auto_login_account_id().empty()); |
517 EXPECT_EQ(0, auto_login_delay()); | 523 EXPECT_EQ(0, auto_login_delay()); |
518 ASSERT_TRUE(auto_login_timer()); | 524 ASSERT_TRUE(auto_login_timer()); |
519 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 525 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
520 } | 526 } |
521 | 527 |
522 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 528 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
523 AutoLoginNoDelay) { | 529 AutoLoginNoDelay) { |
524 // Set up mocks to check login success. | 530 // Set up mocks to check login success. |
525 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, | 531 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
526 public_session_user_id_); | 532 public_session_user_id_.GetUserEmail()); |
527 user_context.SetUserIDHash(user_context.GetUserID()); | 533 user_context.SetUserIDHash(user_context.GetUserID().GetUserEmail()); |
528 ExpectSuccessfulLogin(user_context); | 534 ExpectSuccessfulLogin(user_context); |
529 existing_user_controller()->OnSigninScreenReady(); | 535 existing_user_controller()->OnSigninScreenReady(); |
530 | 536 |
531 // Start auto-login and wait for login tasks to complete. | 537 // Start auto-login and wait for login tasks to complete. |
532 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginNoDelay); | 538 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginNoDelay); |
533 content::RunAllPendingInMessageLoop(); | 539 content::RunAllPendingInMessageLoop(); |
534 } | 540 } |
535 | 541 |
536 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 542 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
537 AutoLoginShortDelay) { | 543 AutoLoginShortDelay) { |
538 // Set up mocks to check login success. | 544 // Set up mocks to check login success. |
539 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, | 545 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
540 public_session_user_id_); | 546 public_session_user_id_.GetUserEmail()); |
541 user_context.SetUserIDHash(user_context.GetUserID()); | 547 user_context.SetUserIDHash(user_context.GetUserID().GetUserEmail()); |
542 ExpectSuccessfulLogin(user_context); | 548 ExpectSuccessfulLogin(user_context); |
543 existing_user_controller()->OnSigninScreenReady(); | 549 existing_user_controller()->OnSigninScreenReady(); |
544 | 550 |
545 content::WindowedNotificationObserver profile_prepared_observer( | 551 content::WindowedNotificationObserver profile_prepared_observer( |
546 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 552 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
547 content::NotificationService::AllSources()); | 553 content::NotificationService::AllSources()); |
548 | 554 |
549 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginShortDelay); | 555 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginShortDelay); |
550 ASSERT_TRUE(auto_login_timer()); | 556 ASSERT_TRUE(auto_login_timer()); |
551 // Don't assert that timer is running: with the short delay sometimes | 557 // Don't assert that timer is running: with the short delay sometimes |
(...skipping 10 matching lines...) Expand all Loading... | |
562 | 568 |
563 profile_prepared_observer.Wait(); | 569 profile_prepared_observer.Wait(); |
564 | 570 |
565 // Wait for login tasks to complete. | 571 // Wait for login tasks to complete. |
566 content::RunAllPendingInMessageLoop(); | 572 content::RunAllPendingInMessageLoop(); |
567 } | 573 } |
568 | 574 |
569 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 575 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
570 LoginStopsAutoLogin) { | 576 LoginStopsAutoLogin) { |
571 // Set up mocks to check login success. | 577 // Set up mocks to check login success. |
572 UserContext user_context(kUsername); | 578 UserContext user_context(account_id_); |
573 user_context.SetGaiaID(kGaiaID); | 579 user_context.SetGaiaID(kGaiaID); |
574 user_context.SetKey(Key(kPassword)); | 580 user_context.SetKey(Key(kPassword)); |
575 user_context.SetUserIDHash(user_context.GetUserID()); | 581 user_context.SetUserIDHash(user_context.GetUserID().GetUserEmail()); |
576 ExpectSuccessfulLogin(user_context); | 582 ExpectSuccessfulLogin(user_context); |
577 | 583 |
578 existing_user_controller()->OnSigninScreenReady(); | 584 existing_user_controller()->OnSigninScreenReady(); |
579 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 585 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
580 EXPECT_TRUE(auto_login_timer()); | 586 EXPECT_TRUE(auto_login_timer()); |
581 | 587 |
582 content::WindowedNotificationObserver profile_prepared_observer( | 588 content::WindowedNotificationObserver profile_prepared_observer( |
583 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 589 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
584 content::NotificationService::AllSources()); | 590 content::NotificationService::AllSources()); |
585 | 591 |
(...skipping 10 matching lines...) Expand all Loading... | |
596 | 602 |
597 // Timer should still be stopped after login completes. | 603 // Timer should still be stopped after login completes. |
598 ASSERT_TRUE(auto_login_timer()); | 604 ASSERT_TRUE(auto_login_timer()); |
599 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 605 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
600 } | 606 } |
601 | 607 |
602 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 608 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
603 GuestModeLoginStopsAutoLogin) { | 609 GuestModeLoginStopsAutoLogin) { |
604 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 610 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
605 .Times(2); | 611 .Times(2); |
606 UserContext user_context(kUsername); | 612 UserContext user_context(account_id_); |
607 user_context.SetGaiaID(kGaiaID); | 613 user_context.SetGaiaID(kGaiaID); |
608 user_context.SetKey(Key(kPassword)); | 614 user_context.SetKey(Key(kPassword)); |
609 test::UserSessionManagerTestApi session_manager_test_api( | 615 test::UserSessionManagerTestApi session_manager_test_api( |
610 UserSessionManager::GetInstance()); | 616 UserSessionManager::GetInstance()); |
611 session_manager_test_api.InjectStubUserContext(user_context); | 617 session_manager_test_api.InjectStubUserContext(user_context); |
612 | 618 |
613 existing_user_controller()->OnSigninScreenReady(); | 619 existing_user_controller()->OnSigninScreenReady(); |
614 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 620 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
615 EXPECT_TRUE(auto_login_timer()); | 621 EXPECT_TRUE(auto_login_timer()); |
616 | 622 |
617 // Login and check that it stopped the timer. | 623 // Login and check that it stopped the timer. |
618 existing_user_controller()->Login(UserContext(user_manager::USER_TYPE_GUEST, | 624 existing_user_controller()->Login(UserContext(user_manager::USER_TYPE_GUEST, |
619 std::string()), | 625 std::string()), |
620 SigninSpecifics()); | 626 SigninSpecifics()); |
621 EXPECT_TRUE(is_login_in_progress()); | 627 EXPECT_TRUE(is_login_in_progress()); |
622 ASSERT_TRUE(auto_login_timer()); | 628 ASSERT_TRUE(auto_login_timer()); |
623 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 629 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
624 | 630 |
625 // Wait for login tasks to complete. | 631 // Wait for login tasks to complete. |
626 content::RunAllPendingInMessageLoop(); | 632 content::RunAllPendingInMessageLoop(); |
627 | 633 |
628 // Timer should still be stopped after login completes. | 634 // Timer should still be stopped after login completes. |
629 ASSERT_TRUE(auto_login_timer()); | 635 ASSERT_TRUE(auto_login_timer()); |
630 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 636 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
631 } | 637 } |
632 | 638 |
633 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 639 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
634 CompleteLoginStopsAutoLogin) { | 640 CompleteLoginStopsAutoLogin) { |
635 // Set up mocks to check login success. | 641 // Set up mocks to check login success. |
636 UserContext user_context(kUsername); | 642 UserContext user_context(account_id_); |
637 user_context.SetGaiaID(kGaiaID); | 643 user_context.SetGaiaID(kGaiaID); |
638 user_context.SetKey(Key(kPassword)); | 644 user_context.SetKey(Key(kPassword)); |
639 user_context.SetUserIDHash(user_context.GetUserID()); | 645 user_context.SetUserIDHash(user_context.GetUserID().GetUserEmail()); |
640 ExpectSuccessfulLogin(user_context); | 646 ExpectSuccessfulLogin(user_context); |
641 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()) | 647 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()) |
642 .Times(1); | 648 .Times(1); |
643 | 649 |
644 existing_user_controller()->OnSigninScreenReady(); | 650 existing_user_controller()->OnSigninScreenReady(); |
645 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 651 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
646 EXPECT_TRUE(auto_login_timer()); | 652 EXPECT_TRUE(auto_login_timer()); |
647 | 653 |
648 content::WindowedNotificationObserver profile_prepared_observer( | 654 content::WindowedNotificationObserver profile_prepared_observer( |
649 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 655 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
(...skipping 11 matching lines...) Expand all Loading... | |
661 | 667 |
662 // Timer should still be stopped after login completes. | 668 // Timer should still be stopped after login completes. |
663 ASSERT_TRUE(auto_login_timer()); | 669 ASSERT_TRUE(auto_login_timer()); |
664 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 670 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
665 } | 671 } |
666 | 672 |
667 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 673 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
668 PublicSessionLoginStopsAutoLogin) { | 674 PublicSessionLoginStopsAutoLogin) { |
669 // Set up mocks to check login success. | 675 // Set up mocks to check login success. |
670 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, | 676 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
671 public_session_user_id_); | 677 public_session_user_id_.GetUserEmail()); |
672 user_context.SetUserIDHash(user_context.GetUserID()); | 678 user_context.SetUserIDHash(user_context.GetUserID().GetUserEmail()); |
673 ExpectSuccessfulLogin(user_context); | 679 ExpectSuccessfulLogin(user_context); |
674 existing_user_controller()->OnSigninScreenReady(); | 680 existing_user_controller()->OnSigninScreenReady(); |
675 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 681 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
676 EXPECT_TRUE(auto_login_timer()); | 682 EXPECT_TRUE(auto_login_timer()); |
677 | 683 |
678 content::WindowedNotificationObserver profile_prepared_observer( | 684 content::WindowedNotificationObserver profile_prepared_observer( |
679 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 685 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
680 content::NotificationService::AllSources()); | 686 content::NotificationService::AllSources()); |
681 | 687 |
682 // Login and check that it stopped the timer. | 688 // Login and check that it stopped the timer. |
683 existing_user_controller()->Login( | 689 existing_user_controller()->Login( |
684 UserContext(user_manager::USER_TYPE_PUBLIC_ACCOUNT, | 690 UserContext(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
685 public_session_user_id_), | 691 public_session_user_id_.GetUserEmail()), |
686 SigninSpecifics()); | 692 SigninSpecifics()); |
687 | 693 |
688 EXPECT_TRUE(is_login_in_progress()); | 694 EXPECT_TRUE(is_login_in_progress()); |
689 ASSERT_TRUE(auto_login_timer()); | 695 ASSERT_TRUE(auto_login_timer()); |
690 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 696 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
691 | 697 |
692 profile_prepared_observer.Wait(); | 698 profile_prepared_observer.Wait(); |
693 | 699 |
694 // Wait for login tasks to complete. | 700 // Wait for login tasks to complete. |
695 content::RunAllPendingInMessageLoop(); | 701 content::RunAllPendingInMessageLoop(); |
696 | 702 |
697 // Timer should still be stopped after login completes. | 703 // Timer should still be stopped after login completes. |
698 ASSERT_TRUE(auto_login_timer()); | 704 ASSERT_TRUE(auto_login_timer()); |
699 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 705 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
700 } | 706 } |
701 | 707 |
702 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 708 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
703 LoginForbiddenWhenUntrusted) { | 709 LoginForbiddenWhenUntrusted) { |
704 // Make cros settings untrusted. | 710 // Make cros settings untrusted. |
705 MakeCrosSettingsPermanentlyUntrusted(); | 711 MakeCrosSettingsPermanentlyUntrusted(); |
706 | 712 |
707 // Check that the attempt to start a public session fails with an error. | 713 // Check that the attempt to start a public session fails with an error. |
708 ExpectLoginFailure(); | 714 ExpectLoginFailure(); |
709 UserContext user_context(kUsername); | 715 UserContext user_context(account_id_); |
710 user_context.SetGaiaID(kGaiaID); | 716 user_context.SetGaiaID(kGaiaID); |
711 user_context.SetKey(Key(kPassword)); | 717 user_context.SetKey(Key(kPassword)); |
712 user_context.SetUserIDHash(user_context.GetUserID()); | 718 user_context.SetUserIDHash(user_context.GetUserID().GetUserEmail()); |
713 existing_user_controller()->Login(user_context, SigninSpecifics()); | 719 existing_user_controller()->Login(user_context, SigninSpecifics()); |
714 } | 720 } |
715 | 721 |
716 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 722 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
717 NoAutoLoginWhenUntrusted) { | 723 NoAutoLoginWhenUntrusted) { |
718 // Start the public session timer. | 724 // Start the public session timer. |
719 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 725 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
720 existing_user_controller()->OnSigninScreenReady(); | 726 existing_user_controller()->OnSigninScreenReady(); |
721 EXPECT_TRUE(auto_login_timer()); | 727 EXPECT_TRUE(auto_login_timer()); |
722 | 728 |
723 // Make cros settings untrusted. | 729 // Make cros settings untrusted. |
724 MakeCrosSettingsPermanentlyUntrusted(); | 730 MakeCrosSettingsPermanentlyUntrusted(); |
725 | 731 |
726 // Check that when the timer fires, auto-login fails with an error. | 732 // Check that when the timer fires, auto-login fails with an error. |
727 ExpectLoginFailure(); | 733 ExpectLoginFailure(); |
728 FireAutoLogin(); | 734 FireAutoLogin(); |
729 } | 735 } |
730 | 736 |
731 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 737 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
732 PRE_TestLoadingPublicUsersFromLocalState) { | 738 PRE_TestLoadingPublicUsersFromLocalState) { |
733 // First run propagates public accounts and stores them in Local State. | 739 // First run propagates public accounts and stores them in Local State. |
734 } | 740 } |
735 | 741 |
736 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 742 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
737 TestLoadingPublicUsersFromLocalState) { | 743 TestLoadingPublicUsersFromLocalState) { |
738 // Second run loads list of public accounts from Local State. | 744 // Second run loads list of public accounts from Local State. |
739 } | 745 } |
740 | 746 |
741 } // namespace chromeos | 747 } // namespace chromeos |
OLD | NEW |