proxygen
Mocks.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree.
7  */
8 
9 #pragma once
10 
13 #include <fizz/client/PskCache.h>
15 
16 namespace fizz {
17 namespace client {
18 namespace test {
19 
21  public:
23  _processConnect,
25  const State&,
26  std::shared_ptr<const FizzClientContext> context,
27  std::shared_ptr<const CertificateVerifier>,
30  const std::shared_ptr<ClientExtensions>& extensions));
32  const State& state,
33  std::shared_ptr<const FizzClientContext> context,
34  std::shared_ptr<const CertificateVerifier> verifier,
37  const std::shared_ptr<ClientExtensions>& extensions) override {
38  return *_processConnect(
39  state, context, verifier, host, cachedPsk, extensions);
40  }
41 
43  _processSocketData,
46  override {
47  return *_processSocketData(state, queue);
48  }
49 
51  _processAppWrite,
54  return *_processAppWrite(state, appWrite);
55  }
56 
58  _processEarlyAppWrite,
61  override {
62  return *_processEarlyAppWrite(state, appWrite);
63  }
64 
65  MOCK_METHOD1(_processAppClose, folly::Optional<Actions>(const State&));
66  Actions processAppClose(const State& state) override {
67  return *_processAppClose(state);
68  }
69 };
70 
71 template <typename SM>
73  public:
74  MOCK_METHOD0(_fizzHandshakeSuccess, void());
76  _fizzHandshakeSuccess();
77  }
78 
79  MOCK_METHOD1(_fizzHandshakeError, void(folly::exception_wrapper));
82  folly::exception_wrapper ew) noexcept override {
83  _fizzHandshakeError(std::move(ew));
84  }
85 };
86 
88 
90  public:
94  new folly::test::MockAsyncTransport()),
95  std::make_shared<FizzClientContext>()) {}
97  connect,
98  void(
100  std::shared_ptr<const CertificateVerifier>,
103  std::chrono::milliseconds));
104  MOCK_METHOD0(close, void());
105  MOCK_METHOD0(closeWithReset, void());
106  MOCK_METHOD0(closeNow, void());
107 };
108 
109 class MockPskCache : public PskCache {
110  public:
111  MOCK_METHOD1(getPsk, folly::Optional<CachedPsk>(const std::string& identity));
112  MOCK_METHOD2(putPsk, void(const std::string& identity, CachedPsk));
113  MOCK_METHOD1(removePsk, void(const std::string& identity));
114 };
115 
117  public:
118  MOCK_CONST_METHOD0(getClientHelloExtensions, std::vector<Extension>());
119  MOCK_METHOD1(onEncryptedExtensions, void(const std::vector<Extension>&));
120 };
121 } // namespace test
122 } // namespace client
123 } // namespace fizz
void fizzHandshakeSuccess(AsyncFizzClientT< SM > *) noexceptoverride
Definition: Mocks.h:75
void fizzHandshakeError(AsyncFizzClientT< SM > *, folly::exception_wrapper ew) noexceptoverride
Definition: Mocks.h:80
int connect(NetworkSocket s, const sockaddr *name, socklen_t namelen)
Definition: NetOps.cpp:94
context
Definition: CMakeCache.txt:563
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
Actions processSocketData(const State &state, folly::IOBufQueue &queue) override
Definition: Mocks.h:45
STL namespace.
MOCK_METHOD1(_processAppClose, folly::Optional< Actions >(const State &))
static AppWrite appWrite(const std::string &str)
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
Actions processAppClose(const State &state) override
Definition: Mocks.h:66
requires E e noexcept(noexcept(s.error(std::move(e))))
std::unique_ptr< AsyncFizzClientT, folly::DelayedDestruction::Destructor > UniquePtr
MOCK_METHOD2(_processSocketData, folly::Optional< Actions >(const State &, folly::IOBufQueue &))
Actions processEarlyAppWrite(const State &state, EarlyAppWrite appWrite) override
Definition: Mocks.h:60
Actions processAppWrite(const State &state, AppWrite appWrite) override
Definition: Mocks.h:53
#define MOCK_METHOD5(m,...)
Definition: Actions.h:16
Actions processConnect(const State &state, std::shared_ptr< const FizzClientContext > context, std::shared_ptr< const CertificateVerifier > verifier, folly::Optional< std::string > host, folly::Optional< CachedPsk > cachedPsk, const std::shared_ptr< ClientExtensions > &extensions) override
Definition: Mocks.h:31
MOCK_METHOD6(_processConnect, folly::Optional< Actions >(const State &, std::shared_ptr< const FizzClientContext > context, std::shared_ptr< const CertificateVerifier >, folly::Optional< std::string > host, folly::Optional< CachedPsk > cachedPsk, const std::shared_ptr< ClientExtensions > &extensions))
std::vector< Action > Actions
const char * string
Definition: Conv.cpp:212
#define MOCK_CONST_METHOD0(m,...)
int close(NetworkSocket s)
Definition: NetOps.cpp:90
state
Definition: http_parser.c:272
#define MOCK_METHOD0(m,...)