• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "net/socket/connect_job_factory.h"
6 
7 #include <memory>
8 #include <vector>
9 
10 #include "base/memory/raw_ptr.h"
11 #include "base/memory/scoped_refptr.h"
12 #include "net/base/host_port_pair.h"
13 #include "net/base/network_isolation_key.h"
14 #include "net/base/privacy_mode.h"
15 #include "net/base/proxy_chain.h"
16 #include "net/base/proxy_server.h"
17 #include "net/base/request_priority.h"
18 #include "net/dns/public/secure_dns_policy.h"
19 #include "net/http/http_proxy_connect_job.h"
20 #include "net/log/net_log_with_source.h"
21 #include "net/socket/connect_job.h"
22 #include "net/socket/connect_job_test_util.h"
23 #include "net/socket/next_proto.h"
24 #include "net/socket/socket_tag.h"
25 #include "net/socket/socks_connect_job.h"
26 #include "net/socket/ssl_connect_job.h"
27 #include "net/socket/transport_connect_job.h"
28 #include "net/socket/websocket_endpoint_lock_manager.h"
29 #include "net/ssl/ssl_config.h"
30 #include "net/test/test_with_task_environment.h"
31 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
32 #include "testing/gmock/include/gmock/gmock.h"
33 #include "testing/gtest/include/gtest/gtest.h"
34 #include "third_party/abseil-cpp/absl/types/optional.h"
35 #include "url/scheme_host_port.h"
36 #include "url/url_constants.h"
37 
38 namespace net {
39 namespace {
40 
41 // Mock HttpProxyConnectJob::Factory that records the `params` used and then
42 // passes on to a real factory.
43 class TestHttpProxyConnectJobFactory : public HttpProxyConnectJob::Factory {
44  public:
Create(RequestPriority priority,const SocketTag & socket_tag,const CommonConnectJobParams * common_connect_job_params,scoped_refptr<HttpProxySocketParams> params,ConnectJob::Delegate * delegate,const NetLogWithSource * net_log)45   std::unique_ptr<HttpProxyConnectJob> Create(
46       RequestPriority priority,
47       const SocketTag& socket_tag,
48       const CommonConnectJobParams* common_connect_job_params,
49       scoped_refptr<HttpProxySocketParams> params,
50       ConnectJob::Delegate* delegate,
51       const NetLogWithSource* net_log) override {
52     params_.push_back(params);
53     return HttpProxyConnectJob::Factory::Create(priority, socket_tag,
54                                                 common_connect_job_params,
55                                                 params, delegate, net_log);
56   }
57 
params() const58   const std::vector<scoped_refptr<HttpProxySocketParams>>& params() const {
59     return params_;
60   }
61 
62  private:
63   std::vector<scoped_refptr<HttpProxySocketParams>> params_;
64 };
65 
66 // Mock SOCKSConnectJob::Factory that records the `params` used and then passes
67 // on to a real factory.
68 class TestSocksConnectJobFactory : public SOCKSConnectJob::Factory {
69  public:
Create(RequestPriority priority,const SocketTag & socket_tag,const CommonConnectJobParams * common_connect_job_params,scoped_refptr<SOCKSSocketParams> socks_params,ConnectJob::Delegate * delegate,const NetLogWithSource * net_log)70   std::unique_ptr<SOCKSConnectJob> Create(
71       RequestPriority priority,
72       const SocketTag& socket_tag,
73       const CommonConnectJobParams* common_connect_job_params,
74       scoped_refptr<SOCKSSocketParams> socks_params,
75       ConnectJob::Delegate* delegate,
76       const NetLogWithSource* net_log) override {
77     params_.push_back(socks_params);
78     return SOCKSConnectJob::Factory::Create(priority, socket_tag,
79                                             common_connect_job_params,
80                                             socks_params, delegate, net_log);
81   }
82 
params() const83   const std::vector<scoped_refptr<SOCKSSocketParams>>& params() const {
84     return params_;
85   }
86 
87  private:
88   std::vector<scoped_refptr<SOCKSSocketParams>> params_;
89 };
90 
91 // Mock SSLConnectJob::Factory that records the `params` used and then passes on
92 // to a real factory.
93 class TestSslConnectJobFactory : public SSLConnectJob::Factory {
94  public:
Create(RequestPriority priority,const SocketTag & socket_tag,const CommonConnectJobParams * common_connect_job_params,scoped_refptr<SSLSocketParams> params,ConnectJob::Delegate * delegate,const NetLogWithSource * net_log)95   std::unique_ptr<SSLConnectJob> Create(
96       RequestPriority priority,
97       const SocketTag& socket_tag,
98       const CommonConnectJobParams* common_connect_job_params,
99       scoped_refptr<SSLSocketParams> params,
100       ConnectJob::Delegate* delegate,
101       const NetLogWithSource* net_log) override {
102     params_.push_back(params);
103     return SSLConnectJob::Factory::Create(priority, socket_tag,
104                                           common_connect_job_params, params,
105                                           delegate, net_log);
106   }
107 
params() const108   const std::vector<scoped_refptr<SSLSocketParams>>& params() const {
109     return params_;
110   }
111 
112  private:
113   std::vector<scoped_refptr<SSLSocketParams>> params_;
114 };
115 
116 // Mock TransportConnectJob::Factory that records the `params` used and then
117 // passes on to a real factory.
118 class TestTransportConnectJobFactory : public TransportConnectJob::Factory {
119  public:
Create(RequestPriority priority,const SocketTag & socket_tag,const CommonConnectJobParams * common_connect_job_params,const scoped_refptr<TransportSocketParams> & params,ConnectJob::Delegate * delegate,const NetLogWithSource * net_log)120   std::unique_ptr<TransportConnectJob> Create(
121       RequestPriority priority,
122       const SocketTag& socket_tag,
123       const CommonConnectJobParams* common_connect_job_params,
124       const scoped_refptr<TransportSocketParams>& params,
125       ConnectJob::Delegate* delegate,
126       const NetLogWithSource* net_log) override {
127     params_.push_back(params);
128     return TransportConnectJob::Factory::Create(priority, socket_tag,
129                                                 common_connect_job_params,
130                                                 params, delegate, net_log);
131   }
132 
params() const133   const std::vector<scoped_refptr<TransportSocketParams>>& params() const {
134     return params_;
135   }
136 
137  private:
138   std::vector<scoped_refptr<TransportSocketParams>> params_;
139 };
140 
141 class ConnectJobFactoryTest : public TestWithTaskEnvironment {
142  public:
ConnectJobFactoryTest()143   ConnectJobFactoryTest() {
144     auto http_proxy_job_factory =
145         std::make_unique<TestHttpProxyConnectJobFactory>();
146     http_proxy_job_factory_ = http_proxy_job_factory.get();
147 
148     auto socks_job_factory = std::make_unique<TestSocksConnectJobFactory>();
149     socks_job_factory_ = socks_job_factory.get();
150 
151     auto ssl_job_factory = std::make_unique<TestSslConnectJobFactory>();
152     ssl_job_factory_ = ssl_job_factory.get();
153 
154     auto transport_job_factory =
155         std::make_unique<TestTransportConnectJobFactory>();
156     transport_job_factory_ = transport_job_factory.get();
157 
158     factory_ = std::make_unique<ConnectJobFactory>(
159         std::move(http_proxy_job_factory), std::move(socks_job_factory),
160         std::move(ssl_job_factory), std::move(transport_job_factory));
161   }
162 
163  protected:
164   // Gets the total number of ConnectJob creations across all types.
GetCreationCount() const165   size_t GetCreationCount() const {
166     return http_proxy_job_factory_->params().size() +
167            socks_job_factory_->params().size() +
168            ssl_job_factory_->params().size() +
169            transport_job_factory_->params().size();
170   }
171 
172   const CommonConnectJobParams common_connect_job_params_{
173       /*client_socket_factory=*/nullptr,
174       /*host_resolver=*/nullptr,
175       /*http_auth_cache=*/nullptr,
176       /*http_auth_handler_factory=*/nullptr,
177       /*spdy_session_pool=*/nullptr,
178       /*quic_supported_versions=*/nullptr,
179       /*quic_stream_factory=*/nullptr,
180       /*proxy_delegate=*/nullptr,
181       /*http_user_agent_settings=*/nullptr,
182       /*ssl_client_context=*/nullptr,
183       /*socket_performance_watcher_factory=*/nullptr,
184       /*network_quality_estimator=*/nullptr,
185       /*net_log=*/nullptr,
186       /*websocket_endpoint_lock_manager=*/nullptr,
187       /*http_server_properties=*/nullptr,
188       /*alpn_protos=*/nullptr,
189       /*application_settings=*/nullptr,
190       /*ignore_certificate_errors=*/nullptr};
191   TestConnectJobDelegate delegate_;
192 
193   std::unique_ptr<ConnectJobFactory> factory_;
194   raw_ptr<TestHttpProxyConnectJobFactory> http_proxy_job_factory_;
195   raw_ptr<TestSocksConnectJobFactory> socks_job_factory_;
196   raw_ptr<TestSslConnectJobFactory> ssl_job_factory_;
197   raw_ptr<TestTransportConnectJobFactory> transport_job_factory_;
198 };
199 
TEST_F(ConnectJobFactoryTest,CreateConnectJob)200 TEST_F(ConnectJobFactoryTest, CreateConnectJob) {
201   const url::SchemeHostPort kEndpoint(url::kHttpScheme, "test", 82);
202 
203   std::unique_ptr<ConnectJob> job = factory_->CreateConnectJob(
204       kEndpoint, ProxyChain::Direct(),
205       /*proxy_annotation_tag=*/absl::nullopt,
206       /*ssl_config_for_origin=*/nullptr,
207       /*base_ssl_config_for_proxies=*/nullptr,
208       /*force_tunnel=*/false, PrivacyMode::PRIVACY_MODE_DISABLED,
209       OnHostResolutionCallback(), DEFAULT_PRIORITY, SocketTag(),
210       NetworkAnonymizationKey(), SecureDnsPolicy::kAllow,
211       &common_connect_job_params_, &delegate_);
212   EXPECT_EQ(GetCreationCount(), 1u);
213 
214   ASSERT_THAT(transport_job_factory_->params(), testing::SizeIs(1));
215   const TransportSocketParams& params =
216       *transport_job_factory_->params().front();
217   EXPECT_THAT(params.destination(),
218               testing::VariantWith<url::SchemeHostPort>(kEndpoint));
219 }
220 
TEST_F(ConnectJobFactoryTest,CreateConnectJobWithoutScheme)221 TEST_F(ConnectJobFactoryTest, CreateConnectJobWithoutScheme) {
222   const HostPortPair kEndpoint("test", 82);
223 
224   std::unique_ptr<ConnectJob> job = factory_->CreateConnectJob(
225       /*using_ssl=*/false, kEndpoint, ProxyChain::Direct(),
226       /*proxy_annotation_tag=*/absl::nullopt,
227       /*ssl_config_for_origin=*/nullptr,
228       /*base_ssl_config_for_proxies=*/nullptr,
229       /*force_tunnel=*/false, PrivacyMode::PRIVACY_MODE_DISABLED,
230       OnHostResolutionCallback(), DEFAULT_PRIORITY, SocketTag(),
231       NetworkAnonymizationKey(), SecureDnsPolicy::kAllow,
232       &common_connect_job_params_, &delegate_);
233   EXPECT_EQ(GetCreationCount(), 1u);
234 
235   ASSERT_THAT(transport_job_factory_->params(), testing::SizeIs(1));
236   const TransportSocketParams& params =
237       *transport_job_factory_->params().front();
238   EXPECT_THAT(params.destination(),
239               testing::VariantWith<HostPortPair>(kEndpoint));
240 }
241 
TEST_F(ConnectJobFactoryTest,CreateHttpsConnectJob)242 TEST_F(ConnectJobFactoryTest, CreateHttpsConnectJob) {
243   const url::SchemeHostPort kEndpoint(url::kHttpsScheme, "test", 84);
244   SSLConfig ssl_config;
245   ssl_config.alpn_protos = {kProtoHTTP2, kProtoHTTP11};
246 
247   std::unique_ptr<ConnectJob> job = factory_->CreateConnectJob(
248       kEndpoint, ProxyChain::Direct(),
249       /*proxy_annotation_tag=*/absl::nullopt,
250       /*ssl_config_for_origin=*/&ssl_config,
251       /*base_ssl_config_for_proxies=*/nullptr,
252       /*force_tunnel=*/false, PrivacyMode::PRIVACY_MODE_DISABLED,
253       OnHostResolutionCallback(), DEFAULT_PRIORITY, SocketTag(),
254       NetworkAnonymizationKey(), SecureDnsPolicy::kAllow,
255       &common_connect_job_params_, &delegate_);
256   EXPECT_EQ(GetCreationCount(), 1u);
257 
258   ASSERT_THAT(ssl_job_factory_->params(), testing::SizeIs(1));
259   const SSLSocketParams& params = *ssl_job_factory_->params().front();
260   EXPECT_EQ(params.host_and_port(),
261             HostPortPair::FromSchemeHostPort(kEndpoint));
262   EXPECT_FALSE(params.ssl_config().disable_cert_verification_network_fetches);
263   EXPECT_EQ(0, params.ssl_config().GetCertVerifyFlags());
264 
265   ASSERT_EQ(params.GetConnectionType(), SSLSocketParams::DIRECT);
266   const TransportSocketParams& transport_params =
267       *params.GetDirectConnectionParams();
268   EXPECT_THAT(transport_params.destination(),
269               testing::VariantWith<url::SchemeHostPort>(kEndpoint));
270   EXPECT_THAT(transport_params.supported_alpns(),
271               testing::UnorderedElementsAre("h2", "http/1.1"));
272 }
273 
TEST_F(ConnectJobFactoryTest,CreateHttpsConnectJobWithoutScheme)274 TEST_F(ConnectJobFactoryTest, CreateHttpsConnectJobWithoutScheme) {
275   const HostPortPair kEndpoint("test", 84);
276   SSLConfig ssl_config;
277 
278   std::unique_ptr<ConnectJob> job = factory_->CreateConnectJob(
279       /*using_ssl=*/true, kEndpoint, ProxyChain::Direct(),
280       /*proxy_annotation_tag=*/absl::nullopt,
281       /*ssl_config_for_origin=*/&ssl_config,
282       /*base_ssl_config_for_proxies=*/nullptr,
283       /*force_tunnel=*/false, PrivacyMode::PRIVACY_MODE_DISABLED,
284       OnHostResolutionCallback(), DEFAULT_PRIORITY, SocketTag(),
285       NetworkAnonymizationKey(), SecureDnsPolicy::kAllow,
286       &common_connect_job_params_, &delegate_);
287   EXPECT_EQ(GetCreationCount(), 1u);
288 
289   ASSERT_THAT(ssl_job_factory_->params(), testing::SizeIs(1));
290   const SSLSocketParams& params = *ssl_job_factory_->params().front();
291   EXPECT_EQ(params.host_and_port(), kEndpoint);
292   EXPECT_FALSE(params.ssl_config().disable_cert_verification_network_fetches);
293   EXPECT_EQ(0, params.ssl_config().GetCertVerifyFlags());
294 
295   ASSERT_EQ(params.GetConnectionType(), SSLSocketParams::DIRECT);
296   const TransportSocketParams& transport_params =
297       *params.GetDirectConnectionParams();
298   EXPECT_THAT(transport_params.destination(),
299               testing::VariantWith<HostPortPair>(kEndpoint));
300 }
301 
TEST_F(ConnectJobFactoryTest,CreateHttpProxyConnectJob)302 TEST_F(ConnectJobFactoryTest, CreateHttpProxyConnectJob) {
303   const url::SchemeHostPort kEndpoint(url::kHttpScheme, "test", 85);
304   const ProxyChain kProxy(ProxyServer::SCHEME_HTTP,
305                           HostPortPair("proxy.test", 86));
306 
307   std::unique_ptr<ConnectJob> job = factory_->CreateConnectJob(
308       kEndpoint, kProxy, TRAFFIC_ANNOTATION_FOR_TESTS,
309       /*ssl_config_for_origin=*/nullptr,
310       /*base_ssl_config_for_proxies=*/nullptr,
311       /*force_tunnel=*/false, PrivacyMode::PRIVACY_MODE_DISABLED,
312       OnHostResolutionCallback(), DEFAULT_PRIORITY, SocketTag(),
313       NetworkAnonymizationKey(), SecureDnsPolicy::kAllow,
314       &common_connect_job_params_, &delegate_);
315   EXPECT_EQ(GetCreationCount(), 1u);
316 
317   ASSERT_THAT(http_proxy_job_factory_->params(), testing::SizeIs(1));
318   const HttpProxySocketParams& params =
319       *http_proxy_job_factory_->params().front();
320   EXPECT_FALSE(params.proxy_server().is_quic());
321   EXPECT_EQ(params.endpoint(), HostPortPair::FromSchemeHostPort(kEndpoint));
322 
323   ASSERT_TRUE(params.transport_params());
324   const TransportSocketParams& transport_params = *params.transport_params();
325   EXPECT_THAT(transport_params.destination(),
326               testing::VariantWith<HostPortPair>(
327                   kProxy.proxy_server().host_port_pair()));
328 }
329 
TEST_F(ConnectJobFactoryTest,CreateHttpProxyConnectJobWithoutScheme)330 TEST_F(ConnectJobFactoryTest, CreateHttpProxyConnectJobWithoutScheme) {
331   const HostPortPair kEndpoint("test", 85);
332   const ProxyChain kProxy(ProxyServer::SCHEME_HTTP,
333                           HostPortPair("proxy.test", 86));
334 
335   std::unique_ptr<ConnectJob> job = factory_->CreateConnectJob(
336       /*using_ssl=*/false, kEndpoint, kProxy, TRAFFIC_ANNOTATION_FOR_TESTS,
337       /*ssl_config_for_origin=*/nullptr,
338       /*base_ssl_config_for_proxies=*/nullptr,
339       /*force_tunnel=*/false, PrivacyMode::PRIVACY_MODE_DISABLED,
340       OnHostResolutionCallback(), DEFAULT_PRIORITY, SocketTag(),
341       NetworkAnonymizationKey(), SecureDnsPolicy::kAllow,
342       &common_connect_job_params_, &delegate_);
343   EXPECT_EQ(GetCreationCount(), 1u);
344 
345   ASSERT_THAT(http_proxy_job_factory_->params(), testing::SizeIs(1));
346   const HttpProxySocketParams& params =
347       *http_proxy_job_factory_->params().front();
348   EXPECT_FALSE(params.proxy_server().is_quic());
349   EXPECT_EQ(params.endpoint(), kEndpoint);
350 
351   ASSERT_TRUE(params.transport_params());
352   const TransportSocketParams& transport_params = *params.transport_params();
353   EXPECT_THAT(transport_params.destination(),
354               testing::VariantWith<HostPortPair>(
355                   kProxy.proxy_server().host_port_pair()));
356 }
357 
TEST_F(ConnectJobFactoryTest,CreateHttpProxyConnectJobForHttps)358 TEST_F(ConnectJobFactoryTest, CreateHttpProxyConnectJobForHttps) {
359   const url::SchemeHostPort kEndpoint(url::kHttpsScheme, "test", 87);
360   const ProxyChain kProxy(ProxyServer::SCHEME_HTTP,
361                           HostPortPair("proxy.test", 88));
362   SSLConfig ssl_config;
363 
364   std::unique_ptr<ConnectJob> job = factory_->CreateConnectJob(
365       kEndpoint, kProxy, TRAFFIC_ANNOTATION_FOR_TESTS,
366       /*ssl_config_for_origin=*/&ssl_config,
367       /*base_ssl_config_for_proxies=*/nullptr,
368       /*force_tunnel=*/false, PrivacyMode::PRIVACY_MODE_DISABLED,
369       OnHostResolutionCallback(), DEFAULT_PRIORITY, SocketTag(),
370       NetworkAnonymizationKey(), SecureDnsPolicy::kAllow,
371       &common_connect_job_params_, &delegate_);
372   EXPECT_EQ(GetCreationCount(), 1u);
373 
374   ASSERT_THAT(ssl_job_factory_->params(), testing::SizeIs(1));
375   const SSLSocketParams& params = *ssl_job_factory_->params().front();
376   EXPECT_EQ(params.host_and_port(),
377             HostPortPair::FromSchemeHostPort(kEndpoint));
378   EXPECT_FALSE(params.ssl_config().disable_cert_verification_network_fetches);
379   EXPECT_EQ(0, params.ssl_config().GetCertVerifyFlags());
380 
381   ASSERT_EQ(params.GetConnectionType(), SSLSocketParams::HTTP_PROXY);
382   const HttpProxySocketParams& proxy_params =
383       *params.GetHttpProxyConnectionParams();
384   EXPECT_FALSE(proxy_params.proxy_server().is_quic());
385   EXPECT_EQ(proxy_params.endpoint(),
386             HostPortPair::FromSchemeHostPort(kEndpoint));
387 
388   ASSERT_TRUE(proxy_params.transport_params());
389   const TransportSocketParams& transport_params =
390       *proxy_params.transport_params();
391   EXPECT_THAT(transport_params.destination(),
392               testing::VariantWith<HostPortPair>(
393                   kProxy.proxy_server().host_port_pair()));
394 }
395 
TEST_F(ConnectJobFactoryTest,CreateHttpProxyConnectJobForHttpsWithoutScheme)396 TEST_F(ConnectJobFactoryTest, CreateHttpProxyConnectJobForHttpsWithoutScheme) {
397   const HostPortPair kEndpoint("test", 87);
398   const ProxyChain kProxy(ProxyServer::SCHEME_HTTP,
399                           HostPortPair("proxy.test", 88));
400   SSLConfig ssl_config;
401 
402   std::unique_ptr<ConnectJob> job = factory_->CreateConnectJob(
403       /*using_ssl=*/true, kEndpoint, kProxy, TRAFFIC_ANNOTATION_FOR_TESTS,
404       /*ssl_config_for_origin=*/&ssl_config,
405       /*base_ssl_config_for_proxies=*/nullptr,
406       /*force_tunnel=*/false, PrivacyMode::PRIVACY_MODE_DISABLED,
407       OnHostResolutionCallback(), DEFAULT_PRIORITY, SocketTag(),
408       NetworkAnonymizationKey(), SecureDnsPolicy::kAllow,
409       &common_connect_job_params_, &delegate_);
410   EXPECT_EQ(GetCreationCount(), 1u);
411 
412   ASSERT_THAT(ssl_job_factory_->params(), testing::SizeIs(1));
413   const SSLSocketParams& params = *ssl_job_factory_->params().front();
414   EXPECT_EQ(params.host_and_port(), kEndpoint);
415 
416   ASSERT_EQ(params.GetConnectionType(), SSLSocketParams::HTTP_PROXY);
417   const HttpProxySocketParams& proxy_params =
418       *params.GetHttpProxyConnectionParams();
419   EXPECT_FALSE(proxy_params.proxy_server().is_quic());
420   EXPECT_EQ(proxy_params.endpoint(), kEndpoint);
421 
422   ASSERT_TRUE(proxy_params.transport_params());
423   const TransportSocketParams& transport_params =
424       *proxy_params.transport_params();
425   EXPECT_THAT(transport_params.destination(),
426               testing::VariantWith<HostPortPair>(
427                   kProxy.proxy_server().host_port_pair()));
428 }
429 
TEST_F(ConnectJobFactoryTest,CreateHttpsProxyConnectJob)430 TEST_F(ConnectJobFactoryTest, CreateHttpsProxyConnectJob) {
431   const url::SchemeHostPort kEndpoint(url::kHttpScheme, "test", 89);
432   const ProxyChain kProxy(ProxyServer::SCHEME_HTTPS,
433                           HostPortPair("proxy.test", 90));
434   SSLConfig ssl_config;
435 
436   std::unique_ptr<ConnectJob> job = factory_->CreateConnectJob(
437       kEndpoint, kProxy, TRAFFIC_ANNOTATION_FOR_TESTS,
438       /*ssl_config_for_origin=*/nullptr,
439       /*base_ssl_config_for_proxies=*/&ssl_config,
440       /*force_tunnel=*/false, PrivacyMode::PRIVACY_MODE_DISABLED,
441       OnHostResolutionCallback(), DEFAULT_PRIORITY, SocketTag(),
442       NetworkAnonymizationKey(), SecureDnsPolicy::kAllow,
443       &common_connect_job_params_, &delegate_);
444   EXPECT_EQ(GetCreationCount(), 1u);
445 
446   ASSERT_THAT(http_proxy_job_factory_->params(), testing::SizeIs(1));
447   const HttpProxySocketParams& params =
448       *http_proxy_job_factory_->params().front();
449   EXPECT_FALSE(params.proxy_server().is_quic());
450   EXPECT_EQ(params.endpoint(), HostPortPair::FromSchemeHostPort(kEndpoint));
451 
452   ASSERT_TRUE(params.ssl_params());
453   const SSLSocketParams& ssl_params = *params.ssl_params();
454   EXPECT_EQ(ssl_params.host_and_port(), kProxy.proxy_server().host_port_pair());
455   EXPECT_TRUE(
456       ssl_params.ssl_config().disable_cert_verification_network_fetches);
457   EXPECT_EQ(CertVerifier::VERIFY_DISABLE_NETWORK_FETCHES,
458             ssl_params.ssl_config().GetCertVerifyFlags());
459 
460   ASSERT_EQ(ssl_params.GetConnectionType(), SSLSocketParams::DIRECT);
461   const TransportSocketParams& transport_params =
462       *ssl_params.GetDirectConnectionParams();
463   EXPECT_THAT(transport_params.destination(),
464               testing::VariantWith<HostPortPair>(
465                   kProxy.proxy_server().host_port_pair()));
466 }
467 
TEST_F(ConnectJobFactoryTest,CreateHttpsProxyConnectJobWithoutScheme)468 TEST_F(ConnectJobFactoryTest, CreateHttpsProxyConnectJobWithoutScheme) {
469   const HostPortPair kEndpoint("test", 89);
470   const ProxyChain kProxy(ProxyServer::SCHEME_HTTPS,
471                           HostPortPair("proxy.test", 90));
472   SSLConfig ssl_config;
473 
474   std::unique_ptr<ConnectJob> job = factory_->CreateConnectJob(
475       /*using_ssl=*/false, kEndpoint, kProxy, TRAFFIC_ANNOTATION_FOR_TESTS,
476       /*ssl_config_for_origin=*/nullptr,
477       /*base_ssl_config_for_proxies=*/&ssl_config,
478       /*force_tunnel=*/false, PrivacyMode::PRIVACY_MODE_DISABLED,
479       OnHostResolutionCallback(), DEFAULT_PRIORITY, SocketTag(),
480       NetworkAnonymizationKey(), SecureDnsPolicy::kAllow,
481       &common_connect_job_params_, &delegate_);
482   EXPECT_EQ(GetCreationCount(), 1u);
483 
484   ASSERT_THAT(http_proxy_job_factory_->params(), testing::SizeIs(1));
485   const HttpProxySocketParams& params =
486       *http_proxy_job_factory_->params().front();
487   EXPECT_FALSE(params.proxy_server().is_quic());
488   EXPECT_EQ(params.endpoint(), kEndpoint);
489 
490   ASSERT_TRUE(params.ssl_params());
491   const SSLSocketParams& ssl_params = *params.ssl_params();
492   EXPECT_EQ(ssl_params.host_and_port(), kProxy.proxy_server().host_port_pair());
493   EXPECT_TRUE(
494       ssl_params.ssl_config().disable_cert_verification_network_fetches);
495   EXPECT_EQ(CertVerifier::VERIFY_DISABLE_NETWORK_FETCHES,
496             ssl_params.ssl_config().GetCertVerifyFlags());
497 
498   ASSERT_EQ(ssl_params.GetConnectionType(), SSLSocketParams::DIRECT);
499   const TransportSocketParams& transport_params =
500       *ssl_params.GetDirectConnectionParams();
501   EXPECT_THAT(transport_params.destination(),
502               testing::VariantWith<HostPortPair>(
503                   kProxy.proxy_server().host_port_pair()));
504 }
505 
TEST_F(ConnectJobFactoryTest,CreateNestedHttpsProxyConnectJob)506 TEST_F(ConnectJobFactoryTest, CreateNestedHttpsProxyConnectJob) {
507   const url::SchemeHostPort kEndpoint(url::kHttpScheme, "test", 89);
508   const ProxyServer kProxyServer1{ProxyServer::SCHEME_HTTPS,
509                                   HostPortPair("proxy1.test", 443)};
510   const ProxyServer kProxyServer2{ProxyServer::SCHEME_HTTPS,
511                                   HostPortPair("proxy2.test", 443)};
512   const ProxyChain kNestedProxyChain{{kProxyServer1, kProxyServer2}};
513   SSLConfig ssl_config;
514 
515   std::unique_ptr<ConnectJob> job = factory_->CreateConnectJob(
516       kEndpoint, kNestedProxyChain, TRAFFIC_ANNOTATION_FOR_TESTS,
517       /*ssl_config_for_origin=*/nullptr,
518       /*base_ssl_config_for_proxies=*/&ssl_config,
519       /*force_tunnel=*/false, PrivacyMode::PRIVACY_MODE_DISABLED,
520       OnHostResolutionCallback(), DEFAULT_PRIORITY, SocketTag(),
521       NetworkAnonymizationKey(), SecureDnsPolicy::kAllow,
522       &common_connect_job_params_, &delegate_);
523   EXPECT_EQ(GetCreationCount(), 1u);
524 
525   ASSERT_THAT(http_proxy_job_factory_->params(), testing::SizeIs(1));
526   // The corresponding HttpProxySocketParams and SSLSocketParams for each hop
527   // should be present in reverse order.
528   const HttpProxySocketParams& proxy_server2_http_params =
529       *http_proxy_job_factory_->params().front();
530   EXPECT_FALSE(proxy_server2_http_params.proxy_server().is_quic());
531   // We should to send a CONNECT to `kProxyServer2` for `kEndpoint`.
532   EXPECT_EQ(proxy_server2_http_params.endpoint(),
533             HostPortPair::FromSchemeHostPort(kEndpoint));
534 
535   const SSLSocketParams& proxy_server2_ssl_params =
536       *proxy_server2_http_params.ssl_params();
537   EXPECT_EQ(proxy_server2_ssl_params.host_and_port(),
538             kProxyServer2.host_port_pair());
539 
540   const HttpProxySocketParams& proxy_server1_http_params =
541       *proxy_server2_ssl_params.GetHttpProxyConnectionParams();
542   EXPECT_FALSE(proxy_server1_http_params.proxy_server().is_quic());
543   // We should to send a CONNECT to `kProxyServer1` for `kProxyServer2`.
544   EXPECT_EQ(proxy_server1_http_params.endpoint(),
545             kProxyServer2.host_port_pair());
546 
547   ASSERT_TRUE(proxy_server1_http_params.ssl_params());
548   const SSLSocketParams& proxy_server1_ssl_params =
549       *proxy_server1_http_params.ssl_params();
550   EXPECT_EQ(proxy_server1_ssl_params.host_and_port(),
551             kProxyServer1.host_port_pair());
552 
553   ASSERT_EQ(proxy_server1_ssl_params.GetConnectionType(),
554             SSLSocketParams::DIRECT);
555   ASSERT_EQ(proxy_server2_ssl_params.GetConnectionType(),
556             SSLSocketParams::HTTP_PROXY);
557 
558   const TransportSocketParams& transport_params =
559       *proxy_server1_ssl_params.GetDirectConnectionParams();
560   EXPECT_THAT(
561       transport_params.destination(),
562       testing::VariantWith<HostPortPair>(kProxyServer1.host_port_pair()));
563 }
564 
TEST_F(ConnectJobFactoryTest,CreateNestedHttpsProxyConnectJobWithoutScheme)565 TEST_F(ConnectJobFactoryTest, CreateNestedHttpsProxyConnectJobWithoutScheme) {
566   const HostPortPair kEndpoint("test", 89);
567   const ProxyServer kProxyServer1{ProxyServer::SCHEME_HTTPS,
568                                   HostPortPair("proxy1.test", 443)};
569   const ProxyServer kProxyServer2{ProxyServer::SCHEME_HTTPS,
570                                   HostPortPair("proxy2.test", 443)};
571   const ProxyChain kNestedProxyChain{{kProxyServer1, kProxyServer2}};
572   SSLConfig ssl_config;
573 
574   std::unique_ptr<ConnectJob> job = factory_->CreateConnectJob(
575       /*using_ssl=*/false, kEndpoint, kNestedProxyChain,
576       TRAFFIC_ANNOTATION_FOR_TESTS,
577       /*ssl_config_for_origin=*/nullptr,
578       /*base_ssl_config_for_proxies=*/&ssl_config,
579       /*force_tunnel=*/false, PrivacyMode::PRIVACY_MODE_DISABLED,
580       OnHostResolutionCallback(), DEFAULT_PRIORITY, SocketTag(),
581       NetworkAnonymizationKey(), SecureDnsPolicy::kAllow,
582       &common_connect_job_params_, &delegate_);
583   EXPECT_EQ(GetCreationCount(), 1u);
584 
585   ASSERT_THAT(http_proxy_job_factory_->params(), testing::SizeIs(1));
586   // The corresponding HttpProxySocketParams and SSLSocketParams for each hop
587   // should be present in reverse order.
588   const HttpProxySocketParams& proxy_server2_http_params =
589       *http_proxy_job_factory_->params().front();
590   EXPECT_FALSE(proxy_server2_http_params.proxy_server().is_quic());
591   // We should to send a CONNECT to `kProxyServer2` for `kEndpoint`.
592   EXPECT_EQ(proxy_server2_http_params.endpoint(), kEndpoint);
593 
594   const SSLSocketParams& proxy_server2_ssl_params =
595       *proxy_server2_http_params.ssl_params();
596   EXPECT_EQ(proxy_server2_ssl_params.host_and_port(),
597             kProxyServer2.host_port_pair());
598 
599   const HttpProxySocketParams& proxy_server1_http_params =
600       *proxy_server2_ssl_params.GetHttpProxyConnectionParams();
601   EXPECT_FALSE(proxy_server1_http_params.proxy_server().is_quic());
602   // We should to send a CONNECT to `kProxyServer1` for `kProxyServer2`.
603   EXPECT_EQ(proxy_server1_http_params.endpoint(),
604             kProxyServer2.host_port_pair());
605 
606   ASSERT_TRUE(proxy_server1_http_params.ssl_params());
607   const SSLSocketParams& proxy_server1_ssl_params =
608       *proxy_server1_http_params.ssl_params();
609   EXPECT_EQ(proxy_server1_ssl_params.host_and_port(),
610             kProxyServer1.host_port_pair());
611 
612   ASSERT_EQ(proxy_server1_ssl_params.GetConnectionType(),
613             SSLSocketParams::DIRECT);
614   ASSERT_EQ(proxy_server2_ssl_params.GetConnectionType(),
615             SSLSocketParams::HTTP_PROXY);
616 
617   ASSERT_EQ(proxy_server1_ssl_params.GetConnectionType(),
618             SSLSocketParams::DIRECT);
619   const TransportSocketParams& transport_params =
620       *proxy_server1_ssl_params.GetDirectConnectionParams();
621   EXPECT_THAT(
622       transport_params.destination(),
623       testing::VariantWith<HostPortPair>(kProxyServer1.host_port_pair()));
624 }
625 
TEST_F(ConnectJobFactoryTest,CreateNestedHttpsProxyConnectJobForHttps)626 TEST_F(ConnectJobFactoryTest, CreateNestedHttpsProxyConnectJobForHttps) {
627   const url::SchemeHostPort kEndpoint(url::kHttpsScheme, "test", 443);
628 
629   const ProxyServer kProxyServer1{ProxyServer::SCHEME_HTTPS,
630                                   HostPortPair("proxy1.test", 443)};
631   const ProxyServer kProxyServer2{ProxyServer::SCHEME_HTTPS,
632                                   HostPortPair("proxy2.test", 443)};
633 
634   const ProxyChain kNestedProxyChain{{kProxyServer1, kProxyServer2}};
635   SSLConfig ssl_config;
636 
637   std::unique_ptr<ConnectJob> job = factory_->CreateConnectJob(
638       kEndpoint, kNestedProxyChain, TRAFFIC_ANNOTATION_FOR_TESTS,
639       /*ssl_config_for_origin=*/&ssl_config,
640       /*base_ssl_config_for_proxies=*/&ssl_config,
641       /*force_tunnel=*/false, PrivacyMode::PRIVACY_MODE_DISABLED,
642       OnHostResolutionCallback(), DEFAULT_PRIORITY, SocketTag(),
643       NetworkAnonymizationKey(), SecureDnsPolicy::kAllow,
644       &common_connect_job_params_, &delegate_);
645   EXPECT_EQ(GetCreationCount(), 1u);
646 
647   ASSERT_THAT(ssl_job_factory_->params(), testing::SizeIs(1));
648   const SSLSocketParams& endpoint_ssl_params =
649       *ssl_job_factory_->params().at(0);
650   // The SSLSocketParams for the destination should be configured to go through
651   // the chain of proxies, with the corresponding HttpProxySocketParams and
652   // SSLSocketParams for each hop present in reverse order.
653   const HttpProxySocketParams& proxy_server2_http_params =
654       *endpoint_ssl_params.GetHttpProxyConnectionParams();
655   EXPECT_FALSE(proxy_server2_http_params.proxy_server().is_quic());
656   // We should to send a CONNECT to `kProxyServer2` for `kEndpoint`.
657   EXPECT_EQ(proxy_server2_http_params.endpoint(),
658             HostPortPair::FromSchemeHostPort(kEndpoint));
659 
660   const SSLSocketParams& proxy_server2_ssl_params =
661       *proxy_server2_http_params.ssl_params();
662   EXPECT_EQ(proxy_server2_ssl_params.host_and_port(),
663             kProxyServer2.host_port_pair());
664 
665   const HttpProxySocketParams& proxy_server1_http_params =
666       *proxy_server2_ssl_params.GetHttpProxyConnectionParams();
667   EXPECT_FALSE(proxy_server1_http_params.proxy_server().is_quic());
668   // We should to send a CONNECT to `kProxyServer1` for `kProxyServer2`.
669   EXPECT_EQ(proxy_server1_http_params.endpoint(),
670             kProxyServer2.host_port_pair());
671 
672   ASSERT_TRUE(proxy_server1_http_params.ssl_params());
673   const SSLSocketParams& proxy_server1_ssl_params =
674       *proxy_server1_http_params.ssl_params();
675   EXPECT_EQ(proxy_server1_ssl_params.host_and_port(),
676             kProxyServer1.host_port_pair());
677 
678   ASSERT_EQ(proxy_server1_ssl_params.GetConnectionType(),
679             SSLSocketParams::DIRECT);
680   ASSERT_EQ(proxy_server2_ssl_params.GetConnectionType(),
681             SSLSocketParams::HTTP_PROXY);
682   ASSERT_EQ(endpoint_ssl_params.GetConnectionType(),
683             SSLSocketParams::HTTP_PROXY);
684 
685   const TransportSocketParams& transport_params =
686       *proxy_server1_ssl_params.GetDirectConnectionParams();
687   // We should establish a physical socket / direct connection to
688   // `kProxyServer1` (and will tunnel all subsequent traffic through
689   // that).
690   EXPECT_THAT(
691       transport_params.destination(),
692       testing::VariantWith<HostPortPair>(kProxyServer1.host_port_pair()));
693 }
694 
TEST_F(ConnectJobFactoryTest,CreateNestedHttpsProxyConnectJobForHttpsWithoutScheme)695 TEST_F(ConnectJobFactoryTest,
696        CreateNestedHttpsProxyConnectJobForHttpsWithoutScheme) {
697   const HostPortPair kEndpoint("test", 443);
698 
699   const ProxyServer kProxyServer1{ProxyServer::SCHEME_HTTPS,
700                                   HostPortPair("proxy1.test", 443)};
701   const ProxyServer kProxyServer2{ProxyServer::SCHEME_HTTPS,
702                                   HostPortPair("proxy2.test", 443)};
703 
704   const ProxyChain kNestedProxyChain{{kProxyServer1, kProxyServer2}};
705   SSLConfig ssl_config;
706 
707   std::unique_ptr<ConnectJob> job = factory_->CreateConnectJob(
708       /*using_ssl=*/true, kEndpoint, kNestedProxyChain,
709       TRAFFIC_ANNOTATION_FOR_TESTS,
710       /*ssl_config_for_origin=*/&ssl_config,
711       /*base_ssl_config_for_proxies=*/&ssl_config,
712       /*force_tunnel=*/false, PrivacyMode::PRIVACY_MODE_DISABLED,
713       OnHostResolutionCallback(), DEFAULT_PRIORITY, SocketTag(),
714       NetworkAnonymizationKey(), SecureDnsPolicy::kAllow,
715       &common_connect_job_params_, &delegate_);
716   EXPECT_EQ(GetCreationCount(), 1u);
717 
718   ASSERT_THAT(ssl_job_factory_->params(), testing::SizeIs(1));
719   const SSLSocketParams& endpoint_ssl_params =
720       *ssl_job_factory_->params().at(0);
721   // The SSLSocketParams for the destination should be configured to go through
722   // the chain of proxies, with the corresponding HttpProxySocketParams and
723   // SSLSocketParams for each hop present in reverse order.
724   const HttpProxySocketParams& proxy_server2_http_params =
725       *endpoint_ssl_params.GetHttpProxyConnectionParams();
726   EXPECT_FALSE(proxy_server2_http_params.proxy_server().is_quic());
727   // We should to send a CONNECT to `kProxyServer2` for `kEndpoint`.
728   EXPECT_EQ(proxy_server2_http_params.endpoint(), kEndpoint);
729 
730   const SSLSocketParams& proxy_server2_ssl_params =
731       *proxy_server2_http_params.ssl_params();
732   EXPECT_EQ(proxy_server2_ssl_params.host_and_port(),
733             kProxyServer2.host_port_pair());
734 
735   const HttpProxySocketParams& proxy_server1_http_params =
736       *proxy_server2_ssl_params.GetHttpProxyConnectionParams();
737   EXPECT_FALSE(proxy_server1_http_params.proxy_server().is_quic());
738   // We should to send a CONNECT to `kProxyServer1` for `kProxyServer2`.
739   EXPECT_EQ(proxy_server1_http_params.endpoint(),
740             kProxyServer2.host_port_pair());
741 
742   ASSERT_TRUE(proxy_server1_http_params.ssl_params());
743   const SSLSocketParams& proxy_server1_ssl_params =
744       *proxy_server1_http_params.ssl_params();
745   EXPECT_EQ(proxy_server1_ssl_params.host_and_port(),
746             kProxyServer1.host_port_pair());
747 
748   ASSERT_EQ(proxy_server1_ssl_params.GetConnectionType(),
749             SSLSocketParams::DIRECT);
750   ASSERT_EQ(proxy_server2_ssl_params.GetConnectionType(),
751             SSLSocketParams::HTTP_PROXY);
752   ASSERT_EQ(endpoint_ssl_params.GetConnectionType(),
753             SSLSocketParams::HTTP_PROXY);
754 
755   const TransportSocketParams& transport_params =
756       *proxy_server1_ssl_params.GetDirectConnectionParams();
757   // We should establish a physical socket / direct connection to
758   // `kProxyServer1` (and will tunnel all subsequent traffic through
759   // that).
760   EXPECT_THAT(
761       transport_params.destination(),
762       testing::VariantWith<HostPortPair>(kProxyServer1.host_port_pair()));
763 }
764 
TEST_F(ConnectJobFactoryTest,CreateSocksProxyConnectJob)765 TEST_F(ConnectJobFactoryTest, CreateSocksProxyConnectJob) {
766   const url::SchemeHostPort kEndpoint(url::kHttpScheme, "test", 91);
767   const ProxyChain kProxy(ProxyServer::SCHEME_SOCKS5,
768                           HostPortPair("proxy.test", 92));
769 
770   std::unique_ptr<ConnectJob> job = factory_->CreateConnectJob(
771       kEndpoint, kProxy, TRAFFIC_ANNOTATION_FOR_TESTS,
772       /*ssl_config_for_origin=*/nullptr,
773       /*base_ssl_config_for_proxies=*/nullptr,
774       /*force_tunnel=*/false, PrivacyMode::PRIVACY_MODE_DISABLED,
775       OnHostResolutionCallback(), DEFAULT_PRIORITY, SocketTag(),
776       NetworkAnonymizationKey(), SecureDnsPolicy::kAllow,
777       &common_connect_job_params_, &delegate_);
778   EXPECT_EQ(GetCreationCount(), 1u);
779 
780   ASSERT_THAT(socks_job_factory_->params(), testing::SizeIs(1));
781   const SOCKSSocketParams& params = *socks_job_factory_->params().front();
782   EXPECT_EQ(params.destination(), HostPortPair::FromSchemeHostPort(kEndpoint));
783   EXPECT_TRUE(params.is_socks_v5());
784 
785   const TransportSocketParams& transport_params = *params.transport_params();
786   EXPECT_THAT(transport_params.destination(),
787               testing::VariantWith<HostPortPair>(
788                   kProxy.proxy_server().host_port_pair()));
789 }
790 
TEST_F(ConnectJobFactoryTest,CreateSocksProxyConnectJobWithoutScheme)791 TEST_F(ConnectJobFactoryTest, CreateSocksProxyConnectJobWithoutScheme) {
792   const HostPortPair kEndpoint("test", 91);
793   const ProxyChain kProxy(ProxyServer::SCHEME_SOCKS5,
794                           HostPortPair("proxy.test", 92));
795 
796   std::unique_ptr<ConnectJob> job = factory_->CreateConnectJob(
797       /*using_ssl=*/false, kEndpoint, kProxy, TRAFFIC_ANNOTATION_FOR_TESTS,
798       /*ssl_config_for_origin=*/nullptr,
799       /*base_ssl_config_for_proxies=*/nullptr,
800       /*force_tunnel=*/false, PrivacyMode::PRIVACY_MODE_DISABLED,
801       OnHostResolutionCallback(), DEFAULT_PRIORITY, SocketTag(),
802       NetworkAnonymizationKey(), SecureDnsPolicy::kAllow,
803       &common_connect_job_params_, &delegate_);
804   EXPECT_EQ(GetCreationCount(), 1u);
805 
806   ASSERT_THAT(socks_job_factory_->params(), testing::SizeIs(1));
807   const SOCKSSocketParams& params = *socks_job_factory_->params().front();
808   EXPECT_EQ(params.destination(), kEndpoint);
809   EXPECT_TRUE(params.is_socks_v5());
810 
811   const TransportSocketParams& transport_params = *params.transport_params();
812   EXPECT_THAT(transport_params.destination(),
813               testing::VariantWith<HostPortPair>(
814                   kProxy.proxy_server().host_port_pair()));
815 }
816 
TEST_F(ConnectJobFactoryTest,CreateWebsocketConnectJob)817 TEST_F(ConnectJobFactoryTest, CreateWebsocketConnectJob) {
818   const url::SchemeHostPort kEndpoint(url::kHttpScheme, "test", 93);
819 
820   WebSocketEndpointLockManager websocket_endpoint_lock_manager;
821   CommonConnectJobParams common_connect_job_params = common_connect_job_params_;
822   common_connect_job_params.websocket_endpoint_lock_manager =
823       &websocket_endpoint_lock_manager;
824 
825   std::unique_ptr<ConnectJob> job = factory_->CreateConnectJob(
826       kEndpoint, ProxyChain::Direct(),
827       /*proxy_annotation_tag=*/absl::nullopt,
828       /*ssl_config_for_origin=*/nullptr,
829       /*base_ssl_config_for_proxies=*/nullptr,
830       /*force_tunnel=*/false, PrivacyMode::PRIVACY_MODE_DISABLED,
831       OnHostResolutionCallback(), DEFAULT_PRIORITY, SocketTag(),
832       NetworkAnonymizationKey(), SecureDnsPolicy::kAllow,
833       &common_connect_job_params, &delegate_);
834   EXPECT_EQ(GetCreationCount(), 1u);
835 
836   ASSERT_THAT(transport_job_factory_->params(), testing::SizeIs(1));
837   const TransportSocketParams& params =
838       *transport_job_factory_->params().front();
839   EXPECT_THAT(params.destination(),
840               testing::VariantWith<url::SchemeHostPort>(kEndpoint));
841 }
842 
TEST_F(ConnectJobFactoryTest,CreateWebsocketConnectJobWithoutScheme)843 TEST_F(ConnectJobFactoryTest, CreateWebsocketConnectJobWithoutScheme) {
844   const HostPortPair kEndpoint("test", 93);
845 
846   WebSocketEndpointLockManager websocket_endpoint_lock_manager;
847   CommonConnectJobParams common_connect_job_params = common_connect_job_params_;
848   common_connect_job_params.websocket_endpoint_lock_manager =
849       &websocket_endpoint_lock_manager;
850 
851   std::unique_ptr<ConnectJob> job = factory_->CreateConnectJob(
852       /*using_ssl=*/false, kEndpoint, ProxyChain::Direct(),
853       /*proxy_annotation_tag=*/absl::nullopt,
854       /*ssl_config_for_origin=*/nullptr,
855       /*base_ssl_config_for_proxies=*/nullptr,
856       /*force_tunnel=*/false, PrivacyMode::PRIVACY_MODE_DISABLED,
857       OnHostResolutionCallback(), DEFAULT_PRIORITY, SocketTag(),
858       NetworkAnonymizationKey(), SecureDnsPolicy::kAllow,
859       &common_connect_job_params, &delegate_);
860   EXPECT_EQ(GetCreationCount(), 1u);
861 
862   ASSERT_THAT(transport_job_factory_->params(), testing::SizeIs(1));
863   const TransportSocketParams& params =
864       *transport_job_factory_->params().front();
865   EXPECT_THAT(params.destination(),
866               testing::VariantWith<HostPortPair>(kEndpoint));
867 }
868 
869 }  // namespace
870 }  // namespace net
871