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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h
" | 24 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h
" |
25 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 25 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
26 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" | 26 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" |
27 #include "chrome/browser/prefs/browser_prefs.h" | 27 #include "chrome/browser/prefs/browser_prefs.h" |
28 #include "chrome/test/base/testing_browser_process.h" | 28 #include "chrome/test/base/testing_browser_process.h" |
29 #include "chromeos/cryptohome/system_salt_getter.h" | 29 #include "chromeos/cryptohome/system_salt_getter.h" |
30 #include "chromeos/dbus/dbus_client_implementation_type.h" | 30 #include "chromeos/dbus/dbus_client_implementation_type.h" |
31 #include "chromeos/dbus/dbus_thread_manager.h" | 31 #include "chromeos/dbus/dbus_thread_manager.h" |
32 #include "chromeos/dbus/fake_cryptohome_client.h" | 32 #include "chromeos/dbus/fake_cryptohome_client.h" |
33 #include "chromeos/dbus/fake_session_manager_client.h" | 33 #include "chromeos/dbus/fake_session_manager_client.h" |
34 #include "chromeos/system/mock_statistics_provider.h" | 34 #include "chromeos/system/fake_statistics_provider.h" |
35 #include "chromeos/system/statistics_provider.h" | 35 #include "chromeos/system/statistics_provider.h" |
36 #include "components/policy/core/common/cloud/cloud_policy_client.h" | 36 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
37 #include "components/policy/core/common/cloud/mock_device_management_service.h" | 37 #include "components/policy/core/common/cloud/mock_device_management_service.h" |
38 #include "components/policy/core/common/external_data_fetcher.h" | 38 #include "components/policy/core/common/external_data_fetcher.h" |
39 #include "components/policy/core/common/schema_registry.h" | 39 #include "components/policy/core/common/schema_registry.h" |
40 #include "google_apis/gaia/gaia_oauth_client.h" | 40 #include "google_apis/gaia/gaia_oauth_client.h" |
41 #include "net/url_request/test_url_fetcher_factory.h" | 41 #include "net/url_request/test_url_fetcher_factory.h" |
42 #include "net/url_request/url_request_test_util.h" | 42 #include "net/url_request/url_request_test_util.h" |
43 #include "policy/policy_constants.h" | 43 #include "policy/policy_constants.h" |
44 #include "policy/proto/device_management_backend.pb.h" | 44 #include "policy/proto/device_management_backend.pb.h" |
(...skipping 22 matching lines...) Expand all Loading... |
67 } | 67 } |
68 | 68 |
69 class DeviceCloudPolicyManagerChromeOSTest | 69 class DeviceCloudPolicyManagerChromeOSTest |
70 : public chromeos::DeviceSettingsTestBase { | 70 : public chromeos::DeviceSettingsTestBase { |
71 protected: | 71 protected: |
72 DeviceCloudPolicyManagerChromeOSTest() | 72 DeviceCloudPolicyManagerChromeOSTest() |
73 : fake_cryptohome_client_(new chromeos::FakeCryptohomeClient()), | 73 : fake_cryptohome_client_(new chromeos::FakeCryptohomeClient()), |
74 state_keys_broker_(&fake_session_manager_client_, | 74 state_keys_broker_(&fake_session_manager_client_, |
75 base::MessageLoopProxy::current()), | 75 base::MessageLoopProxy::current()), |
76 store_(NULL) { | 76 store_(NULL) { |
77 EXPECT_CALL(mock_statistics_provider_, | 77 fake_statistics_provider_.SetMachineStatistic("serial_numer", "test_sn"); |
78 GetMachineStatistic(_, _)) | |
79 .WillRepeatedly(Return(false)); | |
80 EXPECT_CALL(mock_statistics_provider_, | |
81 GetMachineStatistic("serial_number", _)) | |
82 .WillRepeatedly(DoAll(SetArgumentPointee<1>(std::string("test_sn")), | |
83 Return(true))); | |
84 chromeos::system::StatisticsProvider::SetTestProvider( | |
85 &mock_statistics_provider_); | |
86 std::vector<std::string> state_keys; | 78 std::vector<std::string> state_keys; |
87 state_keys.push_back("1"); | 79 state_keys.push_back("1"); |
88 state_keys.push_back("2"); | 80 state_keys.push_back("2"); |
89 state_keys.push_back("3"); | 81 state_keys.push_back("3"); |
90 fake_session_manager_client_.set_server_backed_state_keys(state_keys); | 82 fake_session_manager_client_.set_server_backed_state_keys(state_keys); |
91 } | 83 } |
92 | 84 |
93 virtual ~DeviceCloudPolicyManagerChromeOSTest() { | 85 virtual ~DeviceCloudPolicyManagerChromeOSTest() { |
94 chromeos::system::StatisticsProvider::SetTestProvider(NULL); | 86 chromeos::system::StatisticsProvider::SetTestProvider(NULL); |
95 } | 87 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 176 |
185 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 177 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
186 net::TestURLFetcherFactory url_fetcher_factory_; | 178 net::TestURLFetcherFactory url_fetcher_factory_; |
187 int url_fetcher_response_code_; | 179 int url_fetcher_response_code_; |
188 string url_fetcher_response_string_; | 180 string url_fetcher_response_string_; |
189 TestingPrefServiceSimple local_state_; | 181 TestingPrefServiceSimple local_state_; |
190 MockDeviceManagementService device_management_service_; | 182 MockDeviceManagementService device_management_service_; |
191 MockDeviceManagementService consumer_device_management_service_; | 183 MockDeviceManagementService consumer_device_management_service_; |
192 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 184 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
193 chromeos::ScopedTestCrosSettings test_cros_settings_; | 185 chromeos::ScopedTestCrosSettings test_cros_settings_; |
194 chromeos::system::MockStatisticsProvider mock_statistics_provider_; | 186 chromeos::system::ScopedFakeStatisticsProvider fake_statistics_provider_; |
195 chromeos::FakeSessionManagerClient fake_session_manager_client_; | 187 chromeos::FakeSessionManagerClient fake_session_manager_client_; |
196 chromeos::FakeCryptohomeClient* fake_cryptohome_client_; | 188 chromeos::FakeCryptohomeClient* fake_cryptohome_client_; |
197 ServerBackedStateKeysBroker state_keys_broker_; | 189 ServerBackedStateKeysBroker state_keys_broker_; |
198 | 190 |
199 DeviceCloudPolicyStoreChromeOS* store_; | 191 DeviceCloudPolicyStoreChromeOS* store_; |
200 SchemaRegistry schema_registry_; | 192 SchemaRegistry schema_registry_; |
201 scoped_ptr<DeviceCloudPolicyManagerChromeOS> manager_; | 193 scoped_ptr<DeviceCloudPolicyManagerChromeOS> manager_; |
202 scoped_ptr<DeviceCloudPolicyInitializer> initializer_; | 194 scoped_ptr<DeviceCloudPolicyInitializer> initializer_; |
203 | 195 |
204 private: | 196 private: |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 | 612 |
621 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentBlankSystemSaltTest, | 613 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentBlankSystemSaltTest, |
622 RobotRefreshSaveFailed) { | 614 RobotRefreshSaveFailed) { |
623 // Without the system salt, the robot token can't be stored. | 615 // Without the system salt, the robot token can't be stored. |
624 RunTest(); | 616 RunTest(); |
625 ExpectFailedEnrollment(EnrollmentStatus::STATUS_ROBOT_REFRESH_STORE_FAILED); | 617 ExpectFailedEnrollment(EnrollmentStatus::STATUS_ROBOT_REFRESH_STORE_FAILED); |
626 } | 618 } |
627 | 619 |
628 } // namespace | 620 } // namespace |
629 } // namespace policy | 621 } // namespace policy |
OLD | NEW |