proxygen
fizz::client::test::ClientProtocolTest Class Reference
Inheritance diagram for fizz::client::test::ClientProtocolTest:
fizz::test::ProtocolTest< ClientTypes, Actions > testing::Test

Public Member Functions

void SetUp () override
 
- Public Member Functions inherited from testing::Test
virtual ~Test ()
 
virtual ~Test ()
 
virtual ~Test ()
 

Protected Member Functions

void setMockRecord ()
 
void setMockHandshakeEncryptedRecord ()
 
void setMockEarlyRecord ()
 
void setMockContextAndScheduler ()
 
CachedPsk getCachedPsk ()
 
EarlyDataParams getEarlyDataParams ()
 
void setupExpectingServerHello ()
 
void setupExpectingServerHelloAfterHrr ()
 
void setupExpectingEncryptedExtensions ()
 
void setupExpectingEncryptedExtensionsEarlySent ()
 
void setupExpectingCertificate ()
 
void setupExpectingCertificateRequest ()
 
void setupExpectingCertificateVerify ()
 
void setupExpectingFinished ()
 
void setupAcceptingData ()
 
void doFinishedFlow (ClientAuthType authType)
 
- Protected Member Functions inherited from fizz::test::ProtocolTest< ClientTypes, Actions >
void expectActions (const Actions &actions)
 
T expectAction (Actions &actions)
 
T expectSingleAction (Actions actions)
 
void processStateMutations (Actions &actions)
 
uint32_t getNumActions (const Actions &actions, bool expectNonZero)
 
uint32_t getNumActions (const Actions &actions, bool expectNonZero)
 
void expectExceptionType (Actions &actions)
 
void expectError (Actions &actions, folly::Optional< AlertDescription > alert, std::string msg="")
 
void expectAeadCreation (std::map< std::string, MockAead ** > keys)
 
void expectAeadCreation (MockAead **clientAead, MockAead **serverAead)
 
void expectEncryptedReadRecordLayerCreation (MockEncryptedReadRecordLayer **recordLayer, MockAead **readAead, folly::ByteRange expectedBaseSecret, folly::Optional< bool > skipFailedDecryption=folly::none, Sequence *s=nullptr)
 
void expectEncryptedWriteRecordLayerCreation (MockEncryptedWriteRecordLayer **recordLayer, MockAead **writeAead, folly::ByteRange expectedBaseSecret, std::function< TLSContent(TLSMessage &, MockEncryptedWriteRecordLayer *)> expectedWrite=nullptr, Sequence *s=nullptr)
 
- Protected Member Functions inherited from testing::Test
 Test ()
 
virtual void TearDown ()
 
 Test ()
 
virtual void TearDown ()
 
 Test ()
 
virtual void TearDown ()
 

Static Protected Member Functions

static ClientHello getDefaultClientHello ()
 

Protected Attributes

std::shared_ptr< FizzClientContextcontext_
 
MockPlaintextReadRecordLayermockRead_
 
MockPlaintextWriteRecordLayermockWrite_
 
MockEncryptedWriteRecordLayermockEarlyWrite_
 
MockEncryptedWriteRecordLayermockHandshakeWrite_
 
MockEncryptedReadRecordLayermockHandshakeRead_
 
MockKeyExchangemockKex_
 
MockKeySchedulermockKeyScheduler_
 
MockHandshakeContextmockHandshakeContext_
 
std::shared_ptr< MockPeerCertmockLeaf_
 
std::shared_ptr< MockPeerCertmockIntermediate_
 
std::shared_ptr< MockSelfCertmockClientCert_
 
std::shared_ptr< MockCertificateVerifierverifier_
 
std::shared_ptr< MockPskCachepskCache_
 
- Protected Attributes inherited from fizz::test::ProtocolTest< ClientTypes, Actions >
ClientTypes::State state_
 
MockFactoryfactory_
 

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 Types inherited from fizz::test::ProtocolTest< ClientTypes, Actions >
using MutateState = folly::Function< void(typename ClientTypes::State &)>
 

Detailed Description

Definition at line 28 of file ClientProtocolTest.cpp.

Member Function Documentation

void fizz::client::test::ClientProtocolTest::doFinishedFlow ( ClientAuthType  authType)
protected

Definition at line 2591 of file ClientProtocolTest.cpp.

References testing::_, fizz::client::detail::actions(), fizz::AppTraffic, fizz::test::TestMessages::certificate(), fizz::test::TestMessages::certificateVerify(), fizz::Client, fizz::ClientAppTraffic, fizz::TLSContent::contentType, folly::IOBuf::copyBuffer(), fizz::TLSContent::data, fizz::ecdsa_secp256r1_sha256, fizz::encodeHandshake(), fizz::TLSContent::encryptionLevel, EXPECT_CALL, EXPECT_EQ, EXPECT_FALSE, EXPECT_TRUE, fizz::ExporterMaster, fizz::test::TestMessages::finished(), fizz::TLSMessage::fragment, fizz::detail::getFinishedData(), fizz::Handshake, fizz::handshake, testing::Invoke(), testing::InvokeWithoutArgs(), fizz::client::detail::processEvent(), fizz::ResumptionMaster, fizz::ServerAppTraffic, fizz::TLSMessage::type, and fizz::detail::write().

2591  {
2592  Sequence contextSeq;
2593  EXPECT_CALL(*mockHandshakeContext_, getFinishedData(RangeMatches("sht")))
2594  .InSequence(contextSeq)
2595  .WillOnce(
2596  InvokeWithoutArgs([]() { return IOBuf::copyBuffer("verifydata"); }));
2597  EXPECT_CALL(
2599  appendToTranscript(BufMatches("finishedencoding")))
2600  .InSequence(contextSeq);
2601  EXPECT_CALL(*mockHandshakeContext_, getHandshakeContext())
2602  .InSequence(contextSeq)
2603  .WillRepeatedly(
2604  Invoke([]() { return IOBuf::copyBuffer("sfincontext"); }));
2605  if (authType != ClientAuthType::NotRequested) {
2606  if (authType == ClientAuthType::Sent) {
2607  EXPECT_CALL(*mockClientCert_, _getCertMessage(_))
2608  .InSequence(contextSeq)
2609  .WillOnce(
2610  InvokeWithoutArgs([]() { return TestMessages::certificate(); }));
2611  }
2612  EXPECT_CALL(*mockHandshakeContext_, appendToTranscript(_))
2613  .InSequence(contextSeq)
2614  .WillOnce(Invoke([authType](const Buf& enc) {
2615  if (authType == ClientAuthType::Sent) {
2618  } else {
2619  EXPECT_TRUE(IOBufEqualTo()(enc, encodeHandshake(CertificateMsg())));
2620  }
2621  }));
2622  if (authType == ClientAuthType::Sent) {
2623  EXPECT_CALL(*mockHandshakeContext_, getHandshakeContext())
2624  .InSequence(contextSeq)
2625  .WillRepeatedly(
2626  Invoke([]() { return IOBuf::copyBuffer("csentcontext"); }));
2627  EXPECT_CALL(
2628  *mockClientCert_,
2629  sign(
2632  RangeMatches("csentcontext")))
2633  .InSequence(contextSeq)
2634  .WillOnce(InvokeWithoutArgs(
2635  []() { return IOBuf::copyBuffer("signature"); }));
2636  EXPECT_CALL(*mockHandshakeContext_, appendToTranscript(_))
2637  .InSequence(contextSeq)
2638  .WillOnce(Invoke([](const Buf& enc) {
2641  }));
2642  }
2643  }
2644  EXPECT_CALL(*mockHandshakeContext_, getFinishedData(RangeMatches("cht")))
2645  .InSequence(contextSeq)
2646  .WillRepeatedly(
2647  InvokeWithoutArgs([]() { return IOBuf::copyBuffer("verifydata"); }));
2648  EXPECT_CALL(*mockHandshakeContext_, appendToTranscript(_))
2649  .InSequence(contextSeq);
2650  EXPECT_CALL(*mockHandshakeContext_, getHandshakeContext())
2651  .InSequence(contextSeq)
2652  .WillRepeatedly(Invoke([]() { return IOBuf::copyBuffer("fincontext"); }));
2653  EXPECT_CALL(*mockHandshakeWrite_, _write(_))
2654  .WillOnce(Invoke([&](TLSMessage& msg) {
2655  TLSContent content;
2656  content.contentType = msg.type;
2657  content.encryptionLevel = mockHandshakeWrite_->getEncryptionLevel();
2658  EXPECT_EQ(msg.type, ContentType::handshake);
2659 
2660  switch (authType) {
2664  msg.fragment, encodeHandshake(TestMessages::finished())));
2665  break;
2667  auto expectedMessages = encodeHandshake(CertificateMsg());
2668  expectedMessages->prependChain(
2670  EXPECT_TRUE(IOBufEqualTo()(msg.fragment, expectedMessages));
2671  break;
2672  }
2673  case ClientAuthType::Sent: {
2674  auto expectedMessages =
2676  expectedMessages->prependChain(
2678  expectedMessages->prependChain(
2680  EXPECT_TRUE(IOBufEqualTo()(msg.fragment, expectedMessages));
2681  break;
2682  }
2683  }
2684  content.data = folly::IOBuf::copyBuffer("finwrite");
2685  return content;
2686  }));
2687  EXPECT_CALL(*mockKeyScheduler_, deriveMasterSecret());
2688  EXPECT_CALL(
2690  getSecret(MasterSecrets::ExporterMaster, RangeMatches("sfincontext")));
2691  EXPECT_CALL(
2693  getSecret(MasterSecrets::ResumptionMaster, RangeMatches("fincontext")))
2694  .WillOnce(InvokeWithoutArgs([]() {
2695  return std::vector<uint8_t>({'r', 'e', 's'});
2696  }));
2697  EXPECT_CALL(
2698  *mockKeyScheduler_, deriveAppTrafficSecrets(RangeMatches("sfincontext")));
2699  EXPECT_CALL(
2701  .WillOnce(InvokeWithoutArgs([]() {
2702  return std::vector<uint8_t>({'s', 'a', 't'});
2703  }));
2704  EXPECT_CALL(
2706  .WillOnce(InvokeWithoutArgs([]() {
2707  return std::vector<uint8_t>({'c', 'a', 't'});
2708  }));
2709  EXPECT_CALL(*mockKeyScheduler_, getTrafficKey(RangeMatches("sat"), _, _))
2710  .WillOnce(InvokeWithoutArgs([]() {
2711  return TrafficKey{IOBuf::copyBuffer("serverkey"),
2712  IOBuf::copyBuffer("serveriv")};
2713  }));
2714  EXPECT_CALL(*mockKeyScheduler_, getTrafficKey(RangeMatches("cat"), _, _))
2715  .WillOnce(InvokeWithoutArgs([]() {
2716  return TrafficKey{IOBuf::copyBuffer("clientkey"),
2717  IOBuf::copyBuffer("clientiv")};
2718  }));
2719  MockAead* raead;
2720  MockAead* waead;
2721  MockEncryptedReadRecordLayer* rrl;
2722  MockEncryptedWriteRecordLayer* wrl;
2723  expectAeadCreation(&waead, &raead);
2726  EXPECT_CALL(*mockKeyScheduler_, clearMasterSecret());
2727 
2729  expectActions<MutateState, ReportHandshakeSuccess, WriteToSocket>(actions);
2730  auto write = expectAction<WriteToSocket>(actions);
2731  EXPECT_EQ(write.contents[0].encryptionLevel, EncryptionLevel::Handshake);
2732  EXPECT_EQ(write.contents[0].contentType, ContentType::handshake);
2733  EXPECT_TRUE(
2734  IOBufEqualTo()(write.contents[0].data, IOBuf::copyBuffer("finwrite")));
2735  auto reportSuccess = expectAction<ReportHandshakeSuccess>(actions);
2736  EXPECT_EQ(reportSuccess.earlyDataAccepted, false);
2738  EXPECT_EQ(state_.readRecordLayer().get(), rrl);
2739  EXPECT_EQ(
2740  state_.readRecordLayer()->getEncryptionLevel(),
2742  EXPECT_EQ(state_.writeRecordLayer().get(), wrl);
2743  EXPECT_EQ(
2744  state_.writeRecordLayer()->getEncryptionLevel(),
2747  EXPECT_TRUE(
2748  IOBufEqualTo()(*state_.resumptionSecret(), IOBuf::copyBuffer("res")));
2749  EXPECT_FALSE(state_.sentCCS());
2750 }
EncryptionLevel getEncryptionLevel() const override
Buf encodeHandshake(T &&handshakeMsg)
Definition: Types-inl.h:515
void write(const T &in, folly::io::Appender &appender)
Definition: Types-inl.h:112
void expectAeadCreation(std::map< std::string, MockAead ** > keys)
Definition: ProtocolTest.h:112
#define EXPECT_EQ(val1, val2)
Definition: gtest.h:1922
static CertificateMsg certificate()
Definition: TestMessages.h:158
PolymorphicAction< internal::InvokeWithoutArgsAction< FunctionImpl > > InvokeWithoutArgs(FunctionImpl function_impl)
static Finished finished()
Definition: TestMessages.h:196
PolymorphicAction< internal::InvokeAction< FunctionImpl > > Invoke(FunctionImpl function_impl)
static CertificateVerify certificateVerify()
Definition: TestMessages.h:175
Buf getFinishedData(std::unique_ptr< KeyDerivation > &deriver, Buf &finishedMacKey, const Buf &finishedTranscript)
Actions actions(Args &&...act)
Definition: Actions.h:86
#define EXPECT_TRUE(condition)
Definition: gtest.h:1859
void expectEncryptedWriteRecordLayerCreation(MockEncryptedWriteRecordLayer **recordLayer, MockAead **writeAead, folly::ByteRange expectedBaseSecret, std::function< TLSContent(TLSMessage &, MockEncryptedWriteRecordLayer *)> expectedWrite=nullptr, Sequence *s=nullptr)
Definition: ProtocolTest.h:153
MockEncryptedWriteRecordLayer * mockHandshakeWrite_
std::unique_ptr< folly::IOBuf > Buf
Definition: Types.h:22
void expectEncryptedReadRecordLayerCreation(MockEncryptedReadRecordLayer **recordLayer, MockAead **readAead, folly::ByteRange expectedBaseSecret, folly::Optional< bool > skipFailedDecryption=folly::none, Sequence *s=nullptr)
Definition: ProtocolTest.h:128
std::shared_ptr< MockSelfCert > mockClientCert_
#define EXPECT_CALL(obj, call)
const internal::AnythingMatcher _
#define EXPECT_FALSE(condition)
Definition: gtest.h:1862
Range< const char * > StringPiece
Actions processEvent(const State &state, Param param)
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
CachedPsk fizz::client::test::ClientProtocolTest::getCachedPsk ( )
inlineprotected

Definition at line 89 of file ClientProtocolTest.cpp.

References fizz::client::CachedPsk::clientCert, fizz::client::test::getTestPsk(), now(), and fizz::client::CachedPsk::serverCert.

89  {
90  CachedPsk psk = getTestPsk("PSK", std::chrono::system_clock::now());
91  psk.serverCert = mockLeaf_;
92  psk.clientCert = mockClientCert_;
93  return psk;
94  }
std::chrono::steady_clock::time_point now()
std::shared_ptr< MockPeerCert > mockLeaf_
CachedPsk getTestPsk(std::string pskName, std::chrono::system_clock::time_point issueTime)
Definition: Utilities.h:16
std::shared_ptr< MockSelfCert > mockClientCert_
static ClientHello fizz::client::test::ClientProtocolTest::getDefaultClientHello ( )
inlinestaticprotected

Definition at line 85 of file ClientProtocolTest.cpp.

References fizz::test::TestMessages::clientHello().

85  {
87  }
static ClientHello clientHello()
Definition: TestMessages.h:26
EarlyDataParams fizz::client::test::ClientProtocolTest::getEarlyDataParams ( )
inlineprotected

Definition at line 96 of file ClientProtocolTest.cpp.

References fizz::client::EarlyDataParams::alpn, fizz::client::EarlyDataParams::cipher, fizz::client::EarlyDataParams::clientCert, folly::IOBuf::copyBuffer(), fizz::client::EarlyDataParams::earlyExporterSecret, params, fizz::client::EarlyDataParams::serverCert, fizz::test::TestProtocolVersion, fizz::TLS_AES_128_GCM_SHA256, and fizz::client::EarlyDataParams::version.

96  {
97  EarlyDataParams params;
98  params.version = TestProtocolVersion;
100  params.serverCert = mockLeaf_;
101  params.clientCert = mockClientCert_;
102  params.alpn = "h2";
103  params.earlyExporterSecret = IOBuf::copyBuffer("earlyexporter");
104  return params;
105  }
std::shared_ptr< MockPeerCert > mockLeaf_
constexpr Params params[]
std::shared_ptr< MockSelfCert > mockClientCert_
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
constexpr ProtocolVersion TestProtocolVersion
Definition: ProtocolTest.h:22
void fizz::client::test::ClientProtocolTest::setMockContextAndScheduler ( )
inlineprotected

Definition at line 74 of file ClientProtocolTest.cpp.

References folly::gen::move.

74  {
75  auto handshakeContext = std::make_unique<MockHandshakeContext>();
76  mockHandshakeContext_ = handshakeContext.get();
77  mockHandshakeContext_->setDefaults();
78  state_.handshakeContext() = std::move(handshakeContext);
79  auto keyScheduler = std::make_unique<MockKeyScheduler>();
80  mockKeyScheduler_ = keyScheduler.get();
81  mockKeyScheduler_->setDefaults();
82  state_.keyScheduler() = std::move(keyScheduler);
83  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void fizz::client::test::ClientProtocolTest::setMockEarlyRecord ( )
inlineprotected

Definition at line 67 of file ClientProtocolTest.cpp.

References fizz::EarlyData.

67  {
69  new MockEncryptedWriteRecordLayer(EncryptionLevel::EarlyData);
71  state_.earlyWriteRecordLayer().reset(mockEarlyWrite_);
72  }
MockEncryptedWriteRecordLayer * mockEarlyWrite_
void fizz::client::test::ClientProtocolTest::setMockHandshakeEncryptedRecord ( )
inlineprotected

Definition at line 57 of file ClientProtocolTest.cpp.

References fizz::Handshake.

57  {
59  new MockEncryptedReadRecordLayer(EncryptionLevel::Handshake);
61  new MockEncryptedWriteRecordLayer(EncryptionLevel::Handshake);
63  state_.readRecordLayer().reset(mockHandshakeRead_);
64  state_.writeRecordLayer().reset(mockHandshakeWrite_);
65  }
MockEncryptedWriteRecordLayer * mockHandshakeWrite_
MockEncryptedReadRecordLayer * mockHandshakeRead_
void fizz::client::test::ClientProtocolTest::setMockRecord ( )
inlineprotected

Definition at line 49 of file ClientProtocolTest.cpp.

49  {
50  mockRead_ = new MockPlaintextReadRecordLayer();
51  mockWrite_ = new MockPlaintextWriteRecordLayer();
53  state_.readRecordLayer().reset(mockRead_);
54  state_.writeRecordLayer().reset(mockWrite_);
55  }
MockPlaintextWriteRecordLayer * mockWrite_
MockPlaintextReadRecordLayer * mockRead_
void fizz::client::test::ClientProtocolTest::SetUp ( )
inlineoverridevirtual

Reimplemented from testing::Test.

Definition at line 30 of file ClientProtocolTest.cpp.

References folly::gen::move, fizz::tls_1_3, fizz::TLS_AES_128_GCM_SHA256, fizz::TLS_AES_256_GCM_SHA384, and verifier_.

30  {
31  context_ = std::make_shared<FizzClientContext>();
32  context_->setSupportedVersions({ProtocolVersion::tls_1_3});
33  context_->setSupportedCiphers({CipherSuite::TLS_AES_128_GCM_SHA256,
35  auto mockFactory = std::make_unique<MockFactory>();
36  mockFactory->setDefaults();
37  factory_ = mockFactory.get();
38  context_->setFactory(std::move(mockFactory));
39  context_->setSupportedAlpns({"h2"});
40  verifier_ = std::make_shared<MockCertificateVerifier>();
41  pskCache_ = std::make_shared<MockPskCache>();
42  context_->setPskCache(pskCache_);
43  context_->setSendEarlyData(true);
44  mockLeaf_ = std::make_shared<MockPeerCert>();
45  mockClientCert_ = std::make_shared<MockSelfCert>();
46  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::shared_ptr< MockPskCache > pskCache_
std::shared_ptr< MockPeerCert > mockLeaf_
std::shared_ptr< MockSelfCert > mockClientCert_
std::shared_ptr< FizzClientContext > context_
std::shared_ptr< MockCertificateVerifier > verifier_
void fizz::client::test::ClientProtocolTest::setupAcceptingData ( )
inlineprotected

Definition at line 225 of file ClientProtocolTest.cpp.

References folly::IOBuf::copyBuffer(), fizz::tls_1_3, fizz::TLS_AES_128_GCM_SHA256, and fizz::x25519.

225  {
226  setMockRecord();
228  state_.version() = ProtocolVersion::tls_1_3;
230  state_.group() = NamedGroup::x25519;
231  state_.context() = context_;
232  state_.state() = StateEnum::Established;
233  state_.resumptionSecret() = IOBuf::copyBuffer("resumptionsecret");
234  state_.sni() = "www.hostname.com";
235  state_.serverCert() = mockLeaf_;
236  }
std::shared_ptr< MockPeerCert > mockLeaf_
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
std::shared_ptr< FizzClientContext > context_
void fizz::client::test::ClientProtocolTest::setupExpectingCertificate ( )
inlineprotected
void fizz::client::test::ClientProtocolTest::setupExpectingCertificateRequest ( )
inlineprotected
void fizz::client::test::ClientProtocolTest::setupExpectingCertificateVerify ( )
inlineprotected

Definition at line 197 of file ClientProtocolTest.cpp.

References folly::gen::move, and verifier_.

197  {
198  setMockRecord();
200  state_.context() = context_;
201  state_.verifier() = verifier_;
202  mockIntermediate_ = std::make_shared<MockPeerCert>();
203  std::vector<std::shared_ptr<const PeerCert>> certs;
204  certs.push_back(mockLeaf_);
205  certs.push_back(mockIntermediate_);
206  state_.unverifiedCertChain() = std::move(certs);
208  state_.clientAuthRequested() = ClientAuthType::NotRequested;
209  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::shared_ptr< MockPeerCert > mockLeaf_
std::shared_ptr< MockPeerCert > mockIntermediate_
std::shared_ptr< FizzClientContext > context_
std::shared_ptr< MockCertificateVerifier > verifier_
void fizz::client::test::ClientProtocolTest::setupExpectingEncryptedExtensions ( )
inlineprotected

Definition at line 155 of file ClientProtocolTest.cpp.

References fizz::application_layer_protocol_negotiation, fizz::early_data, fizz::key_share, fizz::key_share_old, fizz::NotAttempted, fizz::pre_shared_key, fizz::server_name, fizz::supported_versions, fizz::test::TestProtocolVersion, and fizz::TLS_AES_128_GCM_SHA256.

155  {
156  setMockRecord();
158  state_.context() = context_;
159  state_.earlyDataType() = EarlyDataType::NotAttempted;
160  state_.version() = TestProtocolVersion;
163  state_.requestedExtensions() = std::vector<ExtensionType>(
171  }
std::shared_ptr< FizzClientContext > context_
constexpr ProtocolVersion TestProtocolVersion
Definition: ProtocolTest.h:22
void fizz::client::test::ClientProtocolTest::setupExpectingEncryptedExtensionsEarlySent ( )
inlineprotected
void fizz::client::test::ClientProtocolTest::setupExpectingFinished ( )
inlineprotected

Definition at line 211 of file ClientProtocolTest.cpp.

References folly::IOBuf::copyBuffer(), fizz::NotAttempted, fizz::test::TestProtocolVersion, fizz::TLS_AES_128_GCM_SHA256, and fizz::x25519.

211  {
214  state_.context() = context_;
215  state_.version() = TestProtocolVersion;
217  state_.group() = NamedGroup::x25519;
218  state_.clientHandshakeSecret() = IOBuf::copyBuffer("cht");
219  state_.serverHandshakeSecret() = IOBuf::copyBuffer("sht");
221  state_.clientAuthRequested() = ClientAuthType::NotRequested;
222  state_.earlyDataType() = EarlyDataType::NotAttempted;
223  }
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
std::shared_ptr< FizzClientContext > context_
constexpr ProtocolVersion TestProtocolVersion
Definition: ProtocolTest.h:22
void fizz::client::test::ClientProtocolTest::setupExpectingServerHello ( )
inlineprotected

Definition at line 107 of file ClientProtocolTest.cpp.

References fizz::application_layer_protocol_negotiation, folly::IOBuf::copyBuffer(), folly::IOBuf::create(), fizz::early_data, fizz::key_share, fizz::key_share_old, folly::gen::move, fizz::NotAttempted, fizz::pre_shared_key, random(), fizz::server_name, fizz::supported_versions, verifier_, and fizz::x25519.

107  {
108  setMockRecord();
109  state_.context() = context_;
110  state_.encodedClientHello() = IOBuf::copyBuffer("chlo");
111  auto mockKex = std::make_unique<MockKeyExchange>();
112  mockKex_ = mockKex.get();
113  mockKex_->setDefaults();
114  std::map<NamedGroup, std::unique_ptr<KeyExchange>> kexs;
115  kexs.emplace(NamedGroup::x25519, std::move(mockKex));
116  state_.keyExchangers() = std::move(kexs);
117  Random random;
118  random.fill(0x44);
119  state_.clientRandom() = std::move(random);
120  state_.legacySessionId() = IOBuf::create(0);
121  state_.sni() = "www.hostname.com";
122  state_.verifier() = verifier_;
123  state_.earlyDataType() = EarlyDataType::NotAttempted;
125  state_.requestedExtensions() = std::vector<ExtensionType>(
133  }
Integral2 random(Integral1 low, Integral2 up)
static std::unique_ptr< IOBuf > create(std::size_t capacity)
Definition: IOBuf.cpp:229
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void setDefaults()
Definition: Mocks.h:26
static std::unique_ptr< IOBuf > copyBuffer(const void *buf, std::size_t size, std::size_t headroom=0, std::size_t minTailroom=0)
Definition: IOBuf.h:1587
std::shared_ptr< FizzClientContext > context_
std::shared_ptr< MockCertificateVerifier > verifier_
void fizz::client::test::ClientProtocolTest::setupExpectingServerHelloAfterHrr ( )
inlineprotected

Definition at line 135 of file ClientProtocolTest.cpp.

References fizz::application_layer_protocol_negotiation, fizz::early_data, fizz::HelloRetryRequest, fizz::key_share, fizz::key_share_old, folly::gen::move, fizz::pre_shared_key, fizz::server_name, fizz::supported_versions, fizz::test::TestProtocolVersion, fizz::TLS_AES_128_GCM_SHA256, and fizz::x25519.

135  {
137  state_.keyExchangeType() = KeyExchangeType::HelloRetryRequest;
138  auto handshakeContext = std::make_unique<MockHandshakeContext>();
139  mockHandshakeContext_ = handshakeContext.get();
140  mockHandshakeContext_->setDefaults();
141  state_.handshakeContext() = std::move(handshakeContext);
142  state_.version() = TestProtocolVersion;
144  state_.group() = NamedGroup::x25519;
145  state_.requestedExtensions() = std::vector<ExtensionType>(
153  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
constexpr ProtocolVersion TestProtocolVersion
Definition: ProtocolTest.h:22

Member Data Documentation

std::shared_ptr<FizzClientContext> fizz::client::test::ClientProtocolTest::context_
protected

Definition at line 240 of file ClientProtocolTest.cpp.

std::shared_ptr<MockSelfCert> fizz::client::test::ClientProtocolTest::mockClientCert_
protected

Definition at line 251 of file ClientProtocolTest.cpp.

MockEncryptedWriteRecordLayer* fizz::client::test::ClientProtocolTest::mockEarlyWrite_
protected

Definition at line 243 of file ClientProtocolTest.cpp.

MockHandshakeContext* fizz::client::test::ClientProtocolTest::mockHandshakeContext_
protected

Definition at line 248 of file ClientProtocolTest.cpp.

MockEncryptedReadRecordLayer* fizz::client::test::ClientProtocolTest::mockHandshakeRead_
protected

Definition at line 245 of file ClientProtocolTest.cpp.

MockEncryptedWriteRecordLayer* fizz::client::test::ClientProtocolTest::mockHandshakeWrite_
protected

Definition at line 244 of file ClientProtocolTest.cpp.

std::shared_ptr<MockPeerCert> fizz::client::test::ClientProtocolTest::mockIntermediate_
protected

Definition at line 250 of file ClientProtocolTest.cpp.

MockKeyExchange* fizz::client::test::ClientProtocolTest::mockKex_
protected

Definition at line 246 of file ClientProtocolTest.cpp.

MockKeyScheduler* fizz::client::test::ClientProtocolTest::mockKeyScheduler_
protected

Definition at line 247 of file ClientProtocolTest.cpp.

std::shared_ptr<MockPeerCert> fizz::client::test::ClientProtocolTest::mockLeaf_
protected

Definition at line 249 of file ClientProtocolTest.cpp.

MockPlaintextReadRecordLayer* fizz::client::test::ClientProtocolTest::mockRead_
protected

Definition at line 241 of file ClientProtocolTest.cpp.

MockPlaintextWriteRecordLayer* fizz::client::test::ClientProtocolTest::mockWrite_
protected

Definition at line 242 of file ClientProtocolTest.cpp.

std::shared_ptr<MockPskCache> fizz::client::test::ClientProtocolTest::pskCache_
protected

Definition at line 253 of file ClientProtocolTest.cpp.

std::shared_ptr<MockCertificateVerifier> fizz::client::test::ClientProtocolTest::verifier_
protected

Definition at line 252 of file ClientProtocolTest.cpp.


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