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

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

Issue 192583004: QUIC - use QuicSessionKey tuple (host, port, is_https) instead of server_hostname (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use QuicSessionKey as arg and delete server_hostname as arg Created 6 years, 9 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 | Annotate | Revision Log
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/base/test_data_directory.h" 9 #include "net/base/test_data_directory.h"
10 #include "net/cert/cert_verifier.h" 10 #include "net/cert/cert_verifier.h"
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 string r1_host_name("r1"); 1022 string r1_host_name("r1");
1023 string r2_host_name("r2"); 1023 string r2_host_name("r2");
1024 r1_host_name.append(cannoncial_suffixes[i]); 1024 r1_host_name.append(cannoncial_suffixes[i]);
1025 r2_host_name.append(cannoncial_suffixes[i]); 1025 r2_host_name.append(cannoncial_suffixes[i]);
1026 1026
1027 HostPortPair host_port_pair1(r1_host_name, 80); 1027 HostPortPair host_port_pair1(r1_host_name, 80);
1028 QuicCryptoClientConfig* crypto_config1 = 1028 QuicCryptoClientConfig* crypto_config1 =
1029 QuicStreamFactoryPeer::GetOrCreateCryptoConfig( 1029 QuicStreamFactoryPeer::GetOrCreateCryptoConfig(
1030 &factory_, host_port_pair1, is_https_); 1030 &factory_, host_port_pair1, is_https_);
1031 DCHECK(crypto_config1); 1031 DCHECK(crypto_config1);
1032 QuicSessionKey session_key1(host_port_pair1, is_https_);
1032 QuicCryptoClientConfig::CachedState* cached1 = 1033 QuicCryptoClientConfig::CachedState* cached1 =
1033 crypto_config1->LookupOrCreate(host_port_pair1.host()); 1034 crypto_config1->LookupOrCreate(session_key1);
1034 EXPECT_FALSE(cached1->proof_valid()); 1035 EXPECT_FALSE(cached1->proof_valid());
1035 EXPECT_TRUE(cached1->source_address_token().empty()); 1036 EXPECT_TRUE(cached1->source_address_token().empty());
1036 1037
1037 // Mutate the cached1 to have different data. 1038 // Mutate the cached1 to have different data.
1038 // TODO(rtenneti): mutate other members of CachedState. 1039 // TODO(rtenneti): mutate other members of CachedState.
1039 cached1->set_source_address_token(r1_host_name); 1040 cached1->set_source_address_token(r1_host_name);
1040 cached1->SetProofValid(); 1041 cached1->SetProofValid();
1041 1042
1042 HostPortPair host_port_pair2(r2_host_name, 80); 1043 HostPortPair host_port_pair2(r2_host_name, 80);
1043 QuicCryptoClientConfig* crypto_config2 = 1044 QuicCryptoClientConfig* crypto_config2 =
1044 QuicStreamFactoryPeer::GetOrCreateCryptoConfig( 1045 QuicStreamFactoryPeer::GetOrCreateCryptoConfig(
1045 &factory_, host_port_pair2, is_https_); 1046 &factory_, host_port_pair2, is_https_);
1046 DCHECK(crypto_config2); 1047 DCHECK(crypto_config2);
1048 QuicSessionKey session_key2(host_port_pair2, is_https_);
1047 QuicCryptoClientConfig::CachedState* cached2 = 1049 QuicCryptoClientConfig::CachedState* cached2 =
1048 crypto_config2->LookupOrCreate(host_port_pair2.host()); 1050 crypto_config2->LookupOrCreate(session_key2);
1049 EXPECT_EQ(cached1->source_address_token(), cached2->source_address_token()); 1051 EXPECT_EQ(cached1->source_address_token(), cached2->source_address_token());
1050 EXPECT_TRUE(cached2->proof_valid()); 1052 EXPECT_TRUE(cached2->proof_valid());
1051 } 1053 }
1052 } 1054 }
1053 1055
1054 TEST_P(QuicStreamFactoryTest, CryptoConfigWhenProofIsInvalid) { 1056 TEST_P(QuicStreamFactoryTest, CryptoConfigWhenProofIsInvalid) {
1055 vector<string> cannoncial_suffixes; 1057 vector<string> cannoncial_suffixes;
1056 cannoncial_suffixes.push_back(string(".c.youtube.com")); 1058 cannoncial_suffixes.push_back(string(".c.youtube.com"));
1057 cannoncial_suffixes.push_back(string(".googlevideo.com")); 1059 cannoncial_suffixes.push_back(string(".googlevideo.com"));
1058 1060
1059 for (unsigned i = 0; i < cannoncial_suffixes.size(); ++i) { 1061 for (unsigned i = 0; i < cannoncial_suffixes.size(); ++i) {
1060 string r3_host_name("r3"); 1062 string r3_host_name("r3");
1061 string r4_host_name("r4"); 1063 string r4_host_name("r4");
1062 r3_host_name.append(cannoncial_suffixes[i]); 1064 r3_host_name.append(cannoncial_suffixes[i]);
1063 r4_host_name.append(cannoncial_suffixes[i]); 1065 r4_host_name.append(cannoncial_suffixes[i]);
1064 1066
1065 HostPortPair host_port_pair1(r3_host_name, 80); 1067 HostPortPair host_port_pair1(r3_host_name, 80);
1066 QuicCryptoClientConfig* crypto_config1 = 1068 QuicCryptoClientConfig* crypto_config1 =
1067 QuicStreamFactoryPeer::GetOrCreateCryptoConfig( 1069 QuicStreamFactoryPeer::GetOrCreateCryptoConfig(
1068 &factory_, host_port_pair1, is_https_); 1070 &factory_, host_port_pair1, is_https_);
1069 DCHECK(crypto_config1); 1071 DCHECK(crypto_config1);
1072 QuicSessionKey session_key1(host_port_pair1, is_https_);
1070 QuicCryptoClientConfig::CachedState* cached1 = 1073 QuicCryptoClientConfig::CachedState* cached1 =
1071 crypto_config1->LookupOrCreate(host_port_pair1.host()); 1074 crypto_config1->LookupOrCreate(session_key1);
1072 EXPECT_FALSE(cached1->proof_valid()); 1075 EXPECT_FALSE(cached1->proof_valid());
1073 EXPECT_TRUE(cached1->source_address_token().empty()); 1076 EXPECT_TRUE(cached1->source_address_token().empty());
1074 1077
1075 // Mutate the cached1 to have different data. 1078 // Mutate the cached1 to have different data.
1076 // TODO(rtenneti): mutate other members of CachedState. 1079 // TODO(rtenneti): mutate other members of CachedState.
1077 cached1->set_source_address_token(r3_host_name); 1080 cached1->set_source_address_token(r3_host_name);
1078 cached1->SetProofInvalid(); 1081 cached1->SetProofInvalid();
1079 1082
1080 HostPortPair host_port_pair2(r4_host_name, 80); 1083 HostPortPair host_port_pair2(r4_host_name, 80);
1081 QuicCryptoClientConfig* crypto_config2 = 1084 QuicCryptoClientConfig* crypto_config2 =
1082 QuicStreamFactoryPeer::GetOrCreateCryptoConfig( 1085 QuicStreamFactoryPeer::GetOrCreateCryptoConfig(
1083 &factory_, host_port_pair2, is_https_); 1086 &factory_, host_port_pair2, is_https_);
1084 DCHECK(crypto_config2); 1087 DCHECK(crypto_config2);
1088 QuicSessionKey session_key2(host_port_pair2, is_https_);
1085 QuicCryptoClientConfig::CachedState* cached2 = 1089 QuicCryptoClientConfig::CachedState* cached2 =
1086 crypto_config2->LookupOrCreate(host_port_pair2.host()); 1090 crypto_config2->LookupOrCreate(session_key2);
1087 EXPECT_NE(cached1->source_address_token(), cached2->source_address_token()); 1091 EXPECT_NE(cached1->source_address_token(), cached2->source_address_token());
1088 EXPECT_TRUE(cached2->source_address_token().empty()); 1092 EXPECT_TRUE(cached2->source_address_token().empty());
1089 EXPECT_FALSE(cached2->proof_valid()); 1093 EXPECT_FALSE(cached2->proof_valid());
1090 } 1094 }
1091 } 1095 }
1092 1096
1093 } // namespace test 1097 } // namespace test
1094 } // namespace net 1098 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698