| 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 22 matching lines...) Expand all Loading... |
| 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 : cryptohome_library_(chromeos::CryptohomeLibrary::GetTestImpl()), |
| 39 stub_cryptohome_client_(chromeos::CryptohomeClient::Create( | 39 stub_cryptohome_client_(chromeos::CryptohomeClient::Create( |
| 40 chromeos::STUB_DBUS_CLIENT_IMPLEMENTATION, NULL)), | 40 chromeos::STUB_DBUS_CLIENT_IMPLEMENTATION, NULL)), |
| 41 install_attributes_(new EnterpriseInstallAttributes( | 41 install_attributes_(new EnterpriseInstallAttributes( |
| 42 cryptohome_library_.get(), stub_cryptohome_client_.get())), | 42 cryptohome_library_.get(), stub_cryptohome_client_.get())), |
| 43 store_(new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, | 43 store_(new DeviceCloudPolicyStoreChromeOS( |
| 44 install_attributes_.get())) {} | 44 chromeos::DeviceSettingsService::Get(), |
| 45 install_attributes_.get())) {} |
| 45 | 46 |
| 46 virtual void SetUp() OVERRIDE { | 47 virtual void SetUp() OVERRIDE { |
| 47 DeviceSettingsTestBase::SetUp(); | 48 DeviceSettingsTestBase::SetUp(); |
| 48 | 49 |
| 49 base::RunLoop loop; | 50 base::RunLoop loop; |
| 50 EnterpriseInstallAttributes::LockResult result; | 51 EnterpriseInstallAttributes::LockResult result; |
| 51 install_attributes_->LockDevice( | 52 install_attributes_->LockDevice( |
| 52 PolicyBuilder::kFakeUsername, | 53 PolicyBuilder::kFakeUsername, |
| 53 DEVICE_MODE_ENTERPRISE, | 54 DEVICE_MODE_ENTERPRISE, |
| 54 PolicyBuilder::kFakeDeviceId, | 55 PolicyBuilder::kFakeDeviceId, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 owner_key_util_->SetPublicKeyFromPrivateKey( | 94 owner_key_util_->SetPublicKeyFromPrivateKey( |
| 94 device_policy_.new_signing_key()); | 95 device_policy_.new_signing_key()); |
| 95 } | 96 } |
| 96 | 97 |
| 97 void ResetToNonEnterprise() { | 98 void ResetToNonEnterprise() { |
| 98 store_.reset(); | 99 store_.reset(); |
| 99 cryptohome_library_->InstallAttributesSet("enterprise.owned", | 100 cryptohome_library_->InstallAttributesSet("enterprise.owned", |
| 100 std::string()); | 101 std::string()); |
| 101 install_attributes_.reset(new EnterpriseInstallAttributes( | 102 install_attributes_.reset(new EnterpriseInstallAttributes( |
| 102 cryptohome_library_.get(), stub_cryptohome_client_.get())); | 103 cryptohome_library_.get(), stub_cryptohome_client_.get())); |
| 103 store_.reset(new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, | 104 store_.reset(new DeviceCloudPolicyStoreChromeOS( |
| 104 install_attributes_.get())); | 105 chromeos::DeviceSettingsService::Get(), install_attributes_.get())); |
| 105 } | 106 } |
| 106 | 107 |
| 107 scoped_ptr<chromeos::CryptohomeLibrary> cryptohome_library_; | 108 scoped_ptr<chromeos::CryptohomeLibrary> cryptohome_library_; |
| 108 scoped_ptr<chromeos::CryptohomeClient> stub_cryptohome_client_; | 109 scoped_ptr<chromeos::CryptohomeClient> stub_cryptohome_client_; |
| 109 scoped_ptr<EnterpriseInstallAttributes> install_attributes_; | 110 scoped_ptr<EnterpriseInstallAttributes> install_attributes_; |
| 110 | 111 |
| 111 scoped_ptr<DeviceCloudPolicyStoreChromeOS> store_; | 112 scoped_ptr<DeviceCloudPolicyStoreChromeOS> store_; |
| 112 | 113 |
| 113 private: | 114 private: |
| 114 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyStoreChromeOSTest); | 115 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyStoreChromeOSTest); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 210 |
| 210 TEST_F(DeviceCloudPolicyStoreChromeOSTest, InstallInitialPolicyNotEnterprise) { | 211 TEST_F(DeviceCloudPolicyStoreChromeOSTest, InstallInitialPolicyNotEnterprise) { |
| 211 PrepareNewSigningKey(); | 212 PrepareNewSigningKey(); |
| 212 ResetToNonEnterprise(); | 213 ResetToNonEnterprise(); |
| 213 store_->InstallInitialPolicy(device_policy_.policy()); | 214 store_->InstallInitialPolicy(device_policy_.policy()); |
| 214 FlushDeviceSettings(); | 215 FlushDeviceSettings(); |
| 215 ExpectFailure(CloudPolicyStore::STATUS_BAD_STATE); | 216 ExpectFailure(CloudPolicyStore::STATUS_BAD_STATE); |
| 216 } | 217 } |
| 217 | 218 |
| 218 } // namespace policy | 219 } // namespace policy |
| OLD | NEW |