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" |
(...skipping 17 matching lines...) Expand all Loading... |
28 *out = result; | 28 *out = result; |
29 loop->Quit(); | 29 loop->Quit(); |
30 } | 30 } |
31 | 31 |
32 } // namespace | 32 } // namespace |
33 | 33 |
34 class DeviceCloudPolicyStoreChromeOSTest | 34 class DeviceCloudPolicyStoreChromeOSTest |
35 : public chromeos::DeviceSettingsTestBase { | 35 : public chromeos::DeviceSettingsTestBase { |
36 protected: | 36 protected: |
37 DeviceCloudPolicyStoreChromeOSTest() | 37 DeviceCloudPolicyStoreChromeOSTest() |
38 : cryptohome_library_(chromeos::CryptohomeLibrary::GetTestImpl()), | 38 : fake_cryptohome_client_(new chromeos::FakeCryptohomeClient()), |
39 fake_cryptohome_client_(new chromeos::FakeCryptohomeClient()), | |
40 install_attributes_(new EnterpriseInstallAttributes( | 39 install_attributes_(new EnterpriseInstallAttributes( |
41 cryptohome_library_.get(), fake_cryptohome_client_.get())), | 40 fake_cryptohome_client_.get())), |
42 store_(new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, | 41 store_(new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, |
43 install_attributes_.get())) { | 42 install_attributes_.get())) { |
44 fake_cryptohome_client_->Init(NULL /* no dbus::Bus */); | 43 fake_cryptohome_client_->Init(NULL /* no dbus::Bus */); |
45 } | 44 } |
46 | 45 |
47 virtual void SetUp() OVERRIDE { | 46 virtual void SetUp() OVERRIDE { |
48 DeviceSettingsTestBase::SetUp(); | 47 DeviceSettingsTestBase::SetUp(); |
49 | 48 |
50 base::RunLoop loop; | 49 base::RunLoop loop; |
51 EnterpriseInstallAttributes::LockResult result; | 50 EnterpriseInstallAttributes::LockResult result; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 88 |
90 void PrepareNewSigningKey() { | 89 void PrepareNewSigningKey() { |
91 device_policy_.SetDefaultNewSigningKey(); | 90 device_policy_.SetDefaultNewSigningKey(); |
92 device_policy_.Build(); | 91 device_policy_.Build(); |
93 owner_key_util_->SetPublicKeyFromPrivateKey( | 92 owner_key_util_->SetPublicKeyFromPrivateKey( |
94 *device_policy_.GetNewSigningKey()); | 93 *device_policy_.GetNewSigningKey()); |
95 } | 94 } |
96 | 95 |
97 void ResetToNonEnterprise() { | 96 void ResetToNonEnterprise() { |
98 store_.reset(); | 97 store_.reset(); |
99 cryptohome_library_->InstallAttributesSet("enterprise.owned", | 98 chromeos::cryptohome_util::InstallAttributesSet("enterprise.owned", |
100 std::string()); | 99 std::string()); |
101 install_attributes_.reset(new EnterpriseInstallAttributes( | 100 install_attributes_.reset(new EnterpriseInstallAttributes( |
102 cryptohome_library_.get(), fake_cryptohome_client_.get())); | 101 fake_cryptohome_client_.get())); |
103 store_.reset(new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, | 102 store_.reset(new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, |
104 install_attributes_.get())); | 103 install_attributes_.get())); |
105 } | 104 } |
106 | 105 |
107 scoped_ptr<chromeos::CryptohomeLibrary> cryptohome_library_; | |
108 scoped_ptr<chromeos::FakeCryptohomeClient> fake_cryptohome_client_; | 106 scoped_ptr<chromeos::FakeCryptohomeClient> fake_cryptohome_client_; |
109 scoped_ptr<EnterpriseInstallAttributes> install_attributes_; | 107 scoped_ptr<EnterpriseInstallAttributes> install_attributes_; |
110 | 108 |
111 scoped_ptr<DeviceCloudPolicyStoreChromeOS> store_; | 109 scoped_ptr<DeviceCloudPolicyStoreChromeOS> store_; |
112 | 110 |
113 private: | 111 private: |
114 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyStoreChromeOSTest); | 112 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyStoreChromeOSTest); |
115 }; | 113 }; |
116 | 114 |
117 TEST_F(DeviceCloudPolicyStoreChromeOSTest, LoadNoKey) { | 115 TEST_F(DeviceCloudPolicyStoreChromeOSTest, LoadNoKey) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 208 |
211 TEST_F(DeviceCloudPolicyStoreChromeOSTest, InstallInitialPolicyNotEnterprise) { | 209 TEST_F(DeviceCloudPolicyStoreChromeOSTest, InstallInitialPolicyNotEnterprise) { |
212 PrepareNewSigningKey(); | 210 PrepareNewSigningKey(); |
213 ResetToNonEnterprise(); | 211 ResetToNonEnterprise(); |
214 store_->InstallInitialPolicy(device_policy_.policy()); | 212 store_->InstallInitialPolicy(device_policy_.policy()); |
215 FlushDeviceSettings(); | 213 FlushDeviceSettings(); |
216 ExpectFailure(CloudPolicyStore::STATUS_BAD_STATE); | 214 ExpectFailure(CloudPolicyStore::STATUS_BAD_STATE); |
217 } | 215 } |
218 | 216 |
219 } // namespace policy | 217 } // namespace policy |
OLD | NEW |