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/message_loop.h" | |
10 #include "base/prefs/pref_registry_simple.h" | 11 #include "base/prefs/pref_registry_simple.h" |
11 #include "base/prefs/testing_pref_service.h" | 12 #include "base/prefs/testing_pref_service.h" |
12 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "chrome/browser/chromeos/cros/cros_library.h" | |
13 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | 15 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
14 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" | 16 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" |
15 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" | 17 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
16 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" | 18 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
17 #include "chrome/browser/chromeos/settings/cros_settings.h" | 19 #include "chrome/browser/chromeos/settings/cros_settings.h" |
20 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" | |
21 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h " | |
18 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" | 22 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" |
19 #include "chrome/browser/policy/cloud/cloud_policy_client.h" | 23 #include "chrome/browser/policy/cloud/cloud_policy_client.h" |
20 #include "chrome/browser/policy/cloud/mock_device_management_service.h" | 24 #include "chrome/browser/policy/cloud/mock_device_management_service.h" |
21 #include "chrome/browser/policy/cloud/proto/device_management_backend.pb.h" | 25 #include "chrome/browser/policy/cloud/proto/device_management_backend.pb.h" |
22 #include "chrome/browser/prefs/browser_prefs.h" | 26 #include "chrome/browser/prefs/browser_prefs.h" |
27 #include "chrome/test/base/testing_browser_process.h" | |
23 #include "chromeos/dbus/cryptohome_client.h" | 28 #include "chromeos/dbus/cryptohome_client.h" |
24 #include "chromeos/dbus/dbus_client_implementation_type.h" | 29 #include "chromeos/dbus/dbus_client_implementation_type.h" |
30 #include "net/url_request/test_url_fetcher_factory.h" | |
31 #include "net/url_request/url_request_test_util.h" | |
25 #include "policy/policy_constants.h" | 32 #include "policy/policy_constants.h" |
26 #include "testing/gmock/include/gmock/gmock.h" | 33 #include "testing/gmock/include/gmock/gmock.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 34 #include "testing/gtest/include/gtest/gtest.h" |
28 | 35 |
29 using testing::AnyNumber; | 36 using testing::AnyNumber; |
30 using testing::AtMost; | 37 using testing::AtMost; |
31 using testing::DoAll; | 38 using testing::DoAll; |
32 using testing::Mock; | 39 using testing::Mock; |
33 using testing::SaveArg; | 40 using testing::SaveArg; |
34 using testing::_; | 41 using testing::_; |
(...skipping 20 matching lines...) Expand all Loading... | |
55 install_attributes_(cryptohome_library_.get(), | 62 install_attributes_(cryptohome_library_.get(), |
56 stub_cryptohome_client_.get()), | 63 stub_cryptohome_client_.get()), |
57 store_(new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, | 64 store_(new DeviceCloudPolicyStoreChromeOS(&device_settings_service_, |
58 &install_attributes_)), | 65 &install_attributes_)), |
59 manager_(make_scoped_ptr(store_), &install_attributes_) {} | 66 manager_(make_scoped_ptr(store_), &install_attributes_) {} |
60 | 67 |
61 virtual void SetUp() OVERRIDE { | 68 virtual void SetUp() OVERRIDE { |
62 DeviceSettingsTestBase::SetUp(); | 69 DeviceSettingsTestBase::SetUp(); |
63 chrome::RegisterLocalState(local_state_.registry()); | 70 chrome::RegisterLocalState(local_state_.registry()); |
64 manager_.Init(); | 71 manager_.Init(); |
72 | |
73 // DeviceOAuth2TokenService uses the system request context to fetch | |
74 // OAuth tokens, then writes the token to local state, encrypting it | |
75 // first with methods in CrosLibrary. | |
76 request_context_getter_ = new net::TestURLRequestContextGetter( | |
77 loop_.message_loop_proxy()); | |
78 TestingBrowserProcess::GetGlobal()->SetSystemRequestContext( | |
79 request_context_getter_); | |
80 TestingBrowserProcess::GetGlobal()->SetLocalState(&local_state_); | |
81 chromeos::DeviceOAuth2TokenServiceFactory::Initialize(); | |
82 chromeos::CrosLibrary::Initialize(true); | |
83 url_fetcher_response_code_ = 200; | |
84 url_fetcher_response_string_ = "{\"access_token\":\"accessToken4Test\"," | |
85 "\"expires_in\":1234," | |
86 "\"refresh_token\":\"refreshToken4Test\"}"; | |
65 } | 87 } |
66 | 88 |
67 virtual void TearDown() OVERRIDE { | 89 virtual void TearDown() OVERRIDE { |
68 manager_.Shutdown(); | 90 manager_.Shutdown(); |
69 DeviceSettingsTestBase::TearDown(); | 91 DeviceSettingsTestBase::TearDown(); |
92 | |
93 chromeos::DeviceOAuth2TokenServiceFactory::Shutdown(); | |
94 chromeos::CrosLibrary::Shutdown(); | |
95 TestingBrowserProcess::GetGlobal()->SetLocalState(NULL); | |
70 } | 96 } |
71 | 97 |
72 scoped_ptr<chromeos::CryptohomeLibrary> cryptohome_library_; | 98 scoped_ptr<chromeos::CryptohomeLibrary> cryptohome_library_; |
73 scoped_ptr<chromeos::CryptohomeClient> stub_cryptohome_client_; | 99 scoped_ptr<chromeos::CryptohomeClient> stub_cryptohome_client_; |
74 EnterpriseInstallAttributes install_attributes_; | 100 EnterpriseInstallAttributes install_attributes_; |
75 | 101 |
102 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | |
103 net::TestURLFetcherFactory url_fetcher_factory_; | |
104 int url_fetcher_response_code_; | |
105 string url_fetcher_response_string_; | |
76 TestingPrefServiceSimple local_state_; | 106 TestingPrefServiceSimple local_state_; |
77 MockDeviceManagementService device_management_service_; | 107 MockDeviceManagementService device_management_service_; |
78 chromeos::ScopedTestCrosSettings test_cros_settings_; | 108 chromeos::ScopedTestCrosSettings test_cros_settings_; |
79 | 109 |
80 DeviceCloudPolicyStoreChromeOS* store_; | 110 DeviceCloudPolicyStoreChromeOS* store_; |
81 DeviceCloudPolicyManagerChromeOS manager_; | 111 DeviceCloudPolicyManagerChromeOS manager_; |
82 | 112 |
83 private: | 113 private: |
84 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyManagerChromeOSTest); | 114 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyManagerChromeOSTest); |
85 }; | 115 }; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 public: | 177 public: |
148 void Done(EnrollmentStatus status) { | 178 void Done(EnrollmentStatus status) { |
149 status_ = status; | 179 status_ = status; |
150 done_ = true; | 180 done_ = true; |
151 } | 181 } |
152 | 182 |
153 protected: | 183 protected: |
154 DeviceCloudPolicyManagerChromeOSEnrollmentTest() | 184 DeviceCloudPolicyManagerChromeOSEnrollmentTest() |
155 : is_auto_enrollment_(false), | 185 : is_auto_enrollment_(false), |
156 register_status_(DM_STATUS_SUCCESS), | 186 register_status_(DM_STATUS_SUCCESS), |
157 fetch_status_(DM_STATUS_SUCCESS), | 187 policy_fetch_status_(DM_STATUS_SUCCESS), |
188 robot_auth_fetch_status_(DM_STATUS_SUCCESS), | |
158 store_result_(true), | 189 store_result_(true), |
159 status_(EnrollmentStatus::ForStatus(EnrollmentStatus::STATUS_SUCCESS)), | 190 status_(EnrollmentStatus::ForStatus(EnrollmentStatus::STATUS_SUCCESS)), |
160 done_(false) {} | 191 done_(false) {} |
161 | 192 |
162 virtual void SetUp() OVERRIDE { | 193 virtual void SetUp() OVERRIDE { |
163 DeviceCloudPolicyManagerChromeOSTest::SetUp(); | 194 DeviceCloudPolicyManagerChromeOSTest::SetUp(); |
164 | 195 |
165 // Set up test data. | 196 // Set up test data. |
166 device_policy_.set_new_signing_key( | 197 device_policy_.set_new_signing_key( |
167 PolicyBuilder::CreateTestNewSigningKey()); | 198 PolicyBuilder::CreateTestNewSigningKey()); |
168 device_policy_.policy_data().set_timestamp( | 199 device_policy_.policy_data().set_timestamp( |
169 (base::Time::NowFromSystemTime() - | 200 (base::Time::NowFromSystemTime() - |
170 base::Time::UnixEpoch()).InMilliseconds()); | 201 base::Time::UnixEpoch()).InMilliseconds()); |
171 device_policy_.Build(); | 202 device_policy_.Build(); |
172 | 203 |
173 register_response_.mutable_register_response()->set_device_management_token( | 204 register_response_.mutable_register_response()->set_device_management_token( |
174 PolicyBuilder::kFakeToken); | 205 PolicyBuilder::kFakeToken); |
175 fetch_response_.mutable_policy_response()->add_response()->CopyFrom( | 206 policy_fetch_response_.mutable_policy_response()->add_response()->CopyFrom( |
176 device_policy_.policy()); | 207 device_policy_.policy()); |
208 robot_auth_fetch_response_.mutable_service_api_access_response() | |
209 ->set_auth_code("auth_code_for_test"); | |
177 loaded_blob_ = device_policy_.GetBlob(); | 210 loaded_blob_ = device_policy_.GetBlob(); |
178 | 211 |
179 // Initialize the manager. | 212 // Initialize the manager. |
180 FlushDeviceSettings(); | 213 FlushDeviceSettings(); |
181 EXPECT_EQ(CloudPolicyStore::STATUS_BAD_STATE, store_->status()); | 214 EXPECT_EQ(CloudPolicyStore::STATUS_BAD_STATE, store_->status()); |
182 EXPECT_TRUE(manager_.IsInitializationComplete(POLICY_DOMAIN_CHROME)); | 215 EXPECT_TRUE(manager_.IsInitializationComplete(POLICY_DOMAIN_CHROME)); |
183 | 216 |
184 PolicyBundle bundle; | 217 PolicyBundle bundle; |
185 EXPECT_TRUE(manager_.policies().Equals(bundle)); | 218 EXPECT_TRUE(manager_.policies().Equals(bundle)); |
186 | 219 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 "auth token", is_auto_enrollment_, modes, | 262 "auth token", is_auto_enrollment_, modes, |
230 base::Bind(&DeviceCloudPolicyManagerChromeOSEnrollmentTest::Done, | 263 base::Bind(&DeviceCloudPolicyManagerChromeOSEnrollmentTest::Done, |
231 base::Unretained(this))); | 264 base::Unretained(this))); |
232 Mock::VerifyAndClearExpectations(&device_management_service_); | 265 Mock::VerifyAndClearExpectations(&device_management_service_); |
233 | 266 |
234 if (done_) | 267 if (done_) |
235 return; | 268 return; |
236 | 269 |
237 // Process registration. | 270 // Process registration. |
238 ASSERT_TRUE(register_job); | 271 ASSERT_TRUE(register_job); |
239 MockDeviceManagementJob* fetch_job = NULL; | 272 MockDeviceManagementJob* policy_fetch_job = NULL; |
240 EXPECT_CALL(device_management_service_, | 273 EXPECT_CALL(device_management_service_, |
241 CreateJob(DeviceManagementRequestJob::TYPE_POLICY_FETCH)) | 274 CreateJob(DeviceManagementRequestJob::TYPE_POLICY_FETCH)) |
242 .Times(AtMost(1)) | 275 .Times(AtMost(1)) |
243 .WillOnce(device_management_service_.CreateAsyncJob(&fetch_job)); | 276 .WillOnce(device_management_service_.CreateAsyncJob(&policy_fetch_job)); |
244 EXPECT_CALL(device_management_service_, StartJob(_, _, _, _, _, _, _)) | 277 EXPECT_CALL(device_management_service_, StartJob(_, _, _, _, _, _, _)) |
245 .Times(AtMost(1)); | 278 .Times(AtMost(1)); |
246 register_job->SendResponse(register_status_, register_response_); | 279 register_job->SendResponse(register_status_, register_response_); |
247 Mock::VerifyAndClearExpectations(&device_management_service_); | 280 Mock::VerifyAndClearExpectations(&device_management_service_); |
248 | 281 |
249 if (done_) | 282 if (done_) |
250 return; | 283 return; |
251 | 284 |
252 // Process policy fetch. | 285 // Process policy fetch. |
253 ASSERT_TRUE(fetch_job); | 286 ASSERT_TRUE(policy_fetch_job); |
254 fetch_job->SendResponse(fetch_status_, fetch_response_); | 287 policy_fetch_job->SendResponse(policy_fetch_status_, |
288 policy_fetch_response_); | |
255 | 289 |
256 if (done_) | 290 if (done_) |
257 return; | 291 return; |
258 | 292 |
259 // Process verification. | 293 // Process verification. |
294 MockDeviceManagementJob* robot_auth_fetch_job = NULL; | |
295 EXPECT_CALL(device_management_service_, | |
296 CreateJob(DeviceManagementRequestJob::TYPE_API_AUTH_CODE_FETCH)) | |
297 .Times(AtMost(1)) | |
298 .WillOnce(device_management_service_.CreateAsyncJob( | |
299 &robot_auth_fetch_job)); | |
300 EXPECT_CALL(device_management_service_, StartJob(_, _, _, _, _, _, _)) | |
301 .Times(AtMost(1)); | |
260 base::RunLoop().RunUntilIdle(); | 302 base::RunLoop().RunUntilIdle(); |
303 Mock::VerifyAndClearExpectations(&device_management_service_); | |
261 | 304 |
262 if (done_) | 305 if (done_) |
263 return; | 306 return; |
264 | 307 |
308 // Process robot auth token fetch. | |
309 ASSERT_TRUE(robot_auth_fetch_job); | |
310 robot_auth_fetch_job->SendResponse(robot_auth_fetch_status_, | |
311 robot_auth_fetch_response_); | |
312 Mock::VerifyAndClearExpectations(&device_management_service_); | |
313 | |
314 if (done_) | |
315 return; | |
316 | |
317 // Process robot refresh token fetch if the auth code fetch succeeded. | |
318 // DeviceCloudPolicyManagerChromeOS holds an EnrollmentHandlerChromeOS which | |
319 // holds a GaiaOAuthClient that fetches the refresh token during enrollment. | |
320 // We return a successful OAuth response via a TestURLFetcher to trigger the | |
321 // happy path for these classes so that enrollment can continue. | |
322 if (robot_auth_fetch_status_ == DM_STATUS_SUCCESS) { | |
323 net::TestURLFetcher* url_fetcher = url_fetcher_factory_.GetFetcherByID(0); | |
324 ASSERT_TRUE(url_fetcher); | |
325 // The logic in GaiaOAuthClient seems broken, it always retries 1x on | |
326 // non-200 response codes, even if the retries are set to 0. Seems like | |
327 // its num_retries_ > source->GetMaxRetriesOn5xx() should have a >=? | |
Mattias Nissler (ping if slow)
2013/04/24 13:43:13
You shouldn't just dump this in a comment, but pas
David Roche
2013/04/24 15:34:21
I added this to my todo list to do in another CL.
Mattias Nissler (ping if slow)
2013/04/24 17:58:52
Can you just ask the author of that line whether i
| |
328 url_fetcher->SetMaxRetriesOn5xx(-2); | |
329 url_fetcher->set_status(net::URLRequestStatus()); | |
330 url_fetcher->set_response_code(url_fetcher_response_code_); | |
331 url_fetcher->SetResponseString(url_fetcher_response_string_); | |
332 url_fetcher->delegate()->OnURLFetchComplete(url_fetcher); | |
333 } | |
334 base::RunLoop().RunUntilIdle(); | |
335 | |
265 // Process policy store. | 336 // Process policy store. |
266 device_settings_test_helper_.set_store_result(store_result_); | 337 device_settings_test_helper_.set_store_result(store_result_); |
267 device_settings_test_helper_.FlushStore(); | 338 device_settings_test_helper_.FlushStore(); |
268 EXPECT_EQ(device_policy_.GetBlob(), | 339 EXPECT_EQ(device_policy_.GetBlob(), |
269 device_settings_test_helper_.policy_blob()); | 340 device_settings_test_helper_.policy_blob()); |
270 | 341 |
271 if (done_) | 342 if (done_) |
272 return; | 343 return; |
273 | 344 |
274 // Key installation and policy load. | 345 // Key installation, policy load and refresh token save. |
275 device_settings_test_helper_.set_policy_blob(loaded_blob_); | 346 device_settings_test_helper_.set_policy_blob(loaded_blob_); |
276 owner_key_util_->SetPublicKeyFromPrivateKey( | 347 owner_key_util_->SetPublicKeyFromPrivateKey( |
277 device_policy_.new_signing_key()); | 348 device_policy_.new_signing_key()); |
278 ReloadDeviceSettings(); | 349 ReloadDeviceSettings(); |
350 | |
351 if (done_) | |
352 return; | |
353 | |
354 // Process robot refresh token store. | |
355 EXPECT_EQ( | |
356 "refreshToken4Test", | |
357 chromeos::DeviceOAuth2TokenServiceFactory::Get()->GetRefreshToken()); | |
279 } | 358 } |
280 | 359 |
281 bool is_auto_enrollment_; | 360 bool is_auto_enrollment_; |
282 | 361 |
283 DeviceManagementStatus register_status_; | 362 DeviceManagementStatus register_status_; |
284 em::DeviceManagementResponse register_response_; | 363 em::DeviceManagementResponse register_response_; |
285 | 364 |
286 DeviceManagementStatus fetch_status_; | 365 DeviceManagementStatus policy_fetch_status_; |
287 em::DeviceManagementResponse fetch_response_; | 366 em::DeviceManagementResponse policy_fetch_response_; |
367 | |
368 DeviceManagementStatus robot_auth_fetch_status_; | |
369 em::DeviceManagementResponse robot_auth_fetch_response_; | |
288 | 370 |
289 bool store_result_; | 371 bool store_result_; |
290 std::string loaded_blob_; | 372 std::string loaded_blob_; |
291 | 373 |
292 em::DeviceManagementRequest register_request_; | 374 em::DeviceManagementRequest register_request_; |
293 std::string client_id_; | 375 std::string client_id_; |
294 EnrollmentStatus status_; | 376 EnrollmentStatus status_; |
295 | 377 |
296 bool done_; | 378 bool done_; |
297 | 379 |
(...skipping 29 matching lines...) Expand all Loading... | |
327 EXPECT_EQ(PolicyBuilder::kFakeDeviceId, client_id_); | 409 EXPECT_EQ(PolicyBuilder::kFakeDeviceId, client_id_); |
328 } | 410 } |
329 | 411 |
330 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, RegistrationFailed) { | 412 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, RegistrationFailed) { |
331 register_status_ = DM_STATUS_REQUEST_FAILED; | 413 register_status_ = DM_STATUS_REQUEST_FAILED; |
332 RunTest(); | 414 RunTest(); |
333 ExpectFailedEnrollment(EnrollmentStatus::STATUS_REGISTRATION_FAILED); | 415 ExpectFailedEnrollment(EnrollmentStatus::STATUS_REGISTRATION_FAILED); |
334 EXPECT_EQ(DM_STATUS_REQUEST_FAILED, status_.client_status()); | 416 EXPECT_EQ(DM_STATUS_REQUEST_FAILED, status_.client_status()); |
335 } | 417 } |
336 | 418 |
419 // Currently, robot auth tokens are optional. When DMServer support is in | |
420 // producion, thes next 4 tests will be changed. | |
Mattias Nissler (ping if slow)
2013/04/24 13:43:13
production
the
Mattias Nissler (ping if slow)
2013/04/24 13:43:13
Maybe avoid Google-isms like "production" and "DMS
David Roche
2013/04/24 15:34:21
Done.
| |
421 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, | |
422 RobotAuthCodeFetchFailed) { | |
423 robot_auth_fetch_status_ = DM_STATUS_REQUEST_FAILED; | |
424 RunTest(); | |
425 ExpectSuccessfulEnrollment(); | |
426 } | |
427 | |
428 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, | |
429 RobotRefreshTokenFetchResponseCodeFailed) { | |
430 url_fetcher_response_code_ = 400; | |
431 RunTest(); | |
432 ExpectSuccessfulEnrollment(); | |
433 } | |
434 | |
435 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, | |
436 RobotRefreshTokenFetchResponseStringFailed) { | |
437 url_fetcher_response_string_ = "invalid response json"; | |
438 RunTest(); | |
439 ExpectSuccessfulEnrollment(); | |
440 } | |
441 | |
442 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, RobotRefreshSaveFailed) { | |
443 // Without a DeviceOAuth2TokenService, the refresh token can't be saved. | |
444 chromeos::DeviceOAuth2TokenServiceFactory::Shutdown(); | |
445 RunTest(); | |
446 ExpectSuccessfulEnrollment(); | |
447 } | |
448 | |
337 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, PolicyFetchFailed) { | 449 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, PolicyFetchFailed) { |
338 fetch_status_ = DM_STATUS_REQUEST_FAILED; | 450 policy_fetch_status_ = DM_STATUS_REQUEST_FAILED; |
339 RunTest(); | 451 RunTest(); |
340 ExpectFailedEnrollment(EnrollmentStatus::STATUS_POLICY_FETCH_FAILED); | 452 ExpectFailedEnrollment(EnrollmentStatus::STATUS_POLICY_FETCH_FAILED); |
341 EXPECT_EQ(DM_STATUS_REQUEST_FAILED, status_.client_status()); | 453 EXPECT_EQ(DM_STATUS_REQUEST_FAILED, status_.client_status()); |
342 } | 454 } |
343 | 455 |
344 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, ValidationFailed) { | 456 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, ValidationFailed) { |
345 device_policy_.policy().set_policy_data_signature("bad"); | 457 device_policy_.policy().set_policy_data_signature("bad"); |
346 fetch_response_.clear_policy_response(); | 458 policy_fetch_response_.clear_policy_response(); |
347 fetch_response_.mutable_policy_response()->add_response()->CopyFrom( | 459 policy_fetch_response_.mutable_policy_response()->add_response()->CopyFrom( |
348 device_policy_.policy()); | 460 device_policy_.policy()); |
349 RunTest(); | 461 RunTest(); |
350 ExpectFailedEnrollment(EnrollmentStatus::STATUS_VALIDATION_FAILED); | 462 ExpectFailedEnrollment(EnrollmentStatus::STATUS_VALIDATION_FAILED); |
351 EXPECT_EQ(CloudPolicyValidatorBase::VALIDATION_BAD_INITIAL_SIGNATURE, | 463 EXPECT_EQ(CloudPolicyValidatorBase::VALIDATION_BAD_INITIAL_SIGNATURE, |
352 status_.validation_status()); | 464 status_.validation_status()); |
353 } | 465 } |
354 | 466 |
355 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, StoreError) { | 467 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, StoreError) { |
356 store_result_ = false; | 468 store_result_ = false; |
357 RunTest(); | 469 RunTest(); |
358 ExpectFailedEnrollment(EnrollmentStatus::STATUS_STORE_ERROR); | 470 ExpectFailedEnrollment(EnrollmentStatus::STATUS_STORE_ERROR); |
359 EXPECT_EQ(CloudPolicyStore::STATUS_STORE_ERROR, | 471 EXPECT_EQ(CloudPolicyStore::STATUS_STORE_ERROR, |
360 status_.store_status()); | 472 status_.store_status()); |
361 } | 473 } |
362 | 474 |
363 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, LoadError) { | 475 TEST_F(DeviceCloudPolicyManagerChromeOSEnrollmentTest, LoadError) { |
364 loaded_blob_.clear(); | 476 loaded_blob_.clear(); |
365 RunTest(); | 477 RunTest(); |
366 ExpectFailedEnrollment(EnrollmentStatus::STATUS_STORE_ERROR); | 478 ExpectFailedEnrollment(EnrollmentStatus::STATUS_STORE_ERROR); |
367 EXPECT_EQ(CloudPolicyStore::STATUS_LOAD_ERROR, | 479 EXPECT_EQ(CloudPolicyStore::STATUS_LOAD_ERROR, |
368 status_.store_status()); | 480 status_.store_status()); |
369 } | 481 } |
370 | 482 |
371 } // namespace | 483 } // namespace test |
372 } // namespace policy | 484 } // namespace policy |
OLD | NEW |