| Index: trunk/src/chrome/browser/chromeos/login/login_utils_browsertest.cc
|
| ===================================================================
|
| --- trunk/src/chrome/browser/chromeos/login/login_utils_browsertest.cc (revision 282941)
|
| +++ trunk/src/chrome/browser/chromeos/login/login_utils_browsertest.cc (working copy)
|
| @@ -528,16 +528,50 @@
|
| DISALLOW_COPY_AND_ASSIGN(LoginUtilsTest);
|
| };
|
|
|
| -struct LoginUtilsBlockingLoginTestParam {
|
| - const int steps;
|
| - const char* username;
|
| - const bool enroll_device;
|
| -};
|
| -
|
| class LoginUtilsBlockingLoginTest
|
| : public LoginUtilsTest,
|
| - public testing::WithParamInterface<LoginUtilsBlockingLoginTestParam> {};
|
| + public testing::WithParamInterface<int> {};
|
|
|
| +TEST_F(LoginUtilsTest, NormalLoginDoesntBlock) {
|
| + UserManager* user_manager = UserManager::Get();
|
| + EXPECT_FALSE(user_manager->IsUserLoggedIn());
|
| + EXPECT_FALSE(connector_->IsEnterpriseManaged());
|
| + EXPECT_FALSE(prepared_profile_);
|
| + EXPECT_EQ(policy::USER_AFFILIATION_NONE,
|
| + connector_->GetUserAffiliation(kUsername));
|
| +
|
| + // The profile will be created without waiting for a policy response.
|
| + PrepareProfile(kUsername);
|
| +
|
| + EXPECT_TRUE(prepared_profile_);
|
| + ASSERT_TRUE(user_manager->IsUserLoggedIn());
|
| + EXPECT_EQ(kUsername, user_manager->GetLoggedInUser()->email());
|
| +}
|
| +
|
| +TEST_F(LoginUtilsTest, EnterpriseLoginDoesntBlockForNormalUser) {
|
| + UserManager* user_manager = UserManager::Get();
|
| + EXPECT_FALSE(user_manager->IsUserLoggedIn());
|
| + EXPECT_FALSE(connector_->IsEnterpriseManaged());
|
| + EXPECT_FALSE(prepared_profile_);
|
| +
|
| + // Enroll the device.
|
| + EnrollDevice(kUsername);
|
| +
|
| + EXPECT_FALSE(user_manager->IsUserLoggedIn());
|
| + EXPECT_TRUE(connector_->IsEnterpriseManaged());
|
| + EXPECT_EQ(kDomain, connector_->GetEnterpriseDomain());
|
| + EXPECT_FALSE(prepared_profile_);
|
| + EXPECT_EQ(policy::USER_AFFILIATION_NONE,
|
| + connector_->GetUserAffiliation(kUsernameOtherDomain));
|
| +
|
| + // Login with a non-enterprise user shouldn't block.
|
| + PrepareProfile(kUsernameOtherDomain);
|
| +
|
| + EXPECT_TRUE(prepared_profile_);
|
| + ASSERT_TRUE(user_manager->IsUserLoggedIn());
|
| + EXPECT_EQ(kUsernameOtherDomain, user_manager->GetLoggedInUser()->email());
|
| +}
|
| +
|
| #if defined(ENABLE_RLZ)
|
| TEST_F(LoginUtilsTest, RlzInitialized) {
|
| // No RLZ brand code set initially.
|
| @@ -564,26 +598,25 @@
|
| }
|
| #endif
|
|
|
| -TEST_P(LoginUtilsBlockingLoginTest, LoginBlocksForUser) {
|
| +TEST_P(LoginUtilsBlockingLoginTest, EnterpriseLoginBlocksForEnterpriseUser) {
|
| UserManager* user_manager = UserManager::Get();
|
| EXPECT_FALSE(user_manager->IsUserLoggedIn());
|
| EXPECT_FALSE(connector_->IsEnterpriseManaged());
|
| EXPECT_FALSE(prepared_profile_);
|
|
|
| - if (GetParam().enroll_device) {
|
| - // Enroll the device.
|
| - EnrollDevice(kUsername);
|
| + // Enroll the device.
|
| + EnrollDevice(kUsername);
|
|
|
| - EXPECT_FALSE(user_manager->IsUserLoggedIn());
|
| - EXPECT_TRUE(connector_->IsEnterpriseManaged());
|
| - EXPECT_EQ(kDomain, connector_->GetEnterpriseDomain());
|
| - EXPECT_FALSE(prepared_profile_);
|
| - EXPECT_EQ(policy::USER_AFFILIATION_MANAGED,
|
| - connector_->GetUserAffiliation(kUsername));
|
| - EXPECT_FALSE(user_manager->IsKnownUser(kUsername));
|
| - }
|
| + EXPECT_FALSE(user_manager->IsUserLoggedIn());
|
| + EXPECT_TRUE(connector_->IsEnterpriseManaged());
|
| + EXPECT_EQ(kDomain, connector_->GetEnterpriseDomain());
|
| + EXPECT_FALSE(prepared_profile_);
|
| + EXPECT_EQ(policy::USER_AFFILIATION_MANAGED,
|
| + connector_->GetUserAffiliation(kUsername));
|
| + EXPECT_FALSE(user_manager->IsKnownUser(kUsername));
|
|
|
| - PrepareProfile(GetParam().username);
|
| + // Login with a user of the enterprise domain waits for policy.
|
| + PrepareProfile(kUsername);
|
|
|
| EXPECT_FALSE(prepared_profile_);
|
| ASSERT_TRUE(user_manager->IsUserLoggedIn());
|
| @@ -595,7 +628,7 @@
|
| // |steps| is the test parameter, and is the number of successful fetches.
|
| // The first incomplete fetch will fail. In any case, the profile creation
|
| // should resume.
|
| - int steps = GetParam().steps;
|
| + int steps = GetParam();
|
|
|
| // The next expected fetcher ID. This is used to make it fail.
|
| int next_expected_fetcher_id = 0;
|
| @@ -670,30 +703,11 @@
|
| EXPECT_TRUE(prepared_profile_);
|
| }
|
|
|
| -const LoginUtilsBlockingLoginTestParam kBlockinLoginTestCases[] = {
|
| - {0, kUsername, true},
|
| - {1, kUsername, true},
|
| - {2, kUsername, true},
|
| - {3, kUsername, true},
|
| - {4, kUsername, true},
|
| - {5, kUsername, true},
|
| - {0, kUsername, false},
|
| - {1, kUsername, false},
|
| - {2, kUsername, false},
|
| - {3, kUsername, false},
|
| - {4, kUsername, false},
|
| - {5, kUsername, false},
|
| - {0, kUsernameOtherDomain, true},
|
| - {1, kUsernameOtherDomain, true},
|
| - {2, kUsernameOtherDomain, true},
|
| - {3, kUsernameOtherDomain, true},
|
| - {4, kUsernameOtherDomain, true},
|
| - {5, kUsernameOtherDomain, true}};
|
| +INSTANTIATE_TEST_CASE_P(
|
| + LoginUtilsBlockingLoginTestInstance,
|
| + LoginUtilsBlockingLoginTest,
|
| + testing::Values(0, 1, 2, 3, 4, 5));
|
|
|
| -INSTANTIATE_TEST_CASE_P(LoginUtilsBlockingLoginTestInstance,
|
| - LoginUtilsBlockingLoginTest,
|
| - testing::ValuesIn(kBlockinLoginTestCases));
|
| -
|
| } // namespace
|
|
|
| } // namespace chromeos
|
|
|