Index: chrome/browser/chromeos/login/users/multi_profile_user_controller_unittest.cc |
diff --git a/chrome/browser/chromeos/login/users/multi_profile_user_controller_unittest.cc b/chrome/browser/chromeos/login/users/multi_profile_user_controller_unittest.cc |
index 5f3258f7f72607924e0161008bbfc5fd572fb00e..b93d73a2fc6b37a5281b104e285f5946d70b7e89 100644 |
--- a/chrome/browser/chromeos/login/users/multi_profile_user_controller_unittest.cc |
+++ b/chrome/browser/chromeos/login/users/multi_profile_user_controller_unittest.cc |
@@ -34,55 +34,65 @@ const char* kUsers[] = {"a@gmail.com", "b@gmail.com" }; |
struct BehaviorTestCase { |
const char* primary; |
const char* secondary; |
- MultiProfileUserController::UserAllowedInSessionReason expected_allowed; |
+ MultiProfileUserController::UserAllowedInSessionReason |
+ expected_primary_policy; |
+ MultiProfileUserController::UserAllowedInSessionReason |
+ expected_secondary_allowed; |
}; |
const BehaviorTestCase kBehaviorTestCases[] = { |
- { |
- MultiProfileUserController::kBehaviorUnrestricted, |
- MultiProfileUserController::kBehaviorUnrestricted, |
- MultiProfileUserController::ALLOWED, |
- }, |
- { |
- MultiProfileUserController::kBehaviorUnrestricted, |
- MultiProfileUserController::kBehaviorPrimaryOnly, |
- MultiProfileUserController::NOT_ALLOWED_POLICY_FORBIDS, |
- }, |
- { |
- MultiProfileUserController::kBehaviorUnrestricted, |
- MultiProfileUserController::kBehaviorNotAllowed, |
- MultiProfileUserController::NOT_ALLOWED_POLICY_FORBIDS, |
- }, |
- { |
- MultiProfileUserController::kBehaviorPrimaryOnly, |
- MultiProfileUserController::kBehaviorUnrestricted, |
- MultiProfileUserController::ALLOWED, |
- }, |
- { |
- MultiProfileUserController::kBehaviorPrimaryOnly, |
- MultiProfileUserController::kBehaviorPrimaryOnly, |
- MultiProfileUserController::NOT_ALLOWED_POLICY_FORBIDS, |
- }, |
- { |
- MultiProfileUserController::kBehaviorPrimaryOnly, |
- MultiProfileUserController::kBehaviorNotAllowed, |
- MultiProfileUserController::NOT_ALLOWED_POLICY_FORBIDS, |
- }, |
- { |
- MultiProfileUserController::kBehaviorNotAllowed, |
- MultiProfileUserController::kBehaviorUnrestricted, |
- MultiProfileUserController::NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS, |
- }, |
- { |
- MultiProfileUserController::kBehaviorNotAllowed, |
- MultiProfileUserController::kBehaviorPrimaryOnly, |
- MultiProfileUserController::NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS, |
- }, |
- { |
- MultiProfileUserController::kBehaviorNotAllowed, |
- MultiProfileUserController::kBehaviorNotAllowed, |
- MultiProfileUserController::NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS, |
- }, |
+ { |
+ MultiProfileUserController::kBehaviorUnrestricted, |
+ MultiProfileUserController::kBehaviorUnrestricted, |
+ MultiProfileUserController::ALLOWED, MultiProfileUserController::ALLOWED, |
+ }, |
+ { |
+ MultiProfileUserController::kBehaviorUnrestricted, |
+ MultiProfileUserController::kBehaviorPrimaryOnly, |
+ MultiProfileUserController::ALLOWED, |
+ MultiProfileUserController::NOT_ALLOWED_POLICY_FORBIDS, |
+ }, |
+ { |
+ MultiProfileUserController::kBehaviorUnrestricted, |
+ MultiProfileUserController::kBehaviorNotAllowed, |
+ MultiProfileUserController::ALLOWED, |
+ MultiProfileUserController::NOT_ALLOWED_POLICY_FORBIDS, |
+ }, |
+ { |
+ MultiProfileUserController::kBehaviorPrimaryOnly, |
+ MultiProfileUserController::kBehaviorUnrestricted, |
+ MultiProfileUserController::ALLOWED, MultiProfileUserController::ALLOWED, |
+ }, |
+ { |
+ MultiProfileUserController::kBehaviorPrimaryOnly, |
+ MultiProfileUserController::kBehaviorPrimaryOnly, |
+ MultiProfileUserController::ALLOWED, |
+ MultiProfileUserController::NOT_ALLOWED_POLICY_FORBIDS, |
+ }, |
+ { |
+ MultiProfileUserController::kBehaviorPrimaryOnly, |
+ MultiProfileUserController::kBehaviorNotAllowed, |
+ MultiProfileUserController::ALLOWED, |
+ MultiProfileUserController::NOT_ALLOWED_POLICY_FORBIDS, |
+ }, |
+ { |
+ MultiProfileUserController::kBehaviorNotAllowed, |
+ MultiProfileUserController::kBehaviorUnrestricted, |
+ MultiProfileUserController::NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS, |
+ MultiProfileUserController::NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS, |
+ }, |
+ { |
+ MultiProfileUserController::kBehaviorNotAllowed, |
+ MultiProfileUserController::kBehaviorPrimaryOnly, |
+ MultiProfileUserController::NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS, |
+ MultiProfileUserController::NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS, |
+ }, |
+ { |
+ MultiProfileUserController::kBehaviorNotAllowed, |
+ MultiProfileUserController::kBehaviorNotAllowed, |
+ MultiProfileUserController::NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS, |
+ MultiProfileUserController::NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS, |
+ }, |
}; |
// Weak ptr to PolicyCertVerifier - object is freed in test destructor once |
@@ -216,6 +226,9 @@ TEST_F(MultiProfileUserControllerTest, AllAllowedBeforeLogin) { |
EXPECT_TRUE(controller()->IsUserAllowedInSession(kUsers[0], &reason)) |
<< "Case " << i; |
EXPECT_EQ(MultiProfileUserController::ALLOWED, reason) << "Case " << i; |
+ EXPECT_EQ(MultiProfileUserController::ALLOWED, |
+ MultiProfileUserController::GetPrimaryUserPolicy()) |
+ << "Case " << i; |
} |
} |
@@ -272,9 +285,13 @@ TEST_F(MultiProfileUserControllerTest, IsSecondaryAllowed) { |
for (size_t i = 0; i < arraysize(kBehaviorTestCases); ++i) { |
SetPrefBehavior(0, kBehaviorTestCases[i].primary); |
SetCachedBehavior(1, kBehaviorTestCases[i].secondary); |
+ EXPECT_EQ(kBehaviorTestCases[i].expected_primary_policy, |
+ MultiProfileUserController::GetPrimaryUserPolicy()) |
+ << "Case " << i; |
MultiProfileUserController::UserAllowedInSessionReason reason; |
controller()->IsUserAllowedInSession(kUsers[1], &reason); |
- EXPECT_EQ(kBehaviorTestCases[i].expected_allowed, reason) << "Case " << i; |
+ EXPECT_EQ(kBehaviorTestCases[i].expected_secondary_allowed, reason) |
+ << "Case " << i; |
} |
} |
@@ -291,11 +308,13 @@ TEST_F(MultiProfileUserControllerTest, PrimaryBehaviorChange) { |
SetPrefBehavior(0, kBehaviorTestCases[i].primary); |
SetPrefBehavior(1, kBehaviorTestCases[i].secondary); |
if (user_not_allowed_count() == 0) { |
- EXPECT_EQ(kBehaviorTestCases[i].expected_allowed, |
- MultiProfileUserController::ALLOWED) << "Case " << i; |
+ EXPECT_EQ(kBehaviorTestCases[i].expected_secondary_allowed, |
+ MultiProfileUserController::ALLOWED) |
+ << "Case " << i; |
} else { |
- EXPECT_NE(kBehaviorTestCases[i].expected_allowed, |
- MultiProfileUserController::ALLOWED) << "Case " << i; |
+ EXPECT_NE(kBehaviorTestCases[i].expected_secondary_allowed, |
+ MultiProfileUserController::ALLOWED) |
+ << "Case " << i; |
} |
} |
} |
@@ -324,6 +343,8 @@ TEST_F(MultiProfileUserControllerTest, |
EXPECT_EQ(MultiProfileUserController::ALLOWED, reason); |
EXPECT_TRUE(controller()->IsUserAllowedInSession(kUsers[1], &reason)); |
EXPECT_EQ(MultiProfileUserController::ALLOWED, reason); |
+ EXPECT_EQ(MultiProfileUserController::ALLOWED, |
+ MultiProfileUserController::GetPrimaryUserPolicy()); |
} |
TEST_F(MultiProfileUserControllerTest, |
@@ -363,10 +384,14 @@ TEST_F(MultiProfileUserControllerTest, |
EXPECT_FALSE(controller()->IsUserAllowedInSession(kUsers[1], &reason)); |
EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, |
reason); |
+ EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, |
+ MultiProfileUserController::GetPrimaryUserPolicy()); |
policy::PolicyCertServiceFactory::SetUsedPolicyCertificates(kUsers[1]); |
EXPECT_FALSE(controller()->IsUserAllowedInSession(kUsers[1], &reason)); |
EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_POLICY_CERT_TAINTED, |
reason); |
+ EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, |
+ MultiProfileUserController::GetPrimaryUserPolicy()); |
// Flush tasks posted to IO. |
base::RunLoop().RunUntilIdle(); |
@@ -395,6 +420,8 @@ TEST_F(MultiProfileUserControllerTest, |
MultiProfileUserController::UserAllowedInSessionReason reason; |
EXPECT_TRUE(controller()->IsUserAllowedInSession(kUsers[1], &reason)); |
EXPECT_EQ(MultiProfileUserController::ALLOWED, reason); |
+ EXPECT_EQ(MultiProfileUserController::ALLOWED, |
+ MultiProfileUserController::GetPrimaryUserPolicy()); |
net::CertificateList certificates; |
certificates.push_back(new net::X509Certificate( |
@@ -404,6 +431,8 @@ TEST_F(MultiProfileUserControllerTest, |
EXPECT_FALSE(controller()->IsUserAllowedInSession(kUsers[1], &reason)); |
EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, |
reason); |
+ EXPECT_EQ(MultiProfileUserController::NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, |
+ MultiProfileUserController::GetPrimaryUserPolicy()); |
// Flush tasks posted to IO. |
base::RunLoop().RunUntilIdle(); |