proxygen
SecurityProtocolContextManagerTest.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2017-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  */
17 
18 #include <thread>
19 #include <gmock/gmock.h>
20 #include <gtest/gtest.h>
21 
22 using namespace wangle;
23 using namespace testing;
24 
25 template<size_t N>
26 class LengthPeeker :
28  public:
30  PeekingAcceptorHandshakeHelper::PeekCallback(N) {}
31 
33  const std::vector<uint8_t>& /* bytes */,
34  const folly::SocketAddress& /* clientAddr */,
35  std::chrono::steady_clock::time_point /* acceptTime */,
36  TransportInfo&) override {
37  return nullptr;
38  }
39 };
40 
42  protected:
48 };
49 
51  manager_.addPeeker(&p0_);
52 
53  EXPECT_EQ(manager_.getPeekBytes(), 0);
54 }
55 
57  manager_.addPeeker(&p9_);
58  manager_.addPeeker(&p0_);
59  manager_.addPeeker(&p4_);
60  manager_.addPeeker(&p2_);
61 
62  EXPECT_EQ(manager_.getPeekBytes(), 9);
63 }
64 
66  manager_.addPeeker(&p0_);
67  manager_.addPeeker(&p4_);
68  manager_.addPeeker(&p2_);
69  manager_.addPeeker(&p9_);
70 
71  EXPECT_EQ(manager_.getPeekBytes(), 9);
72 }
73 
75  manager_.addPeeker(&p0_);
76  manager_.addPeeker(&p9_);
77  manager_.addPeeker(&p2_);
78  manager_.addPeeker(&p0_);
79 
80  EXPECT_EQ(manager_.getPeekBytes(), 9);
81 }
AcceptorHandshakeHelper::UniquePtr getHelper(const std::vector< uint8_t > &, const folly::SocketAddress &, std::chrono::steady_clock::time_point, TransportInfo &) override
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
std::unique_ptr< AcceptorHandshakeHelper, folly::DelayedDestruction::Destructor > UniquePtr
TEST_F(AcceptorTest, TestCanAcceptWithNoConnectionCounter)