#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <list>
#include <memory>
#include <optional>
#include <ostream>
#include <string>
#include <utility>
#include <vector>
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "absl/time/clock.h"
#include "absl/time/time.h"
#include "absl/types/span.h"
#include "quiche/quic/core/crypto/null_encrypter.h"
#include "quiche/quic/core/crypto/quic_client_session_cache.h"
#include "quiche/quic/core/frames/quic_blocked_frame.h"
#include "quiche/quic/core/http/http_constants.h"
#include "quiche/quic/core/http/quic_spdy_client_stream.h"
#include "quiche/quic/core/http/quic_spdy_session.h"
#include "quiche/quic/core/http/web_transport_http3.h"
#include "quiche/quic/core/io/quic_default_event_loop.h"
#include "quiche/quic/core/io/quic_event_loop.h"
#include "quiche/quic/core/qpack/value_splitting_header_list.h"
#include "quiche/quic/core/quic_connection.h"
#include "quiche/quic/core/quic_constants.h"
#include "quiche/quic/core/quic_data_writer.h"
#include "quiche/quic/core/quic_default_clock.h"
#include "quiche/quic/core/quic_dispatcher.h"
#include "quiche/quic/core/quic_error_codes.h"
#include "quiche/quic/core/quic_framer.h"
#include "quiche/quic/core/quic_packet_creator.h"
#include "quiche/quic/core/quic_packet_writer.h"
#include "quiche/quic/core/quic_packet_writer_wrapper.h"
#include "quiche/quic/core/quic_packets.h"
#include "quiche/quic/core/quic_session.h"
#include "quiche/quic/core/quic_types.h"
#include "quiche/quic/core/quic_utils.h"
#include "quiche/quic/core/quic_versions.h"
#include "quiche/quic/platform/api/quic_expect_bug.h"
#include "quiche/quic/platform/api/quic_flags.h"
#include "quiche/quic/platform/api/quic_logging.h"
#include "quiche/quic/platform/api/quic_socket_address.h"
#include "quiche/quic/platform/api/quic_test.h"
#include "quiche/quic/platform/api/quic_test_loopback.h"
#include "quiche/quic/test_tools/bad_packet_writer.h"
#include "quiche/quic/test_tools/crypto_test_utils.h"
#include "quiche/quic/test_tools/packet_dropping_test_writer.h"
#include "quiche/quic/test_tools/packet_reordering_writer.h"
#include "quiche/quic/test_tools/qpack/qpack_encoder_peer.h"
#include "quiche/quic/test_tools/qpack/qpack_test_utils.h"
#include "quiche/quic/test_tools/quic_client_session_cache_peer.h"
#include "quiche/quic/test_tools/quic_config_peer.h"
#include "quiche/quic/test_tools/quic_connection_peer.h"
#include "quiche/quic/test_tools/quic_dispatcher_peer.h"
#include "quiche/quic/test_tools/quic_flow_controller_peer.h"
#include "quiche/quic/test_tools/quic_sent_packet_manager_peer.h"
#include "quiche/quic/test_tools/quic_server_peer.h"
#include "quiche/quic/test_tools/quic_session_peer.h"
#include "quiche/quic/test_tools/quic_spdy_session_peer.h"
#include "quiche/quic/test_tools/quic_spdy_stream_peer.h"
#include "quiche/quic/test_tools/quic_stream_id_manager_peer.h"
#include "quiche/quic/test_tools/quic_stream_peer.h"
#include "quiche/quic/test_tools/quic_stream_sequencer_peer.h"
#include "quiche/quic/test_tools/quic_test_backend.h"
#include "quiche/quic/test_tools/quic_test_client.h"
#include "quiche/quic/test_tools/quic_test_server.h"
#include "quiche/quic/test_tools/quic_test_utils.h"
#include "quiche/quic/test_tools/server_thread.h"
#include "quiche/quic/test_tools/web_transport_test_tools.h"
#include "quiche/quic/tools/quic_backend_response.h"
#include "quiche/quic/tools/quic_memory_cache_backend.h"
#include "quiche/quic/tools/quic_server.h"
#include "quiche/quic/tools/quic_simple_client_stream.h"
#include "quiche/quic/tools/quic_simple_server_stream.h"
#include "quiche/common/http/http_header_block.h"
#include "quiche/common/platform/api/quiche_test.h"
#include "quiche/common/quiche_stream.h"
#include "quiche/common/test_tools/quiche_test_utils.h"
HttpHeaderBlock;
kV3LowestPriority;
SpdyFramer;
SpdySerializedFrame;
SpdySettingsIR;
_;
Assign;
Invoke;
NiceMock;
UnorderedElementsAreArray;
#ifndef NDEBUG
#define EXPECT_DEBUG_EQ(val1, val2) …
#else
#define EXPECT_DEBUG_EQ …
#endif
namespace quic {
namespace test {
namespace {
const char kFooResponseBody[] = …;
const char kBarResponseBody[] = …;
const char kTestUserAgentId[] = …;
const float kSessionToStreamRatio = …;
const int kLongConnectionIdLength = …;
struct TestParams { … };
std::string PrintToString(const TestParams& p) { … }
std::vector<TestParams> GetTestParams() { … }
void WriteHeadersOnStream(QuicSpdyStream* stream) { … }
class ServerDelegate : public PacketDroppingTestWriter::Delegate { … };
class ClientDelegate : public PacketDroppingTestWriter::Delegate { … };
class EndToEndTest : public QuicTestWithParam<TestParams> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(EndToEndTest, HandshakeSuccessful) { … }
TEST_P(EndToEndTest, ExportKeyingMaterial) { … }
TEST_P(EndToEndTest, SimpleRequestResponse) { … }
TEST_P(EndToEndTest, HandshakeConfirmed) { … }
TEST_P(EndToEndTest, TestDispatcherAckWithTwoPacketCHLO) { … }
TEST_P(EndToEndTest,
TestDispatcherAckWithTwoPacketCHLO_SecondPacketRetransmitted) { … }
TEST_P(EndToEndTest, TestDispatcherAckWithTwoPacketCHLO_BothBuffered) { … }
TEST_P(EndToEndTest, TestDispatcherAckWithThreePacketCHLO) { … }
TEST_P(EndToEndTest,
TestDispatcherAckWithThreePacketCHLO_AckCountLimitedByFlag) { … }
TEST_P(EndToEndTest,
TestDispatcherAckWithThreePacketCHLO_SecondAndThirdRetransmitted) { … }
TEST_P(EndToEndTest, SendAndReceiveCoalescedPackets) { … }
TEST_P(EndToEndTest, SimpleRequestResponseWithAckDelayChange) { … }
TEST_P(EndToEndTest, SimpleRequestResponseWithAckExponentChange) { … }
TEST_P(EndToEndTest, SimpleRequestResponseForcedVersionNegotiation) { … }
TEST_P(EndToEndTest, ForcedVersionNegotiation) { … }
TEST_P(EndToEndTest, SimpleRequestResponseZeroConnectionID) { … }
TEST_P(EndToEndTest, ZeroConnectionID) { … }
TEST_P(EndToEndTest, BadConnectionIdLength) { … }
TEST_P(EndToEndTest, ClientConnectionId) { … }
TEST_P(EndToEndTest, ForcedVersionNegotiationAndClientConnectionId) { … }
TEST_P(EndToEndTest, ForcedVersionNegotiationAndBadConnectionIdLength) { … }
TEST_P(EndToEndTest, ForcedVersNegoAndClientCIDAndLongCID) { … }
TEST_P(EndToEndTest, MixGoodAndBadConnectionIdLengths) { … }
TEST_P(EndToEndTest, SimpleRequestResponseWithLargeReject) { … }
TEST_P(EndToEndTest, SimpleRequestResponsev6) { … }
TEST_P(EndToEndTest,
ClientDoesNotAllowServerDataOnServerInitiatedBidirectionalStreams) { … }
TEST_P(EndToEndTest,
ServerDoesNotAllowClientDataOnServerInitiatedBidirectionalStreams) { … }
TEST_P(EndToEndTest,
BothEndpointsDisallowDataOnServerInitiatedBidirectionalStreams) { … }
TEST_P(EndToEndTest, NoUndecryptablePacketsBeforeHandshakeComplete) { … }
TEST_P(EndToEndTest, SeparateFinPacket) { … }
TEST_P(EndToEndTest, MultipleRequestResponse) { … }
TEST_P(EndToEndTest, MultipleRequestResponseZeroConnectionID) { … }
TEST_P(EndToEndTest, MultipleStreams) { … }
TEST_P(EndToEndTest, MultipleClients) { … }
TEST_P(EndToEndTest, RequestOverMultiplePackets) { … }
TEST_P(EndToEndTest, MultiplePacketsRandomOrder) { … }
TEST_P(EndToEndTest, PostMissingBytes) { … }
TEST_P(EndToEndTest, LargePostNoPacketLoss) { … }
TEST_P(EndToEndTest, QUICHE_SLOW_TEST(LargePostNoPacketLoss1sRTT)) { … }
TEST_P(EndToEndTest, LargePostWithPacketLoss) { … }
TEST_P(EndToEndTest, LargePostWithPacketLossAndAlwaysBundleWindowUpdates) { … }
TEST_P(EndToEndTest, LargePostWithPacketLossAndBlockedSocket) { … }
TEST_P(EndToEndTest, LargePostNoPacketLossWithDelayAndReordering) { … }
TEST_P(EndToEndTest, QUICHE_SLOW_TEST(AddressToken)) { … }
TEST_P(EndToEndTest, QUICHE_SLOW_TEST(AddressTokenNotReusedByClient)) { … }
TEST_P(EndToEndTest, LargePostZeroRTTFailure) { … }
TEST_P(EndToEndTest, MultipleZeroRtt) { … }
TEST_P(EndToEndTest, SynchronousRequestZeroRTTFailure) { … }
TEST_P(EndToEndTest, LargePostSynchronousRequest) { … }
TEST_P(EndToEndTest, DisableResumption) { … }
TEST_P(EndToEndTest, PostZeroRTTRequestDuringHandshake) { … }
TEST_P(EndToEndTest, RetransmissionAfterZeroRTTRejectBeforeOneRtt) { … }
TEST_P(EndToEndTest, RejectWithPacketLoss) { … }
TEST_P(EndToEndTest, SetInitialReceivedConnectionOptions) { … }
TEST_P(EndToEndTest, LargePostSmallBandwidthLargeBuffer) { … }
TEST_P(EndToEndTest, DoNotSetSendAlarmIfConnectionFlowControlBlocked) { … }
TEST_P(EndToEndTest, InvalidStream) { … }
TEST_P(EndToEndTest, LargeHeaders) { … }
TEST_P(EndToEndTest, EarlyResponseWithQuicStreamNoError) { … }
TEST_P(EndToEndTest, QUIC_TEST_DISABLED_IN_CHROME(MultipleTermination)) { … }
TEST_P(EndToEndTest, Timeout) { … }
TEST_P(EndToEndTest, MaxDynamicStreamsLimitRespected) { … }
TEST_P(EndToEndTest, SetIndependentMaxDynamicStreamsLimits) { … }
TEST_P(EndToEndTest, NegotiateCongestionControl) { … }
TEST_P(EndToEndTest, ClientSuggestsRTT) { … }
TEST_P(EndToEndTest, ClientSuggestsIgnoredRTT) { … }
TEST_P(EndToEndTest, ClientDisablesGQuicZeroRtt) { … }
TEST_P(EndToEndTest, MaxInitialRTT) { … }
TEST_P(EndToEndTest, MinInitialRTT) { … }
TEST_P(EndToEndTest, ResetConnection) { … }
TEST_P(
EndToEndTest,
HalfRttResponseBlocksShloRetransmissionWithoutTokenBasedAddressValidation) { … }
TEST_P(EndToEndTest, MaxStreamsUberTest) { … }
TEST_P(EndToEndTest, StreamCancelErrorTest) { … }
TEST_P(EndToEndTest, ConnectionMigrationClientIPChanged) { … }
TEST_P(EndToEndTest, IetfConnectionMigrationClientIPChangedMultipleTimes) { … }
TEST_P(EndToEndTest,
ConnectionMigrationWithNonZeroConnectionIDClientIPChangedMultipleTimes) { … }
TEST_P(EndToEndTest, ConnectionMigrationNewTokenForNewIp) { … }
class DuplicatePacketWithSpoofedSelfAddressWriter
: public QuicPacketWriterWrapper { … };
TEST_P(EndToEndTest, ClientAddressSpoofedForSomePeriod) { … }
TEST_P(EndToEndTest,
AsynchronousConnectionMigrationClientIPChangedMultipleTimes) { … }
TEST_P(EndToEndTest,
AsynchronousConnectionMigrationClientIPChangedWithNonEmptyClientCID) { … }
TEST_P(EndToEndTest, ConnectionMigrationClientPortChanged) { … }
TEST_P(EndToEndTest, NegotiatedInitialCongestionWindow) { … }
TEST_P(EndToEndTest, DifferentFlowControlWindows) { … }
TEST_P(EndToEndTest, NegotiatedServerInitialFlowControlWindow) { … }
TEST_P(EndToEndTest, HeadersAndCryptoStreamsNoConnectionFlowControl) { … }
TEST_P(EndToEndTest, FlowControlsSynced) { … }
TEST_P(EndToEndTest, RequestWithNoBodyWillNeverSendStreamFrameWithFIN) { … }
class TestAckListener : public QuicAckListenerInterface { … };
class TestResponseListener : public QuicSpdyClientBase::ResponseListener { … };
TEST_P(EndToEndTest, AckNotifierWithPacketLossAndBlockedSocket) { … }
TEST_P(EndToEndTest, ServerSendPublicReset) { … }
TEST_P(EndToEndTest, ServerSendPublicResetWithDifferentConnectionId) { … }
TEST_P(EndToEndTest, InduceStatelessResetFromServer) { … }
TEST_P(EndToEndTest, ClientSendPublicResetWithDifferentConnectionId) { … }
TEST_P(EndToEndTest, ServerSendVersionNegotiationWithDifferentConnectionId) { … }
class DowngradePacketWriter : public PacketDroppingTestWriter { … };
TEST_P(EndToEndTest, VersionNegotiationDowngradeAttackIsDetected) { … }
TEST_P(EndToEndTest, BadPacketHeaderTruncated) { … }
TEST_P(EndToEndTest, BadPacketHeaderFlags) { … }
TEST_P(EndToEndTest, QUICHE_SLOW_TEST(BadEncryptedData)) { … }
TEST_P(EndToEndTest, CanceledStreamDoesNotBecomeZombie) { … }
class ServerStreamWithErrorResponseBody : public QuicSimpleServerStream { … };
class StreamWithErrorFactory : public QuicTestServer::StreamFactory { … };
class ServerStreamThatDropsBody : public QuicSimpleServerStream { … };
class ServerStreamThatDropsBodyFactory : public QuicTestServer::StreamFactory { … };
class ServerStreamThatSendsHugeResponse : public QuicSimpleServerStream { … };
class ServerStreamThatSendsHugeResponseFactory
: public QuicTestServer::StreamFactory { … };
class BlockedFrameObserver : public QuicConnectionDebugVisitor { … };
TEST_P(EndToEndTest, BlockedFrameIncludesOffset) { … }
TEST_P(EndToEndTest, EarlyResponseFinRecording) { … }
TEST_P(EndToEndTest, Trailers) { … }
TEST_P(EndToEndTest, DISABLED_TestHugePostWithPacketLoss) { … }
TEST_P(EndToEndTest, DISABLED_TestHugeResponseWithPacketLoss) { … }
TEST_P(EndToEndTest, ReleaseHeadersStreamBufferWhenIdle) { … }
TEST_P(EndToEndTest, WayTooLongRequestHeaders) { … }
class WindowUpdateObserver : public QuicConnectionDebugVisitor { … };
TEST_P(EndToEndTest, WindowUpdateInAck) { … }
TEST_P(EndToEndTest, SendStatelessResetTokenInShlo) { … }
TEST_P(EndToEndTest,
SendStatelessResetIfServerConnectionClosedLocallyDuringHandshake) { … }
TEST_P(EndToEndTest,
SendStatelessResetIfServerConnectionClosedLocallyAfterHandshake) { … }
TEST_P(EndToEndTest, DoNotCrashOnPacketWriteError) { … }
TEST_P(EndToEndTest, LastPacketSentIsConnectivityProbing) { … }
TEST_P(EndToEndTest, PreSharedKey) { … }
TEST_P(EndToEndTest, QUIC_TEST_DISABLED_IN_CHROME(PreSharedKeyMismatch)) { … }
TEST_P(EndToEndTest, QUIC_TEST_DISABLED_IN_CHROME(PreSharedKeyNoClient)) { … }
TEST_P(EndToEndTest, QUIC_TEST_DISABLED_IN_CHROME(PreSharedKeyNoServer)) { … }
TEST_P(EndToEndTest, RequestAndStreamRstInOnePacket) { … }
TEST_P(EndToEndTest, ResetStreamOnTtlExpires) { … }
TEST_P(EndToEndTest, SendMessages) { … }
class EndToEndPacketReorderingTest : public EndToEndTest { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(EndToEndPacketReorderingTest, ReorderedConnectivityProbing) { … }
class PacketHoldingWriter : public QuicPacketWriterWrapper { … };
TEST_P(EndToEndTest, ClientValidateNewNetwork) { … }
TEST_P(EndToEndTest, ClientMultiPortConnection) { … }
TEST_P(EndToEndTest, ClientPortMigrationOnPathDegrading) { … }
TEST_P(EndToEndTest, ClientLimitPortMigrationOnPathDegrading) { … }
TEST_P(EndToEndTest, ClientMultiPortMigrationOnPathDegrading) { … }
TEST_P(EndToEndTest, SimpleServerPreferredAddressTest) { … }
TEST_P(EndToEndTest, SimpleServerPreferredAddressTestNoSPAD) { … }
TEST_P(EndToEndTest, OptimizedServerPreferredAddress) { … }
TEST_P(EndToEndPacketReorderingTest, ReorderedPathChallenge) { … }
TEST_P(EndToEndPacketReorderingTest, PathValidationFailure) { … }
TEST_P(EndToEndPacketReorderingTest, MigrateAgainAfterPathValidationFailure) { … }
TEST_P(EndToEndPacketReorderingTest,
MigrateAgainAfterPathValidationFailureWithNonZeroClientCid) { … }
TEST_P(EndToEndPacketReorderingTest, Buffer0RttRequest) { … }
TEST_P(EndToEndTest, SimpleStopSendingRstStreamTest) { … }
class BadShloPacketWriter : public QuicPacketWriterWrapper { … };
TEST_P(EndToEndTest, ConnectionCloseBeforeHandshakeComplete) { … }
class BadShloPacketWriter2 : public QuicPacketWriterWrapper { … };
TEST_P(EndToEndTest, ForwardSecureConnectionClose) { … }
TEST_P(EndToEndTest, TooBigStreamIdClosesConnection) { … }
TEST_P(EndToEndTest, CustomTransportParameters) { … }
class CopyingPacketWriter : public PacketDroppingTestWriter { … };
TEST_P(EndToEndTest, KeyUpdateInitiatedByClient) { … }
TEST_P(EndToEndTest, KeyUpdateInitiatedByServer) { … }
TEST_P(EndToEndTest, KeyUpdateInitiatedByBoth) { … }
TEST_P(EndToEndTest, KeyUpdateInitiatedByConfidentialityLimit) { … }
TEST_P(EndToEndTest, TlsResumptionEnabledOnTheFly) { … }
TEST_P(EndToEndTest, TlsResumptionDisabledOnTheFly) { … }
TEST_P(EndToEndTest, BlockServerUntilSettingsReceived) { … }
TEST_P(EndToEndTest, WebTransportSessionSetup) { … }
TEST_P(EndToEndTest, WebTransportSessionSetupWithEchoWithSuffix) { … }
TEST_P(EndToEndTest, WebTransportSessionWithLoss) { … }
TEST_P(EndToEndTest, WebTransportSessionUnidirectionalStream) { … }
TEST_P(EndToEndTest, WebTransportSessionUnidirectionalStreamSentEarly) { … }
TEST_P(EndToEndTest, WebTransportSessionBidirectionalStream) { … }
TEST_P(EndToEndTest, WebTransportSessionBidirectionalStreamWithBuffering) { … }
TEST_P(EndToEndTest, WebTransportSessionServerBidirectionalStream) { … }
TEST_P(EndToEndTest, WebTransportDatagrams) { … }
TEST_P(EndToEndTest, WebTransportSessionClose) { … }
TEST_P(EndToEndTest, WebTransportSessionCloseWithoutCapsule) { … }
TEST_P(EndToEndTest, WebTransportSessionReceiveClose) { … }
TEST_P(EndToEndTest, WebTransportSessionReceiveDrain) { … }
TEST_P(EndToEndTest, WebTransportSessionStreamTermination) { … }
TEST_P(EndToEndTest, DISABLED_WebTransportSessionResetReliability) { … }
TEST_P(EndToEndTest, WebTransportSession404) { … }
TEST_P(EndToEndTest, WebTransportSessionGoaway) { … }
TEST_P(EndToEndTest, InvalidExtendedConnect) { … }
TEST_P(EndToEndTest, RejectExtendedConnect) { … }
TEST_P(EndToEndTest, RejectInvalidRequestHeader) { … }
TEST_P(EndToEndTest, RejectTransferEncodingResponse) { … }
TEST_P(EndToEndTest, RejectUpperCaseRequest) { … }
TEST_P(EndToEndTest, RejectRequestWithInvalidToken) { … }
TEST_P(EndToEndTest, OriginalConnectionIdClearedFromMap) { … }
TEST_P(EndToEndTest, ServerReportsNotEct) { … }
TEST_P(EndToEndTest, ServerReportsEct0) { … }
TEST_P(EndToEndTest, ServerReportsEct1) { … }
TEST_P(EndToEndTest, ServerReportsCe) { … }
TEST_P(EndToEndTest, ClientReportsEct1) { … }
TEST_P(EndToEndTest, ClientMigrationAfterHalfwayServerMigration) { … }
TEST_P(EndToEndTest, MultiPortCreationFollowingServerMigration) { … }
TEST_P(EndToEndTest, DoNotAdvertisePreferredAddressWithoutSPAD) { … }
TEST_P(EndToEndTest, MaxPacingRate) { … }
TEST_P(EndToEndTest, RequestsBurstMitigation) { … }
TEST_P(EndToEndTest, SerializeConnectionClosePacketWithLargestPacketNumber) { … }
}
}
}