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" |
11 #include "net/dns/mock_host_resolver.h" | 11 #include "net/dns/mock_host_resolver.h" |
12 #include "net/http/http_response_headers.h" | 12 #include "net/http/http_response_headers.h" |
13 #include "net/http/http_response_info.h" | 13 #include "net/http/http_response_info.h" |
14 #include "net/http/http_util.h" | 14 #include "net/http/http_util.h" |
15 #include "net/quic/crypto/crypto_handshake.h" | 15 #include "net/quic/crypto/crypto_handshake.h" |
16 #include "net/quic/crypto/proof_verifier_chromium.h" | 16 #include "net/quic/crypto/proof_verifier_chromium.h" |
17 #include "net/quic/crypto/quic_decrypter.h" | 17 #include "net/quic/crypto/quic_decrypter.h" |
18 #include "net/quic/crypto/quic_encrypter.h" | 18 #include "net/quic/crypto/quic_encrypter.h" |
19 #include "net/quic/quic_http_stream.h" | 19 #include "net/quic/quic_http_stream.h" |
20 #include "net/quic/quic_server_id.h" | 20 #include "net/quic/quic_server_id.h" |
21 #include "net/quic/test_tools/mock_clock.h" | 21 #include "net/quic/test_tools/mock_clock.h" |
22 #include "net/quic/test_tools/mock_crypto_client_stream_factory.h" | 22 #include "net/quic/test_tools/mock_crypto_client_stream_factory.h" |
23 #include "net/quic/test_tools/mock_random.h" | 23 #include "net/quic/test_tools/mock_random.h" |
24 #include "net/quic/test_tools/quic_test_packet_maker.h" | 24 #include "net/quic/test_tools/quic_test_packet_maker.h" |
25 #include "net/quic/test_tools/quic_test_utils.h" | 25 #include "net/quic/test_tools/quic_test_utils.h" |
26 #include "net/socket/socket_test_util.h" | 26 #include "net/socket/socket_test_util.h" |
| 27 #include "net/ssl/default_server_bound_cert_store.h" |
27 #include "net/test/cert_test_util.h" | 28 #include "net/test/cert_test_util.h" |
28 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
29 | 30 |
30 using base::StringPiece; | 31 using base::StringPiece; |
31 using std::string; | 32 using std::string; |
32 using std::vector; | 33 using std::vector; |
33 | 34 |
34 namespace net { | 35 namespace net { |
35 namespace test { | 36 namespace test { |
36 | 37 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 } | 83 } |
83 }; | 84 }; |
84 | 85 |
85 class QuicStreamFactoryTest : public ::testing::TestWithParam<QuicVersion> { | 86 class QuicStreamFactoryTest : public ::testing::TestWithParam<QuicVersion> { |
86 protected: | 87 protected: |
87 QuicStreamFactoryTest() | 88 QuicStreamFactoryTest() |
88 : random_generator_(0), | 89 : random_generator_(0), |
89 maker_(GetParam(), 0), | 90 maker_(GetParam(), 0), |
90 clock_(new MockClock()), | 91 clock_(new MockClock()), |
91 cert_verifier_(CertVerifier::CreateDefault()), | 92 cert_verifier_(CertVerifier::CreateDefault()), |
| 93 server_bound_cert_service_(new ServerBoundCertService( |
| 94 new DefaultServerBoundCertStore(NULL), |
| 95 base::MessageLoopProxy::current())), |
92 factory_(&host_resolver_, &socket_factory_, | 96 factory_(&host_resolver_, &socket_factory_, |
93 base::WeakPtr<HttpServerProperties>(), cert_verifier_.get(), | 97 base::WeakPtr<HttpServerProperties>(), cert_verifier_.get(), |
| 98 server_bound_cert_service_.get(), |
94 &crypto_client_stream_factory_, &random_generator_, clock_, | 99 &crypto_client_stream_factory_, &random_generator_, clock_, |
95 kDefaultMaxPacketSize, std::string(), | 100 kDefaultMaxPacketSize, std::string(), |
96 SupportedVersions(GetParam()), true, true, true, | 101 SupportedVersions(GetParam()), true, true, true, |
97 QuicTagVector()), | 102 QuicTagVector()), |
98 host_port_pair_(kDefaultServerHostName, kDefaultServerPort), | 103 host_port_pair_(kDefaultServerHostName, kDefaultServerPort), |
99 is_https_(false), | 104 is_https_(false), |
100 privacy_mode_(PRIVACY_MODE_DISABLED) { | 105 privacy_mode_(PRIVACY_MODE_DISABLED) { |
101 factory_.set_require_confirmation(false); | 106 factory_.set_require_confirmation(false); |
102 } | 107 } |
103 | 108 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 AdjustErrorForVersion(QUIC_RST_FLOW_CONTROL_ACCOUNTING, GetParam())); | 180 AdjustErrorForVersion(QUIC_RST_FLOW_CONTROL_ACCOUNTING, GetParam())); |
176 } | 181 } |
177 | 182 |
178 MockHostResolver host_resolver_; | 183 MockHostResolver host_resolver_; |
179 DeterministicMockClientSocketFactory socket_factory_; | 184 DeterministicMockClientSocketFactory socket_factory_; |
180 MockCryptoClientStreamFactory crypto_client_stream_factory_; | 185 MockCryptoClientStreamFactory crypto_client_stream_factory_; |
181 MockRandom random_generator_; | 186 MockRandom random_generator_; |
182 QuicTestPacketMaker maker_; | 187 QuicTestPacketMaker maker_; |
183 MockClock* clock_; // Owned by factory_. | 188 MockClock* clock_; // Owned by factory_. |
184 scoped_ptr<CertVerifier> cert_verifier_; | 189 scoped_ptr<CertVerifier> cert_verifier_; |
| 190 scoped_ptr<ServerBoundCertService> server_bound_cert_service_; |
185 QuicStreamFactory factory_; | 191 QuicStreamFactory factory_; |
186 HostPortPair host_port_pair_; | 192 HostPortPair host_port_pair_; |
187 bool is_https_; | 193 bool is_https_; |
188 PrivacyMode privacy_mode_; | 194 PrivacyMode privacy_mode_; |
189 BoundNetLog net_log_; | 195 BoundNetLog net_log_; |
190 TestCompletionCallback callback_; | 196 TestCompletionCallback callback_; |
191 }; | 197 }; |
192 | 198 |
193 INSTANTIATE_TEST_CASE_P(Version, QuicStreamFactoryTest, | 199 INSTANTIATE_TEST_CASE_P(Version, QuicStreamFactoryTest, |
194 ::testing::ValuesIn(QuicSupportedVersions())); | 200 ::testing::ValuesIn(QuicSupportedVersions())); |
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1140 QuicCryptoClientConfig::CachedState* cached2 = | 1146 QuicCryptoClientConfig::CachedState* cached2 = |
1141 crypto_config->LookupOrCreate(server_id2); | 1147 crypto_config->LookupOrCreate(server_id2); |
1142 EXPECT_NE(cached1->source_address_token(), cached2->source_address_token()); | 1148 EXPECT_NE(cached1->source_address_token(), cached2->source_address_token()); |
1143 EXPECT_TRUE(cached2->source_address_token().empty()); | 1149 EXPECT_TRUE(cached2->source_address_token().empty()); |
1144 EXPECT_FALSE(cached2->proof_valid()); | 1150 EXPECT_FALSE(cached2->proof_valid()); |
1145 } | 1151 } |
1146 } | 1152 } |
1147 | 1153 |
1148 } // namespace test | 1154 } // namespace test |
1149 } // namespace net | 1155 } // namespace net |
OLD | NEW |