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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/message_loop/message_loop_proxy.h" | |
14 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 14 #include "base/thread_task_runner_handle.h" |
15 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" | 15 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
16 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 16 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
17 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" | 17 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" |
18 #include "chrome/test/base/scoped_testing_local_state.h" | 18 #include "chrome/test/base/scoped_testing_local_state.h" |
19 #include "chrome/test/base/testing_browser_process.h" | 19 #include "chrome/test/base/testing_browser_process.h" |
20 #include "chromeos/cryptohome/cryptohome_util.h" | 20 #include "chromeos/cryptohome/cryptohome_util.h" |
21 #include "chromeos/dbus/dbus_thread_manager.h" | 21 #include "chromeos/dbus/dbus_thread_manager.h" |
22 #include "chromeos/dbus/fake_cryptohome_client.h" | 22 #include "chromeos/dbus/fake_cryptohome_client.h" |
23 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 23 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
24 #include "content/public/test/test_utils.h" | 24 #include "content/public/test/test_utils.h" |
(...skipping 20 matching lines...) Expand all Loading... |
45 : public chromeos::DeviceSettingsTestBase { | 45 : public chromeos::DeviceSettingsTestBase { |
46 protected: | 46 protected: |
47 DeviceCloudPolicyStoreChromeOSTest() | 47 DeviceCloudPolicyStoreChromeOSTest() |
48 : local_state_(TestingBrowserProcess::GetGlobal()), | 48 : local_state_(TestingBrowserProcess::GetGlobal()), |
49 fake_cryptohome_client_(new chromeos::FakeCryptohomeClient()), | 49 fake_cryptohome_client_(new chromeos::FakeCryptohomeClient()), |
50 install_attributes_( | 50 install_attributes_( |
51 new EnterpriseInstallAttributes(fake_cryptohome_client_)), | 51 new EnterpriseInstallAttributes(fake_cryptohome_client_)), |
52 store_(new DeviceCloudPolicyStoreChromeOS( | 52 store_(new DeviceCloudPolicyStoreChromeOS( |
53 &device_settings_service_, | 53 &device_settings_service_, |
54 install_attributes_.get(), | 54 install_attributes_.get(), |
55 base::MessageLoopProxy::current())) { | 55 base::ThreadTaskRunnerHandle::Get())) {} |
56 } | |
57 | 56 |
58 void SetUp() override { | 57 void SetUp() override { |
59 DeviceSettingsTestBase::SetUp(); | 58 DeviceSettingsTestBase::SetUp(); |
60 | 59 |
61 dbus_setter_->SetCryptohomeClient( | 60 dbus_setter_->SetCryptohomeClient( |
62 scoped_ptr<chromeos::CryptohomeClient>(fake_cryptohome_client_)); | 61 scoped_ptr<chromeos::CryptohomeClient>(fake_cryptohome_client_)); |
63 | 62 |
64 base::RunLoop loop; | 63 base::RunLoop loop; |
65 EnterpriseInstallAttributes::LockResult result; | 64 EnterpriseInstallAttributes::LockResult result; |
66 install_attributes_->LockDevice( | 65 install_attributes_->LockDevice( |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 owner_key_util_->SetPublicKeyFromPrivateKey( | 127 owner_key_util_->SetPublicKeyFromPrivateKey( |
129 *device_policy_.GetNewSigningKey()); | 128 *device_policy_.GetNewSigningKey()); |
130 } | 129 } |
131 | 130 |
132 void ResetToNonEnterprise() { | 131 void ResetToNonEnterprise() { |
133 store_.reset(); | 132 store_.reset(); |
134 chromeos::cryptohome_util::InstallAttributesSet("enterprise.owned", | 133 chromeos::cryptohome_util::InstallAttributesSet("enterprise.owned", |
135 std::string()); | 134 std::string()); |
136 install_attributes_.reset( | 135 install_attributes_.reset( |
137 new EnterpriseInstallAttributes(fake_cryptohome_client_)); | 136 new EnterpriseInstallAttributes(fake_cryptohome_client_)); |
138 store_.reset( | 137 store_.reset(new DeviceCloudPolicyStoreChromeOS( |
139 new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, | 138 &device_settings_service_, install_attributes_.get(), |
140 install_attributes_.get(), | 139 base::ThreadTaskRunnerHandle::Get())); |
141 base::MessageLoopProxy::current())); | |
142 } | 140 } |
143 | 141 |
144 ScopedTestingLocalState local_state_; | 142 ScopedTestingLocalState local_state_; |
145 chromeos::FakeCryptohomeClient* fake_cryptohome_client_; | 143 chromeos::FakeCryptohomeClient* fake_cryptohome_client_; |
146 scoped_ptr<EnterpriseInstallAttributes> install_attributes_; | 144 scoped_ptr<EnterpriseInstallAttributes> install_attributes_; |
147 | 145 |
148 scoped_ptr<DeviceCloudPolicyStoreChromeOS> store_; | 146 scoped_ptr<DeviceCloudPolicyStoreChromeOS> store_; |
149 | 147 |
150 private: | 148 private: |
151 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyStoreChromeOSTest); | 149 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyStoreChromeOSTest); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 | 306 |
309 TEST_F(DeviceCloudPolicyStoreChromeOSTest, InstallInitialPolicyNotEnterprise) { | 307 TEST_F(DeviceCloudPolicyStoreChromeOSTest, InstallInitialPolicyNotEnterprise) { |
310 PrepareNewSigningKey(); | 308 PrepareNewSigningKey(); |
311 ResetToNonEnterprise(); | 309 ResetToNonEnterprise(); |
312 store_->InstallInitialPolicy(device_policy_.policy()); | 310 store_->InstallInitialPolicy(device_policy_.policy()); |
313 FlushDeviceSettings(); | 311 FlushDeviceSettings(); |
314 ExpectFailure(CloudPolicyStore::STATUS_BAD_STATE); | 312 ExpectFailure(CloudPolicyStore::STATUS_BAD_STATE); |
315 } | 313 } |
316 | 314 |
317 } // namespace policy | 315 } // namespace policy |
OLD | NEW |