proxygen
HTTP2CodecTest Class Reference
Inheritance diagram for HTTP2CodecTest:
HTTPParallelCodecTest testing::Test

Public Member Functions

 HTTP2CodecTest ()
 
void SetUp () override
 
void testHeaderListSize (bool oversized)
 
void testFrameSizeLimit (bool oversized)
 
- Public Member Functions inherited from HTTPParallelCodecTest
 HTTPParallelCodecTest (proxygen::HTTPParallelCodec &upstreamCodec, proxygen::HTTPParallelCodec &downstreamCodec)
 
void SetUp () override
 
void SetUpUpstreamTest ()
 
bool parse (std::function< void(folly::IOBuf *)> hackIngress=std::function< void(folly::IOBuf *)>())
 
bool parseUpstream (std::function< void(folly::IOBuf *)> hackIngress=std::function< void(folly::IOBuf *)>())
 
bool parseImpl (proxygen::HTTPParallelCodec &codec, std::function< void(folly::IOBuf *)> hackIngress)
 
void dumpToFile (bool isUpstream=false)
 
- Public Member Functions inherited from testing::Test
virtual ~Test ()
 
virtual ~Test ()
 
virtual ~Test ()
 

Protected Attributes

HTTP2Codec upstreamCodec_ {TransportDirection::UPSTREAM}
 
HTTP2Codec downstreamCodec_ {TransportDirection::DOWNSTREAM}
 
- Protected Attributes inherited from HTTPParallelCodecTest
proxygen::FakeHTTPCodecCallback callbacks_
 
proxygen::HTTPParallelCodecupstreamCodec_
 
proxygen::HTTPParallelCodecdownstreamCodec_
 
folly::IOBufQueue output_ {folly::IOBufQueue::cacheChainLength()}
 
const testing::TestInfotestInfo_ {testing::UnitTest::GetInstance()->current_test_info()}
 
bool dump_ {false}
 

Additional Inherited Members

- Public Types inherited from testing::Test
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
- Static Public Member Functions inherited from testing::Test
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 
- Protected Member Functions inherited from testing::Test
 Test ()
 
virtual void TearDown ()
 
 Test ()
 
virtual void TearDown ()
 
 Test ()
 
virtual void TearDown ()
 

Detailed Description

Definition at line 48 of file HTTP2CodecTest.cpp.

Constructor & Destructor Documentation

HTTP2CodecTest::HTTP2CodecTest ( )
inline

Definition at line 51 of file HTTP2CodecTest.cpp.

HTTP2Codec upstreamCodec_
HTTP2Codec downstreamCodec_
HTTPParallelCodecTest(proxygen::HTTPParallelCodec &upstreamCodec, proxygen::HTTPParallelCodec &downstreamCodec)

Member Function Documentation

void HTTP2CodecTest::SetUp ( )
inlineoverridevirtual

Reimplemented from testing::Test.

Definition at line 54 of file HTTP2CodecTest.cpp.

References HTTPParallelCodecTest::SetUp().

54  {
56  }
void HTTP2CodecTest::testFrameSizeLimit ( bool  oversized)

Definition at line 513 of file HTTP2CodecTest.cpp.

References EXPECT_EQ, proxygen::getBigGetRequest(), proxygen::http2::kMaxFramePayloadLengthMin, proxygen::MAX_FRAME_SIZE, proxygen::parse(), and settings.

513  {
514  HTTPMessage req = getBigGetRequest("/guacamole");
516 
517  parse(); // consume preface
518  if (oversized) {
519  // trick upstream for sending a 2x bigger HEADERS frame
520  settings->setSetting(SettingsId::MAX_FRAME_SIZE,
523  parseUpstream();
524  }
525 
526  settings->setSetting(SettingsId::MAX_FRAME_SIZE,
528  upstreamCodec_.generateHeader(output_, 1, req, true /* eom */);
529 
530  parse();
531  // session error
532  EXPECT_EQ(callbacks_.messageBegin, oversized ? 0 : 1);
533  EXPECT_EQ(callbacks_.headersComplete, oversized ? 0 : 1);
534  EXPECT_EQ(callbacks_.messageComplete, oversized ? 0 : 1);
536  EXPECT_EQ(callbacks_.sessionErrors, oversized ? 1 : 0);
537 }
HTTP2Codec upstreamCodec_
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
bool parseUpstream(std::function< void(folly::IOBuf *)> hackIngress=std::function< void(folly::IOBuf *)>())
HTTPMessage getBigGetRequest(const std::string &url)
Definition: TestUtils.cpp:85
bool parse(std::function< void(folly::IOBuf *)> hackIngress=std::function< void(folly::IOBuf *)>())
void generateHeader(folly::IOBufQueue &writeBuf, StreamID stream, const HTTPMessage &msg, bool eom=false, HTTPHeaderSize *size=nullptr) override
static http_parser_settings settings
Definition: test.c:1529
const uint32_t kMaxFramePayloadLengthMin
HTTP2Codec downstreamCodec_
proxygen::FakeHTTPCodecCallback callbacks_
HTTPSettings * getEgressSettings() override
Definition: HTTP2Codec.h:116
size_t generateSettings(folly::IOBufQueue &writeBuf) override
void HTTP2CodecTest::testHeaderListSize ( bool  oversized)

Definition at line 492 of file HTTP2CodecTest.cpp.

References proxygen::HTTPHeaders::add(), EXPECT_EQ, proxygen::getGetRequest(), proxygen::HTTPMessage::getHeaders(), proxygen::HTTP_HEADER_USER_AGENT, proxygen::MAX_HEADER_LIST_SIZE, proxygen::parse(), and settings.

492  {
493  if (oversized) {
495  settings->setSetting(SettingsId::MAX_HEADER_LIST_SIZE, 37);
496  }
497 
498  HTTPMessage req = getGetRequest("/guacamole");
499  req.getHeaders().add(HTTP_HEADER_USER_AGENT, "coolio");
500  req.getHeaders().add("x-long-long-header",
501  "supercalafragalisticexpialadoshus");
502  upstreamCodec_.generateHeader(output_, 1, req, true /* eom */);
503 
504  parse();
505  // session error
506  EXPECT_EQ(callbacks_.messageBegin, oversized ? 0 : 1);
507  EXPECT_EQ(callbacks_.headersComplete, oversized ? 0 : 1);
508  EXPECT_EQ(callbacks_.messageComplete, oversized ? 0 : 1);
510  EXPECT_EQ(callbacks_.sessionErrors, oversized ? 1 : 0);
511 }
HTTP2Codec upstreamCodec_
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
bool parse(std::function< void(folly::IOBuf *)> hackIngress=std::function< void(folly::IOBuf *)>())
void generateHeader(folly::IOBufQueue &writeBuf, StreamID stream, const HTTPMessage &msg, bool eom=false, HTTPHeaderSize *size=nullptr) override
static http_parser_settings settings
Definition: test.c:1529
HTTP2Codec downstreamCodec_
proxygen::FakeHTTPCodecCallback callbacks_
HTTPHeaders & getHeaders()
Definition: HTTPMessage.h:273
HTTPSettings * getEgressSettings() override
Definition: HTTP2Codec.h:116
HTTPMessage getGetRequest(const std::string &url)
Definition: TestUtils.cpp:76
void add(folly::StringPiece name, folly::StringPiece value)
Definition: HTTPHeaders.cpp:52

Member Data Documentation

HTTP2Codec HTTP2CodecTest::downstreamCodec_ {TransportDirection::DOWNSTREAM}
protected

Definition at line 62 of file HTTP2CodecTest.cpp.

HTTP2Codec HTTP2CodecTest::upstreamCodec_ {TransportDirection::UPSTREAM}
protected

Definition at line 61 of file HTTP2CodecTest.cpp.


The documentation for this class was generated from the following file: