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

Side by Side Diff: chrome/browser/policy/device_policy_cache_unittest.cc

Issue 8727037: Signed settings refactoring: Proper caching and more tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased to ToT and removed some debug output left. Created 9 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/policy/device_policy_cache.h" 5 #include "chrome/browser/policy/device_policy_cache.h"
6 6
7 #include "chrome/browser/chromeos/cros/cryptohome_library.h" 7 #include "chrome/browser/chromeos/cros/cryptohome_library.h"
8 #include "chrome/browser/chromeos/login/mock_signed_settings_helper.h" 8 #include "chrome/browser/chromeos/login/mock_signed_settings_helper.h"
9 #include "chrome/browser/policy/cloud_policy_data_store.h" 9 #include "chrome/browser/policy/cloud_policy_data_store.h"
10 #include "chrome/browser/policy/enterprise_install_attributes.h" 10 #include "chrome/browser/policy/enterprise_install_attributes.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 install_attributes_(cryptohome_.get()) {} 73 install_attributes_(cryptohome_.get()) {}
74 74
75 virtual void SetUp() { 75 virtual void SetUp() {
76 data_store_.reset(CloudPolicyDataStore::CreateForUserPolicies()); 76 data_store_.reset(CloudPolicyDataStore::CreateForUserPolicies());
77 cache_.reset(new DevicePolicyCache(data_store_.get(), 77 cache_.reset(new DevicePolicyCache(data_store_.get(),
78 &install_attributes_, 78 &install_attributes_,
79 &signed_settings_helper_)); 79 &signed_settings_helper_));
80 } 80 }
81 81
82 virtual void TearDown() { 82 virtual void TearDown() {
83 EXPECT_CALL(signed_settings_helper_, CancelCallback(_));
84 cache_.reset(); 83 cache_.reset();
85 } 84 }
86 85
87 void MakeEnterpriseDevice(const char* registration_user) { 86 void MakeEnterpriseDevice(const char* registration_user) {
88 ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS, 87 ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS,
89 install_attributes_.LockDevice(registration_user)); 88 install_attributes_.LockDevice(registration_user));
90 } 89 }
91 90
92 const Value* GetMandatoryPolicy(ConfigurationPolicyType policy) { 91 const Value* GetMandatoryPolicy(ConfigurationPolicyType policy) {
93 return cache_->mandatory_policy_.Get(policy); 92 return cache_->mandatory_policy_.Get(policy);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 kPolicyDevicePolicyRefreshRate))); 139 kPolicyDevicePolicyRefreshRate)));
141 140
142 // Set new policy information. 141 // Set new policy information.
143 em::PolicyFetchResponse new_policy; 142 em::PolicyFetchResponse new_policy;
144 CreateRefreshRatePolicy(&new_policy, kTestUser, 300); 143 CreateRefreshRatePolicy(&new_policy, kTestUser, 300);
145 EXPECT_CALL(signed_settings_helper_, StartStorePolicyOp(_, _)).WillOnce( 144 EXPECT_CALL(signed_settings_helper_, StartStorePolicyOp(_, _)).WillOnce(
146 MockSignedSettingsHelperStorePolicy(chromeos::SignedSettings::SUCCESS)); 145 MockSignedSettingsHelperStorePolicy(chromeos::SignedSettings::SUCCESS));
147 EXPECT_CALL(signed_settings_helper_, StartRetrievePolicyOp(_)).WillOnce( 146 EXPECT_CALL(signed_settings_helper_, StartRetrievePolicyOp(_)).WillOnce(
148 MockSignedSettingsHelperRetrievePolicy(SignedSettings::SUCCESS, 147 MockSignedSettingsHelperRetrievePolicy(SignedSettings::SUCCESS,
149 new_policy)); 148 new_policy));
150 EXPECT_CALL(signed_settings_helper_, CancelCallback(_));
151 cache_->SetPolicy(new_policy); 149 cache_->SetPolicy(new_policy);
152 testing::Mock::VerifyAndClearExpectations(&signed_settings_helper_); 150 testing::Mock::VerifyAndClearExpectations(&signed_settings_helper_);
153 base::FundamentalValue updated_expected(300); 151 base::FundamentalValue updated_expected(300);
154 EXPECT_TRUE(Value::Equals(&updated_expected, 152 EXPECT_TRUE(Value::Equals(&updated_expected,
155 GetMandatoryPolicy( 153 GetMandatoryPolicy(
156 kPolicyDevicePolicyRefreshRate))); 154 kPolicyDevicePolicyRefreshRate)));
157 } 155 }
158 156
159 TEST_F(DevicePolicyCacheTest, SetPolicyWrongUser) { 157 TEST_F(DevicePolicyCacheTest, SetPolicyWrongUser) {
160 InSequence s; 158 InSequence s;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 policy)); 247 policy));
250 cache_->Load(); 248 cache_->Load();
251 testing::Mock::VerifyAndClearExpectations(&signed_settings_helper_); 249 testing::Mock::VerifyAndClearExpectations(&signed_settings_helper_);
252 StringValue expected_config(fake_config); 250 StringValue expected_config(fake_config);
253 EXPECT_TRUE( 251 EXPECT_TRUE(
254 Value::Equals(&expected_config, 252 Value::Equals(&expected_config,
255 GetMandatoryPolicy(kPolicyDeviceOpenNetworkConfiguration))); 253 GetMandatoryPolicy(kPolicyDeviceOpenNetworkConfiguration)));
256 } 254 }
257 255
258 } // namespace policy 256 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698