Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1301)

Unified Diff: chrome/browser/policy/device_policy_cache_unittest.cc

Issue 10443125: Allow re-enrollment to the same domain in case of policy data loss. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/device_policy_cache_unittest.cc
diff --git a/chrome/browser/policy/device_policy_cache_unittest.cc b/chrome/browser/policy/device_policy_cache_unittest.cc
index 42105ca8fc742d2e0031e2972d4a770b0c40a763..9e37548b7bcd222cadd1158c7ca873a21b68662a 100644
--- a/chrome/browser/policy/device_policy_cache_unittest.cc
+++ b/chrome/browser/policy/device_policy_cache_unittest.cc
@@ -192,7 +192,7 @@ TEST_F(DevicePolicyCacheTest, SetPolicy) {
cache_->RemoveObserver(&observer_);
}
-TEST_F(DevicePolicyCacheTest, SetPolicyWrongUser) {
+TEST_F(DevicePolicyCacheTest, SetPolicyOtherUserSameDomain) {
InSequence s;
MakeEnterpriseDevice(kTestUser);
@@ -207,9 +207,33 @@ TEST_F(DevicePolicyCacheTest, SetPolicyWrongUser) {
cache_->Load();
Mock::VerifyAndClearExpectations(&signed_settings_helper_);
- // Set new policy information. This should fail due to invalid user.
+ // Set new policy information. This should succeed as the domain is the same.
+ em::PolicyFetchResponse new_policy;
+ CreateRefreshRatePolicy(&new_policy, "another_user@example.com", 300);
+ EXPECT_CALL(signed_settings_helper_, StartStorePolicyOp(_, _)).Times(1);
+ EXPECT_TRUE(cache_->SetPolicy(new_policy));
+ Mock::VerifyAndClearExpectations(&signed_settings_helper_);
+}
+
+TEST_F(DevicePolicyCacheTest, SetPolicyOtherUserOtherDomain) {
+ InSequence s;
+
+ MakeEnterpriseDevice(kTestUser);
+
+ // Startup.
+ em::PolicyFetchResponse policy;
+ CreateRefreshRatePolicy(&policy, kTestUser, 120);
+ EXPECT_CALL(signed_settings_helper_, StartRetrievePolicyOp(_)).WillOnce(
+ MockSignedSettingsHelperRetrievePolicy(SignedSettings::SUCCESS,
+ policy));
+ EXPECT_CALL(observer_, OnCacheUpdate(cache_.get()));
+ cache_->Load();
+ Mock::VerifyAndClearExpectations(&signed_settings_helper_);
+
+ // Set new policy information. This should fail because the user is from
+ // different domain.
em::PolicyFetchResponse new_policy;
- CreateRefreshRatePolicy(&new_policy, "foreign_user@example.com", 300);
+ CreateRefreshRatePolicy(&new_policy, "foreign_user@hackers.com", 300);
EXPECT_CALL(signed_settings_helper_, StartStorePolicyOp(_, _)).Times(0);
EXPECT_FALSE(cache_->SetPolicy(new_policy));
Mock::VerifyAndClearExpectations(&signed_settings_helper_);
« no previous file with comments | « chrome/browser/policy/device_policy_cache.cc ('k') | chrome/browser/policy/enterprise_install_attributes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698