| 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_manager_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
| 11 #include "base/prefs/testing_pref_service.h" | 11 #include "base/prefs/testing_pref_service.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | |
| 14 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" | 13 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" |
| 15 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" | 14 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
| 16 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 15 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
| 17 #include "chrome/browser/chromeos/settings/cros_settings.h" | 16 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 18 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 17 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 19 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" | 18 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" |
| 20 #include "chrome/browser/policy/cloud/cloud_policy_client.h" | 19 #include "chrome/browser/policy/cloud/cloud_policy_client.h" |
| 21 #include "chrome/browser/policy/cloud/mock_device_management_service.h" | 20 #include "chrome/browser/policy/cloud/mock_device_management_service.h" |
| 22 #include "chrome/browser/policy/cloud/proto/device_management_backend.pb.h" | 21 #include "chrome/browser/policy/cloud/proto/device_management_backend.pb.h" |
| 23 #include "chrome/browser/prefs/browser_prefs.h" | 22 #include "chrome/browser/prefs/browser_prefs.h" |
| 23 #include "chromeos/cryptohome/cryptohome_library.h" |
| 24 #include "chromeos/dbus/cryptohome_client.h" | 24 #include "chromeos/dbus/cryptohome_client.h" |
| 25 #include "chromeos/dbus/dbus_client_implementation_type.h" | 25 #include "chromeos/dbus/dbus_client_implementation_type.h" |
| 26 #include "policy/policy_constants.h" | 26 #include "policy/policy_constants.h" |
| 27 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 29 | 29 |
| 30 using testing::AnyNumber; | 30 using testing::AnyNumber; |
| 31 using testing::AtMost; | 31 using testing::AtMost; |
| 32 using testing::DoAll; | 32 using testing::DoAll; |
| 33 using testing::Mock; | 33 using testing::Mock; |
| 34 using testing::SaveArg; | 34 using testing::SaveArg; |
| 35 using testing::_; | 35 using testing::_; |
| 36 | 36 |
| 37 namespace em = enterprise_management; | 37 namespace em = enterprise_management; |
| 38 | 38 |
| 39 namespace policy { | 39 namespace policy { |
| 40 namespace { | 40 namespace { |
| 41 | 41 |
| 42 void CopyLockResult(base::RunLoop* loop, | 42 void CopyLockResult(base::RunLoop* loop, |
| 43 EnterpriseInstallAttributes::LockResult* out, | 43 EnterpriseInstallAttributes::LockResult* out, |
| 44 EnterpriseInstallAttributes::LockResult result) { | 44 EnterpriseInstallAttributes::LockResult result) { |
| 45 *out = result; | 45 *out = result; |
| 46 loop->Quit(); | 46 loop->Quit(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 class DeviceCloudPolicyManagerChromeOSTest | 49 class DeviceCloudPolicyManagerChromeOSTest |
| 50 : public chromeos::DeviceSettingsTestBase { | 50 : public chromeos::DeviceSettingsTestBase { |
| 51 protected: | 51 protected: |
| 52 DeviceCloudPolicyManagerChromeOSTest() | 52 DeviceCloudPolicyManagerChromeOSTest() |
| 53 : cryptohome_library_(chromeos::CryptohomeLibrary::GetImpl(true)), | 53 : cryptohome_library_(chromeos::CryptohomeLibrary::GetTestImpl()), |
| 54 stub_cryptohome_client_(chromeos::CryptohomeClient::Create( | 54 stub_cryptohome_client_(chromeos::CryptohomeClient::Create( |
| 55 chromeos::STUB_DBUS_CLIENT_IMPLEMENTATION, NULL)), | 55 chromeos::STUB_DBUS_CLIENT_IMPLEMENTATION, NULL)), |
| 56 install_attributes_(cryptohome_library_.get(), | 56 install_attributes_(cryptohome_library_.get(), |
| 57 stub_cryptohome_client_.get()), | 57 stub_cryptohome_client_.get()), |
| 58 store_(new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, | 58 store_(new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, |
| 59 &install_attributes_)), | 59 &install_attributes_)), |
| 60 manager_(make_scoped_ptr(store_), &install_attributes_) {} | 60 manager_(make_scoped_ptr(store_), &install_attributes_) {} |
| 61 | 61 |
| 62 virtual void SetUp() OVERRIDE { | 62 virtual void SetUp() OVERRIDE { |
| 63 DeviceSettingsTestBase::SetUp(); | 63 DeviceSettingsTestBase::SetUp(); |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, LoadError) { | 365 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, LoadError) { |
| 366 loaded_blob_.clear(); | 366 loaded_blob_.clear(); |
| 367 RunTest(); | 367 RunTest(); |
| 368 ExpectFailedEnrollment(EnrollmentStatus::STATUS_STORE_ERROR); | 368 ExpectFailedEnrollment(EnrollmentStatus::STATUS_STORE_ERROR); |
| 369 EXPECT_EQ(CloudPolicyStore::STATUS_LOAD_ERROR, | 369 EXPECT_EQ(CloudPolicyStore::STATUS_LOAD_ERROR, |
| 370 status_.store_status()); | 370 status_.store_status()); |
| 371 } | 371 } |
| 372 | 372 |
| 373 } // namespace | 373 } // namespace |
| 374 } // namespace policy | 374 } // namespace policy |
| OLD | NEW |