OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/chromeos/policy/device_cloud_policy_store_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/message_loop/message_loop_proxy.h" | 12 #include "base/message_loop/message_loop_proxy.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" | 14 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
15 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 15 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
16 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" | 16 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" |
| 17 #include "chrome/test/base/scoped_testing_local_state.h" |
| 18 #include "chrome/test/base/testing_browser_process.h" |
17 #include "chromeos/cryptohome/cryptohome_util.h" | 19 #include "chromeos/cryptohome/cryptohome_util.h" |
18 #include "chromeos/dbus/fake_cryptohome_client.h" | 20 #include "chromeos/dbus/fake_cryptohome_client.h" |
19 #include "chromeos/dbus/fake_dbus_thread_manager.h" | 21 #include "chromeos/dbus/fake_dbus_thread_manager.h" |
20 #include "policy/policy_constants.h" | 22 #include "policy/policy_constants.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
22 | 24 |
23 namespace policy { | 25 namespace policy { |
24 | 26 |
25 namespace { | 27 namespace { |
26 | 28 |
27 void CopyLockResult(base::RunLoop* loop, | 29 void CopyLockResult(base::RunLoop* loop, |
28 EnterpriseInstallAttributes::LockResult* out, | 30 EnterpriseInstallAttributes::LockResult* out, |
29 EnterpriseInstallAttributes::LockResult result) { | 31 EnterpriseInstallAttributes::LockResult result) { |
30 *out = result; | 32 *out = result; |
31 loop->Quit(); | 33 loop->Quit(); |
32 } | 34 } |
33 | 35 |
34 } // namespace | 36 } // namespace |
35 | 37 |
36 class DeviceCloudPolicyStoreChromeOSTest | 38 class DeviceCloudPolicyStoreChromeOSTest |
37 : public chromeos::DeviceSettingsTestBase { | 39 : public chromeos::DeviceSettingsTestBase { |
38 protected: | 40 protected: |
39 DeviceCloudPolicyStoreChromeOSTest() | 41 DeviceCloudPolicyStoreChromeOSTest() |
40 : fake_cryptohome_client_(new chromeos::FakeCryptohomeClient()), | 42 : local_state_(TestingBrowserProcess::GetGlobal()), |
| 43 fake_cryptohome_client_(new chromeos::FakeCryptohomeClient()), |
41 install_attributes_( | 44 install_attributes_( |
42 new EnterpriseInstallAttributes(fake_cryptohome_client_)), | 45 new EnterpriseInstallAttributes(fake_cryptohome_client_)), |
43 store_(new DeviceCloudPolicyStoreChromeOS( | 46 store_(new DeviceCloudPolicyStoreChromeOS( |
44 &device_settings_service_, | 47 &device_settings_service_, |
45 install_attributes_.get(), | 48 install_attributes_.get(), |
46 base::MessageLoopProxy::current())) { | 49 base::MessageLoopProxy::current())) { |
47 fake_dbus_thread_manager_->SetCryptohomeClient( | 50 fake_dbus_thread_manager_->SetCryptohomeClient( |
48 scoped_ptr<chromeos::CryptohomeClient>(fake_cryptohome_client_)); | 51 scoped_ptr<chromeos::CryptohomeClient>(fake_cryptohome_client_)); |
49 } | 52 } |
50 | 53 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 chromeos::cryptohome_util::InstallAttributesSet("enterprise.owned", | 106 chromeos::cryptohome_util::InstallAttributesSet("enterprise.owned", |
104 std::string()); | 107 std::string()); |
105 install_attributes_.reset( | 108 install_attributes_.reset( |
106 new EnterpriseInstallAttributes(fake_cryptohome_client_)); | 109 new EnterpriseInstallAttributes(fake_cryptohome_client_)); |
107 store_.reset( | 110 store_.reset( |
108 new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, | 111 new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, |
109 install_attributes_.get(), | 112 install_attributes_.get(), |
110 base::MessageLoopProxy::current())); | 113 base::MessageLoopProxy::current())); |
111 } | 114 } |
112 | 115 |
| 116 ScopedTestingLocalState local_state_; |
113 chromeos::FakeCryptohomeClient* fake_cryptohome_client_; | 117 chromeos::FakeCryptohomeClient* fake_cryptohome_client_; |
114 scoped_ptr<EnterpriseInstallAttributes> install_attributes_; | 118 scoped_ptr<EnterpriseInstallAttributes> install_attributes_; |
115 | 119 |
116 scoped_ptr<DeviceCloudPolicyStoreChromeOS> store_; | 120 scoped_ptr<DeviceCloudPolicyStoreChromeOS> store_; |
117 | 121 |
118 private: | 122 private: |
119 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyStoreChromeOSTest); | 123 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyStoreChromeOSTest); |
120 }; | 124 }; |
121 | 125 |
122 TEST_F(DeviceCloudPolicyStoreChromeOSTest, LoadNoKey) { | 126 TEST_F(DeviceCloudPolicyStoreChromeOSTest, LoadNoKey) { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 269 |
266 TEST_F(DeviceCloudPolicyStoreChromeOSTest, InstallInitialPolicyNotEnterprise) { | 270 TEST_F(DeviceCloudPolicyStoreChromeOSTest, InstallInitialPolicyNotEnterprise) { |
267 PrepareNewSigningKey(); | 271 PrepareNewSigningKey(); |
268 ResetToNonEnterprise(); | 272 ResetToNonEnterprise(); |
269 store_->InstallInitialPolicy(device_policy_.policy()); | 273 store_->InstallInitialPolicy(device_policy_.policy()); |
270 FlushDeviceSettings(); | 274 FlushDeviceSettings(); |
271 ExpectFailure(CloudPolicyStore::STATUS_BAD_STATE); | 275 ExpectFailure(CloudPolicyStore::STATUS_BAD_STATE); |
272 } | 276 } |
273 | 277 |
274 } // namespace policy | 278 } // namespace policy |
OLD | NEW |