blob: da1787bb367ff1410d92750398f21a5df47d6124 [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//
Gaurav Shahed9389c2013-05-09 15:17:06 -070016
Alex Vakulenko8a532292014-06-16 17:18:44 -070017#include "shill/mock_crypto_util_proxy.h"
Gaurav Shahed9389c2013-05-09 15:17:06 -070018
19#include <string>
20#include <vector>
21
Gaurav Shahed9389c2013-05-09 15:17:06 -070022#include "shill/callbacks.h"
23#include "shill/error.h"
24#include "shill/event_dispatcher.h"
Prathmesh Prabhu125aea82014-09-17 16:11:32 -070025#include "shill/testing.h"
26
27using testing::_;
28using testing::DoAll;
29using testing::Return;
Gaurav Shahed9389c2013-05-09 15:17:06 -070030
31namespace shill {
32
33MockCryptoUtilProxy::MockCryptoUtilProxy(
mukesh agrawal13d581f2015-08-14 15:48:14 -070034 EventDispatcher* dispatcher)
35 : CryptoUtilProxy(dispatcher) {
Prathmesh Prabhu125aea82014-09-17 16:11:32 -070036 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 Shahed9389c2013-05-09 15:17:06 -070043
44MockCryptoUtilProxy::~MockCryptoUtilProxy() {}
45
46bool MockCryptoUtilProxy::RealVerifyDestination(
Paul Stewart1e006c62015-06-16 12:29:06 -070047 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 Shahed9389c2013-05-09 15:17:06 -070056 return CryptoUtilProxy::VerifyDestination(certificate, public_key,
Alex Vakulenko8a532292014-06-16 17:18:44 -070057 nonce, signed_data,
Gaurav Shahed9389c2013-05-09 15:17:06 -070058 destination_udn, ssid, bssid,
59 result_callback, error);
60}
61
62bool MockCryptoUtilProxy::RealEncryptData(
Paul Stewart1e006c62015-06-16 12:29:06 -070063 const std::string& public_key,
64 const std::string& data,
65 const ResultStringCallback& result_callback,
66 Error* error) {
Gaurav Shahed9389c2013-05-09 15:17:06 -070067 return CryptoUtilProxy::EncryptData(public_key, data,
68 result_callback, error);
69}
70
71bool MockCryptoUtilProxy::RealStartShimForCommand(
Paul Stewart1e006c62015-06-16 12:29:06 -070072 const std::string& command,
73 const std::string& input,
74 const StringCallback& result_handler) {
Gaurav Shahed9389c2013-05-09 15:17:06 -070075 return CryptoUtilProxy::StartShimForCommand(command, input,
76 result_handler);
77}
78
79} // namespace shill