| OLD | NEW |
| 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 Loading... |
| 1022 string r2_host_name("r2"); | 1022 string r2_host_name("r2"); |
| 1023 r1_host_name.append(cannoncial_suffixes[i]); | 1023 r1_host_name.append(cannoncial_suffixes[i]); |
| 1024 r2_host_name.append(cannoncial_suffixes[i]); | 1024 r2_host_name.append(cannoncial_suffixes[i]); |
| 1025 | 1025 |
| 1026 HostPortPair host_port_pair1(r1_host_name, 80); | 1026 HostPortPair host_port_pair1(r1_host_name, 80); |
| 1027 QuicCryptoClientConfig* crypto_config1 = | 1027 QuicCryptoClientConfig* crypto_config1 = |
| 1028 QuicStreamFactoryPeer::GetOrCreateCryptoConfig( | 1028 QuicStreamFactoryPeer::GetOrCreateCryptoConfig( |
| 1029 &factory_, host_port_pair1, is_https_); | 1029 &factory_, host_port_pair1, is_https_); |
| 1030 DCHECK(crypto_config1); | 1030 DCHECK(crypto_config1); |
| 1031 QuicCryptoClientConfig::CachedState* cached1 = | 1031 QuicCryptoClientConfig::CachedState* cached1 = |
| 1032 crypto_config1->LookupOrCreate(host_port_pair1.host()); | 1032 crypto_config1->LookupOrCreate(host_port_pair1.host(), |
| 1033 host_port_pair1.port()); |
| 1033 EXPECT_FALSE(cached1->proof_valid()); | 1034 EXPECT_FALSE(cached1->proof_valid()); |
| 1034 EXPECT_TRUE(cached1->source_address_token().empty()); | 1035 EXPECT_TRUE(cached1->source_address_token().empty()); |
| 1035 | 1036 |
| 1036 // Mutate the cached1 to have different data. | 1037 // Mutate the cached1 to have different data. |
| 1037 // TODO(rtenneti): mutate other members of CachedState. | 1038 // TODO(rtenneti): mutate other members of CachedState. |
| 1038 cached1->set_source_address_token(r1_host_name); | 1039 cached1->set_source_address_token(r1_host_name); |
| 1039 cached1->SetProofValid(); | 1040 cached1->SetProofValid(); |
| 1040 | 1041 |
| 1041 HostPortPair host_port_pair2(r2_host_name, 80); | 1042 HostPortPair host_port_pair2(r2_host_name, 80); |
| 1042 QuicCryptoClientConfig* crypto_config2 = | 1043 QuicCryptoClientConfig* crypto_config2 = |
| 1043 QuicStreamFactoryPeer::GetOrCreateCryptoConfig( | 1044 QuicStreamFactoryPeer::GetOrCreateCryptoConfig( |
| 1044 &factory_, host_port_pair2, is_https_); | 1045 &factory_, host_port_pair2, is_https_); |
| 1045 DCHECK(crypto_config2); | 1046 DCHECK(crypto_config2); |
| 1046 QuicCryptoClientConfig::CachedState* cached2 = | 1047 QuicCryptoClientConfig::CachedState* cached2 = |
| 1047 crypto_config2->LookupOrCreate(host_port_pair2.host()); | 1048 crypto_config2->LookupOrCreate(host_port_pair2.host(), |
| 1049 host_port_pair2.port()); |
| 1048 EXPECT_EQ(cached1->source_address_token(), cached2->source_address_token()); | 1050 EXPECT_EQ(cached1->source_address_token(), cached2->source_address_token()); |
| 1049 EXPECT_TRUE(cached2->proof_valid()); | 1051 EXPECT_TRUE(cached2->proof_valid()); |
| 1050 } | 1052 } |
| 1051 } | 1053 } |
| 1052 | 1054 |
| 1053 TEST_P(QuicStreamFactoryTest, CryptoConfigWhenProofIsInvalid) { | 1055 TEST_P(QuicStreamFactoryTest, CryptoConfigWhenProofIsInvalid) { |
| 1054 vector<string> cannoncial_suffixes; | 1056 vector<string> cannoncial_suffixes; |
| 1055 cannoncial_suffixes.push_back(string(".c.youtube.com")); | 1057 cannoncial_suffixes.push_back(string(".c.youtube.com")); |
| 1056 cannoncial_suffixes.push_back(string(".googlevideo.com")); | 1058 cannoncial_suffixes.push_back(string(".googlevideo.com")); |
| 1057 | 1059 |
| 1058 for (unsigned i = 0; i < cannoncial_suffixes.size(); ++i) { | 1060 for (unsigned i = 0; i < cannoncial_suffixes.size(); ++i) { |
| 1059 string r3_host_name("r3"); | 1061 string r3_host_name("r3"); |
| 1060 string r4_host_name("r4"); | 1062 string r4_host_name("r4"); |
| 1061 r3_host_name.append(cannoncial_suffixes[i]); | 1063 r3_host_name.append(cannoncial_suffixes[i]); |
| 1062 r4_host_name.append(cannoncial_suffixes[i]); | 1064 r4_host_name.append(cannoncial_suffixes[i]); |
| 1063 | 1065 |
| 1064 HostPortPair host_port_pair1(r3_host_name, 80); | 1066 HostPortPair host_port_pair1(r3_host_name, 80); |
| 1065 QuicCryptoClientConfig* crypto_config1 = | 1067 QuicCryptoClientConfig* crypto_config1 = |
| 1066 QuicStreamFactoryPeer::GetOrCreateCryptoConfig( | 1068 QuicStreamFactoryPeer::GetOrCreateCryptoConfig( |
| 1067 &factory_, host_port_pair1, is_https_); | 1069 &factory_, host_port_pair1, is_https_); |
| 1068 DCHECK(crypto_config1); | 1070 DCHECK(crypto_config1); |
| 1069 QuicCryptoClientConfig::CachedState* cached1 = | 1071 QuicCryptoClientConfig::CachedState* cached1 = |
| 1070 crypto_config1->LookupOrCreate(host_port_pair1.host()); | 1072 crypto_config1->LookupOrCreate(host_port_pair1.host(), |
| 1073 host_port_pair1.port()); |
| 1071 EXPECT_FALSE(cached1->proof_valid()); | 1074 EXPECT_FALSE(cached1->proof_valid()); |
| 1072 EXPECT_TRUE(cached1->source_address_token().empty()); | 1075 EXPECT_TRUE(cached1->source_address_token().empty()); |
| 1073 | 1076 |
| 1074 // Mutate the cached1 to have different data. | 1077 // Mutate the cached1 to have different data. |
| 1075 // TODO(rtenneti): mutate other members of CachedState. | 1078 // TODO(rtenneti): mutate other members of CachedState. |
| 1076 cached1->set_source_address_token(r3_host_name); | 1079 cached1->set_source_address_token(r3_host_name); |
| 1077 cached1->SetProofInvalid(); | 1080 cached1->SetProofInvalid(); |
| 1078 | 1081 |
| 1079 HostPortPair host_port_pair2(r4_host_name, 80); | 1082 HostPortPair host_port_pair2(r4_host_name, 80); |
| 1080 QuicCryptoClientConfig* crypto_config2 = | 1083 QuicCryptoClientConfig* crypto_config2 = |
| 1081 QuicStreamFactoryPeer::GetOrCreateCryptoConfig( | 1084 QuicStreamFactoryPeer::GetOrCreateCryptoConfig( |
| 1082 &factory_, host_port_pair2, is_https_); | 1085 &factory_, host_port_pair2, is_https_); |
| 1083 DCHECK(crypto_config2); | 1086 DCHECK(crypto_config2); |
| 1084 QuicCryptoClientConfig::CachedState* cached2 = | 1087 QuicCryptoClientConfig::CachedState* cached2 = |
| 1085 crypto_config2->LookupOrCreate(host_port_pair2.host()); | 1088 crypto_config2->LookupOrCreate(host_port_pair2.host(), |
| 1089 host_port_pair2.port()); |
| 1086 EXPECT_NE(cached1->source_address_token(), cached2->source_address_token()); | 1090 EXPECT_NE(cached1->source_address_token(), cached2->source_address_token()); |
| 1087 EXPECT_TRUE(cached2->source_address_token().empty()); | 1091 EXPECT_TRUE(cached2->source_address_token().empty()); |
| 1088 EXPECT_FALSE(cached2->proof_valid()); | 1092 EXPECT_FALSE(cached2->proof_valid()); |
| 1089 } | 1093 } |
| 1090 } | 1094 } |
| 1091 | 1095 |
| 1092 } // namespace test | 1096 } // namespace test |
| 1093 } // namespace net | 1097 } // namespace net |
| OLD | NEW |