| 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 <vector> | 8 #include <vector> |
| 8 | 9 |
| 9 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop/message_loop_proxy.h" | 13 #include "base/message_loop/message_loop_proxy.h" |
| 13 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 14 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" | 15 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
| 15 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 16 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| 16 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" | 17 #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/scoped_testing_local_state.h" |
| 18 #include "chrome/test/base/testing_browser_process.h" | 19 #include "chrome/test/base/testing_browser_process.h" |
| 19 #include "chromeos/cryptohome/cryptohome_util.h" | 20 #include "chromeos/cryptohome/cryptohome_util.h" |
| 20 #include "chromeos/dbus/dbus_thread_manager.h" | 21 #include "chromeos/dbus/dbus_thread_manager.h" |
| 21 #include "chromeos/dbus/fake_cryptohome_client.h" | 22 #include "chromeos/dbus/fake_cryptohome_client.h" |
| 23 #include "content/public/test/test_utils.h" |
| 22 #include "policy/policy_constants.h" | 24 #include "policy/policy_constants.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 24 | 26 |
| 25 namespace policy { | 27 namespace policy { |
| 26 | 28 |
| 27 namespace { | 29 namespace { |
| 28 | 30 |
| 29 void CopyLockResult(base::RunLoop* loop, | 31 void CopyLockResult(base::RunLoop* loop, |
| 30 EnterpriseInstallAttributes::LockResult* out, | 32 EnterpriseInstallAttributes::LockResult* out, |
| 31 EnterpriseInstallAttributes::LockResult result) { | 33 EnterpriseInstallAttributes::LockResult result) { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 EXPECT_EQ(CloudPolicyStore::STATUS_VALIDATION_ERROR, store_->status()); | 178 EXPECT_EQ(CloudPolicyStore::STATUS_VALIDATION_ERROR, store_->status()); |
| 177 EXPECT_EQ(CloudPolicyValidatorBase::VALIDATION_BAD_SIGNATURE, | 179 EXPECT_EQ(CloudPolicyValidatorBase::VALIDATION_BAD_SIGNATURE, |
| 178 store_->validation_status()); | 180 store_->validation_status()); |
| 179 } | 181 } |
| 180 | 182 |
| 181 TEST_F(DeviceCloudPolicyStoreChromeOSTest, StoreKeyRotation) { | 183 TEST_F(DeviceCloudPolicyStoreChromeOSTest, StoreKeyRotation) { |
| 182 PrepareExistingPolicy(); | 184 PrepareExistingPolicy(); |
| 183 device_policy_.SetDefaultNewSigningKey(); | 185 device_policy_.SetDefaultNewSigningKey(); |
| 184 device_policy_.Build(); | 186 device_policy_.Build(); |
| 185 store_->Store(device_policy_.policy()); | 187 store_->Store(device_policy_.policy()); |
| 186 device_settings_test_helper_.FlushLoops(); | 188 content::RunAllBlockingPoolTasksUntilIdle(); |
| 187 device_settings_test_helper_.FlushStore(); | 189 device_settings_test_helper_.FlushStore(); |
| 188 owner_key_util_->SetPublicKeyFromPrivateKey( | 190 owner_key_util_->SetPublicKeyFromPrivateKey( |
| 189 *device_policy_.GetNewSigningKey()); | 191 *device_policy_.GetNewSigningKey()); |
| 190 ReloadDeviceSettings(); | 192 ReloadDeviceSettings(); |
| 191 ExpectSuccess(); | 193 ExpectSuccess(); |
| 192 } | 194 } |
| 193 | 195 |
| 194 TEST_F(DeviceCloudPolicyStoreChromeOSTest, | 196 TEST_F(DeviceCloudPolicyStoreChromeOSTest, |
| 195 StoreKeyRotationVerificationFailure) { | 197 StoreKeyRotationVerificationFailure) { |
| 196 PrepareExistingPolicy(); | 198 PrepareExistingPolicy(); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 | 272 |
| 271 TEST_F(DeviceCloudPolicyStoreChromeOSTest, InstallInitialPolicyNotEnterprise) { | 273 TEST_F(DeviceCloudPolicyStoreChromeOSTest, InstallInitialPolicyNotEnterprise) { |
| 272 PrepareNewSigningKey(); | 274 PrepareNewSigningKey(); |
| 273 ResetToNonEnterprise(); | 275 ResetToNonEnterprise(); |
| 274 store_->InstallInitialPolicy(device_policy_.policy()); | 276 store_->InstallInitialPolicy(device_policy_.policy()); |
| 275 FlushDeviceSettings(); | 277 FlushDeviceSettings(); |
| 276 ExpectFailure(CloudPolicyStore::STATUS_BAD_STATE); | 278 ExpectFailure(CloudPolicyStore::STATUS_BAD_STATE); |
| 277 } | 279 } |
| 278 | 280 |
| 279 } // namespace policy | 281 } // namespace policy |
| OLD | NEW |