| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 QuicServerSessionBaseTest, | 186 QuicServerSessionBaseTest, |
| 187 ::testing::ValuesIn(AllSupportedVersions())); | 187 ::testing::ValuesIn(AllSupportedVersions())); |
| 188 TEST_P(QuicServerSessionBaseTest, ServerPushDisabledByDefault) { | 188 TEST_P(QuicServerSessionBaseTest, ServerPushDisabledByDefault) { |
| 189 FLAGS_quic_reloadable_flag_quic_enable_server_push_by_default = true; | 189 FLAGS_quic_reloadable_flag_quic_enable_server_push_by_default = true; |
| 190 // Without the client explicitly sending kSPSH, server push will be disabled | 190 // Without the client explicitly sending kSPSH, server push will be disabled |
| 191 // at the server, until version 35 when it is enabled by default. | 191 // at the server, until version 35 when it is enabled by default. |
| 192 EXPECT_FALSE( | 192 EXPECT_FALSE( |
| 193 session_->config()->HasReceivedConnectionOptions() && | 193 session_->config()->HasReceivedConnectionOptions() && |
| 194 ContainsQuicTag(session_->config()->ReceivedConnectionOptions(), kSPSH)); | 194 ContainsQuicTag(session_->config()->ReceivedConnectionOptions(), kSPSH)); |
| 195 session_->OnConfigNegotiated(); | 195 session_->OnConfigNegotiated(); |
| 196 if (GetParam() <= QUIC_VERSION_34) { | 196 EXPECT_TRUE(session_->server_push_enabled()); |
| 197 EXPECT_FALSE(session_->server_push_enabled()); | |
| 198 } else { | |
| 199 EXPECT_TRUE(session_->server_push_enabled()); | |
| 200 } | |
| 201 } | 197 } |
| 202 | 198 |
| 203 TEST_P(QuicServerSessionBaseTest, CloseStreamDueToReset) { | 199 TEST_P(QuicServerSessionBaseTest, CloseStreamDueToReset) { |
| 204 // Open a stream, then reset it. | 200 // Open a stream, then reset it. |
| 205 // Send two bytes of payload to open it. | 201 // Send two bytes of payload to open it. |
| 206 QuicStreamFrame data1(kClientDataStreamId1, false, 0, QuicStringPiece("HT")); | 202 QuicStreamFrame data1(kClientDataStreamId1, false, 0, QuicStringPiece("HT")); |
| 207 session_->OnStreamFrame(data1); | 203 session_->OnStreamFrame(data1); |
| 208 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams()); | 204 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams()); |
| 209 | 205 |
| 210 // Send a reset (and expect the peer to send a RST in response). | 206 // Send a reset (and expect the peer to send a RST in response). |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 // The stream should never be opened, now that the reset is received. | 266 // The stream should never be opened, now that the reset is received. |
| 271 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams()); | 267 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams()); |
| 272 EXPECT_TRUE(connection_->connected()); | 268 EXPECT_TRUE(connection_->connected()); |
| 273 } | 269 } |
| 274 | 270 |
| 275 TEST_P(QuicServerSessionBaseTest, MaxOpenStreams) { | 271 TEST_P(QuicServerSessionBaseTest, MaxOpenStreams) { |
| 276 // Test that the server refuses if a client attempts to open too many data | 272 // Test that the server refuses if a client attempts to open too many data |
| 277 // streams. The server accepts slightly more than the negotiated stream limit | 273 // streams. The server accepts slightly more than the negotiated stream limit |
| 278 // to deal with rare cases where a client FIN/RST is lost. | 274 // to deal with rare cases where a client FIN/RST is lost. |
| 279 | 275 |
| 280 if (GetParam() <= QUIC_VERSION_34) { | |
| 281 EXPECT_EQ(kMaxStreamsForTest, session_->max_open_incoming_streams()); | |
| 282 } | |
| 283 | |
| 284 // The slightly increased stream limit is set during config negotiation. It | 276 // The slightly increased stream limit is set during config negotiation. It |
| 285 // is either an increase of 10 over negotiated limit, or a fixed percentage | 277 // is either an increase of 10 over negotiated limit, or a fixed percentage |
| 286 // scaling, whichever is larger. Test both before continuing. | 278 // scaling, whichever is larger. Test both before continuing. |
| 287 session_->OnConfigNegotiated(); | 279 session_->OnConfigNegotiated(); |
| 288 EXPECT_LT(kMaxStreamsMultiplier * kMaxStreamsForTest, | 280 EXPECT_LT(kMaxStreamsMultiplier * kMaxStreamsForTest, |
| 289 kMaxStreamsForTest + kMaxStreamsMinimumIncrement); | 281 kMaxStreamsForTest + kMaxStreamsMinimumIncrement); |
| 290 EXPECT_EQ(kMaxStreamsForTest + kMaxStreamsMinimumIncrement, | 282 EXPECT_EQ(kMaxStreamsForTest + kMaxStreamsMinimumIncrement, |
| 291 session_->max_open_incoming_streams()); | 283 session_->max_open_incoming_streams()); |
| 292 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); | 284 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); |
| 293 QuicStreamId stream_id = kClientDataStreamId1; | 285 QuicStreamId stream_id = kClientDataStreamId1; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 312 // Even if the connection remains open, the stream creation should fail. | 304 // Even if the connection remains open, the stream creation should fail. |
| 313 EXPECT_FALSE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( | 305 EXPECT_FALSE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( |
| 314 session_.get(), stream_id)); | 306 session_.get(), stream_id)); |
| 315 } | 307 } |
| 316 | 308 |
| 317 TEST_P(QuicServerSessionBaseTest, MaxAvailableStreams) { | 309 TEST_P(QuicServerSessionBaseTest, MaxAvailableStreams) { |
| 318 // Test that the server closes the connection if a client makes too many data | 310 // Test that the server closes the connection if a client makes too many data |
| 319 // streams available. The server accepts slightly more than the negotiated | 311 // streams available. The server accepts slightly more than the negotiated |
| 320 // stream limit to deal with rare cases where a client FIN/RST is lost. | 312 // stream limit to deal with rare cases where a client FIN/RST is lost. |
| 321 | 313 |
| 322 if (GetParam() <= QUIC_VERSION_34) { | |
| 323 // The slightly increased stream limit is set during config negotiation. | |
| 324 EXPECT_EQ(kMaxStreamsForTest, session_->max_open_incoming_streams()); | |
| 325 } | |
| 326 session_->OnConfigNegotiated(); | 314 session_->OnConfigNegotiated(); |
| 327 const size_t kAvailableStreamLimit = session_->MaxAvailableStreams(); | 315 const size_t kAvailableStreamLimit = session_->MaxAvailableStreams(); |
| 328 EXPECT_EQ( | 316 EXPECT_EQ( |
| 329 session_->max_open_incoming_streams() * kMaxAvailableStreamsMultiplier, | 317 session_->max_open_incoming_streams() * kMaxAvailableStreamsMultiplier, |
| 330 session_->MaxAvailableStreams()); | 318 session_->MaxAvailableStreams()); |
| 331 // The protocol specification requires that there can be at least 10 times | 319 // The protocol specification requires that there can be at least 10 times |
| 332 // as many available streams as the connection's maximum open streams. | 320 // as many available streams as the connection's maximum open streams. |
| 333 EXPECT_LE(10 * kMaxStreamsForTest, kAvailableStreamLimit); | 321 EXPECT_LE(10 * kMaxStreamsForTest, kAvailableStreamLimit); |
| 334 | 322 |
| 335 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); | 323 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 | 633 |
| 646 // Allow the async ProofSource::GetProof call to complete. Verify (under | 634 // Allow the async ProofSource::GetProof call to complete. Verify (under |
| 647 // asan) that this does not result in accesses to any freed memory from the | 635 // asan) that this does not result in accesses to any freed memory from the |
| 648 // session or its subobjects. | 636 // session or its subobjects. |
| 649 GetFakeProofSource()->InvokePendingCallback(0); | 637 GetFakeProofSource()->InvokePendingCallback(0); |
| 650 } | 638 } |
| 651 | 639 |
| 652 } // namespace | 640 } // namespace |
| 653 } // namespace test | 641 } // namespace test |
| 654 } // namespace net | 642 } // namespace net |
| OLD | NEW |