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 kPublicSessionUserEmail[] = "public_session_user@localhost"; | 79 const char kPublicSessionAccountId[] = "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() {} | 108 ExistingUserControllerTest() : mock_login_display_(NULL) {} |
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 AccountId auto_login_account_id() const { | 199 const std::string& auto_login_username() const { |
200 return AccountId::FromUserEmail( | 200 return existing_user_controller()->public_session_auto_login_username_; |
201 existing_user_controller()->public_session_auto_login_username_); | |
202 } | 201 } |
203 | 202 |
204 int auto_login_delay() const { | 203 int auto_login_delay() const { |
205 return existing_user_controller()->public_session_auto_login_delay_; | 204 return existing_user_controller()->public_session_auto_login_delay_; |
206 } | 205 } |
207 | 206 |
208 bool is_login_in_progress() const { | 207 bool is_login_in_progress() const { |
209 return existing_user_controller()->is_login_in_progress_; | 208 return existing_user_controller()->is_login_in_progress_; |
210 } | 209 } |
211 | 210 |
212 scoped_ptr<ExistingUserController> existing_user_controller_; | 211 scoped_ptr<ExistingUserController> existing_user_controller_; |
213 | 212 |
214 // |mock_login_display_| is owned by the ExistingUserController, which calls | 213 // |mock_login_display_| is owned by the ExistingUserController, which calls |
215 // CreateLoginDisplay() on the |mock_login_display_host_| to get it. | 214 // CreateLoginDisplay() on the |mock_login_display_host_| to get it. |
216 MockLoginDisplay* mock_login_display_ = nullptr; | 215 MockLoginDisplay* mock_login_display_; |
217 scoped_ptr<MockLoginDisplayHost> mock_login_display_host_; | 216 scoped_ptr<MockLoginDisplayHost> mock_login_display_host_; |
218 | 217 |
219 // Mock URLFetcher. | 218 // Mock URLFetcher. |
220 MockURLFetcherFactory<SuccessFetcher> factory_; | 219 MockURLFetcherFactory<SuccessFetcher> factory_; |
221 | 220 |
222 const AccountId account_id_ = AccountId::FromUserEmail(kUsername); | |
223 | |
224 private: | 221 private: |
225 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerTest); | 222 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerTest); |
226 }; | 223 }; |
227 | 224 |
228 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, PRE_ExistingUserLogin) { | 225 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, PRE_ExistingUserLogin) { |
229 RegisterUser(account_id_.GetUserEmail()); | 226 RegisterUser(kUsername); |
230 } | 227 } |
231 | 228 |
232 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) { | 229 IN_PROC_BROWSER_TEST_F(ExistingUserControllerTest, ExistingUserLogin) { |
233 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 230 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
234 .Times(2); | 231 .Times(2); |
235 UserContext user_context(account_id_); | 232 UserContext user_context(kUsername); |
236 user_context.SetGaiaID(kGaiaID); | 233 user_context.SetGaiaID(kGaiaID); |
237 user_context.SetKey(Key(kPassword)); | 234 user_context.SetKey(Key(kPassword)); |
238 user_context.SetUserIDHash(account_id_.GetUserEmail()); | 235 user_context.SetUserIDHash(kUsername); |
239 test::UserSessionManagerTestApi session_manager_test_api( | 236 test::UserSessionManagerTestApi session_manager_test_api( |
240 UserSessionManager::GetInstance()); | 237 UserSessionManager::GetInstance()); |
241 session_manager_test_api.InjectStubUserContext(user_context); | 238 session_manager_test_api.InjectStubUserContext(user_context); |
242 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) | 239 EXPECT_CALL(*mock_login_display_, SetUIEnabled(true)) |
243 .Times(1); | 240 .Times(1); |
244 EXPECT_CALL(*mock_login_display_host_, | 241 EXPECT_CALL(*mock_login_display_host_, |
245 StartWizard(WizardController::kTermsOfServiceScreenName)) | 242 StartWizard(WizardController::kTermsOfServiceScreenName)) |
246 .Times(0); | 243 .Times(0); |
247 | 244 |
248 content::WindowedNotificationObserver profile_prepared_observer( | 245 content::WindowedNotificationObserver profile_prepared_observer( |
(...skipping 27 matching lines...) Expand all Loading... |
276 | 273 |
277 ExpectLoginFailure(); | 274 ExpectLoginFailure(); |
278 } | 275 } |
279 | 276 |
280 void ExistingUserControllerUntrustedTest::SetUpSessionManager() { | 277 void ExistingUserControllerUntrustedTest::SetUpSessionManager() { |
281 InstallOwnerKey(); | 278 InstallOwnerKey(); |
282 } | 279 } |
283 | 280 |
284 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 281 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
285 ExistingUserLoginForbidden) { | 282 ExistingUserLoginForbidden) { |
286 UserContext user_context(account_id_); | 283 UserContext user_context(kUsername); |
287 user_context.SetGaiaID(kGaiaID); | 284 user_context.SetGaiaID(kGaiaID); |
288 user_context.SetKey(Key(kPassword)); | 285 user_context.SetKey(Key(kPassword)); |
289 user_context.SetUserIDHash(account_id_.GetUserEmail()); | 286 user_context.SetUserIDHash(kUsername); |
290 existing_user_controller()->Login(user_context, SigninSpecifics()); | 287 existing_user_controller()->Login(user_context, SigninSpecifics()); |
291 } | 288 } |
292 | 289 |
293 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 290 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
294 NewUserLoginForbidden) { | 291 NewUserLoginForbidden) { |
295 UserContext user_context(account_id_); | 292 UserContext user_context(kUsername); |
296 user_context.SetGaiaID(kGaiaID); | 293 user_context.SetGaiaID(kGaiaID); |
297 user_context.SetKey(Key(kPassword)); | 294 user_context.SetKey(Key(kPassword)); |
298 user_context.SetUserIDHash(account_id_.GetUserEmail()); | 295 user_context.SetUserIDHash(kUsername); |
299 existing_user_controller()->CompleteLogin(user_context); | 296 existing_user_controller()->CompleteLogin(user_context); |
300 } | 297 } |
301 | 298 |
302 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 299 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
303 GuestLoginForbidden) { | 300 GuestLoginForbidden) { |
304 existing_user_controller()->Login( | 301 existing_user_controller()->Login( |
305 UserContext(user_manager::USER_TYPE_GUEST, std::string()), | 302 UserContext(user_manager::USER_TYPE_GUEST, std::string()), |
306 SigninSpecifics()); | 303 SigninSpecifics()); |
307 } | 304 } |
308 | 305 |
309 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 306 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
310 SupervisedUserLoginForbidden) { | 307 SupervisedUserLoginForbidden) { |
311 UserContext user_context(AccountId::FromUserEmail(kSupervisedUserID)); | 308 UserContext user_context(kSupervisedUserID); |
312 user_context.SetKey(Key(kPassword)); | 309 user_context.SetKey(Key(kPassword)); |
313 user_context.SetUserIDHash(account_id_.GetUserEmail()); | 310 user_context.SetUserIDHash(kUsername); |
314 existing_user_controller()->Login(user_context, SigninSpecifics()); | 311 existing_user_controller()->Login(user_context, SigninSpecifics()); |
315 } | 312 } |
316 | 313 |
317 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, | 314 IN_PROC_BROWSER_TEST_F(ExistingUserControllerUntrustedTest, |
318 SupervisedUserCreationForbidden) { | 315 SupervisedUserCreationForbidden) { |
319 MockBaseScreenDelegate mock_base_screen_delegate; | 316 MockBaseScreenDelegate mock_base_screen_delegate; |
320 SupervisedUserCreationScreenHandler supervised_user_creation_screen_handler; | 317 SupervisedUserCreationScreenHandler supervised_user_creation_screen_handler; |
321 SupervisedUserCreationScreen supervised_user_creation_screen( | 318 SupervisedUserCreationScreen supervised_user_creation_screen( |
322 &mock_base_screen_delegate, &supervised_user_creation_screen_handler); | 319 &mock_base_screen_delegate, &supervised_user_creation_screen_handler); |
323 | 320 |
324 supervised_user_creation_screen.AuthenticateManager( | 321 supervised_user_creation_screen.AuthenticateManager(kUsername, kPassword); |
325 account_id_.GetUserEmail(), kPassword); | |
326 } | 322 } |
327 | 323 |
328 MATCHER_P(HasDetails, expected, "") { | 324 MATCHER_P(HasDetails, expected, "") { |
329 return expected == *content::Details<const std::string>(arg).ptr(); | 325 return expected == *content::Details<const std::string>(arg).ptr(); |
330 } | 326 } |
331 | 327 |
332 class ExistingUserControllerPublicSessionTest | 328 class ExistingUserControllerPublicSessionTest |
333 : public ExistingUserControllerTest { | 329 : public ExistingUserControllerTest { |
334 protected: | 330 protected: |
335 ExistingUserControllerPublicSessionTest() {} | 331 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_account_id_)) { | 342 public_session_user_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_account_id_)) | 347 public_session_user_id_)).Wait(); |
348 .Wait(); | |
349 } | 348 } |
350 | 349 |
351 // Wait for the device local account policy to be installed. | 350 // Wait for the device local account policy to be installed. |
352 policy::CloudPolicyStore* store = | 351 policy::CloudPolicyStore* store = |
353 TestingBrowserProcess::GetGlobal() | 352 TestingBrowserProcess::GetGlobal() |
354 ->platform_part() | 353 ->platform_part() |
355 ->browser_policy_connector_chromeos() | 354 ->browser_policy_connector_chromeos() |
356 ->GetDeviceLocalAccountPolicyService() | 355 ->GetDeviceLocalAccountPolicyService() |
357 ->GetBrokerForUser(public_session_account_id_.GetUserEmail()) | 356 ->GetBrokerForUser(public_session_user_id_) |
358 ->core() | 357 ->core() |
359 ->store(); | 358 ->store(); |
360 if (!store->has_policy()) { | 359 if (!store->has_policy()) { |
361 policy::MockCloudPolicyStoreObserver observer; | 360 policy::MockCloudPolicyStoreObserver observer; |
362 | 361 |
363 base::RunLoop loop; | 362 base::RunLoop loop; |
364 store->AddObserver(&observer); | 363 store->AddObserver(&observer); |
365 EXPECT_CALL(observer, OnStoreLoaded(store)) | 364 EXPECT_CALL(observer, OnStoreLoaded(store)) |
366 .Times(1) | 365 .Times(1) |
367 .WillOnce(InvokeWithoutArgs(&loop, &base::RunLoop::Quit)); | 366 .WillOnce(InvokeWithoutArgs(&loop, &base::RunLoop::Quit)); |
368 loop.Run(); | 367 loop.Run(); |
369 store->RemoveObserver(&observer); | 368 store->RemoveObserver(&observer); |
370 } | 369 } |
371 } | 370 } |
372 | 371 |
373 void SetUpSessionManager() override { | 372 void SetUpSessionManager() override { |
374 InstallOwnerKey(); | 373 InstallOwnerKey(); |
375 | 374 |
376 // Setup the device policy. | 375 // Setup the device policy. |
377 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); | 376 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); |
378 em::DeviceLocalAccountInfoProto* account = | 377 em::DeviceLocalAccountInfoProto* account = |
379 proto.mutable_device_local_accounts()->add_account(); | 378 proto.mutable_device_local_accounts()->add_account(); |
380 account->set_account_id(kPublicSessionUserEmail); | 379 account->set_account_id(kPublicSessionAccountId); |
381 account->set_type( | 380 account->set_type( |
382 em::DeviceLocalAccountInfoProto::ACCOUNT_TYPE_PUBLIC_SESSION); | 381 em::DeviceLocalAccountInfoProto::ACCOUNT_TYPE_PUBLIC_SESSION); |
383 RefreshDevicePolicy(); | 382 RefreshDevicePolicy(); |
384 | 383 |
385 // Setup the device local account policy. | 384 // Setup the device local account policy. |
386 policy::UserPolicyBuilder device_local_account_policy; | 385 policy::UserPolicyBuilder device_local_account_policy; |
387 device_local_account_policy.policy_data().set_username( | 386 device_local_account_policy.policy_data().set_username( |
388 kPublicSessionUserEmail); | 387 kPublicSessionAccountId); |
389 device_local_account_policy.policy_data().set_policy_type( | 388 device_local_account_policy.policy_data().set_policy_type( |
390 policy::dm_protocol::kChromePublicAccountPolicyType); | 389 policy::dm_protocol::kChromePublicAccountPolicyType); |
391 device_local_account_policy.policy_data().set_settings_entity_id( | 390 device_local_account_policy.policy_data().set_settings_entity_id( |
392 kPublicSessionUserEmail); | 391 kPublicSessionAccountId); |
393 device_local_account_policy.Build(); | 392 device_local_account_policy.Build(); |
394 session_manager_client()->set_device_local_account_policy( | 393 session_manager_client()->set_device_local_account_policy( |
395 kPublicSessionUserEmail, device_local_account_policy.GetBlob()); | 394 kPublicSessionAccountId, |
| 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& user_email, int delay) { | 434 void SetAutoLoginPolicy(const std::string& username, 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() != user_email) { | 447 proto.device_local_accounts().auto_login_id() != username) { |
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(user_email); | 465 proto.mutable_device_local_accounts()->set_auto_login_id(username); |
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 AccountId public_session_account_id_ = | 494 const std::string public_session_user_id_; |
495 AccountId::FromUserEmail(policy::GenerateDeviceLocalAccountUserId( | |
496 kPublicSessionUserEmail, | |
497 policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION)); | |
498 | 495 |
499 private: | 496 private: |
500 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerPublicSessionTest); | 497 DISALLOW_COPY_AND_ASSIGN(ExistingUserControllerPublicSessionTest); |
501 }; | 498 }; |
502 | 499 |
503 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 500 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
504 ConfigureAutoLoginUsingPolicy) { | 501 ConfigureAutoLoginUsingPolicy) { |
505 existing_user_controller()->OnSigninScreenReady(); | 502 existing_user_controller()->OnSigninScreenReady(); |
506 EXPECT_TRUE(!auto_login_account_id().is_valid()); | 503 EXPECT_EQ("", auto_login_username()); |
507 EXPECT_EQ(0, auto_login_delay()); | 504 EXPECT_EQ(0, auto_login_delay()); |
508 EXPECT_FALSE(auto_login_timer()); | 505 EXPECT_FALSE(auto_login_timer()); |
509 | 506 |
510 // Set the policy. | 507 // Set the policy. |
511 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginLongDelay); | 508 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
512 EXPECT_EQ(public_session_account_id_, auto_login_account_id()); | 509 EXPECT_EQ(public_session_user_id_, auto_login_username()); |
513 EXPECT_EQ(kAutoLoginLongDelay, auto_login_delay()); | 510 EXPECT_EQ(kAutoLoginLongDelay, auto_login_delay()); |
514 ASSERT_TRUE(auto_login_timer()); | 511 ASSERT_TRUE(auto_login_timer()); |
515 EXPECT_TRUE(auto_login_timer()->IsRunning()); | 512 EXPECT_TRUE(auto_login_timer()->IsRunning()); |
516 | 513 |
517 // Unset the policy. | 514 // Unset the policy. |
518 SetAutoLoginPolicy("", 0); | 515 SetAutoLoginPolicy("", 0); |
519 EXPECT_TRUE(!auto_login_account_id().is_valid()); | 516 EXPECT_EQ("", auto_login_username()); |
520 EXPECT_EQ(0, auto_login_delay()); | 517 EXPECT_EQ(0, auto_login_delay()); |
521 ASSERT_TRUE(auto_login_timer()); | 518 ASSERT_TRUE(auto_login_timer()); |
522 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 519 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
523 } | 520 } |
524 | 521 |
525 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 522 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
526 AutoLoginNoDelay) { | 523 AutoLoginNoDelay) { |
527 // Set up mocks to check login success. | 524 // Set up mocks to check login success. |
528 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, | 525 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
529 public_session_account_id_.GetUserEmail()); | 526 public_session_user_id_); |
530 user_context.SetUserIDHash(user_context.GetAccountId().GetUserEmail()); | 527 user_context.SetUserIDHash(user_context.GetUserID()); |
531 ExpectSuccessfulLogin(user_context); | 528 ExpectSuccessfulLogin(user_context); |
532 existing_user_controller()->OnSigninScreenReady(); | 529 existing_user_controller()->OnSigninScreenReady(); |
533 | 530 |
534 // Start auto-login and wait for login tasks to complete. | 531 // Start auto-login and wait for login tasks to complete. |
535 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginNoDelay); | 532 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginNoDelay); |
536 content::RunAllPendingInMessageLoop(); | 533 content::RunAllPendingInMessageLoop(); |
537 } | 534 } |
538 | 535 |
539 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 536 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
540 AutoLoginShortDelay) { | 537 AutoLoginShortDelay) { |
541 // Set up mocks to check login success. | 538 // Set up mocks to check login success. |
542 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, | 539 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
543 public_session_account_id_.GetUserEmail()); | 540 public_session_user_id_); |
544 user_context.SetUserIDHash(user_context.GetAccountId().GetUserEmail()); | 541 user_context.SetUserIDHash(user_context.GetUserID()); |
545 ExpectSuccessfulLogin(user_context); | 542 ExpectSuccessfulLogin(user_context); |
546 existing_user_controller()->OnSigninScreenReady(); | 543 existing_user_controller()->OnSigninScreenReady(); |
547 | 544 |
548 content::WindowedNotificationObserver profile_prepared_observer( | 545 content::WindowedNotificationObserver profile_prepared_observer( |
549 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 546 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
550 content::NotificationService::AllSources()); | 547 content::NotificationService::AllSources()); |
551 | 548 |
552 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginShortDelay); | 549 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginShortDelay); |
553 ASSERT_TRUE(auto_login_timer()); | 550 ASSERT_TRUE(auto_login_timer()); |
554 // Don't assert that timer is running: with the short delay sometimes | 551 // Don't assert that timer is running: with the short delay sometimes |
555 // the trigger happens before the assert. We've already tested that | 552 // the trigger happens before the assert. We've already tested that |
556 // the timer starts when it should. | 553 // the timer starts when it should. |
557 | 554 |
558 // Wait for the timer to fire. | 555 // Wait for the timer to fire. |
559 base::RunLoop runner; | 556 base::RunLoop runner; |
560 base::OneShotTimer timer; | 557 base::OneShotTimer timer; |
561 timer.Start(FROM_HERE, | 558 timer.Start(FROM_HERE, |
562 base::TimeDelta::FromMilliseconds(kAutoLoginShortDelay + 1), | 559 base::TimeDelta::FromMilliseconds(kAutoLoginShortDelay + 1), |
563 runner.QuitClosure()); | 560 runner.QuitClosure()); |
564 runner.Run(); | 561 runner.Run(); |
565 | 562 |
566 profile_prepared_observer.Wait(); | 563 profile_prepared_observer.Wait(); |
567 | 564 |
568 // Wait for login tasks to complete. | 565 // Wait for login tasks to complete. |
569 content::RunAllPendingInMessageLoop(); | 566 content::RunAllPendingInMessageLoop(); |
570 } | 567 } |
571 | 568 |
572 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 569 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
573 LoginStopsAutoLogin) { | 570 LoginStopsAutoLogin) { |
574 // Set up mocks to check login success. | 571 // Set up mocks to check login success. |
575 UserContext user_context(account_id_); | 572 UserContext user_context(kUsername); |
576 user_context.SetGaiaID(kGaiaID); | 573 user_context.SetGaiaID(kGaiaID); |
577 user_context.SetKey(Key(kPassword)); | 574 user_context.SetKey(Key(kPassword)); |
578 user_context.SetUserIDHash(user_context.GetAccountId().GetUserEmail()); | 575 user_context.SetUserIDHash(user_context.GetUserID()); |
579 ExpectSuccessfulLogin(user_context); | 576 ExpectSuccessfulLogin(user_context); |
580 | 577 |
581 existing_user_controller()->OnSigninScreenReady(); | 578 existing_user_controller()->OnSigninScreenReady(); |
582 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginLongDelay); | 579 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
583 EXPECT_TRUE(auto_login_timer()); | 580 EXPECT_TRUE(auto_login_timer()); |
584 | 581 |
585 content::WindowedNotificationObserver profile_prepared_observer( | 582 content::WindowedNotificationObserver profile_prepared_observer( |
586 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 583 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
587 content::NotificationService::AllSources()); | 584 content::NotificationService::AllSources()); |
588 | 585 |
589 // Log in and check that it stopped the timer. | 586 // Log in and check that it stopped the timer. |
590 existing_user_controller()->Login(user_context, SigninSpecifics()); | 587 existing_user_controller()->Login(user_context, SigninSpecifics()); |
591 EXPECT_TRUE(is_login_in_progress()); | 588 EXPECT_TRUE(is_login_in_progress()); |
592 ASSERT_TRUE(auto_login_timer()); | 589 ASSERT_TRUE(auto_login_timer()); |
593 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 590 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
594 | 591 |
595 profile_prepared_observer.Wait(); | 592 profile_prepared_observer.Wait(); |
596 | 593 |
597 // Wait for login tasks to complete. | 594 // Wait for login tasks to complete. |
598 content::RunAllPendingInMessageLoop(); | 595 content::RunAllPendingInMessageLoop(); |
599 | 596 |
600 // Timer should still be stopped after login completes. | 597 // Timer should still be stopped after login completes. |
601 ASSERT_TRUE(auto_login_timer()); | 598 ASSERT_TRUE(auto_login_timer()); |
602 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 599 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
603 } | 600 } |
604 | 601 |
605 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 602 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
606 GuestModeLoginStopsAutoLogin) { | 603 GuestModeLoginStopsAutoLogin) { |
607 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) | 604 EXPECT_CALL(*mock_login_display_, SetUIEnabled(false)) |
608 .Times(2); | 605 .Times(2); |
609 UserContext user_context(account_id_); | 606 UserContext user_context(kUsername); |
610 user_context.SetGaiaID(kGaiaID); | 607 user_context.SetGaiaID(kGaiaID); |
611 user_context.SetKey(Key(kPassword)); | 608 user_context.SetKey(Key(kPassword)); |
612 test::UserSessionManagerTestApi session_manager_test_api( | 609 test::UserSessionManagerTestApi session_manager_test_api( |
613 UserSessionManager::GetInstance()); | 610 UserSessionManager::GetInstance()); |
614 session_manager_test_api.InjectStubUserContext(user_context); | 611 session_manager_test_api.InjectStubUserContext(user_context); |
615 | 612 |
616 existing_user_controller()->OnSigninScreenReady(); | 613 existing_user_controller()->OnSigninScreenReady(); |
617 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginLongDelay); | 614 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
618 EXPECT_TRUE(auto_login_timer()); | 615 EXPECT_TRUE(auto_login_timer()); |
619 | 616 |
620 // Login and check that it stopped the timer. | 617 // Login and check that it stopped the timer. |
621 existing_user_controller()->Login(UserContext(user_manager::USER_TYPE_GUEST, | 618 existing_user_controller()->Login(UserContext(user_manager::USER_TYPE_GUEST, |
622 std::string()), | 619 std::string()), |
623 SigninSpecifics()); | 620 SigninSpecifics()); |
624 EXPECT_TRUE(is_login_in_progress()); | 621 EXPECT_TRUE(is_login_in_progress()); |
625 ASSERT_TRUE(auto_login_timer()); | 622 ASSERT_TRUE(auto_login_timer()); |
626 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 623 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
627 | 624 |
628 // Wait for login tasks to complete. | 625 // Wait for login tasks to complete. |
629 content::RunAllPendingInMessageLoop(); | 626 content::RunAllPendingInMessageLoop(); |
630 | 627 |
631 // Timer should still be stopped after login completes. | 628 // Timer should still be stopped after login completes. |
632 ASSERT_TRUE(auto_login_timer()); | 629 ASSERT_TRUE(auto_login_timer()); |
633 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 630 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
634 } | 631 } |
635 | 632 |
636 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 633 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
637 CompleteLoginStopsAutoLogin) { | 634 CompleteLoginStopsAutoLogin) { |
638 // Set up mocks to check login success. | 635 // Set up mocks to check login success. |
639 UserContext user_context(account_id_); | 636 UserContext user_context(kUsername); |
640 user_context.SetGaiaID(kGaiaID); | 637 user_context.SetGaiaID(kGaiaID); |
641 user_context.SetKey(Key(kPassword)); | 638 user_context.SetKey(Key(kPassword)); |
642 user_context.SetUserIDHash(user_context.GetAccountId().GetUserEmail()); | 639 user_context.SetUserIDHash(user_context.GetUserID()); |
643 ExpectSuccessfulLogin(user_context); | 640 ExpectSuccessfulLogin(user_context); |
644 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()) | 641 EXPECT_CALL(*mock_login_display_host_, OnCompleteLogin()) |
645 .Times(1); | 642 .Times(1); |
646 | 643 |
647 existing_user_controller()->OnSigninScreenReady(); | 644 existing_user_controller()->OnSigninScreenReady(); |
648 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginLongDelay); | 645 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
649 EXPECT_TRUE(auto_login_timer()); | 646 EXPECT_TRUE(auto_login_timer()); |
650 | 647 |
651 content::WindowedNotificationObserver profile_prepared_observer( | 648 content::WindowedNotificationObserver profile_prepared_observer( |
652 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 649 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
653 content::NotificationService::AllSources()); | 650 content::NotificationService::AllSources()); |
654 | 651 |
655 // Check that login completes and stops the timer. | 652 // Check that login completes and stops the timer. |
656 existing_user_controller()->CompleteLogin(user_context); | 653 existing_user_controller()->CompleteLogin(user_context); |
657 ASSERT_TRUE(auto_login_timer()); | 654 ASSERT_TRUE(auto_login_timer()); |
658 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 655 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
659 | 656 |
660 profile_prepared_observer.Wait(); | 657 profile_prepared_observer.Wait(); |
661 | 658 |
662 // Wait for login tasks to complete. | 659 // Wait for login tasks to complete. |
663 content::RunAllPendingInMessageLoop(); | 660 content::RunAllPendingInMessageLoop(); |
664 | 661 |
665 // Timer should still be stopped after login completes. | 662 // Timer should still be stopped after login completes. |
666 ASSERT_TRUE(auto_login_timer()); | 663 ASSERT_TRUE(auto_login_timer()); |
667 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 664 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
668 } | 665 } |
669 | 666 |
670 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 667 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
671 PublicSessionLoginStopsAutoLogin) { | 668 PublicSessionLoginStopsAutoLogin) { |
672 // Set up mocks to check login success. | 669 // Set up mocks to check login success. |
673 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, | 670 UserContext user_context(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
674 public_session_account_id_.GetUserEmail()); | 671 public_session_user_id_); |
675 user_context.SetUserIDHash(user_context.GetAccountId().GetUserEmail()); | 672 user_context.SetUserIDHash(user_context.GetUserID()); |
676 ExpectSuccessfulLogin(user_context); | 673 ExpectSuccessfulLogin(user_context); |
677 existing_user_controller()->OnSigninScreenReady(); | 674 existing_user_controller()->OnSigninScreenReady(); |
678 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginLongDelay); | 675 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
679 EXPECT_TRUE(auto_login_timer()); | 676 EXPECT_TRUE(auto_login_timer()); |
680 | 677 |
681 content::WindowedNotificationObserver profile_prepared_observer( | 678 content::WindowedNotificationObserver profile_prepared_observer( |
682 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 679 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
683 content::NotificationService::AllSources()); | 680 content::NotificationService::AllSources()); |
684 | 681 |
685 // Login and check that it stopped the timer. | 682 // Login and check that it stopped the timer. |
686 existing_user_controller()->Login( | 683 existing_user_controller()->Login( |
687 UserContext(user_manager::USER_TYPE_PUBLIC_ACCOUNT, | 684 UserContext(user_manager::USER_TYPE_PUBLIC_ACCOUNT, |
688 public_session_account_id_.GetUserEmail()), | 685 public_session_user_id_), |
689 SigninSpecifics()); | 686 SigninSpecifics()); |
690 | 687 |
691 EXPECT_TRUE(is_login_in_progress()); | 688 EXPECT_TRUE(is_login_in_progress()); |
692 ASSERT_TRUE(auto_login_timer()); | 689 ASSERT_TRUE(auto_login_timer()); |
693 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 690 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
694 | 691 |
695 profile_prepared_observer.Wait(); | 692 profile_prepared_observer.Wait(); |
696 | 693 |
697 // Wait for login tasks to complete. | 694 // Wait for login tasks to complete. |
698 content::RunAllPendingInMessageLoop(); | 695 content::RunAllPendingInMessageLoop(); |
699 | 696 |
700 // Timer should still be stopped after login completes. | 697 // Timer should still be stopped after login completes. |
701 ASSERT_TRUE(auto_login_timer()); | 698 ASSERT_TRUE(auto_login_timer()); |
702 EXPECT_FALSE(auto_login_timer()->IsRunning()); | 699 EXPECT_FALSE(auto_login_timer()->IsRunning()); |
703 } | 700 } |
704 | 701 |
705 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 702 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
706 LoginForbiddenWhenUntrusted) { | 703 LoginForbiddenWhenUntrusted) { |
707 // Make cros settings untrusted. | 704 // Make cros settings untrusted. |
708 MakeCrosSettingsPermanentlyUntrusted(); | 705 MakeCrosSettingsPermanentlyUntrusted(); |
709 | 706 |
710 // Check that the attempt to start a public session fails with an error. | 707 // Check that the attempt to start a public session fails with an error. |
711 ExpectLoginFailure(); | 708 ExpectLoginFailure(); |
712 UserContext user_context(account_id_); | 709 UserContext user_context(kUsername); |
713 user_context.SetGaiaID(kGaiaID); | 710 user_context.SetGaiaID(kGaiaID); |
714 user_context.SetKey(Key(kPassword)); | 711 user_context.SetKey(Key(kPassword)); |
715 user_context.SetUserIDHash(user_context.GetAccountId().GetUserEmail()); | 712 user_context.SetUserIDHash(user_context.GetUserID()); |
716 existing_user_controller()->Login(user_context, SigninSpecifics()); | 713 existing_user_controller()->Login(user_context, SigninSpecifics()); |
717 } | 714 } |
718 | 715 |
719 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 716 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
720 NoAutoLoginWhenUntrusted) { | 717 NoAutoLoginWhenUntrusted) { |
721 // Start the public session timer. | 718 // Start the public session timer. |
722 SetAutoLoginPolicy(kPublicSessionUserEmail, kAutoLoginLongDelay); | 719 SetAutoLoginPolicy(kPublicSessionAccountId, kAutoLoginLongDelay); |
723 existing_user_controller()->OnSigninScreenReady(); | 720 existing_user_controller()->OnSigninScreenReady(); |
724 EXPECT_TRUE(auto_login_timer()); | 721 EXPECT_TRUE(auto_login_timer()); |
725 | 722 |
726 // Make cros settings untrusted. | 723 // Make cros settings untrusted. |
727 MakeCrosSettingsPermanentlyUntrusted(); | 724 MakeCrosSettingsPermanentlyUntrusted(); |
728 | 725 |
729 // Check that when the timer fires, auto-login fails with an error. | 726 // Check that when the timer fires, auto-login fails with an error. |
730 ExpectLoginFailure(); | 727 ExpectLoginFailure(); |
731 FireAutoLogin(); | 728 FireAutoLogin(); |
732 } | 729 } |
733 | 730 |
734 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 731 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
735 PRE_TestLoadingPublicUsersFromLocalState) { | 732 PRE_TestLoadingPublicUsersFromLocalState) { |
736 // First run propagates public accounts and stores them in Local State. | 733 // First run propagates public accounts and stores them in Local State. |
737 } | 734 } |
738 | 735 |
739 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, | 736 IN_PROC_BROWSER_TEST_F(ExistingUserControllerPublicSessionTest, |
740 TestLoadingPublicUsersFromLocalState) { | 737 TestLoadingPublicUsersFromLocalState) { |
741 // Second run loads list of public accounts from Local State. | 738 // Second run loads list of public accounts from Local State. |
742 } | 739 } |
743 | 740 |
744 } // namespace chromeos | 741 } // namespace chromeos |
OLD | NEW |