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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 namespace chromeos { | 70 namespace chromeos { |
71 | 71 |
72 namespace { | 72 namespace { |
73 | 73 |
74 const char kGaiaID[] = "12345"; | 74 const char kGaiaID[] = "12345"; |
75 const char kUsername[] = "test_user@gmail.com"; | 75 const char kUsername[] = "test_user@gmail.com"; |
76 const char kSupervisedUserID[] = "supervised_user@locally-managed.localhost"; | 76 const char kSupervisedUserID[] = "supervised_user@locally-managed.localhost"; |
77 const char kPassword[] = "test_password"; | 77 const char kPassword[] = "test_password"; |
78 | 78 |
79 const char kPublicSessionAccountId[] = "public_session_user@localhost"; | 79 const char kPublicSessionUserEmail[] = "public_session_user@localhost"; |
80 const int kAutoLoginNoDelay = 0; | 80 const int kAutoLoginNoDelay = 0; |
81 const int kAutoLoginShortDelay = 1; | 81 const int kAutoLoginShortDelay = 1; |
82 const int kAutoLoginLongDelay = 10000; | 82 const int kAutoLoginLongDelay = 10000; |
83 | 83 |
84 // Wait for cros settings to become permanently untrusted and run |callback|. | 84 // Wait for cros settings to become permanently untrusted and run |callback|. |
85 void WaitForPermanentlyUntrustedStatusAndRun(const base::Closure& callback) { | 85 void WaitForPermanentlyUntrustedStatusAndRun(const base::Closure& callback) { |
86 while (true) { | 86 while (true) { |
87 const CrosSettingsProvider::TrustedStatus status = | 87 const CrosSettingsProvider::TrustedStatus status = |
88 CrosSettings::Get()->PrepareTrustedValues(base::Bind( | 88 CrosSettings::Get()->PrepareTrustedValues(base::Bind( |
89 &WaitForPermanentlyUntrustedStatusAndRun, | 89 &WaitForPermanentlyUntrustedStatusAndRun, |
90 callback)); | 90 callback)); |
91 switch (status) { | 91 switch (status) { |
92 case CrosSettingsProvider::PERMANENTLY_UNTRUSTED: | 92 case CrosSettingsProvider::PERMANENTLY_UNTRUSTED: |
93 callback.Run(); | 93 callback.Run(); |
94 return; | 94 return; |
95 case CrosSettingsProvider::TEMPORARILY_UNTRUSTED: | 95 case CrosSettingsProvider::TEMPORARILY_UNTRUSTED: |
96 return; | 96 return; |
97 case CrosSettingsProvider::TRUSTED: | 97 case CrosSettingsProvider::TRUSTED: |
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 | 109 |
110 ExistingUserController* existing_user_controller() { | 110 ExistingUserController* existing_user_controller() { |
111 return ExistingUserController::current_controller(); | 111 return ExistingUserController::current_controller(); |
112 } | 112 } |
113 | 113 |
114 const ExistingUserController* existing_user_controller() const { | 114 const ExistingUserController* existing_user_controller() const { |
115 return ExistingUserController::current_controller(); | 115 return ExistingUserController::current_controller(); |
116 } | 116 } |
117 | 117 |
118 void SetUpInProcessBrowserTestFixture() override { | 118 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(), | 189 ListPrefUpdate users_pref(g_browser_process->local_state(), |
190 "LoggedInUsers"); | 190 "LoggedInUsers"); |
191 users_pref->AppendIfNotPresent(new base::StringValue(user_id)); | 191 users_pref->AppendIfNotPresent(new base::StringValue(user_id)); |
192 } | 192 } |
193 | 193 |
194 // ExistingUserController private member accessors. | 194 // ExistingUserController private member accessors. |
195 base::OneShotTimer* auto_login_timer() { | 195 base::OneShotTimer* auto_login_timer() { |
196 return existing_user_controller()->auto_login_timer_.get(); | 196 return existing_user_controller()->auto_login_timer_.get(); |
197 } | 197 } |
198 | 198 |
199 const std::string& auto_login_username() const { | 199 AccountId auto_login_account_id() const { |
200 return existing_user_controller()->public_session_auto_login_username_; | 200 return AccountId::FromUserEmail( |
| 201 existing_user_controller()->public_session_auto_login_username_); |
201 } | 202 } |
202 | 203 |
203 int auto_login_delay() const { | 204 int auto_login_delay() const { |
204 return existing_user_controller()->public_session_auto_login_delay_; | 205 return existing_user_controller()->public_session_auto_login_delay_; |
205 } | 206 } |
206 | 207 |
207 bool is_login_in_progress() const { | 208 bool is_login_in_progress() const { |
208 return existing_user_controller()->is_login_in_progress_; | 209 return existing_user_controller()->is_login_in_progress_; |
209 } | 210 } |
210 | 211 |
211 scoped_ptr<ExistingUserController> existing_user_controller_; | 212 scoped_ptr<ExistingUserController> existing_user_controller_; |
212 | 213 |
213 // |mock_login_display_| is owned by the ExistingUserController, which calls | 214 // |mock_login_display_| is owned by the ExistingUserController, which calls |
214 // CreateLoginDisplay() on the |mock_login_display_host_| to get it. | 215 // CreateLoginDisplay() on the |mock_login_display_host_| to get it. |
215 MockLoginDisplay* mock_login_display_; | 216 MockLoginDisplay* mock_login_display_ = nullptr; |
216 scoped_ptr<MockLoginDisplayHost> mock_login_display_host_; | 217 scoped_ptr<MockLoginDisplayHost> mock_login_display_host_; |
217 | 218 |
218 // Mock URLFetcher. | 219 // Mock URLFetcher. |
219 MockURLFetcherFactory<SuccessFetcher> factory_; | 220 MockURLFetcherFactory<SuccessFetcher> factory_; |
220 | 221 |
| 222 const AccountId account_id_ = AccountId::FromUserEmail(kUsername); |
| 223 |
221 private: | 224 private: |
222 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerTest); | 225 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerTest); |
223 }; | 226 }; |
224 | 227 |
225 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, PRE_ExistingUserLogin) { | 228 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, PRE_ExistingUserLogin) { |
226 RegisterUser(kUsername); | 229 RegisterUser(account_id_.GetUserEmail()); |
227 } | 230 } |
228 | 231 |
229 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) { | 232 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) { |
230 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 233 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
231 .Times(2); | 234 .Times(2); |
232 UserContext user_context(kUsername); | 235 UserContext user_context(account_id_); |
233 user_context.SetGaiaID(kGaiaID); | 236 user_context.SetGaiaID(kGaiaID); |
234 user_context.SetKey(Key(kPassword)); | 237 user_context.SetKey(Key(kPassword)); |
235 user_context.SetUserIDHash(kUsername); | 238 user_context.SetUserIDHash(account_id_.GetUserEmail()); |
236 test::UserSessionManagerTestApi session_manager_test_api( | 239 test::UserSessionManagerTestApi session_manager_test_api( |
237 UserSessionManager::GetInstance()); | 240 UserSessionManager::GetInstance()); |
238 session_manager_test_api.InjectStubUserContext(user_context); | 241 session_manager_test_api.InjectStubUserContext(user_context); |
239 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) | 242 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) |
240 .Times(1); | 243 .Times(1); |
241 EXPECT_CALL(*mock_login_display_host_, | 244 EXPECT_CALL(*mock_login_display_host_, |
242 StartWizard(WizardController::kTermsOfServiceScreenName)) | 245 StartWizard(WizardController::kTermsOfServiceScreenName)) |
243 .Times(0); | 246 .Times(0); |
244 | 247 |
245 content::WindowedNotificationObserver profile_prepared_observer( | 248 content::WindowedNotificationObserver profile_prepared_observer( |
(...skipping 27 matching lines...) Expand all Loading... |
273 | 276 |
274 ExpectLoginFailure(); | 277 ExpectLoginFailure(); |
275 } | 278 } |
276 | 279 |
277 void ExistingUserControllerUntrustedTest::SetUpSessionManager() { | 280 void ExistingUserControllerUntrustedTest::SetUpSessionManager() { |
278 InstallOwnerKey(); | 281 InstallOwnerKey(); |
279 } | 282 } |
280 | 283 |
281 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 284 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
282 ExistingUserLoginForbidden) { | 285 ExistingUserLoginForbidden) { |
283 UserContext user_context(kUsername); | 286 UserContext user_context(account_id_); |
284 user_context.SetGaiaID(kGaiaID); | 287 user_context.SetGaiaID(kGaiaID); |
285 user_context.SetKey(Key(kPassword)); | 288 user_context.SetKey(Key(kPassword)); |
286 user_context.SetUserIDHash(kUsername); | 289 user_context.SetUserIDHash(account_id_.GetUserEmail()); |
287 existing_user_controller()->Login(user_context, SigninSpecifics()); | 290 existing_user_controller()->Login(user_context, SigninSpecifics()); |
288 } | 291 } |
289 | 292 |
290 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 293 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
291 NewUserLoginForbidden) { | 294 NewUserLoginForbidden) { |
292 UserContext user_context(kUsername); | 295 UserContext user_context(account_id_); |
293 user_context.SetGaiaID(kGaiaID); | 296 user_context.SetGaiaID(kGaiaID); |
294 user_context.SetKey(Key(kPassword)); | 297 user_context.SetKey(Key(kPassword)); |
295 user_context.SetUserIDHash(kUsername); | 298 user_context.SetUserIDHash(account_id_.GetUserEmail()); |
296 existing_user_controller()->CompleteLogin(user_context); | 299 existing_user_controller()->CompleteLogin(user_context); |
297 } | 300 } |
298 | 301 |
299 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 302 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
300 GuestLoginForbidden) { | 303 GuestLoginForbidden) { |
301 existing_user_controller()->Login( | 304 existing_user_controller()->Login( |
302 UserContext(user_manager::USER_TYPE_GUEST, std::string()), | 305 UserContext(user_manager::USER_TYPE_GUEST, std::string()), |
303 SigninSpecifics()); | 306 SigninSpecifics()); |
304 } | 307 } |
305 | 308 |
306 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 309 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
307 SupervisedUserLoginForbidden) { | 310 SupervisedUserLoginForbidden) { |
308 UserContext user_context(kSupervisedUserID); | 311 UserContext user_context(AccountId::FromUserEmail(kSupervisedUserID)); |
309 user_context.SetKey(Key(kPassword)); | 312 user_context.SetKey(Key(kPassword)); |
310 user_context.SetUserIDHash(kUsername); | 313 user_context.SetUserIDHash(account_id_.GetUserEmail()); |
311 existing_user_controller()->Login(user_context, SigninSpecifics()); | 314 existing_user_controller()->Login(user_context, SigninSpecifics()); |
312 } | 315 } |
313 | 316 |
314 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 317 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
315 SupervisedUserCreationForbidden) { | 318 SupervisedUserCreationForbidden) { |
316 MockBaseScreenDelegate mock_base_screen_delegate; | 319 MockBaseScreenDelegate mock_base_screen_delegate; |
317 SupervisedUserCreationScreenHandler supervised_user_creation_screen_handler; | 320 SupervisedUserCreationScreenHandler supervised_user_creation_screen_handler; |
318 SupervisedUserCreationScreen supervised_user_creation_screen( | 321 SupervisedUserCreationScreen supervised_user_creation_screen( |
319 &mock_base_screen_delegate, &supervised_user_creation_screen_handler); | 322 &mock_base_screen_delegate, &supervised_user_creation_screen_handler); |
320 | 323 |
321 supervised_user_creation_screen.AuthenticateManager(kUsername, kPassword); | 324 supervised_user_creation_screen.AuthenticateManager( |
| 325 account_id_.GetUserEmail(), kPassword); |
322 } | 326 } |
323 | 327 |
324 MATCHER_P(HasDetails, expected, "") { | 328 MATCHER_P(HasDetails, expected, "") { |
325 return expected == *content::Details<const std::string>(arg).ptr(); | 329 return expected == *content::Details<const std::string>(arg).ptr(); |
326 } | 330 } |
327 | 331 |
328 class ExistingUserControllerPublicSessionTest | 332 class ExistingUserControllerPublicSessionTest |
329 : public ExistingUserControllerTest { | 333 : public ExistingUserControllerTest { |
330 protected: | 334 protected: |
331 ExistingUserControllerPublicSessionTest() | 335 ExistingUserControllerPublicSessionTest() {} |
332 : public_session_user_id_(policy::GenerateDeviceLocalAccountUserId( | |
333 kPublicSessionAccountId, | |
334 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION)) { | |
335 } | |
336 | 336 |
337 void SetUpOnMainThread() override { | 337 void SetUpOnMainThread() override { |
338 ExistingUserControllerTest::SetUpOnMainThread(); | 338 ExistingUserControllerTest::SetUpOnMainThread(); |
339 | 339 |
340 // Wait for the public session user to be created. | 340 // Wait for the public session user to be created. |
341 if (!user_manager::UserManager::Get()->IsKnownUser( | 341 if (!user_manager::UserManager::Get()->IsKnownUser( |
342 public_session_user_id_)) { | 342 public_session_account_id_)) { |
343 content::WindowedNotificationObserver( | 343 content::WindowedNotificationObserver( |
344 chrome::NOTIFICATION_USER_LIST_CHANGED, | 344 chrome::NOTIFICATION_USER_LIST_CHANGED, |
345 base::Bind(&user_manager::UserManager::IsKnownUser, | 345 base::Bind(&user_manager::UserManager::IsKnownUser, |
346 base::Unretained(user_manager::UserManager::Get()), | 346 base::Unretained(user_manager::UserManager::Get()), |
347 public_session_user_id_)).Wait(); | 347 public_session_account_id_)) |
| 348 .Wait(); |
348 } | 349 } |
349 | 350 |
350 // Wait for the device local account policy to be installed. | 351 // Wait for the device local account policy to be installed. |
351 policy::CloudPolicyStore* store = | 352 policy::CloudPolicyStore* store = |
352 TestingBrowserProcess::GetGlobal() | 353 TestingBrowserProcess::GetGlobal() |
353 ->platform_part() | 354 ->platform_part() |
354 ->browser_policy_connector_chromeos() | 355 ->browser_policy_connector_chromeos() |
355 ->GetDeviceLocalAccountPolicyService() | 356 ->GetDeviceLocalAccountPolicyService() |
356 ->GetBrokerForUser(public_session_user_id_) | 357 ->GetBrokerForUser(public_session_account_id_.GetUserEmail()) |
357 ->core() | 358 ->core() |
358 ->store(); | 359 ->store(); |
359 if (!store->has_policy()) { | 360 if (!store->has_policy()) { |
360 policy::MockCloudPolicyStoreObserver observer; | 361 policy::MockCloudPolicyStoreObserver observer; |
361 | 362 |
362 base::RunLoop loop; | 363 base::RunLoop loop; |
363 store->AddObserver(&observer); | 364 store->AddObserver(&observer); |
364 EXPECT_CALL(observer, OnStoreLoaded(store)) | 365 EXPECT_CALL(observer, OnStoreLoaded(store)) |
365 .Times(1) | 366 .Times(1) |
366 .WillOnce(InvokeWithoutArgs(&loop, &base::RunLoop::Quit)); | 367 .WillOnce(InvokeWithoutArgs(&loop, &base::RunLoop::Quit)); |
367 loop.Run(); | 368 loop.Run(); |
368 store->RemoveObserver(&observer); | 369 store->RemoveObserver(&observer); |
369 } | 370 } |
370 } | 371 } |
371 | 372 |
372 void SetUpSessionManager() override { | 373 void SetUpSessionManager() override { |
373 InstallOwnerKey(); | 374 InstallOwnerKey(); |
374 | 375 |
375 // Setup the device policy. | 376 // Setup the device policy. |
376 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); | 377 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); |
377 em::DeviceLocalAccountInfoProto* account = | 378 em::DeviceLocalAccountInfoProto* account = |
378 proto.mutable_device_local_accounts()->add_account(); | 379 proto.mutable_device_local_accounts()->add_account(); |
379 account->set_account_id(kPublicSessionAccountId); | 380 account->set_account_id(kPublicSessionUserEmail); |
380 account->set_type( | 381 account->set_type( |
381 em::DeviceLocalAccountInfoProto::ACCOUNT_TYPE_PUBLIC_SESSION); | 382 em::DeviceLocalAccountInfoProto::ACCOUNT_TYPE_PUBLIC_SESSION); |
382 RefreshDevicePolicy(); | 383 RefreshDevicePolicy(); |
383 | 384 |
384 // Setup the device local account policy. | 385 // Setup the device local account policy. |
385 policy::UserPolicyBuilder device_local_account_policy; | 386 policy::UserPolicyBuilder device_local_account_policy; |
386 device_local_account_policy.policy_data().set_username( | 387 device_local_account_policy.policy_data().set_username( |
387 kPublicSessionAccountId); | 388 kPublicSessionUserEmail); |
388 device_local_account_policy.policy_data().set_policy_type( | 389 device_local_account_policy.policy_data().set_policy_type( |
389 policy::dm_protocol::kChromePublicAccountPolicyType); | 390 policy::dm_protocol::kChromePublicAccountPolicyType); |
390 device_local_account_policy.policy_data().set_settings_entity_id( | 391 device_local_account_policy.policy_data().set_settings_entity_id( |
391 kPublicSessionAccountId); | 392 kPublicSessionUserEmail); |
392 device_local_account_policy.Build(); | 393 device_local_account_policy.Build(); |
393 session_manager_client()->set_device_local_account_policy( | 394 session_manager_client()->set_device_local_account_policy( |
394 kPublicSessionAccountId, | 395 kPublicSessionUserEmail, device_local_account_policy.GetBlob()); |
395 device_local_account_policy.GetBlob()); | |
396 } | 396 } |
397 | 397 |
398 void SetUpLoginDisplay() override { | 398 void SetUpLoginDisplay() override { |
399 EXPECT_CALL(*mock_login_display_host_.get(), CreateLoginDisplay(_)) | 399 EXPECT_CALL(*mock_login_display_host_.get(), CreateLoginDisplay(_)) |
400 .Times(1) | 400 .Times(1) |
401 .WillOnce(Return(mock_login_display_)); | 401 .WillOnce(Return(mock_login_display_)); |
402 EXPECT_CALL(*mock_login_display_host_.get(), GetNativeWindow()) | 402 EXPECT_CALL(*mock_login_display_host_.get(), GetNativeWindow()) |
403 .Times(AnyNumber()) | 403 .Times(AnyNumber()) |
404 .WillRepeatedly(ReturnNull()); | 404 .WillRepeatedly(ReturnNull()); |
405 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged()) | 405 EXPECT_CALL(*mock_login_display_host_.get(), OnPreferencesChanged()) |
(...skipping 18 matching lines...) Expand all Loading... |
424 test::UserSessionManagerTestApi session_manager_test_api( | 424 test::UserSessionManagerTestApi session_manager_test_api( |
425 UserSessionManager::GetInstance()); | 425 UserSessionManager::GetInstance()); |
426 session_manager_test_api.InjectStubUserContext(user_context); | 426 session_manager_test_api.InjectStubUserContext(user_context); |
427 EXPECT_CALL(*mock_login_display_host_, | 427 EXPECT_CALL(*mock_login_display_host_, |
428 StartWizard(WizardController::kTermsOfServiceScreenName)) | 428 StartWizard(WizardController::kTermsOfServiceScreenName)) |
429 .Times(0); | 429 .Times(0); |
430 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)).Times(AnyNumber()); | 430 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)).Times(AnyNumber()); |
431 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)).Times(AnyNumber()); | 431 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)).Times(AnyNumber()); |
432 } | 432 } |
433 | 433 |
434 void SetAutoLoginPolicy(const std::string& username, int delay) { | 434 void SetAutoLoginPolicy(const std::string& user_email, int delay) { |
435 // Wait until ExistingUserController has finished auto-login | 435 // Wait until ExistingUserController has finished auto-login |
436 // configuration by observing the same settings that trigger | 436 // configuration by observing the same settings that trigger |
437 // ConfigurePublicSessionAutoLogin. | 437 // ConfigurePublicSessionAutoLogin. |
438 | 438 |
439 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); | 439 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); |
440 | 440 |
441 // If both settings have changed we need to wait for both to | 441 // If both settings have changed we need to wait for both to |
442 // propagate, so check the new values against the old ones. | 442 // propagate, so check the new values against the old ones. |
443 scoped_refptr<content::MessageLoopRunner> runner1; | 443 scoped_refptr<content::MessageLoopRunner> runner1; |
444 scoped_ptr<CrosSettings::ObserverSubscription> subscription1; | 444 scoped_ptr<CrosSettings::ObserverSubscription> subscription1; |
445 if (!proto.has_device_local_accounts() || | 445 if (!proto.has_device_local_accounts() || |
446 !proto.device_local_accounts().has_auto_login_id() || | 446 !proto.device_local_accounts().has_auto_login_id() || |
447 proto.device_local_accounts().auto_login_id() != username) { | 447 proto.device_local_accounts().auto_login_id() != user_email) { |
448 runner1 = new content::MessageLoopRunner; | 448 runner1 = new content::MessageLoopRunner; |
449 subscription1 = chromeos::CrosSettings::Get()->AddSettingsObserver( | 449 subscription1 = chromeos::CrosSettings::Get()->AddSettingsObserver( |
450 chromeos::kAccountsPrefDeviceLocalAccountAutoLoginId, | 450 chromeos::kAccountsPrefDeviceLocalAccountAutoLoginId, |
451 runner1->QuitClosure()); | 451 runner1->QuitClosure()); |
452 } | 452 } |
453 scoped_refptr<content::MessageLoopRunner> runner2; | 453 scoped_refptr<content::MessageLoopRunner> runner2; |
454 scoped_ptr<CrosSettings::ObserverSubscription> subscription2; | 454 scoped_ptr<CrosSettings::ObserverSubscription> subscription2; |
455 if (!proto.has_device_local_accounts() || | 455 if (!proto.has_device_local_accounts() || |
456 !proto.device_local_accounts().has_auto_login_delay() || | 456 !proto.device_local_accounts().has_auto_login_delay() || |
457 proto.device_local_accounts().auto_login_delay() != delay) { | 457 proto.device_local_accounts().auto_login_delay() != delay) { |
458 runner2 = new content::MessageLoopRunner; | 458 runner2 = new content::MessageLoopRunner; |
459 subscription2 = chromeos::CrosSettings::Get()->AddSettingsObserver( | 459 subscription2 = chromeos::CrosSettings::Get()->AddSettingsObserver( |
460 chromeos::kAccountsPrefDeviceLocalAccountAutoLoginDelay, | 460 chromeos::kAccountsPrefDeviceLocalAccountAutoLoginDelay, |
461 runner2->QuitClosure()); | 461 runner2->QuitClosure()); |
462 } | 462 } |
463 | 463 |
464 // Update the policy. | 464 // Update the policy. |
465 proto.mutable_device_local_accounts()->set_auto_login_id(username); | 465 proto.mutable_device_local_accounts()->set_auto_login_id(user_email); |
466 proto.mutable_device_local_accounts()->set_auto_login_delay(delay); | 466 proto.mutable_device_local_accounts()->set_auto_login_delay(delay); |
467 RefreshDevicePolicy(); | 467 RefreshDevicePolicy(); |
468 | 468 |
469 // Wait for ExistingUserController to read the updated settings. | 469 // Wait for ExistingUserController to read the updated settings. |
470 if (runner1.get()) | 470 if (runner1.get()) |
471 runner1->Run(); | 471 runner1->Run(); |
472 if (runner2.get()) | 472 if (runner2.get()) |
473 runner2->Run(); | 473 runner2->Run(); |
474 } | 474 } |
475 | 475 |
476 void ConfigureAutoLogin() { | 476 void ConfigureAutoLogin() { |
477 existing_user_controller()->ConfigurePublicSessionAutoLogin(); | 477 existing_user_controller()->ConfigurePublicSessionAutoLogin(); |
478 } | 478 } |
479 | 479 |
480 void FireAutoLogin() { | 480 void FireAutoLogin() { |
481 existing_user_controller()->OnPublicSessionAutoLoginTimerFire(); | 481 existing_user_controller()->OnPublicSessionAutoLoginTimerFire(); |
482 } | 482 } |
483 | 483 |
484 void MakeCrosSettingsPermanentlyUntrusted() { | 484 void MakeCrosSettingsPermanentlyUntrusted() { |
485 device_policy()->policy().set_policy_data_signature("bad signature"); | 485 device_policy()->policy().set_policy_data_signature("bad signature"); |
486 session_manager_client()->set_device_policy(device_policy()->GetBlob()); | 486 session_manager_client()->set_device_policy(device_policy()->GetBlob()); |
487 session_manager_client()->OnPropertyChangeComplete(true); | 487 session_manager_client()->OnPropertyChangeComplete(true); |
488 | 488 |
489 base::RunLoop run_loop; | 489 base::RunLoop run_loop; |
490 WaitForPermanentlyUntrustedStatusAndRun(run_loop.QuitClosure()); | 490 WaitForPermanentlyUntrustedStatusAndRun(run_loop.QuitClosure()); |
491 run_loop.Run(); | 491 run_loop.Run(); |
492 } | 492 } |
493 | 493 |
494 const std::string public_session_user_id_; | 494 const AccountId public_session_account_id_ = |
| 495 AccountId::FromUserEmail(policy::GenerateDeviceLocalAccountUserId( |
| 496 kPublicSessionUserEmail, |
| 497 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION)); |
495 | 498 |
496 private: | 499 private: |
497 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerPublicSessionTest); | 500 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerPublicSessionTest); |
498 }; | 501 }; |
499 | 502 |
500 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 503 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
501 ConfigureAutoLoginUsingPolicy) { | 504 ConfigureAutoLoginUsingPolicy) { |
502 existing_user_controller()->OnSigninScreenReady(); | 505 existing_user_controller()->OnSigninScreenReady(); |
503 EXPECT_EQ("", auto_login_username()); | 506 EXPECT_TRUE(!auto_login_account_id().is_valid()); |
504 EXPECT_EQ(0, auto_login_delay()); | 507 EXPECT_EQ(0, auto_login_delay()); |
505 EXPECT_FALSE(auto_login_timer()); | 508 EXPECT_FALSE(auto_login_timer()); |
506 | 509 |
507 // Set the policy. | 510 // Set the policy. |
508 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 511 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginLongDelay); |
509 EXPECT_EQ(public_session_user_id_, auto_login_username()); | 512 EXPECT_EQ(public_session_account_id_, auto_login_account_id()); |
510 EXPECT_EQ(kAutoLoginLongDelay, auto_login_delay()); | 513 EXPECT_EQ(kAutoLoginLongDelay, auto_login_delay()); |
511 ASSERT_TRUE(auto_login_timer()); | 514 ASSERT_TRUE(auto_login_timer()); |
512 EXPECT_TRUE(auto_login_timer()->IsRunning()); | 515 EXPECT_TRUE(auto_login_timer()->IsRunning()); |
513 | 516 |
514 // Unset the policy. | 517 // Unset the policy. |
515 SetAutoLoginPolicy("", 0); | 518 SetAutoLoginPolicy("", 0); |
516 EXPECT_EQ("", auto_login_username()); | 519 EXPECT_TRUE(!auto_login_account_id().is_valid()); |
517 EXPECT_EQ(0, auto_login_delay()); | 520 EXPECT_EQ(0, auto_login_delay()); |
518 ASSERT_TRUE(auto_login_timer()); | 521 ASSERT_TRUE(auto_login_timer()); |
519 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 522 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
520 } | 523 } |
521 | 524 |
522 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 525 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
523 AutoLoginNoDelay) { | 526 AutoLoginNoDelay) { |
524 // Set up mocks to check login success. | 527 // Set up mocks to check login success. |
525 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, | 528 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
526 public_session_user_id_); | 529 public_session_account_id_.GetUserEmail()); |
527 user_context.SetUserIDHash(user_context.GetUserID()); | 530 user_context.SetUserIDHash(user_context.GetAccountId().GetUserEmail()); |
528 ExpectSuccessfulLogin(user_context); | 531 ExpectSuccessfulLogin(user_context); |
529 existing_user_controller()->OnSigninScreenReady(); | 532 existing_user_controller()->OnSigninScreenReady(); |
530 | 533 |
531 // Start auto-login and wait for login tasks to complete. | 534 // Start auto-login and wait for login tasks to complete. |
532 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginNoDelay); | 535 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginNoDelay); |
533 content::RunAllPendingInMessageLoop(); | 536 content::RunAllPendingInMessageLoop(); |
534 } | 537 } |
535 | 538 |
536 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 539 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
537 AutoLoginShortDelay) { | 540 AutoLoginShortDelay) { |
538 // Set up mocks to check login success. | 541 // Set up mocks to check login success. |
539 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, | 542 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
540 public_session_user_id_); | 543 public_session_account_id_.GetUserEmail()); |
541 user_context.SetUserIDHash(user_context.GetUserID()); | 544 user_context.SetUserIDHash(user_context.GetAccountId().GetUserEmail()); |
542 ExpectSuccessfulLogin(user_context); | 545 ExpectSuccessfulLogin(user_context); |
543 existing_user_controller()->OnSigninScreenReady(); | 546 existing_user_controller()->OnSigninScreenReady(); |
544 | 547 |
545 content::WindowedNotificationObserver profile_prepared_observer( | 548 content::WindowedNotificationObserver profile_prepared_observer( |
546 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 549 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
547 content::NotificationService::AllSources()); | 550 content::NotificationService::AllSources()); |
548 | 551 |
549 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginShortDelay); | 552 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginShortDelay); |
550 ASSERT_TRUE(auto_login_timer()); | 553 ASSERT_TRUE(auto_login_timer()); |
551 // Don't assert that timer is running: with the short delay sometimes | 554 // Don't assert that timer is running: with the short delay sometimes |
552 // the trigger happens before the assert. We've already tested that | 555 // the trigger happens before the assert. We've already tested that |
553 // the timer starts when it should. | 556 // the timer starts when it should. |
554 | 557 |
555 // Wait for the timer to fire. | 558 // Wait for the timer to fire. |
556 base::RunLoop runner; | 559 base::RunLoop runner; |
557 base::OneShotTimer timer; | 560 base::OneShotTimer timer; |
558 timer.Start(FROM_HERE, | 561 timer.Start(FROM_HERE, |
559 base::TimeDelta::FromMilliseconds(kAutoLoginShortDelay + 1), | 562 base::TimeDelta::FromMilliseconds(kAutoLoginShortDelay + 1), |
560 runner.QuitClosure()); | 563 runner.QuitClosure()); |
561 runner.Run(); | 564 runner.Run(); |
562 | 565 |
563 profile_prepared_observer.Wait(); | 566 profile_prepared_observer.Wait(); |
564 | 567 |
565 // Wait for login tasks to complete. | 568 // Wait for login tasks to complete. |
566 content::RunAllPendingInMessageLoop(); | 569 content::RunAllPendingInMessageLoop(); |
567 } | 570 } |
568 | 571 |
569 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 572 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
570 LoginStopsAutoLogin) { | 573 LoginStopsAutoLogin) { |
571 // Set up mocks to check login success. | 574 // Set up mocks to check login success. |
572 UserContext user_context(kUsername); | 575 UserContext user_context(account_id_); |
573 user_context.SetGaiaID(kGaiaID); | 576 user_context.SetGaiaID(kGaiaID); |
574 user_context.SetKey(Key(kPassword)); | 577 user_context.SetKey(Key(kPassword)); |
575 user_context.SetUserIDHash(user_context.GetUserID()); | 578 user_context.SetUserIDHash(user_context.GetAccountId().GetUserEmail()); |
576 ExpectSuccessfulLogin(user_context); | 579 ExpectSuccessfulLogin(user_context); |
577 | 580 |
578 existing_user_controller()->OnSigninScreenReady(); | 581 existing_user_controller()->OnSigninScreenReady(); |
579 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 582 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginLongDelay); |
580 EXPECT_TRUE(auto_login_timer()); | 583 EXPECT_TRUE(auto_login_timer()); |
581 | 584 |
582 content::WindowedNotificationObserver profile_prepared_observer( | 585 content::WindowedNotificationObserver profile_prepared_observer( |
583 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 586 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
584 content::NotificationService::AllSources()); | 587 content::NotificationService::AllSources()); |
585 | 588 |
586 // Log in and check that it stopped the timer. | 589 // Log in and check that it stopped the timer. |
587 existing_user_controller()->Login(user_context, SigninSpecifics()); | 590 existing_user_controller()->Login(user_context, SigninSpecifics()); |
588 EXPECT_TRUE(is_login_in_progress()); | 591 EXPECT_TRUE(is_login_in_progress()); |
589 ASSERT_TRUE(auto_login_timer()); | 592 ASSERT_TRUE(auto_login_timer()); |
590 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 593 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
591 | 594 |
592 profile_prepared_observer.Wait(); | 595 profile_prepared_observer.Wait(); |
593 | 596 |
594 // Wait for login tasks to complete. | 597 // Wait for login tasks to complete. |
595 content::RunAllPendingInMessageLoop(); | 598 content::RunAllPendingInMessageLoop(); |
596 | 599 |
597 // Timer should still be stopped after login completes. | 600 // Timer should still be stopped after login completes. |
598 ASSERT_TRUE(auto_login_timer()); | 601 ASSERT_TRUE(auto_login_timer()); |
599 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 602 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
600 } | 603 } |
601 | 604 |
602 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 605 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
603 GuestModeLoginStopsAutoLogin) { | 606 GuestModeLoginStopsAutoLogin) { |
604 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 607 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
605 .Times(2); | 608 .Times(2); |
606 UserContext user_context(kUsername); | 609 UserContext user_context(account_id_); |
607 user_context.SetGaiaID(kGaiaID); | 610 user_context.SetGaiaID(kGaiaID); |
608 user_context.SetKey(Key(kPassword)); | 611 user_context.SetKey(Key(kPassword)); |
609 test::UserSessionManagerTestApi session_manager_test_api( | 612 test::UserSessionManagerTestApi session_manager_test_api( |
610 UserSessionManager::GetInstance()); | 613 UserSessionManager::GetInstance()); |
611 session_manager_test_api.InjectStubUserContext(user_context); | 614 session_manager_test_api.InjectStubUserContext(user_context); |
612 | 615 |
613 existing_user_controller()->OnSigninScreenReady(); | 616 existing_user_controller()->OnSigninScreenReady(); |
614 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 617 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginLongDelay); |
615 EXPECT_TRUE(auto_login_timer()); | 618 EXPECT_TRUE(auto_login_timer()); |
616 | 619 |
617 // Login and check that it stopped the timer. | 620 // Login and check that it stopped the timer. |
618 existing_user_controller()->Login(UserContext(user_manager::USER_TYPE_GUEST, | 621 existing_user_controller()->Login(UserContext(user_manager::USER_TYPE_GUEST, |
619 std::string()), | 622 std::string()), |
620 SigninSpecifics()); | 623 SigninSpecifics()); |
621 EXPECT_TRUE(is_login_in_progress()); | 624 EXPECT_TRUE(is_login_in_progress()); |
622 ASSERT_TRUE(auto_login_timer()); | 625 ASSERT_TRUE(auto_login_timer()); |
623 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 626 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
624 | 627 |
625 // Wait for login tasks to complete. | 628 // Wait for login tasks to complete. |
626 content::RunAllPendingInMessageLoop(); | 629 content::RunAllPendingInMessageLoop(); |
627 | 630 |
628 // Timer should still be stopped after login completes. | 631 // Timer should still be stopped after login completes. |
629 ASSERT_TRUE(auto_login_timer()); | 632 ASSERT_TRUE(auto_login_timer()); |
630 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 633 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
631 } | 634 } |
632 | 635 |
633 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 636 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
634 CompleteLoginStopsAutoLogin) { | 637 CompleteLoginStopsAutoLogin) { |
635 // Set up mocks to check login success. | 638 // Set up mocks to check login success. |
636 UserContext user_context(kUsername); | 639 UserContext user_context(account_id_); |
637 user_context.SetGaiaID(kGaiaID); | 640 user_context.SetGaiaID(kGaiaID); |
638 user_context.SetKey(Key(kPassword)); | 641 user_context.SetKey(Key(kPassword)); |
639 user_context.SetUserIDHash(user_context.GetUserID()); | 642 user_context.SetUserIDHash(user_context.GetAccountId().GetUserEmail()); |
640 ExpectSuccessfulLogin(user_context); | 643 ExpectSuccessfulLogin(user_context); |
641 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()) | 644 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()) |
642 .Times(1); | 645 .Times(1); |
643 | 646 |
644 existing_user_controller()->OnSigninScreenReady(); | 647 existing_user_controller()->OnSigninScreenReady(); |
645 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 648 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginLongDelay); |
646 EXPECT_TRUE(auto_login_timer()); | 649 EXPECT_TRUE(auto_login_timer()); |
647 | 650 |
648 content::WindowedNotificationObserver profile_prepared_observer( | 651 content::WindowedNotificationObserver profile_prepared_observer( |
649 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 652 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
650 content::NotificationService::AllSources()); | 653 content::NotificationService::AllSources()); |
651 | 654 |
652 // Check that login completes and stops the timer. | 655 // Check that login completes and stops the timer. |
653 existing_user_controller()->CompleteLogin(user_context); | 656 existing_user_controller()->CompleteLogin(user_context); |
654 ASSERT_TRUE(auto_login_timer()); | 657 ASSERT_TRUE(auto_login_timer()); |
655 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 658 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
656 | 659 |
657 profile_prepared_observer.Wait(); | 660 profile_prepared_observer.Wait(); |
658 | 661 |
659 // Wait for login tasks to complete. | 662 // Wait for login tasks to complete. |
660 content::RunAllPendingInMessageLoop(); | 663 content::RunAllPendingInMessageLoop(); |
661 | 664 |
662 // Timer should still be stopped after login completes. | 665 // Timer should still be stopped after login completes. |
663 ASSERT_TRUE(auto_login_timer()); | 666 ASSERT_TRUE(auto_login_timer()); |
664 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 667 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
665 } | 668 } |
666 | 669 |
667 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 670 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
668 PublicSessionLoginStopsAutoLogin) { | 671 PublicSessionLoginStopsAutoLogin) { |
669 // Set up mocks to check login success. | 672 // Set up mocks to check login success. |
670 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, | 673 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
671 public_session_user_id_); | 674 public_session_account_id_.GetUserEmail()); |
672 user_context.SetUserIDHash(user_context.GetUserID()); | 675 user_context.SetUserIDHash(user_context.GetAccountId().GetUserEmail()); |
673 ExpectSuccessfulLogin(user_context); | 676 ExpectSuccessfulLogin(user_context); |
674 existing_user_controller()->OnSigninScreenReady(); | 677 existing_user_controller()->OnSigninScreenReady(); |
675 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 678 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginLongDelay); |
676 EXPECT_TRUE(auto_login_timer()); | 679 EXPECT_TRUE(auto_login_timer()); |
677 | 680 |
678 content::WindowedNotificationObserver profile_prepared_observer( | 681 content::WindowedNotificationObserver profile_prepared_observer( |
679 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 682 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
680 content::NotificationService::AllSources()); | 683 content::NotificationService::AllSources()); |
681 | 684 |
682 // Login and check that it stopped the timer. | 685 // Login and check that it stopped the timer. |
683 existing_user_controller()->Login( | 686 existing_user_controller()->Login( |
684 UserContext(user_manager::USER_TYPE_PUBLIC_ACCOUNT, | 687 UserContext(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
685 public_session_user_id_), | 688 public_session_account_id_.GetUserEmail()), |
686 SigninSpecifics()); | 689 SigninSpecifics()); |
687 | 690 |
688 EXPECT_TRUE(is_login_in_progress()); | 691 EXPECT_TRUE(is_login_in_progress()); |
689 ASSERT_TRUE(auto_login_timer()); | 692 ASSERT_TRUE(auto_login_timer()); |
690 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 693 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
691 | 694 |
692 profile_prepared_observer.Wait(); | 695 profile_prepared_observer.Wait(); |
693 | 696 |
694 // Wait for login tasks to complete. | 697 // Wait for login tasks to complete. |
695 content::RunAllPendingInMessageLoop(); | 698 content::RunAllPendingInMessageLoop(); |
696 | 699 |
697 // Timer should still be stopped after login completes. | 700 // Timer should still be stopped after login completes. |
698 ASSERT_TRUE(auto_login_timer()); | 701 ASSERT_TRUE(auto_login_timer()); |
699 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 702 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
700 } | 703 } |
701 | 704 |
702 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 705 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
703 LoginForbiddenWhenUntrusted) { | 706 LoginForbiddenWhenUntrusted) { |
704 // Make cros settings untrusted. | 707 // Make cros settings untrusted. |
705 MakeCrosSettingsPermanentlyUntrusted(); | 708 MakeCrosSettingsPermanentlyUntrusted(); |
706 | 709 |
707 // Check that the attempt to start a public session fails with an error. | 710 // Check that the attempt to start a public session fails with an error. |
708 ExpectLoginFailure(); | 711 ExpectLoginFailure(); |
709 UserContext user_context(kUsername); | 712 UserContext user_context(account_id_); |
710 user_context.SetGaiaID(kGaiaID); | 713 user_context.SetGaiaID(kGaiaID); |
711 user_context.SetKey(Key(kPassword)); | 714 user_context.SetKey(Key(kPassword)); |
712 user_context.SetUserIDHash(user_context.GetUserID()); | 715 user_context.SetUserIDHash(user_context.GetAccountId().GetUserEmail()); |
713 existing_user_controller()->Login(user_context, SigninSpecifics()); | 716 existing_user_controller()->Login(user_context, SigninSpecifics()); |
714 } | 717 } |
715 | 718 |
716 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 719 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
717 NoAutoLoginWhenUntrusted) { | 720 NoAutoLoginWhenUntrusted) { |
718 // Start the public session timer. | 721 // Start the public session timer. |
719 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); | 722 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginLongDelay); |
720 existing_user_controller()->OnSigninScreenReady(); | 723 existing_user_controller()->OnSigninScreenReady(); |
721 EXPECT_TRUE(auto_login_timer()); | 724 EXPECT_TRUE(auto_login_timer()); |
722 | 725 |
723 // Make cros settings untrusted. | 726 // Make cros settings untrusted. |
724 MakeCrosSettingsPermanentlyUntrusted(); | 727 MakeCrosSettingsPermanentlyUntrusted(); |
725 | 728 |
726 // Check that when the timer fires, auto-login fails with an error. | 729 // Check that when the timer fires, auto-login fails with an error. |
727 ExpectLoginFailure(); | 730 ExpectLoginFailure(); |
728 FireAutoLogin(); | 731 FireAutoLogin(); |
729 } | 732 } |
730 | 733 |
731 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 734 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
732 PRE_TestLoadingPublicUsersFromLocalState) { | 735 PRE_TestLoadingPublicUsersFromLocalState) { |
733 // First run propagates public accounts and stores them in Local State. | 736 // First run propagates public accounts and stores them in Local State. |
734 } | 737 } |
735 | 738 |
736 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 739 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
737 TestLoadingPublicUsersFromLocalState) { | 740 TestLoadingPublicUsersFromLocalState) { |
738 // Second run loads list of public accounts from Local State. | 741 // Second run loads list of public accounts from Local State. |
739 } | 742 } |
740 | 743 |
741 } // namespace chromeos | 744 } // namespace chromeos |
OLD | NEW |