| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_POLICY_DEVICE_POLICY_CACHE_TEST_BASE_H_ |
| 6 #define CHROME_BROWSER_POLICY_DEVICE_POLICY_CACHE_TEST_BASE_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "chrome/browser/policy/device_policy_cache.h" |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
| 14 #include "chrome/browser/chromeos/login/mock_signed_settings_helper.h" |
| 15 #include "chrome/browser/policy/cloud_policy_data_store.h" |
| 16 #include "chrome/browser/policy/enterprise_install_attributes.h" |
| 17 |
| 18 namespace policy { |
| 19 |
| 20 // A class that sets up a DevicePolicyCache for tests, and provides helper |
| 21 // methods to inject policies. |
| 22 class DevicePolicyCacheTestHelper { |
| 23 public: |
| 24 // Test registration user name. |
| 25 static const char kTestUser[]; |
| 26 |
| 27 DevicePolicyCacheTestHelper(); |
| 28 ~DevicePolicyCacheTestHelper(); |
| 29 |
| 30 DevicePolicyCache* cache() { return cache_; } |
| 31 |
| 32 // Marks the device as an enterprise device. Returns true on success. |
| 33 bool MakeEnterpriseDevice(); |
| 34 |
| 35 // Clears all device policies currently set in the protobuf. Use LoadPolicy() |
| 36 // to make the cache read them. |
| 37 void ResetPolicy(); |
| 38 |
| 39 // Sets the refresh rate policy in the protobuf. |
| 40 void SetRefreshRatePolicy(int refresh_rate); |
| 41 |
| 42 // Sets the proxy policy in the protobuf. |
| 43 void SetProxyPolicy(const std::string& proxy_mode, |
| 44 const std::string& proxy_server, |
| 45 const std::string& proxy_pac_url, |
| 46 const std::string& proxy_bypass_list); |
| 47 |
| 48 // Directly overrides all the device policies in the protobuf. |
| 49 void SetSettings( |
| 50 const enterprise_management::ChromeDeviceSettingsProto& proto); |
| 51 |
| 52 // Sets the username that should be used in the next LoadPolicy() or |
| 53 // SetPolicy() call. This is reset to |kTestUser| on ResetPolicy(), which is |
| 54 // the default. Does not take ownership of |username|. |
| 55 void SetUsername(const char* username) { username_ = username; } |
| 56 |
| 57 // Makes the cache load the current protobuf from the mocked signed settings. |
| 58 // Returns true on success. |
| 59 bool LoadPolicy(); |
| 60 |
| 61 // Sets the current protobuf directly into the cache. Returns true on success. |
| 62 // |expect_store| indicates whether it is expected that the store will be |
| 63 // performed or not. |
| 64 bool SetPolicy(bool expect_store); |
| 65 |
| 66 private: |
| 67 // Helper for LoadPolicy() and SetPolicy(). |
| 68 bool SerializePolicy(); |
| 69 |
| 70 scoped_ptr<chromeos::CryptohomeLibrary> cryptohome_; |
| 71 EnterpriseInstallAttributes install_attributes_; |
| 72 scoped_ptr<CloudPolicyDataStore> data_store_; |
| 73 chromeos::MockSignedSettingsHelper signed_settings_helper_; |
| 74 scoped_ptr<DevicePolicyCache> scoped_cache_; |
| 75 DevicePolicyCache* cache_; |
| 76 |
| 77 enterprise_management::PolicyFetchResponse policy_; |
| 78 enterprise_management::ChromeDeviceSettingsProto settings_; |
| 79 |
| 80 const char* username_; |
| 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(DevicePolicyCacheTestHelper); |
| 83 }; |
| 84 |
| 85 } // namespace policy |
| 86 |
| 87 #endif // CHROME_BROWSER_POLICY_DEVICE_POLICY_CACHE_TEST_BASE_H_ |
| OLD | NEW |