blob: 64d7bdc858c4e7ab3c90415d9cd19ccccb40bda1 [file] [log] [blame]
Peter Qiuc0beca52015-09-03 11:25:46 -07001//
2// Copyright (C) 2013 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
Christopher Wiley5a3f23a2013-02-20 17:29:57 -080016
17#ifndef SHILL_MOCK_CRYPTO_UTIL_PROXY_H_
18#define SHILL_MOCK_CRYPTO_UTIL_PROXY_H_
19
20#include "shill/crypto_util_proxy.h"
21
22#include <string>
Gaurav Shahed9389c2013-05-09 15:17:06 -070023#include <vector>
Christopher Wiley5a3f23a2013-02-20 17:29:57 -080024
Ben Chancc67c522014-09-03 07:19:18 -070025#include <base/macros.h>
Christopher Wiley5a3f23a2013-02-20 17:29:57 -080026#include <gmock/gmock.h>
27
Christopher Wiley5a3f23a2013-02-20 17:29:57 -080028namespace shill {
29
Gaurav Shahed9389c2013-05-09 15:17:06 -070030class Error;
Christopher Wiley5a3f23a2013-02-20 17:29:57 -080031class EventDispatcher;
32
33class MockCryptoUtilProxy
34 : public CryptoUtilProxy,
35 public base::SupportsWeakPtr<MockCryptoUtilProxy> {
36 public:
mukesh agrawal13d581f2015-08-14 15:48:14 -070037 explicit MockCryptoUtilProxy(EventDispatcher* dispatcher);
Ben Chan5ea763b2014-08-13 11:07:54 -070038 ~MockCryptoUtilProxy() override;
Christopher Wiley5a3f23a2013-02-20 17:29:57 -080039
40 MOCK_METHOD9(VerifyDestination,
Paul Stewart1e006c62015-06-16 12:29:06 -070041 bool(const std::string& certificate,
42 const std::string& public_key,
43 const std::string& nonce,
44 const std::string& signed_data,
45 const std::string& destination_udn,
46 const std::vector<uint8_t>& ssid,
47 const std::string& bssid,
48 const ResultBoolCallback& result_callback,
49 Error* error));
50 MOCK_METHOD4(EncryptData, bool(const std::string& public_key,
51 const std::string& data,
52 const ResultStringCallback& result_callback,
53 Error* error));
Christopher Wiley5a3f23a2013-02-20 17:29:57 -080054
Paul Stewart1e006c62015-06-16 12:29:06 -070055 bool RealVerifyDestination(const std::string& certificate,
56 const std::string& public_key,
57 const std::string& nonce,
58 const std::string& signed_data,
59 const std::string& destination_udn,
60 const std::vector<uint8_t>& ssid,
61 const std::string& bssid,
62 const ResultBoolCallback& result_callback,
63 Error* error);
Christopher Wiley5a3f23a2013-02-20 17:29:57 -080064
Paul Stewart1e006c62015-06-16 12:29:06 -070065 bool RealEncryptData(const std::string& public_key,
66 const std::string& data,
67 const ResultStringCallback& result_callback,
68 Error* error);
Christopher Wiley5a3f23a2013-02-20 17:29:57 -080069
70 // Mock methods with useful callback signatures. You can bind these to check
71 // that appropriate async callbacks are firing at expected times.
Paul Stewart1e006c62015-06-16 12:29:06 -070072 MOCK_METHOD2(TestResultBoolCallback, void(const Error& error, bool));
73 MOCK_METHOD2(TestResultStringCallback, void(const Error& error,
74 const std::string&));
75 MOCK_METHOD2(TestResultHandlerCallback, void(const std::string& result,
76 const Error& error));
77 MOCK_METHOD3(StartShimForCommand, bool(const std::string& command,
78 const std::string& input,
79 const StringCallback& result_handler));
Christopher Wiley5a3f23a2013-02-20 17:29:57 -080080
81 // Methods injected to permit us to call the real method implementations.
Paul Stewart1e006c62015-06-16 12:29:06 -070082 bool RealStartShimForCommand(const std::string& command,
83 const std::string& input,
84 const StringCallback& result_handler);
Christopher Wiley5a3f23a2013-02-20 17:29:57 -080085
Alex Vakulenko8a532292014-06-16 17:18:44 -070086 private:
Christopher Wiley5a3f23a2013-02-20 17:29:57 -080087 DISALLOW_COPY_AND_ASSIGN(MockCryptoUtilProxy);
88};
89
90} // namespace shill
91
92#endif // SHILL_MOCK_CRYPTO_UTIL_PROXY_H_