blob: 18601fcd4f943ef290a0879e516f7b21ca0c9552 [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(
22 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(
35 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) {
44 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(
51 const std::string &public_key,
52 const std::string &data,
53 const ResultStringCallback &result_callback,
54 Error *error) {
55 return CryptoUtilProxy::EncryptData(public_key, data,
56 result_callback, error);
57}
58
59bool MockCryptoUtilProxy::RealStartShimForCommand(
60 const std::string &command,
61 const std::string &input,
62 const StringCallback &result_handler) {
63 return CryptoUtilProxy::StartShimForCommand(command, input,
64 result_handler);
65}
66
67} // namespace shill