#include "net/http/http_proxy_connect_job.h"
#include <algorithm>
#include <map>
#include <string>
#include <utility>
#include "base/metrics/field_trial.h"
#include "base/metrics/field_trial_param_associator.h"
#include "base/metrics/field_trial_params.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.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/net_errors.h"
#include "net/base/network_anonymization_key.h"
#include "net/base/proxy_chain.h"
#include "net/base/proxy_string_util.h"
#include "net/base/session_usage.h"
#include "net/base/test_proxy_delegate.h"
#include "net/cert/mock_cert_verifier.h"
#include "net/dns/mock_host_resolver.h"
#include "net/dns/public/secure_dns_policy.h"
#include "net/http/http_network_session.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_server_properties.h"
#include "net/http/transport_security_state.h"
#include "net/nqe/network_quality_estimator_test_util.h"
#include "net/quic/quic_context.h"
#include "net/quic/quic_session_pool.h"
#include "net/socket/client_socket_handle.h"
#include "net/socket/connect_job_test_util.h"
#include "net/socket/socket_test_util.h"
#include "net/socket/socks_connect_job.h"
#include "net/socket/ssl_client_socket.h"
#include "net/socket/ssl_connect_job.h"
#include "net/socket/transport_connect_job.h"
#include "net/spdy/spdy_test_util_common.h"
#include "net/ssl/ssl_connection_status_flags.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/quic/core/quic_versions.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "net/url_request/static_http_user_agent_settings.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#include "url/scheme_host_port.h"
_;
namespace net {
namespace {
const char kEndpointHost[] = …;
enum HttpProxyType { … };
const char kHttpProxyHost[] = …;
const char kHttpsProxyHost[] = …;
const char kQuicProxyHost[] = …;
const char kHttpsNestedProxyHost[] = …;
const ProxyServer kHttpProxyServer{ … };
const ProxyServer kHttpsProxyServer{ … };
const ProxyServer kHttpsNestedProxyServer{ … };
const ProxyChain kHttpProxyChain{ … };
const ProxyChain kHttpsProxyChain{ … };
const ProxyChain kHttpsNestedProxyChain{ … };
constexpr char kTestHeaderName[] = …;
constexpr char kTestSpdyHeaderName[] = …;
MATCHER_P(QSRHasProxyChain,
proxy_chain,
base::StringPrintf("QuicStreamRequest %s ProxyChain %s",
negation ? "does not have" : "has",
proxy_chain.ToDebugString().c_str())) { … }
MATCHER_P(
IsQuicVersion,
quic_version,
base::StringPrintf("QUIC version %s %s",
negation ? "is not" : "is",
quic::ParsedQuicVersionToString(quic_version).c_str())) { … }
}
class HttpProxyConnectJobTestBase : public WithTaskEnvironment { … };
class HttpProxyConnectJobTest : public HttpProxyConnectJobTestBase,
public ::testing::TestWithParam<HttpProxyType> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(HttpProxyConnectJobTest, NoTunnel) { … }
TEST_P(HttpProxyConnectJobTest, HasEstablishedConnectionNoTunnel) { … }
TEST_P(HttpProxyConnectJobTest, HasEstablishedConnectionTunnel) { … }
TEST_P(HttpProxyConnectJobTest, ProxyDelegateExtraHeaders) { … }
TEST_P(HttpProxyConnectJobTest, NestedProxyProxyDelegateExtraHeaders) { … }
TEST_P(HttpProxyConnectJobTest, NeedAuth) { … }
TEST_P(HttpProxyConnectJobTest, NeedAuthTwice) { … }
TEST_P(HttpProxyConnectJobTest, HaveAuth) { … }
TEST_P(HttpProxyConnectJobTest, HostResolutionFailure) { … }
TEST_P(HttpProxyConnectJobTest, RequestPriority) { … }
TEST_P(HttpProxyConnectJobTest, SecureDnsPolicy) { … }
TEST_P(HttpProxyConnectJobTest, SpdySessionKeyDisableSecureDns) { … }
TEST_P(HttpProxyConnectJobTest, SetSpdySessionSocketRequestPriority) { … }
TEST_P(HttpProxyConnectJobTest, SpdyInadequateTransportSecurity) { … }
TEST_P(HttpProxyConnectJobTest, SpdyValidAlps) { … }
TEST_P(HttpProxyConnectJobTest, SpdyInvalidAlpsCheckEnabled) { … }
TEST_P(HttpProxyConnectJobTest, SpdyInvalidAlpsCheckDisabled) { … }
TEST_P(HttpProxyConnectJobTest, TCPError) { … }
TEST_P(HttpProxyConnectJobTest, SSLError) { … }
TEST_P(HttpProxyConnectJobTest, TunnelUnexpectedClose) { … }
TEST_P(HttpProxyConnectJobTest, Tunnel1xxResponse) { … }
TEST_P(HttpProxyConnectJobTest, TunnelSetupError) { … }
TEST_P(HttpProxyConnectJobTest, SslClientAuth) { … }
TEST_P(HttpProxyConnectJobTest, TunnelSetupRedirect) { … }
TEST_P(HttpProxyConnectJobTest, TestTimeoutsAuthChallenge) { … }
TEST_P(HttpProxyConnectJobTest, TestTimeoutsAuthChallengeNewConnection) { … }
TEST_P(HttpProxyConnectJobTest, ConnectionTimeoutNoNQE) { … }
TEST_P(HttpProxyConnectJobTest, ConnectionTimeoutMin) { … }
TEST_P(HttpProxyConnectJobTest, ConnectionTimeoutMax) { … }
TEST_P(HttpProxyConnectJobTest, ConnectionTimeoutWithExperiment) { … }
TEST_P(HttpProxyConnectJobTest, ConnectionTimeoutExperimentDifferentParams) { … }
TEST_P(HttpProxyConnectJobTest, ConnectionTimeoutWithConnectionProperty) { … }
TEST_P(HttpProxyConnectJobTest, ProxyPoolTimeoutWithExperimentDefaultParams) { … }
class MockQuicSessionPool : public QuicSessionPool { … };
class HttpProxyConnectQuicJobTest : public HttpProxyConnectJobTestBase,
public testing::Test { … };
TEST_F(HttpProxyConnectQuicJobTest, RequestQuicProxy) { … }
TEST_F(HttpProxyConnectQuicJobTest, QuicProxyRequestUsesRfcV1) { … }
TEST_F(HttpProxyConnectQuicJobTest, RequestMultipleQuicProxies) { … }
}