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 | // |
Gaurav Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 16 | |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 17 | #include "shill/mock_crypto_util_proxy.h" |
Gaurav Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 18 | |
| 19 | #include <string> |
| 20 | #include <vector> |
| 21 | |
Gaurav Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 22 | #include "shill/callbacks.h" |
| 23 | #include "shill/error.h" |
| 24 | #include "shill/event_dispatcher.h" |
Prathmesh Prabhu | 125aea8 | 2014-09-17 16:11:32 -0700 | [diff] [blame] | 25 | #include "shill/testing.h" |
| 26 | |
| 27 | using testing::_; |
| 28 | using testing::DoAll; |
| 29 | using testing::Return; |
Gaurav Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 30 | |
| 31 | namespace shill { |
| 32 | |
| 33 | MockCryptoUtilProxy::MockCryptoUtilProxy( |
mukesh agrawal | 13d581f | 2015-08-14 15:48:14 -0700 | [diff] [blame] | 34 | EventDispatcher* dispatcher) |
| 35 | : CryptoUtilProxy(dispatcher) { |
Prathmesh Prabhu | 125aea8 | 2014-09-17 16:11:32 -0700 | [diff] [blame] | 36 | ON_CALL(*this, VerifyDestination(_, _, _, _, _, _, _, _, _)) |
| 37 | .WillByDefault(DoAll(SetOperationFailedInArgumentAndWarn<8>(), |
| 38 | Return(false))); |
| 39 | ON_CALL(*this, EncryptData(_, _, _, _)) |
| 40 | .WillByDefault(DoAll(SetOperationFailedInArgumentAndWarn<3>(), |
| 41 | Return(false))); |
| 42 | } |
Gaurav Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 43 | |
| 44 | MockCryptoUtilProxy::~MockCryptoUtilProxy() {} |
| 45 | |
| 46 | bool MockCryptoUtilProxy::RealVerifyDestination( |
Paul Stewart | 1e006c6 | 2015-06-16 12:29:06 -0700 | [diff] [blame] | 47 | const std::string& certificate, |
| 48 | const std::string& public_key, |
| 49 | const std::string& nonce, |
| 50 | const std::string& signed_data, |
| 51 | const std::string& destination_udn, |
| 52 | const std::vector<uint8_t>& ssid, |
| 53 | const std::string& bssid, |
| 54 | const ResultBoolCallback& result_callback, |
| 55 | Error* error) { |
Gaurav Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 56 | return CryptoUtilProxy::VerifyDestination(certificate, public_key, |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 57 | nonce, signed_data, |
Gaurav Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 58 | destination_udn, ssid, bssid, |
| 59 | result_callback, error); |
| 60 | } |
| 61 | |
| 62 | bool MockCryptoUtilProxy::RealEncryptData( |
Paul Stewart | 1e006c6 | 2015-06-16 12:29:06 -0700 | [diff] [blame] | 63 | const std::string& public_key, |
| 64 | const std::string& data, |
| 65 | const ResultStringCallback& result_callback, |
| 66 | Error* error) { |
Gaurav Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 67 | return CryptoUtilProxy::EncryptData(public_key, data, |
| 68 | result_callback, error); |
| 69 | } |
| 70 | |
| 71 | bool MockCryptoUtilProxy::RealStartShimForCommand( |
Paul Stewart | 1e006c6 | 2015-06-16 12:29:06 -0700 | [diff] [blame] | 72 | const std::string& command, |
| 73 | const std::string& input, |
| 74 | const StringCallback& result_handler) { |
Gaurav Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 75 | return CryptoUtilProxy::StartShimForCommand(command, input, |
| 76 | result_handler); |
| 77 | } |
| 78 | |
| 79 | } // namespace shill |