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

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

Issue 48893003: QUIC - added googlevideo.com to the list of cannonical hostnames to (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merging with tip Created 7 years, 1 month 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 | « net/quic/quic_stream_factory.cc ('k') | 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 "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "net/cert/cert_verifier.h" 9 #include "net/cert/cert_verifier.h"
10 #include "net/dns/mock_host_resolver.h" 10 #include "net/dns/mock_host_resolver.h"
11 #include "net/http/http_response_headers.h" 11 #include "net/http/http_response_headers.h"
12 #include "net/http/http_response_info.h" 12 #include "net/http/http_response_info.h"
13 #include "net/http/http_util.h" 13 #include "net/http/http_util.h"
14 #include "net/quic/crypto/crypto_handshake.h" 14 #include "net/quic/crypto/crypto_handshake.h"
15 #include "net/quic/crypto/quic_decrypter.h" 15 #include "net/quic/crypto/quic_decrypter.h"
16 #include "net/quic/crypto/quic_encrypter.h" 16 #include "net/quic/crypto/quic_encrypter.h"
17 #include "net/quic/quic_http_stream.h" 17 #include "net/quic/quic_http_stream.h"
18 #include "net/quic/test_tools/mock_clock.h" 18 #include "net/quic/test_tools/mock_clock.h"
19 #include "net/quic/test_tools/mock_crypto_client_stream_factory.h" 19 #include "net/quic/test_tools/mock_crypto_client_stream_factory.h"
20 #include "net/quic/test_tools/mock_random.h" 20 #include "net/quic/test_tools/mock_random.h"
21 #include "net/quic/test_tools/quic_test_utils.h" 21 #include "net/quic/test_tools/quic_test_utils.h"
22 #include "net/socket/socket_test_util.h" 22 #include "net/socket/socket_test_util.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 24
25 using base::StringPiece;
26 using std::string;
27 using std::vector;
28
25 namespace net { 29 namespace net {
26 namespace test { 30 namespace test {
27 31
28 class QuicStreamFactoryPeer { 32 class QuicStreamFactoryPeer {
29 public: 33 public:
30 static QuicCryptoClientConfig* GetOrCreateCryptoConfig( 34 static QuicCryptoClientConfig* GetOrCreateCryptoConfig(
31 QuicStreamFactory* factory, 35 QuicStreamFactory* factory,
32 const HostPortProxyPair& host_port_proxy_pair) { 36 const HostPortProxyPair& host_port_proxy_pair) {
33 return factory->GetOrCreateCryptoConfig(host_port_proxy_pair); 37 return factory->GetOrCreateCryptoConfig(host_port_proxy_pair);
34 } 38 }
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 stream = request2.ReleaseStream(); 456 stream = request2.ReleaseStream();
453 stream.reset(); // Will reset stream 3. 457 stream.reset(); // Will reset stream 3.
454 458
455 EXPECT_TRUE(socket_data.at_read_eof()); 459 EXPECT_TRUE(socket_data.at_read_eof());
456 EXPECT_TRUE(socket_data.at_write_eof()); 460 EXPECT_TRUE(socket_data.at_write_eof());
457 EXPECT_TRUE(socket_data2.at_read_eof()); 461 EXPECT_TRUE(socket_data2.at_read_eof());
458 EXPECT_TRUE(socket_data2.at_write_eof()); 462 EXPECT_TRUE(socket_data2.at_write_eof());
459 } 463 }
460 464
461 TEST_F(QuicStreamFactoryTest, SharedCryptoConfig) { 465 TEST_F(QuicStreamFactoryTest, SharedCryptoConfig) {
462 HostPortProxyPair host_port_proxy_pair1(HostPortPair("r1.c.youtube.com", 80), 466 vector<string> cannoncial_suffixes;
463 ProxyServer::Direct()); 467 cannoncial_suffixes.push_back(string(".c.youtube.com"));
468 cannoncial_suffixes.push_back(string(".googlevideo.com"));
464 469
465 QuicCryptoClientConfig* crypto_config1 = 470 for (unsigned i = 0; i < cannoncial_suffixes.size(); ++i) {
466 QuicStreamFactoryPeer::GetOrCreateCryptoConfig(&factory_, 471 string r1_host_name("r1");
467 host_port_proxy_pair1); 472 string r2_host_name("r2");
468 DCHECK(crypto_config1); 473 r1_host_name.append(cannoncial_suffixes[i]);
469 QuicCryptoClientConfig::CachedState* cached1 = 474 r2_host_name.append(cannoncial_suffixes[i]);
470 crypto_config1->LookupOrCreate(host_port_proxy_pair1.first.host());
471 EXPECT_FALSE(cached1->proof_valid());
472 EXPECT_TRUE(cached1->source_address_token().empty());
473 475
474 // Mutate the cached1 to have different data. 476 HostPortProxyPair host_port_proxy_pair1(HostPortPair(r1_host_name, 80),
475 // TODO(rtenneti): mutate other members of CachedState. 477 ProxyServer::Direct());
476 cached1->set_source_address_token("c.youtube.com");
477 cached1->SetProofValid();
478 478
479 HostPortProxyPair host_port_proxy_pair2(HostPortPair("r2.c.youtube.com", 80), 479 QuicCryptoClientConfig* crypto_config1 =
480 ProxyServer::Direct()); 480 QuicStreamFactoryPeer::GetOrCreateCryptoConfig(&factory_,
481 QuicCryptoClientConfig* crypto_config2 = 481 host_port_proxy_pair1);
482 QuicStreamFactoryPeer::GetOrCreateCryptoConfig(&factory_, 482 DCHECK(crypto_config1);
483 host_port_proxy_pair2); 483 QuicCryptoClientConfig::CachedState* cached1 =
484 DCHECK(crypto_config2); 484 crypto_config1->LookupOrCreate(host_port_proxy_pair1.first.host());
485 QuicCryptoClientConfig::CachedState* cached2 = 485 EXPECT_FALSE(cached1->proof_valid());
486 crypto_config2->LookupOrCreate(host_port_proxy_pair2.first.host()); 486 EXPECT_TRUE(cached1->source_address_token().empty());
487 EXPECT_EQ(cached1->source_address_token(), cached2->source_address_token()); 487
488 EXPECT_TRUE(cached2->proof_valid()); 488 // Mutate the cached1 to have different data.
489 // TODO(rtenneti): mutate other members of CachedState.
490 cached1->set_source_address_token(r1_host_name);
491 cached1->SetProofValid();
492
493 HostPortProxyPair host_port_proxy_pair2(HostPortPair(r2_host_name, 80),
494 ProxyServer::Direct());
495 QuicCryptoClientConfig* crypto_config2 =
496 QuicStreamFactoryPeer::GetOrCreateCryptoConfig(&factory_,
497 host_port_proxy_pair2);
498 DCHECK(crypto_config2);
499 QuicCryptoClientConfig::CachedState* cached2 =
500 crypto_config2->LookupOrCreate(host_port_proxy_pair2.first.host());
501 EXPECT_EQ(cached1->source_address_token(), cached2->source_address_token());
502 EXPECT_TRUE(cached2->proof_valid());
503 }
489 } 504 }
490 505
491 TEST_F(QuicStreamFactoryTest, CryptoConfigWhenProofIsInvalid) { 506 TEST_F(QuicStreamFactoryTest, CryptoConfigWhenProofIsInvalid) {
492 HostPortProxyPair host_port_proxy_pair1(HostPortPair("r1.c.youtube.com", 80), 507 vector<string> cannoncial_suffixes;
493 ProxyServer::Direct()); 508 cannoncial_suffixes.push_back(string(".c.youtube.com"));
509 cannoncial_suffixes.push_back(string(".googlevideo.com"));
494 510
495 QuicCryptoClientConfig* crypto_config1 = 511 for (unsigned i = 0; i < cannoncial_suffixes.size(); ++i) {
496 QuicStreamFactoryPeer::GetOrCreateCryptoConfig(&factory_, 512 string r3_host_name("r3");
497 host_port_proxy_pair1); 513 string r4_host_name("r4");
498 DCHECK(crypto_config1); 514 r3_host_name.append(cannoncial_suffixes[i]);
499 QuicCryptoClientConfig::CachedState* cached1 = 515 r4_host_name.append(cannoncial_suffixes[i]);
500 crypto_config1->LookupOrCreate(host_port_proxy_pair1.first.host());
501 EXPECT_FALSE(cached1->proof_valid());
502 EXPECT_TRUE(cached1->source_address_token().empty());
503 516
504 // Mutate the cached1 to have different data. 517 HostPortProxyPair host_port_proxy_pair1(HostPortPair(r3_host_name, 80),
505 // TODO(rtenneti): mutate other members of CachedState. 518 ProxyServer::Direct());
506 cached1->set_source_address_token("c.youtube.com");
507 cached1->SetProofInvalid();
508 519
509 HostPortProxyPair host_port_proxy_pair2(HostPortPair("r2.c.youtube.com", 80), 520 QuicCryptoClientConfig* crypto_config1 =
510 ProxyServer::Direct()); 521 QuicStreamFactoryPeer::GetOrCreateCryptoConfig(&factory_,
511 QuicCryptoClientConfig* crypto_config2 = 522 host_port_proxy_pair1);
512 QuicStreamFactoryPeer::GetOrCreateCryptoConfig(&factory_, 523 DCHECK(crypto_config1);
513 host_port_proxy_pair2); 524 QuicCryptoClientConfig::CachedState* cached1 =
514 DCHECK(crypto_config2); 525 crypto_config1->LookupOrCreate(host_port_proxy_pair1.first.host());
515 QuicCryptoClientConfig::CachedState* cached2 = 526 EXPECT_FALSE(cached1->proof_valid());
516 crypto_config2->LookupOrCreate(host_port_proxy_pair2.first.host()); 527 EXPECT_TRUE(cached1->source_address_token().empty());
517 EXPECT_NE(cached1->source_address_token(), cached2->source_address_token()); 528
518 EXPECT_TRUE(cached2->source_address_token().empty()); 529 // Mutate the cached1 to have different data.
519 EXPECT_FALSE(cached2->proof_valid()); 530 // TODO(rtenneti): mutate other members of CachedState.
531 cached1->set_source_address_token(r3_host_name);
532 cached1->SetProofInvalid();
533
534 HostPortProxyPair host_port_proxy_pair2(HostPortPair(r4_host_name, 80),
535 ProxyServer::Direct());
536 QuicCryptoClientConfig* crypto_config2 =
537 QuicStreamFactoryPeer::GetOrCreateCryptoConfig(&factory_,
538 host_port_proxy_pair2);
539 DCHECK(crypto_config2);
540 QuicCryptoClientConfig::CachedState* cached2 =
541 crypto_config2->LookupOrCreate(host_port_proxy_pair2.first.host());
542 EXPECT_NE(cached1->source_address_token(), cached2->source_address_token());
543 EXPECT_TRUE(cached2->source_address_token().empty());
544 EXPECT_FALSE(cached2->proof_valid());
545 }
520 } 546 }
521 547
522 } // namespace test 548 } // namespace test
523 } // namespace net 549 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_stream_factory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698