Gaurav Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 1 | // 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 Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 5 | #include "shill/mock_crypto_util_proxy.h" |
Gaurav Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 6 | |
| 7 | #include <string> |
| 8 | #include <vector> |
| 9 | |
Gaurav Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 10 | #include "shill/callbacks.h" |
| 11 | #include "shill/error.h" |
| 12 | #include "shill/event_dispatcher.h" |
Prathmesh Prabhu | 125aea8 | 2014-09-17 16:11:32 -0700 | [diff] [blame] | 13 | #include "shill/testing.h" |
| 14 | |
| 15 | using testing::_; |
| 16 | using testing::DoAll; |
| 17 | using testing::Return; |
Gaurav Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 18 | |
| 19 | namespace shill { |
| 20 | |
| 21 | MockCryptoUtilProxy::MockCryptoUtilProxy( |
| 22 | EventDispatcher *dispatcher, GLib *glib) |
Prathmesh Prabhu | 125aea8 | 2014-09-17 16:11:32 -0700 | [diff] [blame] | 23 | : 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 Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 31 | |
| 32 | MockCryptoUtilProxy::~MockCryptoUtilProxy() {} |
| 33 | |
| 34 | bool 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 Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 45 | nonce, signed_data, |
Gaurav Shah | ed9389c | 2013-05-09 15:17:06 -0700 | [diff] [blame] | 46 | destination_udn, ssid, bssid, |
| 47 | result_callback, error); |
| 48 | } |
| 49 | |
| 50 | bool 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 | |
| 59 | bool 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 |