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_chromium_client_session.h" | 5 #include "net/quic/quic_chromium_client_session.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
13 #include "net/base/socket_performance_watcher.h" | 13 #include "net/base/socket_performance_watcher.h" |
14 #include "net/base/test_completion_callback.h" | 14 #include "net/base/test_completion_callback.h" |
15 #include "net/base/test_data_directory.h" | 15 #include "net/base/test_data_directory.h" |
16 #include "net/cert/cert_verify_result.h" | 16 #include "net/cert/cert_verify_result.h" |
17 #include "net/http/transport_security_state.h" | 17 #include "net/http/transport_security_state.h" |
18 #include "net/log/test_net_log.h" | 18 #include "net/log/test_net_log.h" |
19 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" | 19 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" |
20 #include "net/quic/crypto/crypto_protocol.h" | 20 #include "net/quic/crypto/crypto_protocol.h" |
21 #include "net/quic/crypto/proof_verifier_chromium.h" | 21 #include "net/quic/crypto/proof_verifier_chromium.h" |
22 #include "net/quic/crypto/quic_decrypter.h" | 22 #include "net/quic/crypto/quic_decrypter.h" |
23 #include "net/quic/crypto/quic_encrypter.h" | 23 #include "net/quic/crypto/quic_encrypter.h" |
24 #include "net/quic/crypto/quic_server_info.h" | 24 #include "net/quic/crypto/quic_server_info.h" |
| 25 #include "net/quic/quic_flags.h" |
25 #include "net/quic/quic_packet_reader.h" | 26 #include "net/quic/quic_packet_reader.h" |
| 27 #include "net/quic/quic_protocol.h" |
26 #include "net/quic/test_tools/crypto_test_utils.h" | 28 #include "net/quic/test_tools/crypto_test_utils.h" |
27 #include "net/quic/test_tools/quic_chromium_client_session_peer.h" | 29 #include "net/quic/test_tools/quic_chromium_client_session_peer.h" |
28 #include "net/quic/test_tools/quic_spdy_session_peer.h" | 30 #include "net/quic/test_tools/quic_spdy_session_peer.h" |
29 #include "net/quic/test_tools/quic_test_utils.h" | 31 #include "net/quic/test_tools/quic_test_utils.h" |
30 #include "net/quic/test_tools/simple_quic_framer.h" | 32 #include "net/quic/test_tools/simple_quic_framer.h" |
31 #include "net/socket/socket_test_util.h" | 33 #include "net/socket/socket_test_util.h" |
32 #include "net/spdy/spdy_test_utils.h" | 34 #include "net/spdy/spdy_test_utils.h" |
33 #include "net/test/cert_test_util.h" | 35 #include "net/test/cert_test_util.h" |
34 #include "net/udp/datagram_client_socket.h" | 36 #include "net/udp/datagram_client_socket.h" |
35 | 37 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 MockClock clock_; | 107 MockClock clock_; |
106 MockRandom random_; | 108 MockRandom random_; |
107 QuicConnectionVisitorInterface* visitor_; | 109 QuicConnectionVisitorInterface* visitor_; |
108 TestCompletionCallback callback_; | 110 TestCompletionCallback callback_; |
109 }; | 111 }; |
110 | 112 |
111 INSTANTIATE_TEST_CASE_P(Tests, | 113 INSTANTIATE_TEST_CASE_P(Tests, |
112 QuicChromiumClientSessionTest, | 114 QuicChromiumClientSessionTest, |
113 ::testing::ValuesIn(QuicSupportedVersions())); | 115 ::testing::ValuesIn(QuicSupportedVersions())); |
114 | 116 |
115 #if defined(OPENSSL) | |
116 | |
117 TEST_P(QuicChromiumClientSessionTest, CryptoConnect) { | 117 TEST_P(QuicChromiumClientSessionTest, CryptoConnect) { |
118 CompleteCryptoHandshake(); | 118 CompleteCryptoHandshake(); |
119 } | 119 } |
120 | 120 |
121 TEST_P(QuicChromiumClientSessionTest, MaxNumStreams) { | 121 TEST_P(QuicChromiumClientSessionTest, MaxNumStreams) { |
122 CompleteCryptoHandshake(); | 122 CompleteCryptoHandshake(); |
123 | 123 |
124 std::vector<QuicReliableClientStream*> streams; | 124 std::vector<QuicReliableClientStream*> streams; |
125 for (size_t i = 0; i < kDefaultMaxStreamsPerConnection; i++) { | 125 for (size_t i = 0; i < kDefaultMaxStreamsPerConnection; i++) { |
126 QuicReliableClientStream* stream = session_.CreateOutgoingDynamicStream(); | 126 QuicReliableClientStream* stream = session_.CreateOutgoingDynamicStream(); |
127 EXPECT_TRUE(stream); | 127 EXPECT_TRUE(stream); |
128 streams.push_back(stream); | 128 streams.push_back(stream); |
129 } | 129 } |
130 EXPECT_FALSE(session_.CreateOutgoingDynamicStream()); | 130 EXPECT_FALSE(session_.CreateOutgoingDynamicStream()); |
131 | 131 |
| 132 EXPECT_EQ(kDefaultMaxStreamsPerConnection, session_.GetNumOpenStreams()); |
| 133 |
132 // Close a stream and ensure I can now open a new one. | 134 // Close a stream and ensure I can now open a new one. |
133 session_.CloseStream(streams[0]->id()); | 135 QuicStreamId stream_id = streams[0]->id(); |
| 136 session_.CloseStream(stream_id); |
| 137 |
| 138 EXPECT_FALSE(session_.CreateOutgoingDynamicStream()); |
| 139 QuicRstStreamFrame rst1(stream_id, QUIC_STREAM_NO_ERROR, 0); |
| 140 session_.OnRstStream(rst1); |
| 141 EXPECT_EQ(kDefaultMaxStreamsPerConnection - 1, session_.GetNumOpenStreams()); |
134 EXPECT_TRUE(session_.CreateOutgoingDynamicStream()); | 142 EXPECT_TRUE(session_.CreateOutgoingDynamicStream()); |
135 } | 143 } |
136 | 144 |
137 TEST_P(QuicChromiumClientSessionTest, MaxNumStreamsViaRequest) { | 145 TEST_P(QuicChromiumClientSessionTest, MaxNumStreamsViaRequest) { |
138 CompleteCryptoHandshake(); | 146 CompleteCryptoHandshake(); |
139 | 147 |
140 std::vector<QuicReliableClientStream*> streams; | 148 std::vector<QuicReliableClientStream*> streams; |
141 for (size_t i = 0; i < kDefaultMaxStreamsPerConnection; i++) { | 149 for (size_t i = 0; i < kDefaultMaxStreamsPerConnection; i++) { |
142 QuicReliableClientStream* stream = session_.CreateOutgoingDynamicStream(); | 150 QuicReliableClientStream* stream = session_.CreateOutgoingDynamicStream(); |
143 EXPECT_TRUE(stream); | 151 EXPECT_TRUE(stream); |
144 streams.push_back(stream); | 152 streams.push_back(stream); |
145 } | 153 } |
146 | 154 |
147 QuicReliableClientStream* stream; | 155 QuicReliableClientStream* stream; |
148 QuicChromiumClientSession::StreamRequest stream_request; | 156 QuicChromiumClientSession::StreamRequest stream_request; |
149 TestCompletionCallback callback; | 157 TestCompletionCallback callback; |
150 ASSERT_EQ(ERR_IO_PENDING, | 158 ASSERT_EQ(ERR_IO_PENDING, |
151 stream_request.StartRequest(session_.GetWeakPtr(), &stream, | 159 stream_request.StartRequest(session_.GetWeakPtr(), &stream, |
152 callback.callback())); | 160 callback.callback())); |
153 | 161 |
154 // Close a stream and ensure I can now open a new one. | 162 // Close a stream and ensure I can now open a new one. |
155 session_.CloseStream(streams[0]->id()); | 163 QuicStreamId stream_id = streams[0]->id(); |
| 164 session_.CloseStream(stream_id); |
| 165 QuicRstStreamFrame rst1(stream_id, QUIC_STREAM_NO_ERROR, 0); |
| 166 session_.OnRstStream(rst1); |
156 ASSERT_TRUE(callback.have_result()); | 167 ASSERT_TRUE(callback.have_result()); |
157 EXPECT_EQ(OK, callback.WaitForResult()); | 168 EXPECT_EQ(OK, callback.WaitForResult()); |
158 EXPECT_TRUE(stream != nullptr); | 169 EXPECT_TRUE(stream != nullptr); |
159 } | 170 } |
160 | 171 |
161 TEST_P(QuicChromiumClientSessionTest, GoAwayReceived) { | 172 TEST_P(QuicChromiumClientSessionTest, GoAwayReceived) { |
162 CompleteCryptoHandshake(); | 173 CompleteCryptoHandshake(); |
163 | 174 |
164 // After receiving a GoAway, I should no longer be able to create outgoing | 175 // After receiving a GoAway, I should no longer be able to create outgoing |
165 // streams. | 176 // streams. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 ASSERT_TRUE(details.cert_verify_result.verified_cert.get()); | 262 ASSERT_TRUE(details.cert_verify_result.verified_cert.get()); |
252 | 263 |
253 CompleteCryptoHandshake(); | 264 CompleteCryptoHandshake(); |
254 session_.OnProofVerifyDetailsAvailable(details); | 265 session_.OnProofVerifyDetailsAvailable(details); |
255 QuicChromiumClientSessionPeer::SetHostname(&session_, "www.example.org"); | 266 QuicChromiumClientSessionPeer::SetHostname(&session_, "www.example.org"); |
256 QuicChromiumClientSessionPeer::SetChannelIDSent(&session_, true); | 267 QuicChromiumClientSessionPeer::SetChannelIDSent(&session_, true); |
257 | 268 |
258 EXPECT_TRUE(session_.CanPool("mail.example.org", PRIVACY_MODE_DISABLED)); | 269 EXPECT_TRUE(session_.CanPool("mail.example.org", PRIVACY_MODE_DISABLED)); |
259 } | 270 } |
260 | 271 |
261 #endif | |
262 | |
263 } // namespace | 272 } // namespace |
264 } // namespace test | 273 } // namespace test |
265 } // namespace net | 274 } // namespace net |
OLD | NEW |