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

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

Issue 1397983007: relnote: remove insecure QUIC support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rch_insecure_quic
Patch Set: Compile fix Created 5 years, 2 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 | « net/quic/quic_stream_factory.cc ('k') | net/quic/test_tools/crypto_test_utils.h » ('j') | 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 "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "net/base/test_data_directory.h" 10 #include "net/base/test_data_directory.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 } // namespace anonymous 80 } // namespace anonymous
81 81
82 class QuicStreamFactoryPeer { 82 class QuicStreamFactoryPeer {
83 public: 83 public:
84 static QuicCryptoClientConfig* GetCryptoConfig(QuicStreamFactory* factory) { 84 static QuicCryptoClientConfig* GetCryptoConfig(QuicStreamFactory* factory) {
85 return &factory->crypto_config_; 85 return &factory->crypto_config_;
86 } 86 }
87 87
88 static bool HasActiveSession(QuicStreamFactory* factory, 88 static bool HasActiveSession(QuicStreamFactory* factory,
89 const HostPortPair& host_port_pair) { 89 const HostPortPair& host_port_pair) {
90 QuicServerId server_id(host_port_pair, /*is_https=*/true, 90 QuicServerId server_id(host_port_pair, PRIVACY_MODE_DISABLED);
91 PRIVACY_MODE_DISABLED);
92 return factory->HasActiveSession(server_id); 91 return factory->HasActiveSession(server_id);
93 } 92 }
94 93
95 static QuicChromiumClientSession* GetActiveSession( 94 static QuicChromiumClientSession* GetActiveSession(
96 QuicStreamFactory* factory, 95 QuicStreamFactory* factory,
97 const HostPortPair& host_port_pair) { 96 const HostPortPair& host_port_pair) {
98 QuicServerId server_id(host_port_pair, /*is_https=*/true, 97 QuicServerId server_id(host_port_pair, PRIVACY_MODE_DISABLED);
99 PRIVACY_MODE_DISABLED);
100 DCHECK(factory->HasActiveSession(server_id)); 98 DCHECK(factory->HasActiveSession(server_id));
101 return factory->active_sessions_[server_id]; 99 return factory->active_sessions_[server_id];
102 } 100 }
103 101
104 static scoped_ptr<QuicHttpStream> CreateFromSession( 102 static scoped_ptr<QuicHttpStream> CreateFromSession(
105 QuicStreamFactory* factory, 103 QuicStreamFactory* factory,
106 QuicChromiumClientSession* session) { 104 QuicChromiumClientSession* session) {
107 return factory->CreateFromSession(session); 105 return factory->CreateFromSession(session);
108 } 106 }
109 107
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 1524
1527 for (unsigned i = 0; i < cannoncial_suffixes.size(); ++i) { 1525 for (unsigned i = 0; i < cannoncial_suffixes.size(); ++i) {
1528 string r1_host_name("r1"); 1526 string r1_host_name("r1");
1529 string r2_host_name("r2"); 1527 string r2_host_name("r2");
1530 r1_host_name.append(cannoncial_suffixes[i]); 1528 r1_host_name.append(cannoncial_suffixes[i]);
1531 r2_host_name.append(cannoncial_suffixes[i]); 1529 r2_host_name.append(cannoncial_suffixes[i]);
1532 1530
1533 HostPortPair host_port_pair1(r1_host_name, 80); 1531 HostPortPair host_port_pair1(r1_host_name, 80);
1534 QuicCryptoClientConfig* crypto_config = 1532 QuicCryptoClientConfig* crypto_config =
1535 QuicStreamFactoryPeer::GetCryptoConfig(&factory_); 1533 QuicStreamFactoryPeer::GetCryptoConfig(&factory_);
1536 QuicServerId server_id1(host_port_pair1, /*is_https=*/true, privacy_mode_); 1534 QuicServerId server_id1(host_port_pair1, privacy_mode_);
1537 QuicCryptoClientConfig::CachedState* cached1 = 1535 QuicCryptoClientConfig::CachedState* cached1 =
1538 crypto_config->LookupOrCreate(server_id1); 1536 crypto_config->LookupOrCreate(server_id1);
1539 EXPECT_FALSE(cached1->proof_valid()); 1537 EXPECT_FALSE(cached1->proof_valid());
1540 EXPECT_TRUE(cached1->source_address_token().empty()); 1538 EXPECT_TRUE(cached1->source_address_token().empty());
1541 1539
1542 // Mutate the cached1 to have different data. 1540 // Mutate the cached1 to have different data.
1543 // TODO(rtenneti): mutate other members of CachedState. 1541 // TODO(rtenneti): mutate other members of CachedState.
1544 cached1->set_source_address_token(r1_host_name); 1542 cached1->set_source_address_token(r1_host_name);
1545 cached1->SetProofValid(); 1543 cached1->SetProofValid();
1546 1544
1547 HostPortPair host_port_pair2(r2_host_name, 80); 1545 HostPortPair host_port_pair2(r2_host_name, 80);
1548 QuicServerId server_id2(host_port_pair2, /*is_https=*/true, privacy_mode_); 1546 QuicServerId server_id2(host_port_pair2, privacy_mode_);
1549 QuicCryptoClientConfig::CachedState* cached2 = 1547 QuicCryptoClientConfig::CachedState* cached2 =
1550 crypto_config->LookupOrCreate(server_id2); 1548 crypto_config->LookupOrCreate(server_id2);
1551 EXPECT_EQ(cached1->source_address_token(), cached2->source_address_token()); 1549 EXPECT_EQ(cached1->source_address_token(), cached2->source_address_token());
1552 EXPECT_TRUE(cached2->proof_valid()); 1550 EXPECT_TRUE(cached2->proof_valid());
1553 } 1551 }
1554 } 1552 }
1555 1553
1556 TEST_P(QuicStreamFactoryTest, CryptoConfigWhenProofIsInvalid) { 1554 TEST_P(QuicStreamFactoryTest, CryptoConfigWhenProofIsInvalid) {
1557 vector<string> cannoncial_suffixes; 1555 vector<string> cannoncial_suffixes;
1558 cannoncial_suffixes.push_back(string(".c.youtube.com")); 1556 cannoncial_suffixes.push_back(string(".c.youtube.com"));
1559 cannoncial_suffixes.push_back(string(".googlevideo.com")); 1557 cannoncial_suffixes.push_back(string(".googlevideo.com"));
1560 1558
1561 for (unsigned i = 0; i < cannoncial_suffixes.size(); ++i) { 1559 for (unsigned i = 0; i < cannoncial_suffixes.size(); ++i) {
1562 string r3_host_name("r3"); 1560 string r3_host_name("r3");
1563 string r4_host_name("r4"); 1561 string r4_host_name("r4");
1564 r3_host_name.append(cannoncial_suffixes[i]); 1562 r3_host_name.append(cannoncial_suffixes[i]);
1565 r4_host_name.append(cannoncial_suffixes[i]); 1563 r4_host_name.append(cannoncial_suffixes[i]);
1566 1564
1567 HostPortPair host_port_pair1(r3_host_name, 80); 1565 HostPortPair host_port_pair1(r3_host_name, 80);
1568 QuicCryptoClientConfig* crypto_config = 1566 QuicCryptoClientConfig* crypto_config =
1569 QuicStreamFactoryPeer::GetCryptoConfig(&factory_); 1567 QuicStreamFactoryPeer::GetCryptoConfig(&factory_);
1570 QuicServerId server_id1(host_port_pair1, /*is_https=*/true, privacy_mode_); 1568 QuicServerId server_id1(host_port_pair1, privacy_mode_);
1571 QuicCryptoClientConfig::CachedState* cached1 = 1569 QuicCryptoClientConfig::CachedState* cached1 =
1572 crypto_config->LookupOrCreate(server_id1); 1570 crypto_config->LookupOrCreate(server_id1);
1573 EXPECT_FALSE(cached1->proof_valid()); 1571 EXPECT_FALSE(cached1->proof_valid());
1574 EXPECT_TRUE(cached1->source_address_token().empty()); 1572 EXPECT_TRUE(cached1->source_address_token().empty());
1575 1573
1576 // Mutate the cached1 to have different data. 1574 // Mutate the cached1 to have different data.
1577 // TODO(rtenneti): mutate other members of CachedState. 1575 // TODO(rtenneti): mutate other members of CachedState.
1578 cached1->set_source_address_token(r3_host_name); 1576 cached1->set_source_address_token(r3_host_name);
1579 cached1->SetProofInvalid(); 1577 cached1->SetProofInvalid();
1580 1578
1581 HostPortPair host_port_pair2(r4_host_name, 80); 1579 HostPortPair host_port_pair2(r4_host_name, 80);
1582 QuicServerId server_id2(host_port_pair2, /*is_https=*/true, privacy_mode_); 1580 QuicServerId server_id2(host_port_pair2, privacy_mode_);
1583 QuicCryptoClientConfig::CachedState* cached2 = 1581 QuicCryptoClientConfig::CachedState* cached2 =
1584 crypto_config->LookupOrCreate(server_id2); 1582 crypto_config->LookupOrCreate(server_id2);
1585 EXPECT_NE(cached1->source_address_token(), cached2->source_address_token()); 1583 EXPECT_NE(cached1->source_address_token(), cached2->source_address_token());
1586 EXPECT_TRUE(cached2->source_address_token().empty()); 1584 EXPECT_TRUE(cached2->source_address_token().empty());
1587 EXPECT_FALSE(cached2->proof_valid()); 1585 EXPECT_FALSE(cached2->proof_valid());
1588 } 1586 }
1589 } 1587 }
1590 1588
1591 TEST_P(QuicStreamFactoryTest, RacingConnections) { 1589 TEST_P(QuicStreamFactoryTest, RacingConnections) {
1592 if (!GetParam().enable_connection_racing) 1590 if (!GetParam().enable_connection_racing)
(...skipping 25 matching lines...) Expand all
1618 http_server_properties_.SetAlternativeServices( 1616 http_server_properties_.SetAlternativeServices(
1619 host_port_pair_, alternative_service_info_vector); 1617 host_port_pair_, alternative_service_info_vector);
1620 1618
1621 crypto_client_stream_factory_.set_handshake_mode( 1619 crypto_client_stream_factory_.set_handshake_mode(
1622 MockCryptoClientStream::ZERO_RTT); 1620 MockCryptoClientStream::ZERO_RTT);
1623 host_resolver_.set_synchronous_mode(true); 1621 host_resolver_.set_synchronous_mode(true);
1624 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(), 1622 host_resolver_.rules()->AddIPLiteralRule(host_port_pair_.host(),
1625 "192.168.0.1", ""); 1623 "192.168.0.1", "");
1626 1624
1627 QuicStreamRequest request(&factory_); 1625 QuicStreamRequest request(&factory_);
1628 QuicServerId server_id(host_port_pair_, /*is_https=*/true, privacy_mode_); 1626 QuicServerId server_id(host_port_pair_, privacy_mode_);
1629 EXPECT_EQ(ERR_IO_PENDING, 1627 EXPECT_EQ(ERR_IO_PENDING,
1630 request.Request(host_port_pair_, privacy_mode_, 1628 request.Request(host_port_pair_, privacy_mode_,
1631 /*cert_verify_flags=*/0, host_port_pair_.host(), 1629 /*cert_verify_flags=*/0, host_port_pair_.host(),
1632 "GET", net_log_, callback_.callback())); 1630 "GET", net_log_, callback_.callback()));
1633 EXPECT_EQ(2u, 1631 EXPECT_EQ(2u,
1634 QuicStreamFactoryPeer::GetNumberOfActiveJobs(&factory_, server_id)); 1632 QuicStreamFactoryPeer::GetNumberOfActiveJobs(&factory_, server_id));
1635 1633
1636 runner_->RunNextTask(); 1634 runner_->RunNextTask();
1637 1635
1638 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); 1636 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream();
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
2578 const AlternativeService alternative_service1(QUIC, host_port_pair_.host(), 2576 const AlternativeService alternative_service1(QUIC, host_port_pair_.host(),
2579 host_port_pair_.port()); 2577 host_port_pair_.port());
2580 AlternativeServiceInfoVector alternative_service_info_vector; 2578 AlternativeServiceInfoVector alternative_service_info_vector;
2581 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 2579 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
2582 alternative_service_info_vector.push_back( 2580 alternative_service_info_vector.push_back(
2583 AlternativeServiceInfo(alternative_service1, 1.0, expiration)); 2581 AlternativeServiceInfo(alternative_service1, 1.0, expiration));
2584 2582
2585 http_server_properties_.SetAlternativeServices( 2583 http_server_properties_.SetAlternativeServices(
2586 host_port_pair_, alternative_service_info_vector); 2584 host_port_pair_, alternative_service_info_vector);
2587 2585
2588 QuicServerId quic_server_id("www.google.com", 80, false, 2586 QuicServerId quic_server_id("www.google.com", 80, PRIVACY_MODE_DISABLED);
2589 PRIVACY_MODE_DISABLED);
2590 QuicServerInfoFactory* quic_server_info_factory = 2587 QuicServerInfoFactory* quic_server_info_factory =
2591 new PropertiesBasedQuicServerInfoFactory( 2588 new PropertiesBasedQuicServerInfoFactory(
2592 http_server_properties_.GetWeakPtr()); 2589 http_server_properties_.GetWeakPtr());
2593 factory_.set_quic_server_info_factory(quic_server_info_factory); 2590 factory_.set_quic_server_info_factory(quic_server_info_factory);
2594 2591
2595 scoped_ptr<QuicServerInfo> quic_server_info( 2592 scoped_ptr<QuicServerInfo> quic_server_info(
2596 quic_server_info_factory->GetForServer(quic_server_id)); 2593 quic_server_info_factory->GetForServer(quic_server_id));
2597 2594
2598 // Update quic_server_info's server_config and persist it. 2595 // Update quic_server_info's server_config and persist it.
2599 QuicServerInfo::State* state = quic_server_info->mutable_state(); 2596 QuicServerInfo::State* state = quic_server_info->mutable_state();
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
2728 EXPECT_EQ(1u, observer.executed_count()); 2725 EXPECT_EQ(1u, observer.executed_count());
2729 2726
2730 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream(); 2727 scoped_ptr<QuicHttpStream> stream = request.ReleaseStream();
2731 EXPECT_TRUE(stream.get()); 2728 EXPECT_TRUE(stream.get());
2732 EXPECT_TRUE(socket_data.AllReadDataConsumed()); 2729 EXPECT_TRUE(socket_data.AllReadDataConsumed());
2733 EXPECT_TRUE(socket_data.AllWriteDataConsumed()); 2730 EXPECT_TRUE(socket_data.AllWriteDataConsumed());
2734 } 2731 }
2735 2732
2736 } // namespace test 2733 } // namespace test
2737 } // namespace net 2734 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_stream_factory.cc ('k') | net/quic/test_tools/crypto_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698