OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 #ifndef COMPONENTS_POLICY_CORE_COMMON_CLOUD_MOCK_SIGNING_SERVICE_H_ | 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_CLOUD_MOCK_SIGNING_SERVICE_H_ |
6 #define COMPONENTS_POLICY_CORE_COMMON_CLOUD_MOCK_SIGNING_SERVICE_H_ | 6 #define COMPONENTS_POLICY_CORE_COMMON_CLOUD_MOCK_SIGNING_SERVICE_H_ |
7 | 7 |
8 #include "components/policy/core/common/cloud/signing_service.h" | 8 #include "components/policy/core/common/cloud/signing_service.h" |
9 | 9 |
10 #include "components/policy/proto/device_management_backend.pb.h" | 10 #include "components/policy/proto/device_management_backend.pb.h" |
11 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
12 | 12 |
13 namespace policy { | 13 namespace policy { |
14 | 14 |
15 class FakeSigningService : public SigningService { | 15 class FakeSigningService : public SigningService { |
16 public: | 16 public: |
17 FakeSigningService(); | 17 FakeSigningService(); |
18 virtual ~FakeSigningService(); | 18 virtual ~FakeSigningService(); |
19 | 19 |
| 20 void SignRegistrationData( |
| 21 const enterprise_management::CertificateBasedDeviceRegistrationData* |
| 22 registration_data, |
| 23 enterprise_management::SignedData* signed_data); |
| 24 |
20 void SignData(const std::string& data, const SigningCallback& callback) | 25 void SignData(const std::string& data, const SigningCallback& callback) |
21 override; | 26 override; |
22 | 27 |
23 // Useful for test setups without having to deal with callbacks. | 28 void set_success(bool success); |
24 void SignDataSynchronously(const std::string& data, | 29 private: |
25 enterprise_management::SignedData* signed_data); | 30 void DoSignData(const std::string& data, |
| 31 enterprise_management::SignedData* signed_data); |
26 | 32 |
27 // Determine whether SignData will appear successful or not. | |
28 void set_success(bool success); | |
29 | |
30 private: | |
31 bool success_ = true; | 33 bool success_ = true; |
32 }; | 34 }; |
33 | 35 |
34 class MockSigningService : public FakeSigningService { | 36 class MockSigningService : public FakeSigningService { |
35 public: | 37 public: |
36 MockSigningService(); | 38 MockSigningService(); |
37 ~MockSigningService() override; | 39 ~MockSigningService() override; |
38 | 40 |
39 MOCK_METHOD2(SignRegistrationData, | 41 MOCK_METHOD2(SignRegistrationData, |
40 void(const enterprise_management:: | 42 void(const enterprise_management:: |
41 CertificateBasedDeviceRegistrationData*, | 43 CertificateBasedDeviceRegistrationData*, |
42 enterprise_management::SignedData*)); | 44 enterprise_management::SignedData*)); |
43 MOCK_METHOD2(SignData, void(const std::string&, | 45 MOCK_METHOD2(SignData, void(const std::string&, |
44 const SigningCallback&)); | 46 const SigningCallback&)); |
45 }; | 47 }; |
46 | 48 |
47 } | 49 } |
48 | 50 |
49 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_MOCK_SIGNING_SERVICE_H_ | 51 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_MOCK_SIGNING_SERVICE_H_ |
OLD | NEW |