#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "net/spdy/spdy_session.h"
#include <algorithm>
#include <optional>
#include <string>
#include <string_view>
#include <tuple>
#include <utility>
#include "base/base64.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "net/base/features.h"
#include "net/base/hex_utils.h"
#include "net/base/host_port_pair.h"
#include "net/base/io_buffer.h"
#include "net/base/ip_endpoint.h"
#include "net/base/network_anonymization_key.h"
#include "net/base/privacy_mode.h"
#include "net/base/proxy_chain.h"
#include "net/base/proxy_delegate.h"
#include "net/base/proxy_server.h"
#include "net/base/request_priority.h"
#include "net/base/schemeful_site.h"
#include "net/base/session_usage.h"
#include "net/base/test_completion_callback.h"
#include "net/base/test_data_stream.h"
#include "net/cert/ct_policy_status.h"
#include "net/dns/public/host_resolver_results.h"
#include "net/dns/public/secure_dns_policy.h"
#include "net/http/http_request_info.h"
#include "net/http/transport_security_state_test_util.h"
#include "net/log/net_log.h"
#include "net/log/net_log_event_type.h"
#include "net/log/net_log_source.h"
#include "net/log/test_net_log.h"
#include "net/log/test_net_log_util.h"
#include "net/nqe/network_quality_estimator_test_util.h"
#include "net/socket/client_socket_pool.h"
#include "net/socket/client_socket_pool_manager.h"
#include "net/socket/socket_tag.h"
#include "net/socket/socket_test_util.h"
#include "net/socket/transport_connect_job.h"
#include "net/spdy/alps_decoder.h"
#include "net/spdy/spdy_http_utils.h"
#include "net/spdy/spdy_session_pool.h"
#include "net/spdy/spdy_session_test_util.h"
#include "net/spdy/spdy_stream.h"
#include "net/spdy/spdy_stream_test_util.h"
#include "net/spdy/spdy_test_util_common.h"
#include "net/test/cert_test_util.h"
#include "net/test/gtest_util.h"
#include "net/test/test_data_directory.h"
#include "net/test/test_with_task_environment.h"
#include "net/third_party/quiche/src/quiche/common/http/http_header_block.h"
#include "net/third_party/quiche/src/quiche/http2/test_tools/spdy_test_utils.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/platform_test.h"
#include "url/gurl.h"
#include "url/scheme_host_port.h"
#include "url/url_constants.h"
IsError;
IsOk;
_;
namespace net {
namespace {
const char kBodyData[] = …;
const size_t kBodyDataSize = …;
const std::string_view kBodyDataStringPiece(kBodyData, kBodyDataSize);
static base::TimeDelta g_time_delta;
static base::TimeTicks g_time_now;
base::TimeTicks TheNearFuture() { … }
base::TimeTicks SlowReads() { … }
base::TimeTicks InstantaneousReads() { … }
class MockRequireCTDelegate : public TransportSecurityState::RequireCTDelegate { … };
class SpdySessionRequestDelegate
: public SpdySessionPool::SpdySessionRequest::Delegate { … };
}
class SpdySessionTest : public PlatformTest, public WithTaskEnvironment { … };
class SpdySessionTestWithMockTime : public SpdySessionTest { … };
TEST_F(SpdySessionTest, InitialReadError) { … }
namespace {
class StreamRequestDestroyingCallback : public TestCompletionCallbackBase { … };
}
TEST_F(SpdySessionTest, PendingStreamCancellingAnother) { … }
TEST_F(SpdySessionTest, GoAwayWithNoActiveStreams) { … }
TEST_F(SpdySessionTest, GoAwayImmediatelyWithNoActiveStreams) { … }
TEST_F(SpdySessionTest, GoAwayWithActiveStreams) { … }
TEST_F(SpdySessionTest, GoAwayWithActiveAndCreatedStream) { … }
TEST_F(SpdySessionTest, GoAwayTwice) { … }
TEST_F(SpdySessionTest, GoAwayWithActiveStreamsThenClose) { … }
TEST_F(SpdySessionTest, GoAwayWhileDraining) { … }
TEST_F(SpdySessionTest, GoAwayWithActiveStreamsThenEndStreams) { … }
TEST_F(SpdySessionTest, CreateStreamAfterGoAway) { … }
TEST_F(SpdySessionTest, HeadersAfterGoAway) { … }
TEST_F(SpdySessionTest, NetworkChangeWithActiveStreams) { … }
TEST_F(SpdySessionTestWithMockTime, ClientPing) { … }
TEST_F(SpdySessionTest, ServerPing) { … }
TEST_F(SpdySessionTest, PingAndWriteLoop) { … }
TEST_F(SpdySessionTestWithMockTime, DetectBrokenConnectionPing) { … }
TEST_F(SpdySessionTest, StreamIdSpaceExhausted) { … }
TEST_F(SpdySessionTest, MaxConcurrentStreamsZero) { … }
TEST_F(SpdySessionTest, UnstallRacesWithStreamCreation) { … }
TEST_F(SpdySessionTestWithMockTime, FailedPing) { … }
TEST_F(SpdySessionTestWithMockTime, NoPingSentWhenCheckPingPending) { … }
TEST_F(SpdySessionTest, OnSettings) { … }
TEST_F(SpdySessionTest, CancelPendingCreateStream) { … }
TEST_F(SpdySessionTest, ChangeStreamRequestPriority) { … }
bool NetLogSourceFromEventParameters(const base::Value::Dict* event_params,
NetLogSource* source) { … }
TEST_F(SpdySessionTest, Initialize) { … }
TEST_F(SpdySessionTest, NetLogOnSessionGoaway) { … }
TEST_F(SpdySessionTest, NetLogOnSessionEOF) { … }
TEST_F(SpdySessionTest, HeadersCompressionHistograms) { … }
TEST_F(SpdySessionTest, OutOfOrderHeaders) { … }
TEST_F(SpdySessionTest, CancelStream) { … }
TEST_F(SpdySessionTest, CloseSessionWithTwoCreatedSelfClosingStreams) { … }
TEST_F(SpdySessionTest, CloseSessionWithTwoCreatedMutuallyClosingStreams) { … }
TEST_F(SpdySessionTest, CloseSessionWithTwoActivatedSelfClosingStreams) { … }
TEST_F(SpdySessionTest, CloseSessionWithTwoActivatedMutuallyClosingStreams) { … }
class SessionClosingDelegate : public test::StreamDelegateDoNothing { … };
TEST_F(SpdySessionTest, CloseActivatedStreamThatClosesSession) { … }
TEST_F(SpdySessionTest, VerifyDomainAuthentication) { … }
TEST_F(SpdySessionTest, CloseTwoStalledCreateStream) { … }
TEST_F(SpdySessionTest, CancelTwoStalledCreateStream) { … }
TEST_F(SpdySessionTest, ReadDataWithoutYielding) { … }
TEST_F(SpdySessionTest, TestYieldingSlowReads) { … }
TEST_F(SpdySessionTest, TestYieldingSlowSynchronousReads) { … }
TEST_F(SpdySessionTest, TestYieldingDuringReadData) { … }
TEST_F(SpdySessionTest, TestYieldingDuringAsyncReadData) { … }
TEST_F(SpdySessionTest, GoAwayWhileInDoReadLoop) { … }
TEST_F(SpdySessionTest, ProtocolNegotiation) { … }
TEST_F(SpdySessionTest, CloseOneIdleConnection) { … }
TEST_F(SpdySessionTest, CloseOneIdleConnectionWithAlias) { … }
TEST_F(SpdySessionTest, CloseSessionOnIdleWhenPoolStalled) { … }
TEST_F(SpdySessionTest, SpdySessionKeyPrivacyMode) { … }
class StreamCreatingDelegate : public test::StreamDelegateDoNothing { … };
TEST_F(SpdySessionTest, CreateStreamOnStreamReset) { … }
TEST_F(SpdySessionTest, UpdateStreamsSendWindowSize) { … }
TEST_F(SpdySessionTest, AdjustRecvWindowSize) { … }
TEST_F(SpdySessionTestWithMockTime, FlowControlSlowReads) { … }
TEST_F(SpdySessionTest, AdjustSendWindowSize) { … }
TEST_F(SpdySessionTest, SessionFlowControlInactiveStream) { … }
TEST_F(SpdySessionTest, SessionFlowControlPadding) { … }
TEST_F(SpdySessionTest, StreamFlowControlTooMuchData) { … }
TEST_F(SpdySessionTest, SessionFlowControlTooMuchDataTwoDataFrames) { … }
TEST_F(SpdySessionTest, StreamFlowControlTooMuchDataTwoDataFrames) { … }
class DropReceivedDataDelegate : public test::StreamDelegateSendImmediate { … };
TEST_F(SpdySessionTest, SessionFlowControlNoReceiveLeaks) { … }
TEST_F(SpdySessionTest, SessionFlowControlNoSendLeaks) { … }
TEST_F(SpdySessionTest, SessionFlowControlEndToEnd) { … }
void SpdySessionTest::RunResumeAfterUnstallTest(
base::OnceCallback<void(SpdyStream*)> stall_function,
base::OnceCallback<void(SpdyStream*, int32_t)> unstall_function) { … }
TEST_F(SpdySessionTest, ResumeAfterUnstallSession) { … }
TEST_F(SpdySessionTest, ResumeAfterUnstallStream) { … }
TEST_F(SpdySessionTest, StallSessionStreamResumeAfterUnstallSessionStream) { … }
TEST_F(SpdySessionTest, StallStreamSessionResumeAfterUnstallSessionStream) { … }
TEST_F(SpdySessionTest, StallStreamSessionResumeAfterUnstallStreamSession) { … }
TEST_F(SpdySessionTest, StallSessionStreamResumeAfterUnstallStreamSession) { … }
TEST_F(SpdySessionTest, ResumeByPriorityAfterSendWindowSizeIncrease) { … }
TEST_F(SpdySessionTest, ResumeSessionWithStalledStream) { … }
class StreamBrokenConnectionDetectionCheckDelegate
: public test::StreamDelegateDoNothing { … };
TEST_F(SpdySessionTest, BrokenConnectionDetectionEOF) { … }
TEST_F(SpdySessionTest, BrokenConnectionDetectionCloseSession) { … }
TEST_F(SpdySessionTest, BrokenConnectionDetectionCloseStream) { … }
TEST_F(SpdySessionTest, BrokenConnectionDetectionCancelStream) { … }
TEST_F(SpdySessionTest, BrokenConnectionDetectionMultipleRequests) { … }
class StreamClosingDelegate : public test::StreamDelegateWithBody { … };
TEST_F(SpdySessionTest, SendWindowSizeIncreaseWithDeletedStreams) { … }
TEST_F(SpdySessionTest, SendWindowSizeIncreaseWithDeletedSession) { … }
TEST_F(SpdySessionTest, GoAwayOnSessionFlowControlError) { … }
TEST_F(SpdySessionTest, RejectInvalidUnknownFrames) { … }
TEST_F(SpdySessionTest, EnableWebSocket) { … }
TEST_F(SpdySessionTest, DisableWebSocketDoesNothing) { … }
TEST_F(SpdySessionTest, EnableWebSocketThenDisableIsProtocolError) { … }
TEST_F(SpdySessionTest, GreaseFrameTypeAfterSettings) { … }
enum ReadIfReadySupport { … };
class SpdySessionReadIfReadyTest
: public SpdySessionTest,
public testing::WithParamInterface<ReadIfReadySupport> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(SpdySessionReadIfReadyTest, ReadIfReady) { … }
class SendInitialSettingsOnNewSpdySessionTest : public SpdySessionTest { … };
TEST_F(SendInitialSettingsOnNewSpdySessionTest, Empty) { … }
TEST_F(SendInitialSettingsOnNewSpdySessionTest, ProtocolDefault) { … }
TEST_F(SendInitialSettingsOnNewSpdySessionTest, OverwriteValues) { … }
TEST_F(SendInitialSettingsOnNewSpdySessionTest, UnknownSettings) { … }
class AltSvcFrameTest : public SpdySessionTest { … };
TEST_F(AltSvcFrameTest, ProcessAltSvcFrame) { … }
TEST_F(AltSvcFrameTest, IgnoreQuicAltSvcWithUnsupportedVersion) { … }
TEST_F(AltSvcFrameTest, DoNotProcessAltSvcFrameForOriginNotCoveredByCert) { … }
TEST_F(AltSvcFrameTest, DoNotProcessAltSvcFrameWithEmptyOriginOnStreamZero) { … }
TEST_F(AltSvcFrameTest,
DoNotProcessAltSvcFrameWithNonEmptyOriginOnNonZeroStream) { … }
TEST_F(AltSvcFrameTest, ProcessAltSvcFrameOnActiveStream) { … }
TEST_F(AltSvcFrameTest,
ProcessAltSvcFrameOnActiveStreamWithNetworkAnonymizationKey) { … }
TEST_F(AltSvcFrameTest, DoNotProcessAltSvcFrameOnStreamWithInsecureOrigin) { … }
TEST_F(AltSvcFrameTest, DoNotProcessAltSvcFrameOnNonExistentStream) { … }
TEST_F(AltSvcFrameTest, InvalidOrigin) { … }
TEST(MapFramerErrorToProtocolError, MapsValues) { … }
TEST(MapFramerErrorToNetError, MapsValue) { … }
TEST(MapRstStreamStatusToProtocolError, MapsValues) { … }
TEST(MapNetErrorToGoAwayStatus, MapsValue) { … }
namespace {
class TestSSLConfigService : public SSLConfigService { … };
}
TEST(CanPoolTest, CanPool) { … }
TEST(CanPoolTest, CanNotPoolWithCertErrors) { … }
TEST(CanPoolTest, CanNotPoolWithClientCerts) { … }
TEST(CanPoolTest, CanNotPoolWithBadPins) { … }
TEST(CanPoolTest, CanNotPoolWithBadCTWhenCTRequired) { … }
TEST(CanPoolTest, CanPoolWithBadCTWhenCTNotRequired) { … }
TEST(CanPoolTest, CanPoolWithGoodCTWhenCTRequired) { … }
TEST(CanPoolTest, CanPoolWithAcceptablePins) { … }
TEST(CanPoolTest, CanPoolWithClientCertsAndPolicy) { … }
TEST_F(SpdySessionTest, UpdateHeaderTableSize) { … }
TEST_F(SpdySessionTest, PriorityUpdateDisabled) { … }
TEST_F(SpdySessionTest, PriorityUpdateEnabledHttp2PrioritiesDeprecated) { … }
TEST_F(SpdySessionTest, PriorityUpdateEnabledHttp2PrioritiesNotDeprecated) { … }
TEST_F(SpdySessionTest, SettingsDeprecateHttp2PrioritiesValueMustNotChange) { … }
TEST_F(SpdySessionTest, AlpsEmpty) { … }
TEST_F(SpdySessionTest, AlpsSettings) { … }
TEST_F(SpdySessionTest, AlpsAcceptCh) { … }
TEST_F(SpdySessionTest, AlpsAcceptChInvalidOrigin) { … }
TEST_F(SpdySessionTest, ConfirmHandshakeAfterClose) { … }
}