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 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 r2_host_name.append(cannoncial_suffixes[i]); | 970 r2_host_name.append(cannoncial_suffixes[i]); |
971 | 971 |
972 HostPortProxyPair host_port_proxy_pair1(HostPortPair(r1_host_name, 80), | 972 HostPortProxyPair host_port_proxy_pair1(HostPortPair(r1_host_name, 80), |
973 ProxyServer::Direct()); | 973 ProxyServer::Direct()); |
974 | 974 |
975 QuicCryptoClientConfig* crypto_config1 = | 975 QuicCryptoClientConfig* crypto_config1 = |
976 QuicStreamFactoryPeer::GetOrCreateCryptoConfig(&factory_, | 976 QuicStreamFactoryPeer::GetOrCreateCryptoConfig(&factory_, |
977 host_port_proxy_pair1); | 977 host_port_proxy_pair1); |
978 DCHECK(crypto_config1); | 978 DCHECK(crypto_config1); |
979 QuicCryptoClientConfig::CachedState* cached1 = | 979 QuicCryptoClientConfig::CachedState* cached1 = |
980 crypto_config1->LookupOrCreate(host_port_proxy_pair1.first.host()); | 980 crypto_config1->LookupOrCreate(host_port_proxy_pair1.first.host(), |
| 981 host_port_proxy_pair1.first.port()); |
981 EXPECT_FALSE(cached1->proof_valid()); | 982 EXPECT_FALSE(cached1->proof_valid()); |
982 EXPECT_TRUE(cached1->source_address_token().empty()); | 983 EXPECT_TRUE(cached1->source_address_token().empty()); |
983 | 984 |
984 // Mutate the cached1 to have different data. | 985 // Mutate the cached1 to have different data. |
985 // TODO(rtenneti): mutate other members of CachedState. | 986 // TODO(rtenneti): mutate other members of CachedState. |
986 cached1->set_source_address_token(r1_host_name); | 987 cached1->set_source_address_token(r1_host_name); |
987 cached1->SetProofValid(); | 988 cached1->SetProofValid(); |
988 | 989 |
989 HostPortProxyPair host_port_proxy_pair2(HostPortPair(r2_host_name, 80), | 990 HostPortProxyPair host_port_proxy_pair2(HostPortPair(r2_host_name, 80), |
990 ProxyServer::Direct()); | 991 ProxyServer::Direct()); |
991 QuicCryptoClientConfig* crypto_config2 = | 992 QuicCryptoClientConfig* crypto_config2 = |
992 QuicStreamFactoryPeer::GetOrCreateCryptoConfig(&factory_, | 993 QuicStreamFactoryPeer::GetOrCreateCryptoConfig(&factory_, |
993 host_port_proxy_pair2); | 994 host_port_proxy_pair2); |
994 DCHECK(crypto_config2); | 995 DCHECK(crypto_config2); |
995 QuicCryptoClientConfig::CachedState* cached2 = | 996 QuicCryptoClientConfig::CachedState* cached2 = |
996 crypto_config2->LookupOrCreate(host_port_proxy_pair2.first.host()); | 997 crypto_config2->LookupOrCreate(host_port_proxy_pair2.first.host(), |
| 998 host_port_proxy_pair2.first.port()); |
997 EXPECT_EQ(cached1->source_address_token(), cached2->source_address_token()); | 999 EXPECT_EQ(cached1->source_address_token(), cached2->source_address_token()); |
998 EXPECT_TRUE(cached2->proof_valid()); | 1000 EXPECT_TRUE(cached2->proof_valid()); |
999 } | 1001 } |
1000 } | 1002 } |
1001 | 1003 |
1002 TEST_P(QuicStreamFactoryTest, CryptoConfigWhenProofIsInvalid) { | 1004 TEST_P(QuicStreamFactoryTest, CryptoConfigWhenProofIsInvalid) { |
1003 vector<string> cannoncial_suffixes; | 1005 vector<string> cannoncial_suffixes; |
1004 cannoncial_suffixes.push_back(string(".c.youtube.com")); | 1006 cannoncial_suffixes.push_back(string(".c.youtube.com")); |
1005 cannoncial_suffixes.push_back(string(".googlevideo.com")); | 1007 cannoncial_suffixes.push_back(string(".googlevideo.com")); |
1006 | 1008 |
1007 for (unsigned i = 0; i < cannoncial_suffixes.size(); ++i) { | 1009 for (unsigned i = 0; i < cannoncial_suffixes.size(); ++i) { |
1008 string r3_host_name("r3"); | 1010 string r3_host_name("r3"); |
1009 string r4_host_name("r4"); | 1011 string r4_host_name("r4"); |
1010 r3_host_name.append(cannoncial_suffixes[i]); | 1012 r3_host_name.append(cannoncial_suffixes[i]); |
1011 r4_host_name.append(cannoncial_suffixes[i]); | 1013 r4_host_name.append(cannoncial_suffixes[i]); |
1012 | 1014 |
1013 HostPortProxyPair host_port_proxy_pair1(HostPortPair(r3_host_name, 80), | 1015 HostPortProxyPair host_port_proxy_pair1(HostPortPair(r3_host_name, 80), |
1014 ProxyServer::Direct()); | 1016 ProxyServer::Direct()); |
1015 | 1017 |
1016 QuicCryptoClientConfig* crypto_config1 = | 1018 QuicCryptoClientConfig* crypto_config1 = |
1017 QuicStreamFactoryPeer::GetOrCreateCryptoConfig(&factory_, | 1019 QuicStreamFactoryPeer::GetOrCreateCryptoConfig(&factory_, |
1018 host_port_proxy_pair1); | 1020 host_port_proxy_pair1); |
1019 DCHECK(crypto_config1); | 1021 DCHECK(crypto_config1); |
1020 QuicCryptoClientConfig::CachedState* cached1 = | 1022 QuicCryptoClientConfig::CachedState* cached1 = |
1021 crypto_config1->LookupOrCreate(host_port_proxy_pair1.first.host()); | 1023 crypto_config1->LookupOrCreate(host_port_proxy_pair1.first.host(), |
| 1024 host_port_proxy_pair1.first.port()); |
1022 EXPECT_FALSE(cached1->proof_valid()); | 1025 EXPECT_FALSE(cached1->proof_valid()); |
1023 EXPECT_TRUE(cached1->source_address_token().empty()); | 1026 EXPECT_TRUE(cached1->source_address_token().empty()); |
1024 | 1027 |
1025 // Mutate the cached1 to have different data. | 1028 // Mutate the cached1 to have different data. |
1026 // TODO(rtenneti): mutate other members of CachedState. | 1029 // TODO(rtenneti): mutate other members of CachedState. |
1027 cached1->set_source_address_token(r3_host_name); | 1030 cached1->set_source_address_token(r3_host_name); |
1028 cached1->SetProofInvalid(); | 1031 cached1->SetProofInvalid(); |
1029 | 1032 |
1030 HostPortProxyPair host_port_proxy_pair2(HostPortPair(r4_host_name, 80), | 1033 HostPortProxyPair host_port_proxy_pair2(HostPortPair(r4_host_name, 80), |
1031 ProxyServer::Direct()); | 1034 ProxyServer::Direct()); |
1032 QuicCryptoClientConfig* crypto_config2 = | 1035 QuicCryptoClientConfig* crypto_config2 = |
1033 QuicStreamFactoryPeer::GetOrCreateCryptoConfig(&factory_, | 1036 QuicStreamFactoryPeer::GetOrCreateCryptoConfig(&factory_, |
1034 host_port_proxy_pair2); | 1037 host_port_proxy_pair2); |
1035 DCHECK(crypto_config2); | 1038 DCHECK(crypto_config2); |
1036 QuicCryptoClientConfig::CachedState* cached2 = | 1039 QuicCryptoClientConfig::CachedState* cached2 = |
1037 crypto_config2->LookupOrCreate(host_port_proxy_pair2.first.host()); | 1040 crypto_config2->LookupOrCreate(host_port_proxy_pair2.first.host(), |
| 1041 host_port_proxy_pair2.first.port()); |
1038 EXPECT_NE(cached1->source_address_token(), cached2->source_address_token()); | 1042 EXPECT_NE(cached1->source_address_token(), cached2->source_address_token()); |
1039 EXPECT_TRUE(cached2->source_address_token().empty()); | 1043 EXPECT_TRUE(cached2->source_address_token().empty()); |
1040 EXPECT_FALSE(cached2->proof_valid()); | 1044 EXPECT_FALSE(cached2->proof_valid()); |
1041 } | 1045 } |
1042 } | 1046 } |
1043 | 1047 |
1044 } // namespace test | 1048 } // namespace test |
1045 } // namespace net | 1049 } // namespace net |
OLD | NEW |