Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: net/quic/quic_stream_factory_test.cc

Issue 2113873002: Add PrivacyMode QUIC pooling unittest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/quic_stream_factory.h" 5 #include "net/quic/quic_stream_factory.h"
6 6
7 #include <ostream> 7 #include <ostream>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 4259 matching lines...) Expand 10 before | Expand all | Expand 10 after
4270 QuicHttpStreamPeer::GetSession(stream1.get()); 4270 QuicHttpStreamPeer::GetSession(stream1.get());
4271 QuicChromiumClientSession* session2 = 4271 QuicChromiumClientSession* session2 =
4272 QuicHttpStreamPeer::GetSession(stream2.get()); 4272 QuicHttpStreamPeer::GetSession(stream2.get());
4273 EXPECT_EQ(session1, session2); 4273 EXPECT_EQ(session1, session2);
4274 4274
4275 EXPECT_EQ(QuicServerId(origin1_, privacy_mode_), session1->server_id()); 4275 EXPECT_EQ(QuicServerId(origin1_, privacy_mode_), session1->server_id());
4276 4276
4277 EXPECT_TRUE(AllDataConsumed()); 4277 EXPECT_TRUE(AllDataConsumed());
4278 } 4278 }
4279 4279
4280 // QuicStreamRequest is not pooled if PrivacyMode differs.
4281 TEST_P(QuicStreamFactoryWithDestinationTest, DifferentPrivacyMode) {
4282 Initialize();
4283
4284 GURL url1("https://www.example.org/");
4285 GURL url2("https://mail.example.org/");
4286 origin1_ = HostPortPair::FromURL(url1);
4287 origin2_ = HostPortPair::FromURL(url2);
4288
4289 HostPortPair destination = GetDestination();
4290
4291 scoped_refptr<X509Certificate> cert(
4292 ImportCertFromFile(GetTestCertsDirectory(), "wildcard.pem"));
4293 bool unused;
4294 ASSERT_TRUE(cert->VerifyNameMatch(origin1_.host(), &unused));
4295 ASSERT_TRUE(cert->VerifyNameMatch(origin2_.host(), &unused));
4296 ASSERT_FALSE(cert->VerifyNameMatch(kDifferentHostname, &unused));
4297
4298 ProofVerifyDetailsChromium verify_details1;
4299 verify_details1.cert_verify_result.verified_cert = cert;
4300 verify_details1.cert_verify_result.is_issued_by_known_root = true;
4301 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details1);
4302
4303 ProofVerifyDetailsChromium verify_details2;
4304 verify_details2.cert_verify_result.verified_cert = cert;
4305 verify_details2.cert_verify_result.is_issued_by_known_root = true;
4306 crypto_client_stream_factory_.AddProofVerifyDetails(&verify_details2);
4307
4308 AddHangingSocketData();
4309 AddHangingSocketData();
4310
4311 QuicStreamRequest request1(factory_.get());
4312 EXPECT_EQ(ERR_IO_PENDING,
4313 request1.Request(destination, PRIVACY_MODE_DISABLED,
4314 /*cert_verify_flags=*/0, url1, "GET", net_log_,
4315 callback_.callback()));
4316 EXPECT_EQ(OK, callback_.WaitForResult());
4317 std::unique_ptr<QuicHttpStream> stream1 = request1.CreateStream();
4318 EXPECT_TRUE(stream1.get());
4319 EXPECT_TRUE(HasActiveSession(origin1_));
4320
4321 TestCompletionCallback callback2;
4322 QuicStreamRequest request2(factory_.get());
4323 EXPECT_EQ(ERR_IO_PENDING,
4324 request2.Request(destination, PRIVACY_MODE_ENABLED,
4325 /*cert_verify_flags=*/0, url2, "GET", net_log_,
4326 callback2.callback()));
4327 EXPECT_EQ(OK, callback2.WaitForResult());
4328 std::unique_ptr<QuicHttpStream> stream2 = request2.CreateStream();
4329 EXPECT_TRUE(stream2.get());
4330
4331 // |request2| does not pool to the first session, because PrivacyMode does not
4332 // match. Instead, another session is opened to the same destination, but
4333 // with a different QuicServerId.
4334 QuicChromiumClientSession* session1 =
4335 QuicHttpStreamPeer::GetSession(stream1.get());
4336 QuicChromiumClientSession* session2 =
4337 QuicHttpStreamPeer::GetSession(stream2.get());
4338 EXPECT_NE(session1, session2);
4339
4340 EXPECT_EQ(QuicServerId(origin1_, PRIVACY_MODE_DISABLED),
4341 session1->server_id());
4342 EXPECT_EQ(QuicServerId(origin2_, PRIVACY_MODE_ENABLED),
4343 session2->server_id());
4344
4345 EXPECT_TRUE(AllDataConsumed());
4346 }
4347
4280 // QuicStreamRequest is not pooled if certificate does not match its origin. 4348 // QuicStreamRequest is not pooled if certificate does not match its origin.
4281 TEST_P(QuicStreamFactoryWithDestinationTest, DisjointCertificate) { 4349 TEST_P(QuicStreamFactoryWithDestinationTest, DisjointCertificate) {
4282 Initialize(); 4350 Initialize();
4283 4351
4284 GURL url1("https://news.example.org/"); 4352 GURL url1("https://news.example.org/");
4285 GURL url2("https://mail.example.com/"); 4353 GURL url2("https://mail.example.com/");
4286 origin1_ = HostPortPair::FromURL(url1); 4354 origin1_ = HostPortPair::FromURL(url1);
4287 origin2_ = HostPortPair::FromURL(url2); 4355 origin2_ = HostPortPair::FromURL(url2);
4288 4356
4289 HostPortPair destination = GetDestination(); 4357 HostPortPair destination = GetDestination();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
4343 EXPECT_NE(session1, session2); 4411 EXPECT_NE(session1, session2);
4344 4412
4345 EXPECT_EQ(QuicServerId(origin1_, privacy_mode_), session1->server_id()); 4413 EXPECT_EQ(QuicServerId(origin1_, privacy_mode_), session1->server_id());
4346 EXPECT_EQ(QuicServerId(origin2_, privacy_mode_), session2->server_id()); 4414 EXPECT_EQ(QuicServerId(origin2_, privacy_mode_), session2->server_id());
4347 4415
4348 EXPECT_TRUE(AllDataConsumed()); 4416 EXPECT_TRUE(AllDataConsumed());
4349 } 4417 }
4350 4418
4351 } // namespace test 4419 } // namespace test
4352 } // namespace net 4420 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698