#include "net/socket/connect_job_params_factory.h"
#include <ostream>
#include <tuple>
#include "base/containers/flat_set.h"
#include "base/memory/scoped_refptr.h"
#include "base/strings/strcat.h"
#include "base/test/scoped_feature_list.h"
#include "net/base/features.h"
#include "net/base/host_port_pair.h"
#include "net/base/network_anonymization_key.h"
#include "net/base/privacy_mode.h"
#include "net/base/proxy_chain.h"
#include "net/base/proxy_server.h"
#include "net/base/schemeful_site.h"
#include "net/dns/public/secure_dns_policy.h"
#include "net/http/http_proxy_connect_job.h"
#include "net/socket/connect_job_factory.h"
#include "net/socket/next_proto.h"
#include "net/socket/socks_connect_job.h"
#include "net/socket/ssl_connect_job.h"
#include "net/socket/transport_connect_job.h"
#include "net/ssl/ssl_config.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
#include "url/gurl.h"
#include "url/scheme_host_port.h"
namespace net {
namespace {
struct TestParams { … };
std::ostream& operator<<(std::ostream& os, const TestParams& test_params) { … }
const char* ParamsName(ConnectJobParams& params) { … }
scoped_refptr<HttpProxySocketParams> ExpectHttpProxySocketParams(
ConnectJobParams params) { … }
void VerifyHttpProxySocketParams(
scoped_refptr<HttpProxySocketParams> params,
const char* description,
std::optional<SSLConfig> quic_ssl_config,
const HostPortPair& endpoint,
const ProxyChain& proxy_chain,
size_t proxy_chain_index,
bool tunnel,
const NetworkAnonymizationKey& network_anonymization_key,
const SecureDnsPolicy secure_dns_policy) { … }
scoped_refptr<SOCKSSocketParams> ExpectSOCKSSocketParams(
ConnectJobParams params) { … }
void VerifySOCKSSocketParams(
scoped_refptr<SOCKSSocketParams>& params,
const char* description,
bool is_socks_v5,
const HostPortPair& destination,
const NetworkAnonymizationKey& network_anonymization_key) { … }
scoped_refptr<TransportSocketParams> ExpectTransportSocketParams(
ConnectJobParams params) { … }
void VerifyTransportSocketParams(
scoped_refptr<TransportSocketParams>& params,
const char* description,
const TransportSocketParams::Endpoint destination,
const SecureDnsPolicy secure_dns_policy,
const NetworkAnonymizationKey& network_anonymization_key,
const base::flat_set<std::string>& supported_alpns) { … }
scoped_refptr<SSLSocketParams> ExpectSSLSocketParams(ConnectJobParams params) { … }
void VerifySSLSocketParams(
scoped_refptr<SSLSocketParams>& params,
const char* description,
const HostPortPair& host_and_port,
const SSLConfig& ssl_config,
PrivacyMode privacy_mode,
const NetworkAnonymizationKey& network_anonymization_key) { … }
base::flat_set<std::string> AlpnProtoStringsForMode(
ConnectJobFactory::AlpnMode alpn_mode) { … }
class ConnectJobParamsFactoryTest : public testing::TestWithParam<TestParams> { … };
TEST_P(ConnectJobParamsFactoryTest, HttpEndpoint) { … }
TEST_P(ConnectJobParamsFactoryTest, UnencryptedEndpointWithoutScheme) { … }
TEST_P(ConnectJobParamsFactoryTest, HttpsEndpoint) { … }
TEST_P(ConnectJobParamsFactoryTest, EncryptedEndpointWithoutScheme) { … }
TEST_P(ConnectJobParamsFactoryTest, HttpEndpointViaHttpsProxy) { … }
TEST_P(ConnectJobParamsFactoryTest, HttpEndpointViaQuicProxy) { … }
TEST_P(ConnectJobParamsFactoryTest, HttpsEndpointViaHttpsProxy) { … }
TEST_P(ConnectJobParamsFactoryTest, HttpsEndpointViaQuicProxy) { … }
TEST_P(ConnectJobParamsFactoryTest, HttpsEndpointViaHttpProxy) { … }
TEST_P(ConnectJobParamsFactoryTest, HttpEndpointViaSOCKSProxy) { … }
TEST_P(ConnectJobParamsFactoryTest, HttpsEndpointViaSOCKSProxy) { … }
TEST_P(ConnectJobParamsFactoryTest, HttpEndpointViaHttpsProxyViaHttpsProxy) { … }
TEST_P(ConnectJobParamsFactoryTest, HttpsEndpointViaHttpsProxyViaHttpsProxy) { … }
TEST_P(ConnectJobParamsFactoryTest, HttpsEndpointViaHttpsProxyViaQuicProxy) { … }
TEST_P(ConnectJobParamsFactoryTest, HttpsEndpointViaQuicProxyViaQuicProxy) { … }
TEST_P(ConnectJobParamsFactoryTest, HttpsEndpointViaMixedProxyChain) { … }
INSTANTIATE_TEST_SUITE_P(…);
}
}