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 | |
25 void SignData(const std::string& data, const SigningCallback& callback) | 20 void SignData(const std::string& data, const SigningCallback& callback) |
26 override; | 21 override; |
27 | 22 |
| 23 // Useful for test setups without having to deal with callbacks. |
| 24 void SignDataSynchronously(const std::string& data, |
| 25 enterprise_management::SignedData* signed_data); |
| 26 |
| 27 // Determine whether SignData will appear successful or not. |
28 void set_success(bool success); | 28 void set_success(bool success); |
| 29 |
29 private: | 30 private: |
30 void DoSignData(const std::string& data, | |
31 enterprise_management::SignedData* signed_data); | |
32 | |
33 bool success_ = true; | 31 bool success_ = true; |
34 }; | 32 }; |
35 | 33 |
36 class MockSigningService : public FakeSigningService { | 34 class MockSigningService : public FakeSigningService { |
37 public: | 35 public: |
38 MockSigningService(); | 36 MockSigningService(); |
39 ~MockSigningService() override; | 37 ~MockSigningService() override; |
40 | 38 |
41 MOCK_METHOD2(SignRegistrationData, | 39 MOCK_METHOD2(SignRegistrationData, |
42 void(const enterprise_management:: | 40 void(const enterprise_management:: |
43 CertificateBasedDeviceRegistrationData*, | 41 CertificateBasedDeviceRegistrationData*, |
44 enterprise_management::SignedData*)); | 42 enterprise_management::SignedData*)); |
45 MOCK_METHOD2(SignData, void(const std::string&, | 43 MOCK_METHOD2(SignData, void(const std::string&, |
46 const SigningCallback&)); | 44 const SigningCallback&)); |
47 }; | 45 }; |
48 | 46 |
49 } | 47 } |
50 | 48 |
51 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_MOCK_SIGNING_SERVICE_H_ | 49 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_MOCK_SIGNING_SERVICE_H_ |
OLD | NEW |