blob: dd8afc258126e1ca16c7151a187f0f2fc65ead0e [file] [log] [blame]
Gaurav Shahed9389c2013-05-09 15:17:06 -07001// Copyright (c) 2013 The Chromium OS 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
Alex Vakulenko8a532292014-06-16 17:18:44 -07005#include "shill/mock_crypto_util_proxy.h"
Gaurav Shahed9389c2013-05-09 15:17:06 -07006
7#include <string>
8#include <vector>
9
Gaurav Shahed9389c2013-05-09 15:17:06 -070010#include "shill/callbacks.h"
11#include "shill/error.h"
12#include "shill/event_dispatcher.h"
Prathmesh Prabhu125aea82014-09-17 16:11:32 -070013#include "shill/testing.h"
14
15using testing::_;
16using testing::DoAll;
17using testing::Return;
Gaurav Shahed9389c2013-05-09 15:17:06 -070018
19namespace shill {
20
21MockCryptoUtilProxy::MockCryptoUtilProxy(
Paul Stewart1e006c62015-06-16 12:29:06 -070022 EventDispatcher* dispatcher, GLib* glib)
Prathmesh Prabhu125aea82014-09-17 16:11:32 -070023 : CryptoUtilProxy(dispatcher, glib) {
24 ON_CALL(*this, VerifyDestination(_, _, _, _, _, _, _, _, _))
25 .WillByDefault(DoAll(SetOperationFailedInArgumentAndWarn<8>(),
26 Return(false)));
27 ON_CALL(*this, EncryptData(_, _, _, _))
28 .WillByDefault(DoAll(SetOperationFailedInArgumentAndWarn<3>(),
29 Return(false)));
30}
Gaurav Shahed9389c2013-05-09 15:17:06 -070031
32MockCryptoUtilProxy::~MockCryptoUtilProxy() {}
33
34bool MockCryptoUtilProxy::RealVerifyDestination(
Paul Stewart1e006c62015-06-16 12:29:06 -070035 const std::string& certificate,
36 const std::string& public_key,
37 const std::string& nonce,
38 const std::string& signed_data,
39 const std::string& destination_udn,
40 const std::vector<uint8_t>& ssid,
41 const std::string& bssid,
42 const ResultBoolCallback& result_callback,
43 Error* error) {
Gaurav Shahed9389c2013-05-09 15:17:06 -070044 return CryptoUtilProxy::VerifyDestination(certificate, public_key,
Alex Vakulenko8a532292014-06-16 17:18:44 -070045 nonce, signed_data,
Gaurav Shahed9389c2013-05-09 15:17:06 -070046 destination_udn, ssid, bssid,
47 result_callback, error);
48}
49
50bool MockCryptoUtilProxy::RealEncryptData(
Paul Stewart1e006c62015-06-16 12:29:06 -070051 const std::string& public_key,
52 const std::string& data,
53 const ResultStringCallback& result_callback,
54 Error* error) {
Gaurav Shahed9389c2013-05-09 15:17:06 -070055 return CryptoUtilProxy::EncryptData(public_key, data,
56 result_callback, error);
57}
58
59bool MockCryptoUtilProxy::RealStartShimForCommand(
Paul Stewart1e006c62015-06-16 12:29:06 -070060 const std::string& command,
61 const std::string& input,
62 const StringCallback& result_handler) {
Gaurav Shahed9389c2013-05-09 15:17:06 -070063 return CryptoUtilProxy::StartShimForCommand(command, input,
64 result_handler);
65}
66
67} // namespace shill