| OLD | NEW |
| 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/policy/device_policy_identity_strategy.h" | 8 #include "chrome/browser/policy/cloud_policy_data_store.h" |
| 9 #include "chrome/browser/policy/enterprise_install_attributes.h" | 9 #include "chrome/browser/policy/enterprise_install_attributes.h" |
| 10 #include "policy/configuration_policy_type.h" | 10 #include "policy/configuration_policy_type.h" |
| 11 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace policy { | 14 namespace policy { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 // Test registration user name. | 18 // Test registration user name. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 } // namespace | 103 } // namespace |
| 104 | 104 |
| 105 class DevicePolicyCacheTest : public testing::Test { | 105 class DevicePolicyCacheTest : public testing::Test { |
| 106 protected: | 106 protected: |
| 107 DevicePolicyCacheTest() | 107 DevicePolicyCacheTest() |
| 108 : cryptohome_(chromeos::CryptohomeLibrary::GetImpl(true)), | 108 : cryptohome_(chromeos::CryptohomeLibrary::GetImpl(true)), |
| 109 install_attributes_(cryptohome_.get()) {} | 109 install_attributes_(cryptohome_.get()) {} |
| 110 | 110 |
| 111 virtual void SetUp() { | 111 virtual void SetUp() { |
| 112 cache_.reset(new DevicePolicyCache(&identity_strategy_, | 112 data_store_.reset(CloudPolicyDataStore::CreateForUserPolicies()); |
| 113 cache_.reset(new DevicePolicyCache(data_store_.get(), |
| 113 &install_attributes_, | 114 &install_attributes_, |
| 114 &signed_settings_helper_)); | 115 &signed_settings_helper_)); |
| 115 } | 116 } |
| 116 | 117 |
| 117 virtual void TearDown() { | 118 virtual void TearDown() { |
| 118 EXPECT_CALL(signed_settings_helper_, CancelCallback(_)); | 119 EXPECT_CALL(signed_settings_helper_, CancelCallback(_)); |
| 119 cache_.reset(); | 120 cache_.reset(); |
| 120 } | 121 } |
| 121 | 122 |
| 122 void MakeEnterpriseDevice(const char* registration_user) { | 123 void MakeEnterpriseDevice(const char* registration_user) { |
| 123 ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS, | 124 ASSERT_EQ(EnterpriseInstallAttributes::LOCK_SUCCESS, |
| 124 install_attributes_.LockDevice(registration_user)); | 125 install_attributes_.LockDevice(registration_user)); |
| 125 } | 126 } |
| 126 | 127 |
| 127 const Value* GetMandatoryPolicy(ConfigurationPolicyType policy) { | 128 const Value* GetMandatoryPolicy(ConfigurationPolicyType policy) { |
| 128 return cache_->mandatory_policy_.Get(policy); | 129 return cache_->mandatory_policy_.Get(policy); |
| 129 } | 130 } |
| 130 | 131 |
| 131 const Value* GetRecommendedPolicy(ConfigurationPolicyType policy) { | 132 const Value* GetRecommendedPolicy(ConfigurationPolicyType policy) { |
| 132 return cache_->recommended_policy_.Get(policy); | 133 return cache_->recommended_policy_.Get(policy); |
| 133 } | 134 } |
| 134 | 135 |
| 135 scoped_ptr<chromeos::CryptohomeLibrary> cryptohome_; | 136 scoped_ptr<chromeos::CryptohomeLibrary> cryptohome_; |
| 136 EnterpriseInstallAttributes install_attributes_; | 137 EnterpriseInstallAttributes install_attributes_; |
| 137 DevicePolicyIdentityStrategy identity_strategy_; | 138 scoped_ptr<CloudPolicyDataStore> data_store_; |
| 138 MockSignedSettingsHelper signed_settings_helper_; | 139 MockSignedSettingsHelper signed_settings_helper_; |
| 139 scoped_ptr<DevicePolicyCache> cache_; | 140 scoped_ptr<DevicePolicyCache> cache_; |
| 140 | 141 |
| 141 private: | 142 private: |
| 142 DISALLOW_COPY_AND_ASSIGN(DevicePolicyCacheTest); | 143 DISALLOW_COPY_AND_ASSIGN(DevicePolicyCacheTest); |
| 143 }; | 144 }; |
| 144 | 145 |
| 145 TEST_F(DevicePolicyCacheTest, Startup) { | 146 TEST_F(DevicePolicyCacheTest, Startup) { |
| 146 em::PolicyFetchResponse policy; | 147 em::PolicyFetchResponse policy; |
| 147 CreateRefreshRatePolicy(&policy, kTestUser, 120); | 148 CreateRefreshRatePolicy(&policy, kTestUser, 120); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 GetRecommendedPolicy(kPolicyProxyMode))); | 265 GetRecommendedPolicy(kPolicyProxyMode))); |
| 265 EXPECT_TRUE(Value::Equals(&expected_proxy_server, | 266 EXPECT_TRUE(Value::Equals(&expected_proxy_server, |
| 266 GetRecommendedPolicy(kPolicyProxyServer))); | 267 GetRecommendedPolicy(kPolicyProxyServer))); |
| 267 EXPECT_TRUE(Value::Equals(&expected_proxy_pac_url, | 268 EXPECT_TRUE(Value::Equals(&expected_proxy_pac_url, |
| 268 GetRecommendedPolicy(kPolicyProxyPacUrl))); | 269 GetRecommendedPolicy(kPolicyProxyPacUrl))); |
| 269 EXPECT_TRUE(Value::Equals(&expected_proxy_bypass_list, | 270 EXPECT_TRUE(Value::Equals(&expected_proxy_bypass_list, |
| 270 GetRecommendedPolicy(kPolicyProxyBypassList))); | 271 GetRecommendedPolicy(kPolicyProxyBypassList))); |
| 271 } | 272 } |
| 272 | 273 |
| 273 } // namespace policy | 274 } // namespace policy |
| OLD | NEW |