blob: 74754e9f52694919c1813597ee104454607c386f [file] [log] [blame]
Christopher Wiley5a3f23a2013-02-20 17:29:57 -08001// 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
5#ifndef SHILL_MOCK_CRYPTO_UTIL_PROXY_H_
6#define SHILL_MOCK_CRYPTO_UTIL_PROXY_H_
7
8#include "shill/crypto_util_proxy.h"
9
10#include <string>
Gaurav Shahed9389c2013-05-09 15:17:06 -070011#include <vector>
Christopher Wiley5a3f23a2013-02-20 17:29:57 -080012
13#include <base/basictypes.h>
14#include <gmock/gmock.h>
15
Christopher Wiley5a3f23a2013-02-20 17:29:57 -080016namespace shill {
17
Gaurav Shahed9389c2013-05-09 15:17:06 -070018class Error;
Christopher Wiley5a3f23a2013-02-20 17:29:57 -080019class EventDispatcher;
20
21class MockCryptoUtilProxy
22 : public CryptoUtilProxy,
23 public base::SupportsWeakPtr<MockCryptoUtilProxy> {
24 public:
Gaurav Shahed9389c2013-05-09 15:17:06 -070025 MockCryptoUtilProxy(EventDispatcher *dispatcher, GLib *glib);
26 virtual ~MockCryptoUtilProxy();
Christopher Wiley5a3f23a2013-02-20 17:29:57 -080027
28 MOCK_METHOD9(VerifyDestination,
29 bool(const std::string &certificate,
30 const std::string &public_key,
31 const std::string &nonce,
32 const std::string &signed_data,
33 const std::string &destination_udn,
34 const std::vector<uint8_t> &ssid,
35 const std::string &bssid,
36 const ResultBoolCallback &result_callback,
37 Error *error));
Christopher Wiley5a3f23a2013-02-20 17:29:57 -080038 MOCK_METHOD4(EncryptData, bool(const std::string &public_key,
39 const std::string &data,
40 const ResultStringCallback &result_callback,
41 Error *error));
42
43 bool RealVerifyDestination(const std::string &certificate,
44 const std::string &public_key,
45 const std::string &nonce,
46 const std::string &signed_data,
47 const std::string &destination_udn,
48 const std::vector<uint8_t> &ssid,
49 const std::string &bssid,
50 const ResultBoolCallback &result_callback,
Gaurav Shahed9389c2013-05-09 15:17:06 -070051 Error *error);
Christopher Wiley5a3f23a2013-02-20 17:29:57 -080052
53 bool RealEncryptData(const std::string &public_key,
54 const std::string &data,
55 const ResultStringCallback &result_callback,
Gaurav Shahed9389c2013-05-09 15:17:06 -070056 Error *error);
Christopher Wiley5a3f23a2013-02-20 17:29:57 -080057
58 // Mock methods with useful callback signatures. You can bind these to check
59 // that appropriate async callbacks are firing at expected times.
60 MOCK_METHOD2(TestResultBoolCallback, void(const Error &error, bool));
61 MOCK_METHOD2(TestResultStringCallback, void(const Error &error,
62 const std::string &));
63 MOCK_METHOD2(TestResultHandlerCallback, void(const std::string &result,
64 const Error &error));
65 MOCK_METHOD3(StartShimForCommand, bool(const std::string &command,
66 const std::string &input,
67 const StringCallback &result_handler));
68
69 // Methods injected to permit us to call the real method implementations.
70 bool RealStartShimForCommand(const std::string &command,
71 const std::string &input,
Gaurav Shahed9389c2013-05-09 15:17:06 -070072 const StringCallback &result_handler);
Christopher Wiley5a3f23a2013-02-20 17:29:57 -080073
74 DISALLOW_COPY_AND_ASSIGN(MockCryptoUtilProxy);
75};
76
77} // namespace shill
78
79#endif // SHILL_MOCK_CRYPTO_UTIL_PROXY_H_