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/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 ACTION_P(CheckStatus, expected_status) { | 28 ACTION_P(CheckStatus, expected_status) { |
29 EXPECT_EQ(expected_status, arg0->status()); | 29 EXPECT_EQ(expected_status, arg0->status()); |
30 }; | 30 }; |
31 | 31 |
32 class CloudPolicyValidatorTest : public testing::Test { | 32 class CloudPolicyValidatorTest : public testing::Test { |
33 public: | 33 public: |
34 CloudPolicyValidatorTest() | 34 CloudPolicyValidatorTest() |
35 : loop_(MessageLoop::TYPE_UI), | 35 : loop_(base::MessageLoop::TYPE_UI), |
36 timestamp_(base::Time::UnixEpoch() + | 36 timestamp_(base::Time::UnixEpoch() + |
37 base::TimeDelta::FromMilliseconds( | 37 base::TimeDelta::FromMilliseconds( |
38 PolicyBuilder::kFakeTimestamp)), | 38 PolicyBuilder::kFakeTimestamp)), |
39 ignore_missing_timestamp_(CloudPolicyValidatorBase::TIMESTAMP_REQUIRED), | 39 ignore_missing_timestamp_(CloudPolicyValidatorBase::TIMESTAMP_REQUIRED), |
40 ignore_missing_dm_token_(CloudPolicyValidatorBase::DM_TOKEN_REQUIRED), | 40 ignore_missing_dm_token_(CloudPolicyValidatorBase::DM_TOKEN_REQUIRED), |
41 allow_key_rotation_(true), | 41 allow_key_rotation_(true), |
42 existing_dm_token_(PolicyBuilder::kFakeToken), | 42 existing_dm_token_(PolicyBuilder::kFakeToken), |
43 file_thread_(content::BrowserThread::FILE, &loop_) { | 43 file_thread_(content::BrowserThread::FILE, &loop_) { |
44 policy_.set_new_signing_key(PolicyBuilder::CreateTestNewSigningKey()); | 44 policy_.set_new_signing_key(PolicyBuilder::CreateTestNewSigningKey()); |
45 } | 45 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 void CheckSuccessfulValidation(UserCloudPolicyValidator* validator) { | 83 void CheckSuccessfulValidation(UserCloudPolicyValidator* validator) { |
84 EXPECT_TRUE(validator->success()); | 84 EXPECT_TRUE(validator->success()); |
85 EXPECT_EQ(policy_.policy().SerializeAsString(), | 85 EXPECT_EQ(policy_.policy().SerializeAsString(), |
86 validator->policy()->SerializeAsString()); | 86 validator->policy()->SerializeAsString()); |
87 EXPECT_EQ(policy_.policy_data().SerializeAsString(), | 87 EXPECT_EQ(policy_.policy_data().SerializeAsString(), |
88 validator->policy_data()->SerializeAsString()); | 88 validator->policy_data()->SerializeAsString()); |
89 EXPECT_EQ(policy_.payload().SerializeAsString(), | 89 EXPECT_EQ(policy_.payload().SerializeAsString(), |
90 validator->payload()->SerializeAsString()); | 90 validator->payload()->SerializeAsString()); |
91 } | 91 } |
92 | 92 |
93 MessageLoop loop_; | 93 base::MessageLoop loop_; |
94 base::Time timestamp_; | 94 base::Time timestamp_; |
95 CloudPolicyValidatorBase::ValidateTimestampOption ignore_missing_timestamp_; | 95 CloudPolicyValidatorBase::ValidateTimestampOption ignore_missing_timestamp_; |
96 CloudPolicyValidatorBase::ValidateDMTokenOption ignore_missing_dm_token_; | 96 CloudPolicyValidatorBase::ValidateDMTokenOption ignore_missing_dm_token_; |
97 std::string signing_key_; | 97 std::string signing_key_; |
98 bool allow_key_rotation_; | 98 bool allow_key_rotation_; |
99 std::string existing_dm_token_; | 99 std::string existing_dm_token_; |
100 | 100 |
101 UserPolicyBuilder policy_; | 101 UserPolicyBuilder policy_; |
102 | 102 |
103 private: | 103 private: |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 282 |
283 TEST_F(CloudPolicyValidatorTest, NoRotation) { | 283 TEST_F(CloudPolicyValidatorTest, NoRotation) { |
284 allow_key_rotation_ = false; | 284 allow_key_rotation_ = false; |
285 policy_.set_new_signing_key(scoped_ptr<crypto::RSAPrivateKey>()); | 285 policy_.set_new_signing_key(scoped_ptr<crypto::RSAPrivateKey>()); |
286 Validate(CheckStatus(CloudPolicyValidatorBase::VALIDATION_OK)); | 286 Validate(CheckStatus(CloudPolicyValidatorBase::VALIDATION_OK)); |
287 } | 287 } |
288 | 288 |
289 } // namespace | 289 } // namespace |
290 | 290 |
291 } // namespace policy | 291 } // namespace policy |
OLD | NEW |