| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | |
| 9 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 11 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| 12 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 13 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 14 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 13 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| 15 #include "components/policy/core/common/cloud/cloud_policy_validator.h" | 14 #include "components/policy/core/common/cloud/cloud_policy_validator.h" |
| 16 #include "components/policy/core/common/cloud/policy_builder.h" | 15 #include "components/policy/core/common/cloud/policy_builder.h" |
| 17 #include "components/policy/core/common/policy_switches.h" | 16 #include "components/policy/core/common/policy_switches.h" |
| 18 #include "crypto/rsa_private_key.h" | 17 #include "crypto/rsa_private_key.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 41 PolicyBuilder::kFakeTimestamp)), | 40 PolicyBuilder::kFakeTimestamp)), |
| 42 timestamp_option_(CloudPolicyValidatorBase::TIMESTAMP_REQUIRED), | 41 timestamp_option_(CloudPolicyValidatorBase::TIMESTAMP_REQUIRED), |
| 43 ignore_missing_dm_token_(CloudPolicyValidatorBase::DM_TOKEN_REQUIRED), | 42 ignore_missing_dm_token_(CloudPolicyValidatorBase::DM_TOKEN_REQUIRED), |
| 44 allow_key_rotation_(true), | 43 allow_key_rotation_(true), |
| 45 existing_dm_token_(PolicyBuilder::kFakeToken), | 44 existing_dm_token_(PolicyBuilder::kFakeToken), |
| 46 owning_domain_(PolicyBuilder::kFakeDomain), | 45 owning_domain_(PolicyBuilder::kFakeDomain), |
| 47 cached_key_signature_(PolicyBuilder::GetTestSigningKeySignature()) { | 46 cached_key_signature_(PolicyBuilder::GetTestSigningKeySignature()) { |
| 48 policy_.SetDefaultNewSigningKey(); | 47 policy_.SetDefaultNewSigningKey(); |
| 49 } | 48 } |
| 50 | 49 |
| 51 virtual void SetUp() OVERRIDE { | |
| 52 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 53 switches::kEnablePolicyKeyVerification); | |
| 54 } | |
| 55 | |
| 56 void Validate(testing::Action<void(UserCloudPolicyValidator*)> check_action) { | 50 void Validate(testing::Action<void(UserCloudPolicyValidator*)> check_action) { |
| 57 policy_.Build(); | 51 policy_.Build(); |
| 58 ValidatePolicy(check_action, policy_.GetCopy()); | 52 ValidatePolicy(check_action, policy_.GetCopy()); |
| 59 } | 53 } |
| 60 | 54 |
| 61 void ValidatePolicy( | 55 void ValidatePolicy( |
| 62 testing::Action<void(UserCloudPolicyValidator*)> check_action, | 56 testing::Action<void(UserCloudPolicyValidator*)> check_action, |
| 63 scoped_ptr<enterprise_management::PolicyFetchResponse> policy_response) { | 57 scoped_ptr<enterprise_management::PolicyFetchResponse> policy_response) { |
| 64 // Create a validator. | 58 // Create a validator. |
| 65 scoped_ptr<UserCloudPolicyValidator> validator = CreateValidator( | 59 scoped_ptr<UserCloudPolicyValidator> validator = CreateValidator( |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 | 378 |
| 385 TEST_F(CloudPolicyValidatorTest, NoRotation) { | 379 TEST_F(CloudPolicyValidatorTest, NoRotation) { |
| 386 allow_key_rotation_ = false; | 380 allow_key_rotation_ = false; |
| 387 policy_.UnsetNewSigningKey(); | 381 policy_.UnsetNewSigningKey(); |
| 388 Validate(CheckStatus(CloudPolicyValidatorBase::VALIDATION_OK)); | 382 Validate(CheckStatus(CloudPolicyValidatorBase::VALIDATION_OK)); |
| 389 } | 383 } |
| 390 | 384 |
| 391 } // namespace | 385 } // namespace |
| 392 | 386 |
| 393 } // namespace policy | 387 } // namespace policy |
| OLD | NEW |