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/tools/quic/quic_server_session.h" | 5 #include "net/tools/quic/quic_server_session.h" |
6 | 6 |
7 #include "net/quic/crypto/quic_crypto_server_config.h" | 7 #include "net/quic/crypto/quic_crypto_server_config.h" |
8 #include "net/quic/crypto/quic_random.h" | 8 #include "net/quic/crypto/quic_random.h" |
9 #include "net/quic/proto/cached_network_parameters.pb.h" | 9 #include "net/quic/proto/cached_network_parameters.pb.h" |
10 #include "net/quic/quic_connection.h" | 10 #include "net/quic/quic_connection.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 // Open more streams: server should accept slightly more than the limit. | 225 // Open more streams: server should accept slightly more than the limit. |
226 for (size_t i = 0; i < kMaxStreamsMinimumIncrement; ++i) { | 226 for (size_t i = 0; i < kMaxStreamsMinimumIncrement; ++i) { |
227 EXPECT_TRUE(QuicServerSessionPeer::GetOrCreateDynamicStream(session_.get(), | 227 EXPECT_TRUE(QuicServerSessionPeer::GetOrCreateDynamicStream(session_.get(), |
228 stream_id)); | 228 stream_id)); |
229 stream_id += 2; | 229 stream_id += 2; |
230 } | 230 } |
231 | 231 |
232 // Now violate the server's internal stream limit. | 232 // Now violate the server's internal stream limit. |
233 stream_id += 2; | 233 stream_id += 2; |
234 if (connection_->version() <= QUIC_VERSION_27) { | 234 if (connection_->version() <= QUIC_VERSION_27) { |
235 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_TOO_MANY_OPEN_STREAMS)); | 235 EXPECT_CALL(*connection_, |
| 236 SendConnectionCloseWithDetails(QUIC_TOO_MANY_OPEN_STREAMS, _)); |
236 EXPECT_CALL(*connection_, SendRstStream(_, _, _)).Times(0); | 237 EXPECT_CALL(*connection_, SendRstStream(_, _, _)).Times(0); |
237 } else { | 238 } else { |
238 EXPECT_CALL(*connection_, SendConnectionClose(_)).Times(0); | 239 EXPECT_CALL(*connection_, SendConnectionCloseWithDetails(_, _)).Times(0); |
239 EXPECT_CALL(*connection_, SendRstStream(stream_id, QUIC_REFUSED_STREAM, 0)); | 240 EXPECT_CALL(*connection_, SendRstStream(stream_id, QUIC_REFUSED_STREAM, 0)); |
240 } | 241 } |
241 // Even if the connection remains open, the stream creation should fail. | 242 // Even if the connection remains open, the stream creation should fail. |
242 EXPECT_FALSE(QuicServerSessionPeer::GetOrCreateDynamicStream(session_.get(), | 243 EXPECT_FALSE(QuicServerSessionPeer::GetOrCreateDynamicStream(session_.get(), |
243 stream_id)); | 244 stream_id)); |
244 } | 245 } |
245 | 246 |
246 TEST_P(QuicServerSessionTest, MaxAvailableStreams) { | 247 TEST_P(QuicServerSessionTest, MaxAvailableStreams) { |
247 // Test that the server closes the connection if a client makes too many data | 248 // Test that the server closes the connection if a client makes too many data |
248 // streams available. The server accepts slightly more than the negotiated | 249 // streams available. The server accepts slightly more than the negotiated |
(...skipping 13 matching lines...) Expand all Loading... |
262 EXPECT_TRUE(QuicServerSessionPeer::GetOrCreateDynamicStream( | 263 EXPECT_TRUE(QuicServerSessionPeer::GetOrCreateDynamicStream( |
263 session_.get(), kClientDataStreamId1)); | 264 session_.get(), kClientDataStreamId1)); |
264 | 265 |
265 // Establish available streams up to the server's limit. | 266 // Establish available streams up to the server's limit. |
266 const int kLimitingStreamId = | 267 const int kLimitingStreamId = |
267 kClientDataStreamId1 + (kAvailableStreamLimit)*2 + 2; | 268 kClientDataStreamId1 + (kAvailableStreamLimit)*2 + 2; |
268 EXPECT_TRUE(QuicServerSessionPeer::GetOrCreateDynamicStream( | 269 EXPECT_TRUE(QuicServerSessionPeer::GetOrCreateDynamicStream( |
269 session_.get(), kLimitingStreamId)); | 270 session_.get(), kLimitingStreamId)); |
270 | 271 |
271 // A further available stream will result in connection close. | 272 // A further available stream will result in connection close. |
272 EXPECT_CALL(*connection_, | 273 EXPECT_CALL(*connection_, SendConnectionCloseWithDetails( |
273 SendConnectionClose(QUIC_TOO_MANY_AVAILABLE_STREAMS)); | 274 QUIC_TOO_MANY_AVAILABLE_STREAMS, _)); |
274 // This forces stream kLimitingStreamId + 2 to become available, which | 275 // This forces stream kLimitingStreamId + 2 to become available, which |
275 // violates the quota. | 276 // violates the quota. |
276 EXPECT_FALSE(QuicServerSessionPeer::GetOrCreateDynamicStream( | 277 EXPECT_FALSE(QuicServerSessionPeer::GetOrCreateDynamicStream( |
277 session_.get(), kLimitingStreamId + 4)); | 278 session_.get(), kLimitingStreamId + 4)); |
278 } | 279 } |
279 | 280 |
280 TEST_P(QuicServerSessionTest, GetEvenIncomingError) { | 281 TEST_P(QuicServerSessionTest, GetEvenIncomingError) { |
281 // Incoming streams on the server session must be odd. | 282 // Incoming streams on the server session must be odd. |
282 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_INVALID_STREAM_ID)); | 283 EXPECT_CALL(*connection_, |
| 284 SendConnectionCloseWithDetails(QUIC_INVALID_STREAM_ID, _)); |
283 EXPECT_EQ(nullptr, | 285 EXPECT_EQ(nullptr, |
284 QuicServerSessionPeer::GetOrCreateDynamicStream(session_.get(), 4)); | 286 QuicServerSessionPeer::GetOrCreateDynamicStream(session_.get(), 4)); |
285 } | 287 } |
286 | 288 |
287 TEST_P(QuicServerSessionTest, GetStreamDisconnected) { | 289 TEST_P(QuicServerSessionTest, GetStreamDisconnected) { |
288 // Don't create new streams if the connection is disconnected. | 290 // Don't create new streams if the connection is disconnected. |
289 QuicConnectionPeer::CloseConnection(connection_); | 291 QuicConnectionPeer::CloseConnection(connection_); |
290 EXPECT_DFATAL( | 292 EXPECT_DFATAL( |
291 QuicServerSessionPeer::GetOrCreateDynamicStream(session_.get(), 5), | 293 QuicServerSessionPeer::GetOrCreateDynamicStream(session_.get(), 5), |
292 "ShouldCreateIncomingDynamicStream called when disconnected"); | 294 "ShouldCreateIncomingDynamicStream called when disconnected"); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 // Create peer initiated stream should have no problem. | 554 // Create peer initiated stream should have no problem. |
553 QuicStreamFrame data2(kClientDataStreamId2, false, 0, StringPiece("HT")); | 555 QuicStreamFrame data2(kClientDataStreamId2, false, 0, StringPiece("HT")); |
554 session_->OnStreamFrame(data2); | 556 session_->OnStreamFrame(data2); |
555 EXPECT_EQ(2u, session_->GetNumOpenIncomingStreams()); | 557 EXPECT_EQ(2u, session_->GetNumOpenIncomingStreams()); |
556 } | 558 } |
557 | 559 |
558 } // namespace | 560 } // namespace |
559 } // namespace test | 561 } // namespace test |
560 } // namespace tools | 562 } // namespace tools |
561 } // namespace net | 563 } // namespace net |
OLD | NEW |