proxygen
HTTPSessionAcceptorTest.cpp File Reference

Go to the source code of this file.

Classes

class  HTTPTargetSessionAcceptor
 
class  HTTPSessionAcceptorTestBase
 
class  HTTPSessionAcceptorTestNPN
 
class  HTTPSessionAcceptorTestNPNPlaintext
 
class  HTTPSessionAcceptorTestNPNJunk
 

Functions

 TEST_P (HTTPSessionAcceptorTestNPN, Npn)
 
 INSTANTIATE_TEST_CASE_P (NPNPositive, HTTPSessionAcceptorTestNPN,::testing::ValuesIn(protos1))
 
 TEST_P (HTTPSessionAcceptorTestNPNPlaintext, PlaintextProtocols)
 
 INSTANTIATE_TEST_CASE_P (NPNPlaintext, HTTPSessionAcceptorTestNPNPlaintext,::testing::ValuesIn(protos2))
 
 TEST_F (HTTPSessionAcceptorTestNPNJunk, Npn)
 
 TEST_F (HTTPSessionAcceptorTestNPN, AcceptorConfigCapture)
 

Variables

char const * protos1 []
 
char const * protos2 [] = { "spdy/3", "h2c" }
 

Function Documentation

INSTANTIATE_TEST_CASE_P ( NPNPositive  ,
HTTPSessionAcceptorTestNPN  ,
::testing::ValuesIn(protos1  
)
INSTANTIATE_TEST_CASE_P ( NPNPlaintext  ,
HTTPSessionAcceptorTestNPNPlaintext  ,
::testing::ValuesIn(protos2  
)
TEST_F ( HTTPSessionAcceptorTestNPNJunk  ,
Npn   
)

Definition at line 173 of file HTTPSessionAcceptorTest.cpp.

References acceptor_, EXPECT_CALL, EXPECT_EQ, folly::gen::move, proxygen::NONE, and string.

173  {
174  std::string proto("/http/1.1");
175  MockAsyncSocket::UniquePtr sock(new MockAsyncSocket(&eventBase_));
176  SocketAddress clientAddress;
177  wangle::TransportInfo tinfo;
178  EXPECT_CALL(*sock.get(), closeNow());
179  acceptor_->connectionReady(
180  std::move(sock),
181  clientAddress,
182  proto,
183  SecureTransportType::NONE,
184  tinfo);
185  EXPECT_EQ(acceptor_->sessionsCreated_, 0);
186  EXPECT_EQ(acceptor_->sessionCreationErrors_, 1);
187 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
FizzServerAcceptor * acceptor_
const char * string
Definition: Conv.cpp:212
#define EXPECT_CALL(obj, call)
TEST_F ( HTTPSessionAcceptorTestNPN  ,
AcceptorConfigCapture   
)

Definition at line 189 of file HTTPSessionAcceptorTest.cpp.

References acceptor_, config_, folly::gen::move, and proxygen::NONE.

189  {
190  newAcceptor();
191  config_.reset();
192  acceptor_->expectedProto_ = "http/1.1";
193  AsyncSocket::UniquePtr sock(new AsyncSocket(&eventBase_));
194  SocketAddress clientAddress;
195  wangle::TransportInfo tinfo;
196  acceptor_->connectionReady(
197  std::move(sock), clientAddress, "", SecureTransportType::NONE, tinfo);
198 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
FizzServerAcceptor * acceptor_
***std::atomic< Config * > config_
Definition: Hazptr.h:80
TEST_P ( HTTPSessionAcceptorTestNPN  ,
Npn   
)

Definition at line 114 of file HTTPSessionAcceptorTest.cpp.

References acceptor_, EXPECT_EQ, folly::gen::move, and string.

114  {
115  std::string proto(GetParam());
116  if (proto == "") {
117  acceptor_->expectedProto_ = "http/1.1";
118  } else if (proto.find("h2") != std::string::npos) {
119  acceptor_->expectedProto_ = "http/2";
120  } else {
121  acceptor_->expectedProto_ = proto;
122  }
123 
124  auto ctx = std::make_shared<folly::SSLContext>();
125  AsyncSSLSocket::UniquePtr sock(new AsyncSSLSocket(ctx, &eventBase_));
126  SocketAddress clientAddress;
127  wangle::TransportInfo tinfo;
128  acceptor_->connectionReady(
129  std::move(sock),
130  clientAddress,
131  proto,
132  SecureTransportType::TLS,
133  tinfo);
134  EXPECT_EQ(acceptor_->sessionsCreated_, 1);
135  EXPECT_EQ(acceptor_->sessionCreationErrors_, 0);
136 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
FizzServerAcceptor * acceptor_
const char * string
Definition: Conv.cpp:212
TEST_P ( HTTPSessionAcceptorTestNPNPlaintext  ,
PlaintextProtocols   
)

Definition at line 145 of file HTTPSessionAcceptorTest.cpp.

References acceptor_, config_, EXPECT_EQ, folly::gen::move, proxygen::NONE, and string.

145  {
146  std::string proto(GetParam());
147  config_->plaintextProtocol = proto;
148  newAcceptor();
149  if (proto == "h2c") {
150  acceptor_->expectedProto_ = "http/2";
151  } else {
152  acceptor_->expectedProto_ = proto;
153  }
154  AsyncSocket::UniquePtr sock(new AsyncSocket(&eventBase_));
155  SocketAddress clientAddress;
156  wangle::TransportInfo tinfo;
157  acceptor_->connectionReady(
158  std::move(sock),
159  clientAddress,
160  "",
161  SecureTransportType::NONE,
162  tinfo);
163  EXPECT_EQ(acceptor_->sessionsCreated_, 1);
164  EXPECT_EQ(acceptor_->sessionCreationErrors_, 0);
165 }
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
FizzServerAcceptor * acceptor_
const char * string
Definition: Conv.cpp:212
***std::atomic< Config * > config_
Definition: Hazptr.h:80

Variable Documentation

char const* protos1[]
Initial value:
= { "h2-14", "h2", "spdy/3.1", "spdy/3",
"http/1.1", "" }

Definition at line 138 of file HTTPSessionAcceptorTest.cpp.

char const* protos2[] = { "spdy/3", "h2c" }

Definition at line 167 of file HTTPSessionAcceptorTest.cpp.