11 #include <gmock/gmock.h> 12 #include <gtest/gtest.h> 24 template <
typename SM,
typename Actions>
29 template <
typename...
Args>
31 EXPECT_EQ(getNumActions<Args...>(actions,
true), actions.size());
36 for (
auto&
action : actions) {
39 }
catch (
const boost::bad_get&) {
42 throw std::runtime_error(
"did not find expected action");
48 return expectAction<T>(
actions);
52 for (
auto&
action : actions) {
55 }
catch (
const boost::bad_get&) {
63 for (
const auto&
action : actions) {
67 }
catch (
const boost::bad_get&) {
76 template <
typename T1,
typename T2,
typename...
Args>
78 return getNumActions<T1>(
actions, expectNonZero) +
79 getNumActions<T2, Args...>(actions, expectNonZero);
86 template <
typename ExceptionType>
92 expectActions<MutateState, ReportError, WriteToSocket>(
actions);
95 a.description = *alert;
100 expectActions<MutateState, ReportError>(
actions);
103 auto ex = error.error.template get_exception<ExceptionType>();
114 auto ret = std::make_unique<MockAead>();
117 *keys.at(key.key->clone()->moveToFbString().toStdString()) =
ptr;
125 {{
"clientkey", clientAead}, {
"serverkey", serverAead}});
138 std::make_unique<MockEncryptedReadRecordLayer>(encryptionLevel);
139 *recordLayer = ret.get();
145 if (skipFailedDecryption.hasValue()) {
147 *ret, setSkipFailedDecryption(skipFailedDecryption.value()));
158 expectedWrite =
nullptr,
164 std::make_unique<MockEncryptedWriteRecordLayer>(encryptionLevel);
166 *recordLayer = ret.get();
176 writeRecord = *recordLayer](
auto& msg)
mutable {
177 return writeFunc(msg, writeRecord);
void write(const T &in, folly::io::Appender &appender)
void expectAeadCreation(std::map< std::string, MockAead ** > keys)
#define EXPECT_EQ(val1, val2)
constexpr detail::Map< Move > move
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
void expectAeadCreation(MockAead **clientAead, MockAead **serverAead)
requires And< SemiMovable< VN >... > &&SemiMovable< E > auto error(E e)
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
State
See Core for details.
void expectExceptionType(Actions &actions)
PolymorphicMatcher< internal::HasSubstrMatcher< internal::string > > HasSubstr(const internal::string &substring)
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
Actions actions(Args &&...act)
#define EXPECT_TRUE(condition)
#define EXPECT_THAT(value, matcher)
void expectEncryptedWriteRecordLayerCreation(MockEncryptedWriteRecordLayer **recordLayer, MockAead **writeAead, folly::ByteRange expectedBaseSecret, std::function< TLSContent(TLSMessage &, MockEncryptedWriteRecordLayer *)> expectedWrite=nullptr, Sequence *s=nullptr)
std::vector< Action > Actions
Buf encode(TokenBindingMessage &&message)
uint32_t getNumActions(const Actions &actions, bool expectNonZero)
#define EXPECT_NE(val1, val2)
void expectError(Actions &actions, folly::Optional< AlertDescription > alert, std::string msg="")
void expectEncryptedReadRecordLayerCreation(MockEncryptedReadRecordLayer **recordLayer, MockAead **readAead, folly::ByteRange expectedBaseSecret, folly::Optional< bool > skipFailedDecryption=folly::none, Sequence *s=nullptr)
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
T expectSingleAction(Actions actions)
void expectActions(const Actions &actions)
T expectAction(Actions &actions)
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
void processStateMutations(Actions &actions)
constexpr ProtocolVersion TestProtocolVersion
uint32_t getNumActions(const Actions &actions, bool expectNonZero)