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