Refactor more TLS handshake tests in QUIC.
QuicCryptoServerStreamTest now only tests QUIC Crypto. The TLS tests from
that file have been moved to a new TlsServerHandshakerTest file. The
remaining tests from TlsHandshakerTest have also been moved to
TlsServerHandshakerTest (client tests were moved to TlsClientHandshakerTest
in cl/306682737) and removes TlsHandshakerTest.
gfe-relnote: n/a - test-only refactor.
PiperOrigin-RevId: 307452036
Change-Id: I3f7cb8d88fcc1da9789a65305a9d4079154dde93
diff --git a/quic/test_tools/crypto_test_utils.cc b/quic/test_tools/crypto_test_utils.cc
index 1e3f14d..21561d9 100644
--- a/quic/test_tools/crypto_test_utils.cc
+++ b/quic/test_tools/crypto_test_utils.cc
@@ -756,6 +756,8 @@
// packets should ever be encrypted with the NullEncrypter, instead
// they're encrypted with an obfuscation cipher based on QUIC version and
// connection ID.
+ QUIC_LOG(INFO) << "Attempting to decrypt with NullDecrypter: "
+ "expect a decryption failure on the next log line.";
ASSERT_FALSE(null_encryption_framer.ProcessPacket(
*source_conn->encrypted_packets_[index]))
<< "No TLS packets should be encrypted with the NullEncrypter";
diff --git a/quic/test_tools/quic_test_utils.cc b/quic/test_tools/quic_test_utils.cc
index b534635..47fd05f 100644
--- a/quic/test_tools/quic_test_utils.cc
+++ b/quic/test_tools/quic_test_utils.cc
@@ -1091,6 +1091,12 @@
MockSessionNotifier::MockSessionNotifier() {}
MockSessionNotifier::~MockSessionNotifier() {}
+// static
+QuicCryptoClientStream::HandshakerInterface*
+QuicCryptoClientStreamPeer::GetHandshaker(QuicCryptoClientStream* stream) {
+ return stream->handshaker_.get();
+}
+
void CreateClientSessionForTest(
QuicServerId server_id,
QuicTime::Delta connection_start_time,
diff --git a/quic/test_tools/quic_test_utils.h b/quic/test_tools/quic_test_utils.h
index fafe8d0..b8e0eae 100644
--- a/quic/test_tools/quic_test_utils.h
+++ b/quic/test_tools/quic_test_utils.h
@@ -858,6 +858,7 @@
MOCK_CONST_METHOD1(SelectAlpn,
std::vector<quiche::QuicheStringPiece>::const_iterator(
const std::vector<quiche::QuicheStringPiece>&));
+ MOCK_METHOD(void, OnAlpnSelected, (quiche::QuicheStringPiece));
std::unique_ptr<QuicCryptoServerStreamBase> CreateQuicCryptoServerStream(
const QuicCryptoServerConfig* crypto_config,
QuicCompressedCertsCache* compressed_certs_cache) override;
@@ -924,6 +925,7 @@
MOCK_METHOD0(ShouldCreateOutgoingBidirectionalStream, bool());
MOCK_METHOD0(ShouldCreateOutgoingUnidirectionalStream, bool());
MOCK_CONST_METHOD0(GetAlpnsToOffer, std::vector<std::string>());
+ MOCK_METHOD(void, OnAlpnSelected, (quiche::QuicheStringPiece));
QuicCryptoClientStream* GetMutableCryptoStream() override;
const QuicCryptoClientStream* GetCryptoStream() const override;
@@ -1190,6 +1192,14 @@
MOCK_CONST_METHOD0(HasUnackedStreamData, bool());
};
+class QuicCryptoClientStreamPeer {
+ public:
+ QuicCryptoClientStreamPeer() = delete;
+
+ static QuicCryptoClientStream::HandshakerInterface* GetHandshaker(
+ QuicCryptoClientStream* stream);
+};
+
// Creates a client session for testing.
//
// server_id: The server id associated with this stream.