OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/core/quic_server_session_base.h" | 5 #include "net/quic/core/quic_server_session_base.h" |
6 | 6 |
7 #include <cstdint> | 7 #include <cstdint> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 connection, | 73 connection, |
74 visitor, | 74 visitor, |
75 helper, | 75 helper, |
76 crypto_config, | 76 crypto_config, |
77 compressed_certs_cache), | 77 compressed_certs_cache), |
78 response_cache_(response_cache) {} | 78 response_cache_(response_cache) {} |
79 | 79 |
80 ~TestServerSession() override { delete connection(); }; | 80 ~TestServerSession() override { delete connection(); }; |
81 | 81 |
82 protected: | 82 protected: |
83 // TODO(ckrasic) - for two below, remove when | |
84 // quic_reloadable_flag_quic_refactor_stream_creation is deprecated. | |
85 QuicSpdyStream* CreateIncomingDynamicStream(QuicStreamId id) override { | 83 QuicSpdyStream* CreateIncomingDynamicStream(QuicStreamId id) override { |
86 if (!ShouldCreateIncomingDynamicStream(id)) { | 84 if (!ShouldCreateIncomingDynamicStream(id)) { |
87 return nullptr; | 85 return nullptr; |
88 } | 86 } |
89 QuicSpdyStream* stream = | 87 QuicSpdyStream* stream = |
90 new QuicSimpleServerStream(id, this, response_cache_); | 88 new QuicSimpleServerStream(id, this, response_cache_); |
91 ActivateStream(QuicWrapUnique(stream)); | 89 ActivateStream(QuicWrapUnique(stream)); |
92 return stream; | 90 return stream; |
93 } | 91 } |
94 | 92 |
95 QuicSpdyStream* CreateOutgoingDynamicStream(SpdyPriority priority) override { | 93 QuicSpdyStream* CreateOutgoingDynamicStream(SpdyPriority priority) override { |
96 if (!ShouldCreateOutgoingDynamicStream()) { | 94 if (!ShouldCreateOutgoingDynamicStream()) { |
97 return nullptr; | 95 return nullptr; |
98 } | 96 } |
99 | 97 |
100 QuicSpdyStream* stream = new QuicSimpleServerStream( | 98 QuicSpdyStream* stream = new QuicSimpleServerStream( |
101 GetNextOutgoingStreamId(), this, response_cache_); | 99 GetNextOutgoingStreamId(), this, response_cache_); |
102 stream->SetPriority(priority); | 100 stream->SetPriority(priority); |
103 ActivateStream(QuicWrapUnique(stream)); | 101 ActivateStream(QuicWrapUnique(stream)); |
104 return stream; | 102 return stream; |
105 } | 103 } |
106 | 104 |
107 std::unique_ptr<QuicStream> CreateStream(QuicStreamId id) override { | |
108 return QuicMakeUnique<QuicSimpleServerStream>(id, this, response_cache_); | |
109 } | |
110 | |
111 QuicCryptoServerStreamBase* CreateQuicCryptoServerStream( | 105 QuicCryptoServerStreamBase* CreateQuicCryptoServerStream( |
112 const QuicCryptoServerConfig* crypto_config, | 106 const QuicCryptoServerConfig* crypto_config, |
113 QuicCompressedCertsCache* compressed_certs_cache) override { | 107 QuicCompressedCertsCache* compressed_certs_cache) override { |
114 return new QuicCryptoServerStream( | 108 return new QuicCryptoServerStream( |
115 crypto_config, compressed_certs_cache, | 109 crypto_config, compressed_certs_cache, |
116 FLAGS_quic_reloadable_flag_enable_quic_stateless_reject_support, this, | 110 FLAGS_quic_reloadable_flag_enable_quic_stateless_reject_support, this, |
117 stream_helper()); | 111 stream_helper()); |
118 } | 112 } |
119 | 113 |
120 private: | 114 private: |
(...skipping 29 matching lines...) Expand all Loading... |
150 config_, connection_, &owner_, &stream_helper_, &crypto_config_, | 144 config_, connection_, &owner_, &stream_helper_, &crypto_config_, |
151 &compressed_certs_cache_, &response_cache_)); | 145 &compressed_certs_cache_, &response_cache_)); |
152 MockClock clock; | 146 MockClock clock; |
153 handshake_message_.reset(crypto_config_.AddDefaultConfig( | 147 handshake_message_.reset(crypto_config_.AddDefaultConfig( |
154 QuicRandom::GetInstance(), &clock, | 148 QuicRandom::GetInstance(), &clock, |
155 QuicCryptoServerConfig::ConfigOptions())); | 149 QuicCryptoServerConfig::ConfigOptions())); |
156 session_->Initialize(); | 150 session_->Initialize(); |
157 visitor_ = QuicConnectionPeer::GetVisitor(connection_); | 151 visitor_ = QuicConnectionPeer::GetVisitor(connection_); |
158 } | 152 } |
159 | 153 |
160 QuicStreamId GetNthClientInitiatedId(int n) { | |
161 return QuicSpdySessionPeer::GetNthClientInitiatedStreamId(*session_, n); | |
162 } | |
163 | |
164 QuicStreamId GetNthServerInitiatedId(int n) { | |
165 return QuicSpdySessionPeer::GetNthServerInitiatedStreamId(*session_, n); | |
166 } | |
167 | |
168 StrictMock<MockQuicSessionVisitor> owner_; | 154 StrictMock<MockQuicSessionVisitor> owner_; |
169 StrictMock<MockQuicCryptoServerStreamHelper> stream_helper_; | 155 StrictMock<MockQuicCryptoServerStreamHelper> stream_helper_; |
170 MockQuicConnectionHelper helper_; | 156 MockQuicConnectionHelper helper_; |
171 MockAlarmFactory alarm_factory_; | 157 MockAlarmFactory alarm_factory_; |
172 StrictMock<MockQuicConnection>* connection_; | 158 StrictMock<MockQuicConnection>* connection_; |
173 QuicConfig config_; | 159 QuicConfig config_; |
174 QuicCryptoServerConfig crypto_config_; | 160 QuicCryptoServerConfig crypto_config_; |
175 QuicCompressedCertsCache compressed_certs_cache_; | 161 QuicCompressedCertsCache compressed_certs_cache_; |
176 QuicHttpResponseCache response_cache_; | 162 QuicHttpResponseCache response_cache_; |
177 std::unique_ptr<TestServerSession> session_; | 163 std::unique_ptr<TestServerSession> session_; |
(...skipping 27 matching lines...) Expand all Loading... |
205 EXPECT_FALSE( | 191 EXPECT_FALSE( |
206 session_->config()->HasReceivedConnectionOptions() && | 192 session_->config()->HasReceivedConnectionOptions() && |
207 ContainsQuicTag(session_->config()->ReceivedConnectionOptions(), kSPSH)); | 193 ContainsQuicTag(session_->config()->ReceivedConnectionOptions(), kSPSH)); |
208 session_->OnConfigNegotiated(); | 194 session_->OnConfigNegotiated(); |
209 EXPECT_TRUE(session_->server_push_enabled()); | 195 EXPECT_TRUE(session_->server_push_enabled()); |
210 } | 196 } |
211 | 197 |
212 TEST_P(QuicServerSessionBaseTest, CloseStreamDueToReset) { | 198 TEST_P(QuicServerSessionBaseTest, CloseStreamDueToReset) { |
213 // Open a stream, then reset it. | 199 // Open a stream, then reset it. |
214 // Send two bytes of payload to open it. | 200 // Send two bytes of payload to open it. |
215 QuicStreamFrame data1(GetNthClientInitiatedId(0), false, 0, | 201 QuicStreamFrame data1(kClientDataStreamId1, false, 0, QuicStringPiece("HT")); |
216 QuicStringPiece("HT")); | |
217 session_->OnStreamFrame(data1); | 202 session_->OnStreamFrame(data1); |
218 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams()); | 203 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams()); |
219 | 204 |
220 // Send a reset (and expect the peer to send a RST in response). | 205 // Send a reset (and expect the peer to send a RST in response). |
221 QuicRstStreamFrame rst1(GetNthClientInitiatedId(0), | 206 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, |
222 QUIC_ERROR_PROCESSING_STREAM, 0); | 207 0); |
223 EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1); | 208 EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1); |
224 EXPECT_CALL(*connection_, SendRstStream(GetNthClientInitiatedId(0), | 209 EXPECT_CALL(*connection_, |
225 QUIC_RST_ACKNOWLEDGEMENT, 0)); | 210 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); |
226 visitor_->OnRstStream(rst1); | 211 visitor_->OnRstStream(rst1); |
227 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); | 212 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); |
228 | 213 |
229 // Send the same two bytes of payload in a new packet. | 214 // Send the same two bytes of payload in a new packet. |
230 visitor_->OnStreamFrame(data1); | 215 visitor_->OnStreamFrame(data1); |
231 | 216 |
232 // The stream should not be re-opened. | 217 // The stream should not be re-opened. |
233 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); | 218 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); |
234 EXPECT_TRUE(connection_->connected()); | 219 EXPECT_TRUE(connection_->connected()); |
235 } | 220 } |
236 | 221 |
237 TEST_P(QuicServerSessionBaseTest, NeverOpenStreamDueToReset) { | 222 TEST_P(QuicServerSessionBaseTest, NeverOpenStreamDueToReset) { |
238 // Send a reset (and expect the peer to send a RST in response). | 223 // Send a reset (and expect the peer to send a RST in response). |
239 QuicRstStreamFrame rst1(GetNthClientInitiatedId(0), | 224 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, |
240 QUIC_ERROR_PROCESSING_STREAM, 0); | 225 0); |
241 EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1); | 226 EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1); |
242 EXPECT_CALL(*connection_, SendRstStream(GetNthClientInitiatedId(0), | 227 EXPECT_CALL(*connection_, |
243 QUIC_RST_ACKNOWLEDGEMENT, 0)); | 228 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); |
244 visitor_->OnRstStream(rst1); | 229 visitor_->OnRstStream(rst1); |
245 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); | 230 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); |
246 | 231 |
247 // Send two bytes of payload. | 232 // Send two bytes of payload. |
248 QuicStreamFrame data1(GetNthClientInitiatedId(0), false, 0, | 233 QuicStreamFrame data1(kClientDataStreamId1, false, 0, QuicStringPiece("HT")); |
249 QuicStringPiece("HT")); | |
250 visitor_->OnStreamFrame(data1); | 234 visitor_->OnStreamFrame(data1); |
251 | 235 |
252 // The stream should never be opened, now that the reset is received. | 236 // The stream should never be opened, now that the reset is received. |
253 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); | 237 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); |
254 EXPECT_TRUE(connection_->connected()); | 238 EXPECT_TRUE(connection_->connected()); |
255 } | 239 } |
256 | 240 |
257 TEST_P(QuicServerSessionBaseTest, AcceptClosedStream) { | 241 TEST_P(QuicServerSessionBaseTest, AcceptClosedStream) { |
258 // Send (empty) compressed headers followed by two bytes of data. | 242 // Send (empty) compressed headers followed by two bytes of data. |
259 QuicStreamFrame frame1(GetNthClientInitiatedId(0), false, 0, | 243 QuicStreamFrame frame1(kClientDataStreamId1, false, 0, |
260 QuicStringPiece("\1\0\0\0\0\0\0\0HT")); | 244 QuicStringPiece("\1\0\0\0\0\0\0\0HT")); |
261 QuicStreamFrame frame2(GetNthClientInitiatedId(1), false, 0, | 245 QuicStreamFrame frame2(kClientDataStreamId2, false, 0, |
262 QuicStringPiece("\2\0\0\0\0\0\0\0HT")); | 246 QuicStringPiece("\2\0\0\0\0\0\0\0HT")); |
263 visitor_->OnStreamFrame(frame1); | 247 visitor_->OnStreamFrame(frame1); |
264 visitor_->OnStreamFrame(frame2); | 248 visitor_->OnStreamFrame(frame2); |
265 EXPECT_EQ(2u, session_->GetNumOpenIncomingStreams()); | 249 EXPECT_EQ(2u, session_->GetNumOpenIncomingStreams()); |
266 | 250 |
267 // Send a reset (and expect the peer to send a RST in response). | 251 // Send a reset (and expect the peer to send a RST in response). |
268 QuicRstStreamFrame rst(GetNthClientInitiatedId(0), | 252 QuicRstStreamFrame rst(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, 0); |
269 QUIC_ERROR_PROCESSING_STREAM, 0); | |
270 EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1); | 253 EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1); |
271 EXPECT_CALL(*connection_, SendRstStream(GetNthClientInitiatedId(0), | 254 EXPECT_CALL(*connection_, |
272 QUIC_RST_ACKNOWLEDGEMENT, 0)); | 255 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); |
273 visitor_->OnRstStream(rst); | 256 visitor_->OnRstStream(rst); |
274 | 257 |
275 // If we were tracking, we'd probably want to reject this because it's data | 258 // If we were tracking, we'd probably want to reject this because it's data |
276 // past the reset point of stream 3. As it's a closed stream we just drop the | 259 // past the reset point of stream 3. As it's a closed stream we just drop the |
277 // data on the floor, but accept the packet because it has data for stream 5. | 260 // data on the floor, but accept the packet because it has data for stream 5. |
278 QuicStreamFrame frame3(GetNthClientInitiatedId(0), false, 2, | 261 QuicStreamFrame frame3(kClientDataStreamId1, false, 2, QuicStringPiece("TP")); |
279 QuicStringPiece("TP")); | 262 QuicStreamFrame frame4(kClientDataStreamId2, false, 2, QuicStringPiece("TP")); |
280 QuicStreamFrame frame4(GetNthClientInitiatedId(1), false, 2, | |
281 QuicStringPiece("TP")); | |
282 visitor_->OnStreamFrame(frame3); | 263 visitor_->OnStreamFrame(frame3); |
283 visitor_->OnStreamFrame(frame4); | 264 visitor_->OnStreamFrame(frame4); |
284 // The stream should never be opened, now that the reset is received. | 265 // The stream should never be opened, now that the reset is received. |
285 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams()); | 266 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams()); |
286 EXPECT_TRUE(connection_->connected()); | 267 EXPECT_TRUE(connection_->connected()); |
287 } | 268 } |
288 | 269 |
289 TEST_P(QuicServerSessionBaseTest, MaxOpenStreams) { | 270 TEST_P(QuicServerSessionBaseTest, MaxOpenStreams) { |
290 // Test that the server refuses if a client attempts to open too many data | 271 // Test that the server refuses if a client attempts to open too many data |
291 // streams. The server accepts slightly more than the negotiated stream limit | 272 // streams. The server accepts slightly more than the negotiated stream limit |
292 // to deal with rare cases where a client FIN/RST is lost. | 273 // to deal with rare cases where a client FIN/RST is lost. |
293 | 274 |
294 // The slightly increased stream limit is set during config negotiation. It | 275 // The slightly increased stream limit is set during config negotiation. It |
295 // is either an increase of 10 over negotiated limit, or a fixed percentage | 276 // is either an increase of 10 over negotiated limit, or a fixed percentage |
296 // scaling, whichever is larger. Test both before continuing. | 277 // scaling, whichever is larger. Test both before continuing. |
297 session_->OnConfigNegotiated(); | 278 session_->OnConfigNegotiated(); |
298 EXPECT_LT(kMaxStreamsMultiplier * kMaxStreamsForTest, | 279 EXPECT_LT(kMaxStreamsMultiplier * kMaxStreamsForTest, |
299 kMaxStreamsForTest + kMaxStreamsMinimumIncrement); | 280 kMaxStreamsForTest + kMaxStreamsMinimumIncrement); |
300 EXPECT_EQ(kMaxStreamsForTest + kMaxStreamsMinimumIncrement, | 281 EXPECT_EQ(kMaxStreamsForTest + kMaxStreamsMinimumIncrement, |
301 session_->max_open_incoming_streams()); | 282 session_->max_open_incoming_streams()); |
302 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); | 283 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); |
303 QuicStreamId stream_id = GetNthClientInitiatedId(0); | 284 QuicStreamId stream_id = kClientDataStreamId1; |
304 // Open the max configured number of streams, should be no problem. | 285 // Open the max configured number of streams, should be no problem. |
305 for (size_t i = 0; i < kMaxStreamsForTest; ++i) { | 286 for (size_t i = 0; i < kMaxStreamsForTest; ++i) { |
306 EXPECT_TRUE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( | 287 EXPECT_TRUE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( |
307 session_.get(), stream_id)); | 288 session_.get(), stream_id)); |
308 stream_id += QuicSpdySessionPeer::NextStreamId(*session_); | 289 stream_id += 2; |
309 } | 290 } |
310 | 291 |
311 // Open more streams: server should accept slightly more than the limit. | 292 // Open more streams: server should accept slightly more than the limit. |
312 for (size_t i = 0; i < kMaxStreamsMinimumIncrement; ++i) { | 293 for (size_t i = 0; i < kMaxStreamsMinimumIncrement; ++i) { |
313 EXPECT_TRUE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( | 294 EXPECT_TRUE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( |
314 session_.get(), stream_id)); | 295 session_.get(), stream_id)); |
315 stream_id += QuicSpdySessionPeer::NextStreamId(*session_); | 296 stream_id += 2; |
316 } | 297 } |
317 | 298 |
318 // Now violate the server's internal stream limit. | 299 // Now violate the server's internal stream limit. |
319 stream_id += QuicSpdySessionPeer::NextStreamId(*session_); | 300 stream_id += 2; |
320 EXPECT_CALL(*connection_, CloseConnection(_, _, _)).Times(0); | 301 EXPECT_CALL(*connection_, CloseConnection(_, _, _)).Times(0); |
321 EXPECT_CALL(*connection_, SendRstStream(stream_id, QUIC_REFUSED_STREAM, 0)); | 302 EXPECT_CALL(*connection_, SendRstStream(stream_id, QUIC_REFUSED_STREAM, 0)); |
322 // Even if the connection remains open, the stream creation should fail. | 303 // Even if the connection remains open, the stream creation should fail. |
323 EXPECT_FALSE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( | 304 EXPECT_FALSE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( |
324 session_.get(), stream_id)); | 305 session_.get(), stream_id)); |
325 } | 306 } |
326 | 307 |
327 TEST_P(QuicServerSessionBaseTest, MaxAvailableStreams) { | 308 TEST_P(QuicServerSessionBaseTest, MaxAvailableStreams) { |
328 // Test that the server closes the connection if a client makes too many data | 309 // Test that the server closes the connection if a client makes too many data |
329 // streams available. The server accepts slightly more than the negotiated | 310 // streams available. The server accepts slightly more than the negotiated |
330 // stream limit to deal with rare cases where a client FIN/RST is lost. | 311 // stream limit to deal with rare cases where a client FIN/RST is lost. |
331 | 312 |
332 session_->OnConfigNegotiated(); | 313 session_->OnConfigNegotiated(); |
333 const size_t kAvailableStreamLimit = session_->MaxAvailableStreams(); | 314 const size_t kAvailableStreamLimit = session_->MaxAvailableStreams(); |
334 EXPECT_EQ( | 315 EXPECT_EQ( |
335 session_->max_open_incoming_streams() * kMaxAvailableStreamsMultiplier, | 316 session_->max_open_incoming_streams() * kMaxAvailableStreamsMultiplier, |
336 session_->MaxAvailableStreams()); | 317 session_->MaxAvailableStreams()); |
337 // The protocol specification requires that there can be at least 10 times | 318 // The protocol specification requires that there can be at least 10 times |
338 // as many available streams as the connection's maximum open streams. | 319 // as many available streams as the connection's maximum open streams. |
339 EXPECT_LE(10 * kMaxStreamsForTest, kAvailableStreamLimit); | 320 EXPECT_LE(10 * kMaxStreamsForTest, kAvailableStreamLimit); |
340 | 321 |
341 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); | 322 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); |
342 EXPECT_TRUE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( | 323 EXPECT_TRUE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( |
343 session_.get(), GetNthClientInitiatedId(0))); | 324 session_.get(), kClientDataStreamId1)); |
344 | 325 |
345 // Establish available streams up to the server's limit. | 326 // Establish available streams up to the server's limit. |
346 QuicStreamId next_id = QuicSpdySessionPeer::NextStreamId(*session_); | |
347 const int kLimitingStreamId = | 327 const int kLimitingStreamId = |
348 GetNthClientInitiatedId(kAvailableStreamLimit + 1); | 328 kClientDataStreamId1 + (kAvailableStreamLimit)*2 + 2; |
349 EXPECT_TRUE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( | 329 EXPECT_TRUE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( |
350 session_.get(), kLimitingStreamId)); | 330 session_.get(), kLimitingStreamId)); |
351 | 331 |
352 // A further available stream will result in connection close. | 332 // A further available stream will result in connection close. |
353 EXPECT_CALL(*connection_, | 333 EXPECT_CALL(*connection_, |
354 CloseConnection(QUIC_TOO_MANY_AVAILABLE_STREAMS, _, _)); | 334 CloseConnection(QUIC_TOO_MANY_AVAILABLE_STREAMS, _, _)); |
355 // This forces stream kLimitingStreamId + 2 to become available, which | 335 // This forces stream kLimitingStreamId + 2 to become available, which |
356 // violates the quota. | 336 // violates the quota. |
357 EXPECT_FALSE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( | 337 EXPECT_FALSE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( |
358 session_.get(), kLimitingStreamId + 2 * next_id)); | 338 session_.get(), kLimitingStreamId + 4)); |
359 } | 339 } |
360 | 340 |
361 // TODO(ckrasic): remove this when | 341 // TODO(ckrasic): remove this when |
362 // FLAGS_quic_reloadable_flag_quic_enable_server_push_by_default is | 342 // FLAGS_quic_reloadable_flag_quic_enable_server_push_by_default is |
363 // deprecated. | 343 // deprecated. |
364 TEST_P(QuicServerSessionBaseTest, EnableServerPushThroughConnectionOption) { | 344 TEST_P(QuicServerSessionBaseTest, EnableServerPushThroughConnectionOption) { |
365 FLAGS_quic_reloadable_flag_quic_enable_server_push_by_default = false; | 345 FLAGS_quic_reloadable_flag_quic_enable_server_push_by_default = false; |
366 // Assume server received server push connection option. | 346 // Assume server received server push connection option. |
367 QuicTagVector copt; | 347 QuicTagVector copt; |
368 copt.push_back(kSPSH); | 348 copt.push_back(kSPSH); |
369 QuicConfigPeer::SetReceivedConnectionOptions(session_->config(), copt); | 349 QuicConfigPeer::SetReceivedConnectionOptions(session_->config(), copt); |
370 session_->OnConfigNegotiated(); | 350 session_->OnConfigNegotiated(); |
371 EXPECT_TRUE(session_->server_push_enabled()); | 351 EXPECT_TRUE(session_->server_push_enabled()); |
372 } | 352 } |
373 | 353 |
374 TEST_P(QuicServerSessionBaseTest, GetEvenIncomingError) { | 354 TEST_P(QuicServerSessionBaseTest, GetEvenIncomingError) { |
375 // Incoming streams on the server session must be odd. | 355 // Incoming streams on the server session must be odd. |
376 EXPECT_CALL(*connection_, CloseConnection(QUIC_INVALID_STREAM_ID, _, _)); | 356 EXPECT_CALL(*connection_, CloseConnection(QUIC_INVALID_STREAM_ID, _, _)); |
377 EXPECT_EQ(nullptr, QuicServerSessionBasePeer::GetOrCreateDynamicStream( | 357 EXPECT_EQ(nullptr, QuicServerSessionBasePeer::GetOrCreateDynamicStream( |
378 session_.get(), GetNthServerInitiatedId(0))); | 358 session_.get(), 4)); |
379 } | 359 } |
380 | 360 |
381 TEST_P(QuicServerSessionBaseTest, GetStreamDisconnected) { | 361 TEST_P(QuicServerSessionBaseTest, GetStreamDisconnected) { |
382 // Don't create new streams if the connection is disconnected. | 362 // Don't create new streams if the connection is disconnected. |
383 QuicConnectionPeer::TearDownLocalConnectionState(connection_); | 363 QuicConnectionPeer::TearDownLocalConnectionState(connection_); |
384 if (FLAGS_quic_reloadable_flag_quic_refactor_stream_creation) { | 364 EXPECT_QUIC_BUG( |
385 EXPECT_EQ(nullptr, QuicServerSessionBasePeer::GetOrCreateDynamicStream( | 365 QuicServerSessionBasePeer::GetOrCreateDynamicStream(session_.get(), 5), |
386 session_.get(), GetNthClientInitiatedId(0))); | 366 "ShouldCreateIncomingDynamicStream called when disconnected"); |
387 } else { | |
388 EXPECT_QUIC_BUG( | |
389 QuicServerSessionBasePeer::GetOrCreateDynamicStream( | |
390 session_.get(), GetNthClientInitiatedId(0)), | |
391 "ShouldCreateIncomingDynamicStream called when disconnected"); | |
392 } | |
393 } | 367 } |
394 | 368 |
395 class MockQuicCryptoServerStream : public QuicCryptoServerStream { | 369 class MockQuicCryptoServerStream : public QuicCryptoServerStream { |
396 public: | 370 public: |
397 explicit MockQuicCryptoServerStream( | 371 explicit MockQuicCryptoServerStream( |
398 const QuicCryptoServerConfig* crypto_config, | 372 const QuicCryptoServerConfig* crypto_config, |
399 QuicCompressedCertsCache* compressed_certs_cache, | 373 QuicCompressedCertsCache* compressed_certs_cache, |
400 QuicServerSessionBase* session, | 374 QuicServerSessionBase* session, |
401 QuicCryptoServerStream::Helper* helper) | 375 QuicCryptoServerStream::Helper* helper) |
402 : QuicCryptoServerStream( | 376 : QuicCryptoServerStream( |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 | 632 |
659 // Allow the async ProofSource::GetProof call to complete. Verify (under | 633 // Allow the async ProofSource::GetProof call to complete. Verify (under |
660 // asan) that this does not result in accesses to any freed memory from the | 634 // asan) that this does not result in accesses to any freed memory from the |
661 // session or its subobjects. | 635 // session or its subobjects. |
662 GetFakeProofSource()->InvokePendingCallback(0); | 636 GetFakeProofSource()->InvokePendingCallback(0); |
663 } | 637 } |
664 | 638 |
665 } // namespace | 639 } // namespace |
666 } // namespace test | 640 } // namespace test |
667 } // namespace net | 641 } // namespace net |
OLD | NEW |