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/user_cloud_policy_store_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <vector> | 10 #include <vector> |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 ASSERT_NO_FATAL_FAILURE( | 244 ASSERT_NO_FATAL_FAILURE( |
245 PerformStorePolicy(&new_public_key, NULL, kDefaultHomepage)); | 245 PerformStorePolicy(&new_public_key, NULL, kDefaultHomepage)); |
246 } | 246 } |
247 | 247 |
248 TEST_F(UserCloudPolicyStoreChromeOSTest, InitialStoreValidationFail) { | 248 TEST_F(UserCloudPolicyStoreChromeOSTest, InitialStoreValidationFail) { |
249 // Start without any public key to trigger the initial key checks. | 249 // Start without any public key to trigger the initial key checks. |
250 ASSERT_TRUE(base::DeleteFile(user_policy_key_file(), false)); | 250 ASSERT_TRUE(base::DeleteFile(user_policy_key_file(), false)); |
251 // Make the policy blob contain a new public key. | 251 // Make the policy blob contain a new public key. |
252 policy_.SetDefaultSigningKey(); | 252 policy_.SetDefaultSigningKey(); |
253 policy_.Build(); | 253 policy_.Build(); |
254 *policy_.policy().mutable_new_public_key_verification_signature() = "garbage"; | 254 *policy_.policy().mutable_new_public_key_verification_signature_deprecated() = |
| 255 "garbage"; |
255 | 256 |
256 EXPECT_CALL(session_manager_client_, | 257 EXPECT_CALL(session_manager_client_, |
257 StorePolicyForUser(cryptohome_id_, policy_.GetBlob(), _)) | 258 StorePolicyForUser(cryptohome_id_, policy_.GetBlob(), _)) |
258 .Times(0); | 259 .Times(0); |
259 store_->Store(policy_.policy()); | 260 store_->Store(policy_.policy()); |
260 base::RunLoop().RunUntilIdle(); | 261 base::RunLoop().RunUntilIdle(); |
261 Mock::VerifyAndClearExpectations(&session_manager_client_); | 262 Mock::VerifyAndClearExpectations(&session_manager_client_); |
262 } | 263 } |
263 | 264 |
264 TEST_F(UserCloudPolicyStoreChromeOSTest, InitialStoreMissingSignatureFailure) { | 265 TEST_F(UserCloudPolicyStoreChromeOSTest, InitialStoreMissingSignatureFailure) { |
265 // Start without any public key to trigger the initial key checks. | 266 // Start without any public key to trigger the initial key checks. |
266 ASSERT_TRUE(base::DeleteFile(user_policy_key_file(), false)); | 267 ASSERT_TRUE(base::DeleteFile(user_policy_key_file(), false)); |
267 // Make the policy blob contain a new public key. | 268 // Make the policy blob contain a new public key. |
268 policy_.SetDefaultSigningKey(); | 269 policy_.SetDefaultSigningKey(); |
269 policy_.Build(); | 270 policy_.Build(); |
270 policy_.policy().clear_new_public_key_verification_signature(); | 271 policy_.policy().clear_new_public_key_verification_signature_deprecated(); |
271 | 272 |
272 EXPECT_CALL(session_manager_client_, | 273 EXPECT_CALL(session_manager_client_, |
273 StorePolicyForUser(cryptohome_id_, policy_.GetBlob(), _)) | 274 StorePolicyForUser(cryptohome_id_, policy_.GetBlob(), _)) |
274 .Times(0); | 275 .Times(0); |
275 store_->Store(policy_.policy()); | 276 store_->Store(policy_.policy()); |
276 base::RunLoop().RunUntilIdle(); | 277 base::RunLoop().RunUntilIdle(); |
277 Mock::VerifyAndClearExpectations(&session_manager_client_); | 278 Mock::VerifyAndClearExpectations(&session_manager_client_); |
278 } | 279 } |
279 | 280 |
280 TEST_F(UserCloudPolicyStoreChromeOSTest, StoreWithExistingKey) { | 281 TEST_F(UserCloudPolicyStoreChromeOSTest, StoreWithExistingKey) { |
281 ASSERT_NO_FATAL_FAILURE( | 282 ASSERT_NO_FATAL_FAILURE( |
282 PerformStorePolicy(NULL, NULL, kDefaultHomepage)); | 283 PerformStorePolicy(NULL, NULL, kDefaultHomepage)); |
283 } | 284 } |
284 | 285 |
285 TEST_F(UserCloudPolicyStoreChromeOSTest, StoreWithRotation) { | 286 TEST_F(UserCloudPolicyStoreChromeOSTest, StoreWithRotation) { |
286 // Make the policy blob contain a new public key. | 287 // Make the policy blob contain a new public key. |
287 policy_.SetDefaultNewSigningKey(); | 288 policy_.SetDefaultNewSigningKey(); |
288 policy_.Build(); | 289 policy_.Build(); |
289 std::vector<uint8_t> new_public_key; | 290 std::vector<uint8_t> new_public_key; |
290 ASSERT_TRUE(policy_.GetNewSigningKey()->ExportPublicKey(&new_public_key)); | 291 ASSERT_TRUE(policy_.GetNewSigningKey()->ExportPublicKey(&new_public_key)); |
291 ASSERT_NO_FATAL_FAILURE( | 292 ASSERT_NO_FATAL_FAILURE( |
292 PerformStorePolicy(&new_public_key, NULL, kDefaultHomepage)); | 293 PerformStorePolicy(&new_public_key, NULL, kDefaultHomepage)); |
293 } | 294 } |
294 | 295 |
295 TEST_F(UserCloudPolicyStoreChromeOSTest, | 296 TEST_F(UserCloudPolicyStoreChromeOSTest, |
296 StoreWithRotationMissingSignatureError) { | 297 StoreWithRotationMissingSignatureError) { |
297 // Make the policy blob contain a new public key. | 298 // Make the policy blob contain a new public key. |
298 policy_.SetDefaultNewSigningKey(); | 299 policy_.SetDefaultNewSigningKey(); |
299 policy_.Build(); | 300 policy_.Build(); |
300 policy_.policy().clear_new_public_key_verification_signature(); | 301 policy_.policy().clear_new_public_key_verification_signature_deprecated(); |
301 | 302 |
302 EXPECT_CALL(session_manager_client_, | 303 EXPECT_CALL(session_manager_client_, |
303 StorePolicyForUser(cryptohome_id_, policy_.GetBlob(), _)) | 304 StorePolicyForUser(cryptohome_id_, policy_.GetBlob(), _)) |
304 .Times(0); | 305 .Times(0); |
305 store_->Store(policy_.policy()); | 306 store_->Store(policy_.policy()); |
306 base::RunLoop().RunUntilIdle(); | 307 base::RunLoop().RunUntilIdle(); |
307 Mock::VerifyAndClearExpectations(&session_manager_client_); | 308 Mock::VerifyAndClearExpectations(&session_manager_client_); |
308 } | 309 } |
309 | 310 |
310 TEST_F(UserCloudPolicyStoreChromeOSTest, StoreWithRotationValidationError) { | 311 TEST_F(UserCloudPolicyStoreChromeOSTest, StoreWithRotationValidationError) { |
311 // Make the policy blob contain a new public key. | 312 // Make the policy blob contain a new public key. |
312 policy_.SetDefaultNewSigningKey(); | 313 policy_.SetDefaultNewSigningKey(); |
313 policy_.Build(); | 314 policy_.Build(); |
314 *policy_.policy().mutable_new_public_key_verification_signature() = "garbage"; | 315 *policy_.policy().mutable_new_public_key_verification_signature_deprecated() = |
| 316 "garbage"; |
315 | 317 |
316 EXPECT_CALL(session_manager_client_, | 318 EXPECT_CALL(session_manager_client_, |
317 StorePolicyForUser(cryptohome_id_, policy_.GetBlob(), _)) | 319 StorePolicyForUser(cryptohome_id_, policy_.GetBlob(), _)) |
318 .Times(0); | 320 .Times(0); |
319 store_->Store(policy_.policy()); | 321 store_->Store(policy_.policy()); |
320 base::RunLoop().RunUntilIdle(); | 322 base::RunLoop().RunUntilIdle(); |
321 Mock::VerifyAndClearExpectations(&session_manager_client_); | 323 Mock::VerifyAndClearExpectations(&session_manager_client_); |
322 } | 324 } |
323 | 325 |
324 TEST_F(UserCloudPolicyStoreChromeOSTest, StoreFail) { | 326 TEST_F(UserCloudPolicyStoreChromeOSTest, StoreFail) { |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 Mock::VerifyAndClearExpectations(&cryptohome_client_); | 664 Mock::VerifyAndClearExpectations(&cryptohome_client_); |
663 | 665 |
664 EXPECT_FALSE(store_->policy()); | 666 EXPECT_FALSE(store_->policy()); |
665 EXPECT_TRUE(store_->policy_map().empty()); | 667 EXPECT_TRUE(store_->policy_map().empty()); |
666 EXPECT_EQ(CloudPolicyStore::STATUS_VALIDATION_ERROR, store_->status()); | 668 EXPECT_EQ(CloudPolicyStore::STATUS_VALIDATION_ERROR, store_->status()); |
667 } | 669 } |
668 | 670 |
669 } // namespace | 671 } // namespace |
670 | 672 |
671 } // namespace policy | 673 } // namespace policy |
OLD | NEW |