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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 if (GetParam() <= QUIC_VERSION_34) { | 196 if (GetParam() <= QUIC_VERSION_34) { |
197 EXPECT_FALSE(session_->server_push_enabled()); | 197 EXPECT_FALSE(session_->server_push_enabled()); |
198 } else { | 198 } else { |
199 EXPECT_TRUE(session_->server_push_enabled()); | 199 EXPECT_TRUE(session_->server_push_enabled()); |
200 } | 200 } |
201 } | 201 } |
202 | 202 |
203 TEST_P(QuicServerSessionBaseTest, CloseStreamDueToReset) { | 203 TEST_P(QuicServerSessionBaseTest, CloseStreamDueToReset) { |
204 // Open a stream, then reset it. | 204 // Open a stream, then reset it. |
205 // Send two bytes of payload to open it. | 205 // Send two bytes of payload to open it. |
206 QuicStreamFrame data1(kClientDataStreamId1, false, 0, StringPiece("HT")); | 206 QuicStreamFrame data1(kClientDataStreamId1, false, 0, QuicStringPiece("HT")); |
207 session_->OnStreamFrame(data1); | 207 session_->OnStreamFrame(data1); |
208 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams()); | 208 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams()); |
209 | 209 |
210 // Send a reset (and expect the peer to send a RST in response). | 210 // Send a reset (and expect the peer to send a RST in response). |
211 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, | 211 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, |
212 0); | 212 0); |
213 EXPECT_CALL(*connection_, | 213 EXPECT_CALL(*connection_, |
214 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); | 214 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); |
215 visitor_->OnRstStream(rst1); | 215 visitor_->OnRstStream(rst1); |
216 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); | 216 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); |
217 | 217 |
218 // Send the same two bytes of payload in a new packet. | 218 // Send the same two bytes of payload in a new packet. |
219 visitor_->OnStreamFrame(data1); | 219 visitor_->OnStreamFrame(data1); |
220 | 220 |
221 // The stream should not be re-opened. | 221 // The stream should not be re-opened. |
222 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); | 222 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); |
223 EXPECT_TRUE(connection_->connected()); | 223 EXPECT_TRUE(connection_->connected()); |
224 } | 224 } |
225 | 225 |
226 TEST_P(QuicServerSessionBaseTest, NeverOpenStreamDueToReset) { | 226 TEST_P(QuicServerSessionBaseTest, NeverOpenStreamDueToReset) { |
227 // Send a reset (and expect the peer to send a RST in response). | 227 // Send a reset (and expect the peer to send a RST in response). |
228 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, | 228 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, |
229 0); | 229 0); |
230 EXPECT_CALL(*connection_, | 230 EXPECT_CALL(*connection_, |
231 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); | 231 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); |
232 visitor_->OnRstStream(rst1); | 232 visitor_->OnRstStream(rst1); |
233 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); | 233 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); |
234 | 234 |
235 // Send two bytes of payload. | 235 // Send two bytes of payload. |
236 QuicStreamFrame data1(kClientDataStreamId1, false, 0, StringPiece("HT")); | 236 QuicStreamFrame data1(kClientDataStreamId1, false, 0, QuicStringPiece("HT")); |
237 visitor_->OnStreamFrame(data1); | 237 visitor_->OnStreamFrame(data1); |
238 | 238 |
239 // The stream should never be opened, now that the reset is received. | 239 // The stream should never be opened, now that the reset is received. |
240 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); | 240 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); |
241 EXPECT_TRUE(connection_->connected()); | 241 EXPECT_TRUE(connection_->connected()); |
242 } | 242 } |
243 | 243 |
244 TEST_P(QuicServerSessionBaseTest, AcceptClosedStream) { | 244 TEST_P(QuicServerSessionBaseTest, AcceptClosedStream) { |
245 // Send (empty) compressed headers followed by two bytes of data. | 245 // Send (empty) compressed headers followed by two bytes of data. |
246 QuicStreamFrame frame1(kClientDataStreamId1, false, 0, | 246 QuicStreamFrame frame1(kClientDataStreamId1, false, 0, |
247 StringPiece("\1\0\0\0\0\0\0\0HT")); | 247 QuicStringPiece("\1\0\0\0\0\0\0\0HT")); |
248 QuicStreamFrame frame2(kClientDataStreamId2, false, 0, | 248 QuicStreamFrame frame2(kClientDataStreamId2, false, 0, |
249 StringPiece("\2\0\0\0\0\0\0\0HT")); | 249 QuicStringPiece("\2\0\0\0\0\0\0\0HT")); |
250 visitor_->OnStreamFrame(frame1); | 250 visitor_->OnStreamFrame(frame1); |
251 visitor_->OnStreamFrame(frame2); | 251 visitor_->OnStreamFrame(frame2); |
252 EXPECT_EQ(2u, session_->GetNumOpenIncomingStreams()); | 252 EXPECT_EQ(2u, session_->GetNumOpenIncomingStreams()); |
253 | 253 |
254 // Send a reset (and expect the peer to send a RST in response). | 254 // Send a reset (and expect the peer to send a RST in response). |
255 QuicRstStreamFrame rst(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, 0); | 255 QuicRstStreamFrame rst(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, 0); |
256 EXPECT_CALL(*connection_, | 256 EXPECT_CALL(*connection_, |
257 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); | 257 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); |
258 visitor_->OnRstStream(rst); | 258 visitor_->OnRstStream(rst); |
259 | 259 |
260 // If we were tracking, we'd probably want to reject this because it's data | 260 // If we were tracking, we'd probably want to reject this because it's data |
261 // past the reset point of stream 3. As it's a closed stream we just drop the | 261 // past the reset point of stream 3. As it's a closed stream we just drop the |
262 // data on the floor, but accept the packet because it has data for stream 5. | 262 // data on the floor, but accept the packet because it has data for stream 5. |
263 QuicStreamFrame frame3(kClientDataStreamId1, false, 2, StringPiece("TP")); | 263 QuicStreamFrame frame3(kClientDataStreamId1, false, 2, QuicStringPiece("TP")); |
264 QuicStreamFrame frame4(kClientDataStreamId2, false, 2, StringPiece("TP")); | 264 QuicStreamFrame frame4(kClientDataStreamId2, false, 2, QuicStringPiece("TP")); |
265 visitor_->OnStreamFrame(frame3); | 265 visitor_->OnStreamFrame(frame3); |
266 visitor_->OnStreamFrame(frame4); | 266 visitor_->OnStreamFrame(frame4); |
267 // The stream should never be opened, now that the reset is received. | 267 // The stream should never be opened, now that the reset is received. |
268 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams()); | 268 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams()); |
269 EXPECT_TRUE(connection_->connected()); | 269 EXPECT_TRUE(connection_->connected()); |
270 } | 270 } |
271 | 271 |
272 TEST_P(QuicServerSessionBaseTest, MaxOpenStreams) { | 272 TEST_P(QuicServerSessionBaseTest, MaxOpenStreams) { |
273 // Test that the server refuses if a client attempts to open too many data | 273 // Test that the server refuses if a client attempts to open too many data |
274 // streams. The server accepts slightly more than the negotiated stream limit | 274 // streams. The server accepts slightly more than the negotiated stream limit |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 | 642 |
643 // Allow the async ProofSource::GetProof call to complete. Verify (under | 643 // Allow the async ProofSource::GetProof call to complete. Verify (under |
644 // asan) that this does not result in accesses to any freed memory from the | 644 // asan) that this does not result in accesses to any freed memory from the |
645 // session or its subobjects. | 645 // session or its subobjects. |
646 GetFakeProofSource()->InvokePendingCallback(0); | 646 GetFakeProofSource()->InvokePendingCallback(0); |
647 } | 647 } |
648 | 648 |
649 } // namespace | 649 } // namespace |
650 } // namespace test | 650 } // namespace test |
651 } // namespace net | 651 } // namespace net |
OLD | NEW |