proxygen
MockAsyncSSLSocket.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015-present Facebook, Inc.
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  */
16 #pragma once
17 
20 
21 namespace folly {
22 namespace test {
23 
25  public:
27  const std::shared_ptr<SSLContext>& ctx,
28  EventBase* base,
29  bool deferSecurityNegotiation = false)
30  : AsyncSocket(base),
31  AsyncSSLSocket(ctx, base, deferSecurityNegotiation) {}
32 
34  connect_,
35  void(
37  const folly::SocketAddress&,
38  int,
39  const OptionMap&,
40  const folly::SocketAddress&));
41  void connect(
43  const folly::SocketAddress& address,
44  int timeout,
45  const OptionMap& options,
46  const folly::SocketAddress& bindAddr) noexcept override {
47  connect_(callback, address, timeout, options, bindAddr);
48  }
49 
52  MOCK_METHOD0(closeNow, void());
53  MOCK_CONST_METHOD0(good, bool());
55  MOCK_CONST_METHOD0(hangup, bool());
58  void(const unsigned char**, unsigned*));
61  bool(const unsigned char**, unsigned*));
63 
64  void sslConn(
66  std::chrono::milliseconds timeout,
67  const SSLContext::SSLVerifyPeerEnum& verify) override {
68  if (timeout > std::chrono::milliseconds::zero()) {
70  }
71 
74  handshakeCallback_ = cb;
75 
76  sslConnectMockable(cb, timeout, verify);
77  }
78 
79  void sslAccept(
81  std::chrono::milliseconds timeout,
82  const SSLContext::SSLVerifyPeerEnum& verify) override {
83  if (timeout > std::chrono::milliseconds::zero()) {
85  }
86 
89  handshakeCallback_ = cb;
90 
91  sslAcceptMockable(cb, timeout, verify);
92  }
93 
95  sslConnectMockable,
96  void(
98  std::chrono::milliseconds,
100 
101  MOCK_METHOD3(
102  sslAcceptMockable,
103  void(
105  std::chrono::milliseconds,
107 };
108 
109 } // namespace test
110 } // namespace folly
bool good() const override
void verify(int extras)
void sslConn(AsyncSSLSocket::HandshakeCB *cb, std::chrono::milliseconds timeout, const SSLContext::SSLVerifyPeerEnum &verify) override
virtual bool hangup() const
MOCK_METHOD3(sslConnectMockable, void(AsyncSSLSocket::HandshakeCB *, std::chrono::milliseconds, const SSLContext::SSLVerifyPeerEnum &))
MOCK_METHOD1(setReadCB, void(ReadCallback *))
MOCK_CONST_METHOD2(getSelectedNextProtocol, void(const unsigned char **, unsigned *))
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
requires E e noexcept(noexcept(s.error(std::move(e))))
void sslAccept(AsyncSSLSocket::HandshakeCB *cb, std::chrono::milliseconds timeout, const SSLContext::SSLVerifyPeerEnum &verify) override
MOCK_METHOD0(closeNow, void())
void setReadCB(ReadCallback *callback) override
std::map< OptionKey, int > OptionMap
Definition: AsyncSocket.h:376
SocketAddress getPeerAddress() const
MockAsyncSSLSocket(const std::shared_ptr< SSLContext > &ctx, EventBase *base, bool deferSecurityNegotiation=false)
MOCK_METHOD5(connect_, void(AsyncSocket::ConnectCallback *, const folly::SocketAddress &, int, const OptionMap &, const folly::SocketAddress &))
SocketAddress getLocalAddress() const
virtual bool getSelectedNextProtocolNoThrow(const unsigned char **protoName, unsigned *protoLen) const
StateEnum state_
StateEnum describing current state.
Definition: AsyncSocket.h:1226
bool readable() const override
void connect(AsyncSocket::ConnectCallback *callback, const folly::SocketAddress &address, int timeout, const OptionMap &options, const folly::SocketAddress &bindAddr) noexceptoverride
HandshakeCB * handshakeCallback_
MOCK_CONST_METHOD1(getLocalAddress, void(folly::SocketAddress *))
bool scheduleTimeout(TimeoutManager::timeout_type timeout)
void closeNow() override
virtual void getSelectedNextProtocol(const unsigned char **protoName, unsigned *protoLen) const