Index: components/policy/core/common/cloud/mock_signing_service.cc |
diff --git a/components/policy/core/common/cloud/mock_signing_service.cc b/components/policy/core/common/cloud/mock_signing_service.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..aece3a60d6cb86ffcf9a163de53f9f65b70247ad |
--- /dev/null |
+++ b/components/policy/core/common/cloud/mock_signing_service.cc |
@@ -0,0 +1,52 @@ |
+// Copyright (c) 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "components/policy/core/common/cloud/mock_signing_service.h" |
+ |
+#include <string> |
+ |
+#include "components/policy/core/common/cloud/cloud_policy_client.h" |
+ |
+namespace em = enterprise_management; |
+ |
+namespace policy { |
+ |
+const char kSignedDataNonce[] = "+nonce"; |
+const char kSignature[] = "fake-signature"; |
+ |
+FakeSigningService::FakeSigningService() {} |
+ |
+FakeSigningService::~FakeSigningService() {} |
+ |
+void FakeSigningService::SignRegistrationData( |
+ const em::CertificateBasedDeviceRegistrationData* registration_data, |
+ em::SignedData* signed_data) { |
+ DoSignData(registration_data->SerializeAsString(), signed_data); |
+ } |
+ |
+void FakeSigningService::SignData(const std::string& data, |
+ const SigningCallback& callback) { |
+ em::SignedData signed_data; |
+ if (success_) |
+ DoSignData(data, &signed_data); |
+ callback.Run(success_, signed_data); |
+} |
+ |
+void FakeSigningService::DoSignData(const std::string& data, |
+ em::SignedData* signed_data) { |
+ signed_data->set_data(data + kSignedDataNonce); |
+ signed_data->set_signature(kSignature); |
+ signed_data->set_extra_data_bytes(sizeof(kSignedDataNonce) - 1); |
+} |
+ |
+void FakeSigningService::set_success(bool success) { |
+ success_ = success; |
+} |
+ |
+MockSigningService::MockSigningService() {} |
+ |
+MockSigningService::~MockSigningService() {} |
+ |
+} // namespace policy |
+ |