Peter Qiu | c0beca5 | 2015-09-03 11:25:46 -0700 | [diff] [blame^] | 1 | // |
| 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 Wiley | 5a3f23a | 2013-02-20 17:29:57 -0800 | [diff] [blame] | 16 | |
| 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 Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 23 | #include <vector> |
Christopher Wiley | 5a3f23a | 2013-02-20 17:29:57 -0800 | [diff] [blame] | 24 | |
Ben Chan | cc67c52 | 2014-09-03 07:19:18 -0700 | [diff] [blame] | 25 | #include <base/macros.h> |
Christopher Wiley | 5a3f23a | 2013-02-20 17:29:57 -0800 | [diff] [blame] | 26 | #include <gmock/gmock.h> |
| 27 | |
Christopher Wiley | 5a3f23a | 2013-02-20 17:29:57 -0800 | [diff] [blame] | 28 | namespace shill { |
| 29 | |
Gaurav Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 30 | class Error; |
Christopher Wiley | 5a3f23a | 2013-02-20 17:29:57 -0800 | [diff] [blame] | 31 | class EventDispatcher; |
| 32 | |
| 33 | class MockCryptoUtilProxy |
| 34 | : public CryptoUtilProxy, |
| 35 | public base::SupportsWeakPtr<MockCryptoUtilProxy> { |
| 36 | public: |
mukesh agrawal | 13d581f | 2015-08-14 15:48:14 -0700 | [diff] [blame] | 37 | explicit MockCryptoUtilProxy(EventDispatcher* dispatcher); |
Ben Chan | 5ea763b | 2014-08-13 11:07:54 -0700 | [diff] [blame] | 38 | ~MockCryptoUtilProxy() override; |
Christopher Wiley | 5a3f23a | 2013-02-20 17:29:57 -0800 | [diff] [blame] | 39 | |
| 40 | MOCK_METHOD9(VerifyDestination, |
Paul Stewart | 1e006c6 | 2015-06-16 12:29:06 -0700 | [diff] [blame] | 41 | 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 Wiley | 5a3f23a | 2013-02-20 17:29:57 -0800 | [diff] [blame] | 54 | |
Paul Stewart | 1e006c6 | 2015-06-16 12:29:06 -0700 | [diff] [blame] | 55 | 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 Wiley | 5a3f23a | 2013-02-20 17:29:57 -0800 | [diff] [blame] | 64 | |
Paul Stewart | 1e006c6 | 2015-06-16 12:29:06 -0700 | [diff] [blame] | 65 | bool RealEncryptData(const std::string& public_key, |
| 66 | const std::string& data, |
| 67 | const ResultStringCallback& result_callback, |
| 68 | Error* error); |
Christopher Wiley | 5a3f23a | 2013-02-20 17:29:57 -0800 | [diff] [blame] | 69 | |
| 70 | // Mock methods with useful callback signatures. You can bind these to check |
| 71 | // that appropriate async callbacks are firing at expected times. |
Paul Stewart | 1e006c6 | 2015-06-16 12:29:06 -0700 | [diff] [blame] | 72 | 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 Wiley | 5a3f23a | 2013-02-20 17:29:57 -0800 | [diff] [blame] | 80 | |
| 81 | // Methods injected to permit us to call the real method implementations. |
Paul Stewart | 1e006c6 | 2015-06-16 12:29:06 -0700 | [diff] [blame] | 82 | bool RealStartShimForCommand(const std::string& command, |
| 83 | const std::string& input, |
| 84 | const StringCallback& result_handler); |
Christopher Wiley | 5a3f23a | 2013-02-20 17:29:57 -0800 | [diff] [blame] | 85 | |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 86 | private: |
Christopher Wiley | 5a3f23a | 2013-02-20 17:29:57 -0800 | [diff] [blame] | 87 | DISALLOW_COPY_AND_ASSIGN(MockCryptoUtilProxy); |
| 88 | }; |
| 89 | |
| 90 | } // namespace shill |
| 91 | |
| 92 | #endif // SHILL_MOCK_CRYPTO_UTIL_PROXY_H_ |