Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/login/login_utils.h" | 5 #include "chrome/browser/chromeos/login/login_utils.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 525 std::string device_policy_; | 525 std::string device_policy_; |
| 526 std::string user_policy_; | 526 std::string user_policy_; |
| 527 | 527 |
| 528 DISALLOW_COPY_AND_ASSIGN(LoginUtilsTest); | 528 DISALLOW_COPY_AND_ASSIGN(LoginUtilsTest); |
| 529 }; | 529 }; |
| 530 | 530 |
| 531 class LoginUtilsBlockingLoginTest | 531 class LoginUtilsBlockingLoginTest |
| 532 : public LoginUtilsTest, | 532 : public LoginUtilsTest, |
| 533 public testing::WithParamInterface<int> {}; | 533 public testing::WithParamInterface<int> {}; |
| 534 | 534 |
| 535 TEST_F(LoginUtilsTest, NormalLoginDoesntBlock) { | 535 TEST_F(LoginUtilsTest, NormalLoginDoesBlock) { |
| 536 UserManager* user_manager = UserManager::Get(); | 536 UserManager* user_manager = UserManager::Get(); |
| 537 EXPECT_FALSE(user_manager->IsUserLoggedIn()); | 537 EXPECT_FALSE(user_manager->IsUserLoggedIn()); |
| 538 EXPECT_FALSE(connector_->IsEnterpriseManaged()); | 538 EXPECT_FALSE(connector_->IsEnterpriseManaged()); |
| 539 EXPECT_FALSE(prepared_profile_); | 539 EXPECT_FALSE(prepared_profile_); |
| 540 EXPECT_EQ(policy::USER_AFFILIATION_NONE, | 540 EXPECT_EQ(policy::USER_AFFILIATION_NONE, |
| 541 connector_->GetUserAffiliation(kUsername)); | 541 connector_->GetUserAffiliation(kUsername)); |
| 542 | 542 |
| 543 // The profile will be created without waiting for a policy response. | 543 // The profile will be created without waiting for a policy response. |
| 544 PrepareProfile(kUsername); | 544 PrepareProfile(kUsername); |
| 545 | 545 |
| 546 EXPECT_TRUE(prepared_profile_); | 546 EXPECT_FALSE(prepared_profile_); |
|
Nikita (slow)
2014/07/08 15:08:30
Why profile will be NULL here?
kaliamoorthi
2014/07/08 15:44:34
I have made the first login block on policy fetch
| |
| 547 ASSERT_TRUE(user_manager->IsUserLoggedIn()); | |
| 548 EXPECT_EQ(kUsername, user_manager->GetLoggedInUser()->email()); | |
| 549 } | 547 } |
| 550 | 548 |
| 551 TEST_F(LoginUtilsTest, EnterpriseLoginDoesntBlockForNormalUser) { | 549 TEST_F(LoginUtilsTest, EnterpriseLoginDoesBlockForNormalUser) { |
| 552 UserManager* user_manager = UserManager::Get(); | 550 UserManager* user_manager = UserManager::Get(); |
| 553 EXPECT_FALSE(user_manager->IsUserLoggedIn()); | 551 EXPECT_FALSE(user_manager->IsUserLoggedIn()); |
| 554 EXPECT_FALSE(connector_->IsEnterpriseManaged()); | 552 EXPECT_FALSE(connector_->IsEnterpriseManaged()); |
| 555 EXPECT_FALSE(prepared_profile_); | 553 EXPECT_FALSE(prepared_profile_); |
| 556 | 554 |
| 557 // Enroll the device. | 555 // Enroll the device. |
| 558 EnrollDevice(kUsername); | 556 EnrollDevice(kUsername); |
| 559 | 557 |
| 560 EXPECT_FALSE(user_manager->IsUserLoggedIn()); | 558 EXPECT_FALSE(user_manager->IsUserLoggedIn()); |
| 561 EXPECT_TRUE(connector_->IsEnterpriseManaged()); | 559 EXPECT_TRUE(connector_->IsEnterpriseManaged()); |
| 562 EXPECT_EQ(kDomain, connector_->GetEnterpriseDomain()); | 560 EXPECT_EQ(kDomain, connector_->GetEnterpriseDomain()); |
| 563 EXPECT_FALSE(prepared_profile_); | 561 EXPECT_FALSE(prepared_profile_); |
| 564 EXPECT_EQ(policy::USER_AFFILIATION_NONE, | 562 EXPECT_EQ(policy::USER_AFFILIATION_NONE, |
| 565 connector_->GetUserAffiliation(kUsernameOtherDomain)); | 563 connector_->GetUserAffiliation(kUsernameOtherDomain)); |
| 566 | 564 |
| 567 // Login with a non-enterprise user shouldn't block. | 565 // Login with a non-enterprise user shouldn't block. |
| 568 PrepareProfile(kUsernameOtherDomain); | 566 PrepareProfile(kUsernameOtherDomain); |
| 569 | 567 |
| 570 EXPECT_TRUE(prepared_profile_); | 568 EXPECT_FALSE(prepared_profile_); |
| 571 ASSERT_TRUE(user_manager->IsUserLoggedIn()); | |
| 572 EXPECT_EQ(kUsernameOtherDomain, user_manager->GetLoggedInUser()->email()); | |
| 573 } | 569 } |
| 574 | 570 |
| 575 #if defined(ENABLE_RLZ) | 571 #if defined(ENABLE_RLZ) |
| 576 TEST_F(LoginUtilsTest, RlzInitialized) { | 572 TEST_F(LoginUtilsTest, RlzInitialized) { |
| 577 // No RLZ brand code set initially. | 573 // No RLZ brand code set initially. |
| 578 EXPECT_FALSE(local_state_.Get()->HasPrefPath(prefs::kRLZBrand)); | 574 EXPECT_FALSE(local_state_.Get()->HasPrefPath(prefs::kRLZBrand)); |
| 579 | 575 |
| 580 base::RunLoop wait_for_rlz_init; | 576 base::RunLoop wait_for_rlz_init; |
| 581 rlz_initialized_cb_ = wait_for_rlz_init.QuitClosure(); | 577 rlz_initialized_cb_ = wait_for_rlz_init.QuitClosure(); |
| 582 | 578 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 704 } | 700 } |
| 705 | 701 |
| 706 INSTANTIATE_TEST_CASE_P( | 702 INSTANTIATE_TEST_CASE_P( |
| 707 LoginUtilsBlockingLoginTestInstance, | 703 LoginUtilsBlockingLoginTestInstance, |
| 708 LoginUtilsBlockingLoginTest, | 704 LoginUtilsBlockingLoginTest, |
| 709 testing::Values(0, 1, 2, 3, 4, 5)); | 705 testing::Values(0, 1, 2, 3, 4, 5)); |
| 710 | 706 |
| 711 } // namespace | 707 } // namespace |
| 712 | 708 |
| 713 } // namespace chromeos | 709 } // namespace chromeos |
| OLD | NEW |