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

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

Issue 1866613002: QUIC - Android - Fix the bug in QuicServerInfoMap iteration when server (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comments for PatchSet 1 Created 4 years, 8 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') | 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 "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 3783 matching lines...) Expand 10 before | Expand all | Expand 10 after
3794 3794
3795 const AlternativeService alternative_service1(QUIC, host_port_pair_.host(), 3795 const AlternativeService alternative_service1(QUIC, host_port_pair_.host(),
3796 host_port_pair_.port()); 3796 host_port_pair_.port());
3797 AlternativeServiceInfoVector alternative_service_info_vector; 3797 AlternativeServiceInfoVector alternative_service_info_vector;
3798 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1); 3798 base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
3799 alternative_service_info_vector.push_back( 3799 alternative_service_info_vector.push_back(
3800 AlternativeServiceInfo(alternative_service1, expiration)); 3800 AlternativeServiceInfo(alternative_service1, expiration));
3801 3801
3802 http_server_properties_.SetAlternativeServices( 3802 http_server_properties_.SetAlternativeServices(
3803 host_port_pair_, alternative_service_info_vector); 3803 host_port_pair_, alternative_service_info_vector);
3804
3805 HostPortPair host_port_pair2(kServer2HostName, kDefaultServerPort);
3806 const AlternativeService alternative_service2(QUIC, host_port_pair2.host(),
3807 host_port_pair2.port());
3808 AlternativeServiceInfoVector alternative_service_info_vector2;
3809 alternative_service_info_vector2.push_back(
3810 AlternativeServiceInfo(alternative_service2, expiration));
3811 http_server_properties_.SetAlternativeServices(
3812 host_port_pair2, alternative_service_info_vector2);
3813
3804 http_server_properties_.SetMaxServerConfigsStoredInProperties( 3814 http_server_properties_.SetMaxServerConfigsStoredInProperties(
3805 kMaxQuicServersToPersist); 3815 kMaxQuicServersToPersist);
3806 3816
3807 QuicServerId quic_server_id(kDefaultServerHostName, 80, 3817 QuicServerId quic_server_id(kDefaultServerHostName, 80,
3808 PRIVACY_MODE_DISABLED); 3818 PRIVACY_MODE_DISABLED);
3809 QuicServerInfoFactory* quic_server_info_factory = 3819 QuicServerInfoFactory* quic_server_info_factory =
3810 new PropertiesBasedQuicServerInfoFactory( 3820 new PropertiesBasedQuicServerInfoFactory(
3811 http_server_properties_.GetWeakPtr()); 3821 http_server_properties_.GetWeakPtr());
3812 factory_->set_quic_server_info_factory(quic_server_info_factory); 3822 factory_->set_quic_server_info_factory(quic_server_info_factory);
3813 3823
(...skipping 27 matching lines...) Expand all
3841 certs.push_back(test_cert); 3851 certs.push_back(test_cert);
3842 state->server_config = server_config; 3852 state->server_config = server_config;
3843 state->source_address_token = source_address_token; 3853 state->source_address_token = source_address_token;
3844 state->cert_sct = cert_sct; 3854 state->cert_sct = cert_sct;
3845 state->chlo_hash = chlo_hash; 3855 state->chlo_hash = chlo_hash;
3846 state->server_config_sig = signature; 3856 state->server_config_sig = signature;
3847 state->certs = certs; 3857 state->certs = certs;
3848 3858
3849 quic_server_info->Persist(); 3859 quic_server_info->Persist();
3850 3860
3861 QuicServerId quic_server_id2(kServer2HostName, 80, PRIVACY_MODE_DISABLED);
3862 scoped_ptr<QuicServerInfo> quic_server_info2(
3863 quic_server_info_factory->GetForServer(quic_server_id2));
3864
3865 // Update quic_server_info2's server_config and persist it.
3866 QuicServerInfo::State* state2 = quic_server_info2->mutable_state();
3867
3868 // Minimum SCFG that passes config validation checks.
3869 const char scfg2[] = {// SCFG
3870 0x53, 0x43, 0x46, 0x47,
3871 // num entries
3872 0x01, 0x00,
3873 // padding
3874 0x00, 0x00,
3875 // EXPY
3876 0x45, 0x58, 0x50, 0x59,
3877 // EXPY end offset
3878 0x08, 0x00, 0x00, 0x00,
3879 // Value
3880 '8', '7', '3', '4', '5', '6', '2', '1'};
3881
3882 // Create temporary strings becasue Persist() clears string data in |state2|.
3883 string server_config2(reinterpret_cast<const char*>(&scfg2), sizeof(scfg2));
3884 string source_address_token2("test_source_address_token2");
3885 string cert_sct2("test_cert_sct2");
3886 string chlo_hash2("test_chlo_hash2");
3887 string signature2("test_signature2");
3888 string test_cert2("test_cert2");
3889 vector<string> certs2;
3890 certs2.push_back(test_cert2);
3891 state2->server_config = server_config2;
3892 state2->source_address_token = source_address_token2;
3893 state2->cert_sct = cert_sct2;
3894 state2->chlo_hash = chlo_hash2;
3895 state2->server_config_sig = signature2;
3896 state2->certs = certs2;
3897
3898 quic_server_info2->Persist();
3899
3851 QuicStreamFactoryPeer::MaybeInitialize(factory_.get()); 3900 QuicStreamFactoryPeer::MaybeInitialize(factory_.get());
3852 EXPECT_TRUE(QuicStreamFactoryPeer::HasInitializedData(factory_.get())); 3901 EXPECT_TRUE(QuicStreamFactoryPeer::HasInitializedData(factory_.get()));
3902
3903 // Verify the MRU order is maintained.
3904 const QuicServerInfoMap& quic_server_info_map =
3905 http_server_properties_.quic_server_info_map();
3906 EXPECT_EQ(2u, quic_server_info_map.size());
3907 QuicServerInfoMap::const_iterator quic_server_info_map_it =
3908 quic_server_info_map.begin();
3909 EXPECT_EQ(quic_server_info_map_it->first, quic_server_id2);
3910 ++quic_server_info_map_it;
3911 EXPECT_EQ(quic_server_info_map_it->first, quic_server_id);
3912
3853 EXPECT_TRUE(QuicStreamFactoryPeer::SupportsQuicAtStartUp(factory_.get(), 3913 EXPECT_TRUE(QuicStreamFactoryPeer::SupportsQuicAtStartUp(factory_.get(),
3854 host_port_pair_)); 3914 host_port_pair_));
3855 EXPECT_FALSE(QuicStreamFactoryPeer::CryptoConfigCacheIsEmpty(factory_.get(), 3915 EXPECT_FALSE(QuicStreamFactoryPeer::CryptoConfigCacheIsEmpty(factory_.get(),
3856 quic_server_id)); 3916 quic_server_id));
3857 QuicCryptoClientConfig* crypto_config = 3917 QuicCryptoClientConfig* crypto_config =
3858 QuicStreamFactoryPeer::GetCryptoConfig(factory_.get()); 3918 QuicStreamFactoryPeer::GetCryptoConfig(factory_.get());
3859 QuicCryptoClientConfig::CachedState* cached = 3919 QuicCryptoClientConfig::CachedState* cached =
3860 crypto_config->LookupOrCreate(quic_server_id); 3920 crypto_config->LookupOrCreate(quic_server_id);
3861 EXPECT_FALSE(cached->server_config().empty()); 3921 EXPECT_FALSE(cached->server_config().empty());
3862 EXPECT_TRUE(cached->GetServerConfig()); 3922 EXPECT_TRUE(cached->GetServerConfig());
3863 EXPECT_EQ(server_config, cached->server_config()); 3923 EXPECT_EQ(server_config, cached->server_config());
3864 EXPECT_EQ(source_address_token, cached->source_address_token()); 3924 EXPECT_EQ(source_address_token, cached->source_address_token());
3865 EXPECT_EQ(cert_sct, cached->cert_sct()); 3925 EXPECT_EQ(cert_sct, cached->cert_sct());
3866 EXPECT_EQ(chlo_hash, cached->chlo_hash()); 3926 EXPECT_EQ(chlo_hash, cached->chlo_hash());
3867 EXPECT_EQ(signature, cached->signature()); 3927 EXPECT_EQ(signature, cached->signature());
3868 ASSERT_EQ(1U, cached->certs().size()); 3928 ASSERT_EQ(1U, cached->certs().size());
3869 EXPECT_EQ(test_cert, cached->certs()[0]); 3929 EXPECT_EQ(test_cert, cached->certs()[0]);
3930
3931 EXPECT_TRUE(QuicStreamFactoryPeer::SupportsQuicAtStartUp(factory_.get(),
3932 host_port_pair2));
3933 EXPECT_FALSE(QuicStreamFactoryPeer::CryptoConfigCacheIsEmpty(
3934 factory_.get(), quic_server_id2));
3935 QuicCryptoClientConfig::CachedState* cached2 =
3936 crypto_config->LookupOrCreate(quic_server_id2);
3937 EXPECT_FALSE(cached2->server_config().empty());
3938 EXPECT_TRUE(cached2->GetServerConfig());
3939 EXPECT_EQ(server_config2, cached2->server_config());
3940 EXPECT_EQ(source_address_token2, cached2->source_address_token());
3941 EXPECT_EQ(cert_sct2, cached2->cert_sct());
3942 EXPECT_EQ(chlo_hash2, cached2->chlo_hash());
3943 EXPECT_EQ(signature2, cached2->signature());
3944 ASSERT_EQ(1U, cached->certs().size());
3945 EXPECT_EQ(test_cert2, cached2->certs()[0]);
3870 } 3946 }
3871 3947
3872 TEST_P(QuicStreamFactoryTest, QuicDoingZeroRTT) { 3948 TEST_P(QuicStreamFactoryTest, QuicDoingZeroRTT) {
3873 Initialize(); 3949 Initialize();
3874 3950
3875 factory_->set_require_confirmation(true); 3951 factory_->set_require_confirmation(true);
3876 QuicServerId quic_server_id(host_port_pair_, PRIVACY_MODE_DISABLED); 3952 QuicServerId quic_server_id(host_port_pair_, PRIVACY_MODE_DISABLED);
3877 EXPECT_FALSE(factory_->ZeroRTTEnabledFor(quic_server_id)); 3953 EXPECT_FALSE(factory_->ZeroRTTEnabledFor(quic_server_id));
3878 3954
3879 factory_->set_require_confirmation(false); 3955 factory_->set_require_confirmation(false);
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
4080 EXPECT_TRUE(stream2.get()); 4156 EXPECT_TRUE(stream2.get());
4081 4157
4082 EXPECT_TRUE(socket_data1.AllReadDataConsumed()); 4158 EXPECT_TRUE(socket_data1.AllReadDataConsumed());
4083 EXPECT_TRUE(socket_data1.AllWriteDataConsumed()); 4159 EXPECT_TRUE(socket_data1.AllWriteDataConsumed());
4084 EXPECT_TRUE(socket_data2.AllReadDataConsumed()); 4160 EXPECT_TRUE(socket_data2.AllReadDataConsumed());
4085 EXPECT_TRUE(socket_data2.AllWriteDataConsumed()); 4161 EXPECT_TRUE(socket_data2.AllWriteDataConsumed());
4086 } 4162 }
4087 4163
4088 } // namespace test 4164 } // namespace test
4089 } // namespace net 4165 } // 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