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 "components/policy/core/common/cloud/cloud_policy_validator.h" | 5 #include "components/policy/core/common/cloud/cloud_policy_validator.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/run_loop.h" |
17 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
19 #include "base/threading/thread_task_runner_handle.h" | 20 #include "base/threading/thread_task_runner_handle.h" |
20 #include "build/build_config.h" | 21 #include "build/build_config.h" |
21 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 22 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
22 #include "components/policy/core/common/cloud/policy_builder.h" | 23 #include "components/policy/core/common/cloud/policy_builder.h" |
23 #include "components/policy/core/common/policy_switches.h" | 24 #include "components/policy/core/common/policy_switches.h" |
24 #include "crypto/rsa_private_key.h" | 25 #include "crypto/rsa_private_key.h" |
25 #include "policy/proto/device_management_backend.pb.h" | 26 #include "policy/proto/device_management_backend.pb.h" |
26 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // Create a validator. | 66 // Create a validator. |
66 std::unique_ptr<UserCloudPolicyValidator> validator = | 67 std::unique_ptr<UserCloudPolicyValidator> validator = |
67 CreateValidator(std::move(policy_response)); | 68 CreateValidator(std::move(policy_response)); |
68 | 69 |
69 // Run validation and check the result. | 70 // Run validation and check the result. |
70 EXPECT_CALL(*this, ValidationCompletion(validator.get())).WillOnce( | 71 EXPECT_CALL(*this, ValidationCompletion(validator.get())).WillOnce( |
71 check_action); | 72 check_action); |
72 validator.release()->StartValidation( | 73 validator.release()->StartValidation( |
73 base::Bind(&CloudPolicyValidatorTest::ValidationCompletion, | 74 base::Bind(&CloudPolicyValidatorTest::ValidationCompletion, |
74 base::Unretained(this))); | 75 base::Unretained(this))); |
75 loop_.RunUntilIdle(); | 76 base::RunLoop().RunUntilIdle(); |
76 Mock::VerifyAndClearExpectations(this); | 77 Mock::VerifyAndClearExpectations(this); |
77 } | 78 } |
78 | 79 |
79 std::unique_ptr<UserCloudPolicyValidator> CreateValidator( | 80 std::unique_ptr<UserCloudPolicyValidator> CreateValidator( |
80 std::unique_ptr<em::PolicyFetchResponse> policy_response) { | 81 std::unique_ptr<em::PolicyFetchResponse> policy_response) { |
81 std::vector<uint8_t> public_key_bytes; | 82 std::vector<uint8_t> public_key_bytes; |
82 EXPECT_TRUE( | 83 EXPECT_TRUE( |
83 PolicyBuilder::CreateTestSigningKey()->ExportPublicKey( | 84 PolicyBuilder::CreateTestSigningKey()->ExportPublicKey( |
84 &public_key_bytes)); | 85 &public_key_bytes)); |
85 | 86 |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 | 386 |
386 TEST_F(CloudPolicyValidatorTest, NoRotation) { | 387 TEST_F(CloudPolicyValidatorTest, NoRotation) { |
387 allow_key_rotation_ = false; | 388 allow_key_rotation_ = false; |
388 policy_.UnsetNewSigningKey(); | 389 policy_.UnsetNewSigningKey(); |
389 Validate(CheckStatus(CloudPolicyValidatorBase::VALIDATION_OK)); | 390 Validate(CheckStatus(CloudPolicyValidatorBase::VALIDATION_OK)); |
390 } | 391 } |
391 | 392 |
392 } // namespace | 393 } // namespace |
393 | 394 |
394 } // namespace policy | 395 } // namespace policy |
OLD | NEW |