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_base.h" | 5 #include "net/tools/quic/quic_server_session_base.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "net/quic/crypto/quic_crypto_server_config.h" | 8 #include "net/quic/crypto/quic_crypto_server_config.h" |
9 #include "net/quic/crypto/quic_random.h" | 9 #include "net/quic/crypto/quic_random.h" |
10 #include "net/quic/proto/cached_network_parameters.pb.h" | 10 #include "net/quic/proto/cached_network_parameters.pb.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 reference.max_bandwidth_timestamp_seconds() && | 168 reference.max_bandwidth_timestamp_seconds() && |
169 arg->min_rtt_ms() == reference.min_rtt_ms() && | 169 arg->min_rtt_ms() == reference.min_rtt_ms() && |
170 arg->previous_connection_state() == | 170 arg->previous_connection_state() == |
171 reference.previous_connection_state()); | 171 reference.previous_connection_state()); |
172 } | 172 } |
173 | 173 |
174 INSTANTIATE_TEST_CASE_P(Tests, | 174 INSTANTIATE_TEST_CASE_P(Tests, |
175 QuicServerSessionBaseTest, | 175 QuicServerSessionBaseTest, |
176 ::testing::ValuesIn(QuicSupportedVersions())); | 176 ::testing::ValuesIn(QuicSupportedVersions())); |
177 | 177 |
| 178 TEST_P(QuicServerSessionBaseTest, ServerPushDisabledByDefault) { |
| 179 // Without the client explicitly sending kSPSH, server push will be disabled |
| 180 // at the server. |
| 181 EXPECT_FALSE( |
| 182 session_->config()->HasReceivedConnectionOptions() && |
| 183 ContainsQuicTag(session_->config()->ReceivedConnectionOptions(), kSPSH)); |
| 184 session_->OnConfigNegotiated(); |
| 185 EXPECT_FALSE(session_->server_push_enabled()); |
| 186 } |
| 187 |
178 TEST_P(QuicServerSessionBaseTest, CloseStreamDueToReset) { | 188 TEST_P(QuicServerSessionBaseTest, CloseStreamDueToReset) { |
179 // Open a stream, then reset it. | 189 // Open a stream, then reset it. |
180 // Send two bytes of payload to open it. | 190 // Send two bytes of payload to open it. |
181 QuicStreamFrame data1(kClientDataStreamId1, false, 0, StringPiece("HT")); | 191 QuicStreamFrame data1(kClientDataStreamId1, false, 0, StringPiece("HT")); |
182 session_->OnStreamFrame(data1); | 192 session_->OnStreamFrame(data1); |
183 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams()); | 193 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams()); |
184 | 194 |
185 // Send a reset (and expect the peer to send a RST in response). | 195 // Send a reset (and expect the peer to send a RST in response). |
186 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, | 196 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, |
187 0); | 197 0); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 | 327 |
318 // A further available stream will result in connection close. | 328 // A further available stream will result in connection close. |
319 EXPECT_CALL(*connection_, | 329 EXPECT_CALL(*connection_, |
320 CloseConnection(QUIC_TOO_MANY_AVAILABLE_STREAMS, _, _)); | 330 CloseConnection(QUIC_TOO_MANY_AVAILABLE_STREAMS, _, _)); |
321 // This forces stream kLimitingStreamId + 2 to become available, which | 331 // This forces stream kLimitingStreamId + 2 to become available, which |
322 // violates the quota. | 332 // violates the quota. |
323 EXPECT_FALSE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( | 333 EXPECT_FALSE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( |
324 session_.get(), kLimitingStreamId + 4)); | 334 session_.get(), kLimitingStreamId + 4)); |
325 } | 335 } |
326 | 336 |
| 337 TEST_P(QuicServerSessionBaseTest, EnableServerPushThroughConnectionOption) { |
| 338 // Assume server received server push connection option. |
| 339 QuicTagVector copt; |
| 340 copt.push_back(kSPSH); |
| 341 QuicConfigPeer::SetReceivedConnectionOptions(session_->config(), copt); |
| 342 session_->OnConfigNegotiated(); |
| 343 EXPECT_TRUE(session_->server_push_enabled()); |
| 344 } |
| 345 |
327 TEST_P(QuicServerSessionBaseTest, GetEvenIncomingError) { | 346 TEST_P(QuicServerSessionBaseTest, GetEvenIncomingError) { |
328 // Incoming streams on the server session must be odd. | 347 // Incoming streams on the server session must be odd. |
329 EXPECT_CALL(*connection_, CloseConnection(QUIC_INVALID_STREAM_ID, _, _)); | 348 EXPECT_CALL(*connection_, CloseConnection(QUIC_INVALID_STREAM_ID, _, _)); |
330 EXPECT_EQ(nullptr, QuicServerSessionBasePeer::GetOrCreateDynamicStream( | 349 EXPECT_EQ(nullptr, QuicServerSessionBasePeer::GetOrCreateDynamicStream( |
331 session_.get(), 4)); | 350 session_.get(), 4)); |
332 } | 351 } |
333 | 352 |
334 TEST_P(QuicServerSessionBaseTest, GetStreamDisconnected) { | 353 TEST_P(QuicServerSessionBaseTest, GetStreamDisconnected) { |
335 // Don't create new streams if the connection is disconnected. | 354 // Don't create new streams if the connection is disconnected. |
336 QuicConnectionPeer::TearDownLocalConnectionState(connection_); | 355 QuicConnectionPeer::TearDownLocalConnectionState(connection_); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 EXPECT_FALSE( | 544 EXPECT_FALSE( |
526 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); | 545 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); |
527 session_->OnConfigNegotiated(); | 546 session_->OnConfigNegotiated(); |
528 EXPECT_FALSE( | 547 EXPECT_FALSE( |
529 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); | 548 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); |
530 } | 549 } |
531 | 550 |
532 } // namespace | 551 } // namespace |
533 } // namespace test | 552 } // namespace test |
534 } // namespace net | 553 } // namespace net |
OLD | NEW |