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" |
8 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
11 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
13 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 14 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
14 #include "components/policy/core/common/cloud/cloud_policy_validator.h" | 15 #include "components/policy/core/common/cloud/cloud_policy_validator.h" |
15 #include "components/policy/core/common/cloud/policy_builder.h" | 16 #include "components/policy/core/common/cloud/policy_builder.h" |
| 17 #include "components/policy/core/common/policy_switches.h" |
16 #include "crypto/rsa_private_key.h" | 18 #include "crypto/rsa_private_key.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
19 | 21 |
20 namespace em = enterprise_management; | 22 namespace em = enterprise_management; |
21 | 23 |
22 using testing::Invoke; | 24 using testing::Invoke; |
23 using testing::Mock; | 25 using testing::Mock; |
24 | 26 |
25 namespace policy { | 27 namespace policy { |
(...skipping 10 matching lines...) Expand all Loading... |
36 : timestamp_(base::Time::UnixEpoch() + | 38 : timestamp_(base::Time::UnixEpoch() + |
37 base::TimeDelta::FromMilliseconds( | 39 base::TimeDelta::FromMilliseconds( |
38 PolicyBuilder::kFakeTimestamp)), | 40 PolicyBuilder::kFakeTimestamp)), |
39 timestamp_option_(CloudPolicyValidatorBase::TIMESTAMP_REQUIRED), | 41 timestamp_option_(CloudPolicyValidatorBase::TIMESTAMP_REQUIRED), |
40 ignore_missing_dm_token_(CloudPolicyValidatorBase::DM_TOKEN_REQUIRED), | 42 ignore_missing_dm_token_(CloudPolicyValidatorBase::DM_TOKEN_REQUIRED), |
41 allow_key_rotation_(true), | 43 allow_key_rotation_(true), |
42 existing_dm_token_(PolicyBuilder::kFakeToken) { | 44 existing_dm_token_(PolicyBuilder::kFakeToken) { |
43 policy_.SetDefaultNewSigningKey(); | 45 policy_.SetDefaultNewSigningKey(); |
44 } | 46 } |
45 | 47 |
| 48 virtual void SetUp() OVERRIDE { |
| 49 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 50 switches::kEnablePolicyKeyVerification); |
| 51 } |
| 52 |
46 void Validate(testing::Action<void(UserCloudPolicyValidator*)> check_action) { | 53 void Validate(testing::Action<void(UserCloudPolicyValidator*)> check_action) { |
47 // Create a validator. | 54 // Create a validator. |
48 scoped_ptr<UserCloudPolicyValidator> validator = CreateValidator(); | 55 scoped_ptr<UserCloudPolicyValidator> validator = CreateValidator(); |
49 | 56 |
50 // Run validation and check the result. | 57 // Run validation and check the result. |
51 EXPECT_CALL(*this, ValidationCompletion(validator.get())).WillOnce( | 58 EXPECT_CALL(*this, ValidationCompletion(validator.get())).WillOnce( |
52 check_action); | 59 check_action); |
53 validator.release()->StartValidation( | 60 validator.release()->StartValidation( |
54 base::Bind(&CloudPolicyValidatorTest::ValidationCompletion, | 61 base::Bind(&CloudPolicyValidatorTest::ValidationCompletion, |
55 base::Unretained(this))); | 62 base::Unretained(this))); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 | 315 |
309 TEST_F(CloudPolicyValidatorTest, NoRotation) { | 316 TEST_F(CloudPolicyValidatorTest, NoRotation) { |
310 allow_key_rotation_ = false; | 317 allow_key_rotation_ = false; |
311 policy_.UnsetNewSigningKey(); | 318 policy_.UnsetNewSigningKey(); |
312 Validate(CheckStatus(CloudPolicyValidatorBase::VALIDATION_OK)); | 319 Validate(CheckStatus(CloudPolicyValidatorBase::VALIDATION_OK)); |
313 } | 320 } |
314 | 321 |
315 } // namespace | 322 } // namespace |
316 | 323 |
317 } // namespace policy | 324 } // namespace policy |
OLD | NEW |