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 #include "components/policy/core/common/cloud/mock_signing_service.h" | 5 #include "components/policy/core/common/cloud/mock_signing_service.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "components/policy/core/common/cloud/cloud_policy_client.h" | 9 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
10 | 10 |
11 namespace em = enterprise_management; | 11 namespace em = enterprise_management; |
12 | 12 |
13 namespace policy { | 13 namespace policy { |
14 | 14 |
15 const char kSignedDataNonce[] = "+nonce"; | 15 const char kSignedDataNonce[] = "+nonce"; |
16 const char kSignature[] = "fake-signature"; | 16 const char kSignature[] = "fake-signature"; |
17 | 17 |
18 FakeSigningService::FakeSigningService() {} | 18 FakeSigningService::FakeSigningService() {} |
19 | 19 |
20 FakeSigningService::~FakeSigningService() {} | 20 FakeSigningService::~FakeSigningService() {} |
21 | 21 |
| 22 void FakeSigningService::SignRegistrationData( |
| 23 const em::CertificateBasedDeviceRegistrationData* registration_data, |
| 24 em::SignedData* signed_data) { |
| 25 DoSignData(registration_data->SerializeAsString(), signed_data); |
| 26 } |
| 27 |
22 void FakeSigningService::SignData(const std::string& data, | 28 void FakeSigningService::SignData(const std::string& data, |
23 const SigningCallback& callback) { | 29 const SigningCallback& callback) { |
24 em::SignedData signed_data; | 30 em::SignedData signed_data; |
25 if (success_) { | 31 if (success_) |
26 SignDataSynchronously(data, &signed_data); | 32 DoSignData(data, &signed_data); |
27 } | |
28 callback.Run(success_, signed_data); | 33 callback.Run(success_, signed_data); |
29 } | 34 } |
30 | 35 |
31 void FakeSigningService::SignDataSynchronously(const std::string& data, | 36 void FakeSigningService::DoSignData(const std::string& data, |
32 em::SignedData* signed_data) { | 37 em::SignedData* signed_data) { |
33 signed_data->set_data(data + kSignedDataNonce); | 38 signed_data->set_data(data + kSignedDataNonce); |
34 signed_data->set_signature(kSignature); | 39 signed_data->set_signature(kSignature); |
35 signed_data->set_extra_data_bytes(sizeof(kSignedDataNonce) - 1); | 40 signed_data->set_extra_data_bytes(sizeof(kSignedDataNonce) - 1); |
36 } | 41 } |
37 | 42 |
38 void FakeSigningService::set_success(bool success) { | 43 void FakeSigningService::set_success(bool success) { |
39 success_ = success; | 44 success_ = success; |
40 } | 45 } |
41 | 46 |
42 MockSigningService::MockSigningService() {} | 47 MockSigningService::MockSigningService() {} |
43 | 48 |
44 MockSigningService::~MockSigningService() {} | 49 MockSigningService::~MockSigningService() {} |
45 | 50 |
46 } // namespace policy | 51 } // namespace policy |
| 52 |
OLD | NEW |