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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, StringPiece("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(owner_, OnRstStreamReceived(_)).Times(1); | |
214 EXPECT_CALL(*connection_, | 213 EXPECT_CALL(*connection_, |
215 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); | 214 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); |
216 visitor_->OnRstStream(rst1); | 215 visitor_->OnRstStream(rst1); |
217 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); | 216 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); |
218 | 217 |
219 // Send the same two bytes of payload in a new packet. | 218 // Send the same two bytes of payload in a new packet. |
220 visitor_->OnStreamFrame(data1); | 219 visitor_->OnStreamFrame(data1); |
221 | 220 |
222 // The stream should not be re-opened. | 221 // The stream should not be re-opened. |
223 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); | 222 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); |
224 EXPECT_TRUE(connection_->connected()); | 223 EXPECT_TRUE(connection_->connected()); |
225 } | 224 } |
226 | 225 |
227 TEST_P(QuicServerSessionBaseTest, NeverOpenStreamDueToReset) { | 226 TEST_P(QuicServerSessionBaseTest, NeverOpenStreamDueToReset) { |
228 // 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). |
229 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, | 228 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, |
230 0); | 229 0); |
231 EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1); | |
232 EXPECT_CALL(*connection_, | 230 EXPECT_CALL(*connection_, |
233 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); | 231 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); |
234 visitor_->OnRstStream(rst1); | 232 visitor_->OnRstStream(rst1); |
235 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); | 233 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); |
236 | 234 |
237 // Send two bytes of payload. | 235 // Send two bytes of payload. |
238 QuicStreamFrame data1(kClientDataStreamId1, false, 0, StringPiece("HT")); | 236 QuicStreamFrame data1(kClientDataStreamId1, false, 0, StringPiece("HT")); |
239 visitor_->OnStreamFrame(data1); | 237 visitor_->OnStreamFrame(data1); |
240 | 238 |
241 // 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. |
242 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); | 240 EXPECT_EQ(0u, session_->GetNumOpenIncomingStreams()); |
243 EXPECT_TRUE(connection_->connected()); | 241 EXPECT_TRUE(connection_->connected()); |
244 } | 242 } |
245 | 243 |
246 TEST_P(QuicServerSessionBaseTest, AcceptClosedStream) { | 244 TEST_P(QuicServerSessionBaseTest, AcceptClosedStream) { |
247 // Send (empty) compressed headers followed by two bytes of data. | 245 // Send (empty) compressed headers followed by two bytes of data. |
248 QuicStreamFrame frame1(kClientDataStreamId1, false, 0, | 246 QuicStreamFrame frame1(kClientDataStreamId1, false, 0, |
249 StringPiece("\1\0\0\0\0\0\0\0HT")); | 247 StringPiece("\1\0\0\0\0\0\0\0HT")); |
250 QuicStreamFrame frame2(kClientDataStreamId2, false, 0, | 248 QuicStreamFrame frame2(kClientDataStreamId2, false, 0, |
251 StringPiece("\2\0\0\0\0\0\0\0HT")); | 249 StringPiece("\2\0\0\0\0\0\0\0HT")); |
252 visitor_->OnStreamFrame(frame1); | 250 visitor_->OnStreamFrame(frame1); |
253 visitor_->OnStreamFrame(frame2); | 251 visitor_->OnStreamFrame(frame2); |
254 EXPECT_EQ(2u, session_->GetNumOpenIncomingStreams()); | 252 EXPECT_EQ(2u, session_->GetNumOpenIncomingStreams()); |
255 | 253 |
256 // 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). |
257 QuicRstStreamFrame rst(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, 0); | 255 QuicRstStreamFrame rst(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, 0); |
258 EXPECT_CALL(owner_, OnRstStreamReceived(_)).Times(1); | |
259 EXPECT_CALL(*connection_, | 256 EXPECT_CALL(*connection_, |
260 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); | 257 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); |
261 visitor_->OnRstStream(rst); | 258 visitor_->OnRstStream(rst); |
262 | 259 |
263 // 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 |
264 // 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 |
265 // 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. |
266 QuicStreamFrame frame3(kClientDataStreamId1, false, 2, StringPiece("TP")); | 263 QuicStreamFrame frame3(kClientDataStreamId1, false, 2, StringPiece("TP")); |
267 QuicStreamFrame frame4(kClientDataStreamId2, false, 2, StringPiece("TP")); | 264 QuicStreamFrame frame4(kClientDataStreamId2, false, 2, StringPiece("TP")); |
268 visitor_->OnStreamFrame(frame3); | 265 visitor_->OnStreamFrame(frame3); |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 | 642 |
646 // Allow the async ProofSource::GetProof call to complete. Verify (under | 643 // 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 | 644 // asan) that this does not result in accesses to any freed memory from the |
648 // session or its subobjects. | 645 // session or its subobjects. |
649 GetFakeProofSource()->InvokePendingCallback(0); | 646 GetFakeProofSource()->InvokePendingCallback(0); |
650 } | 647 } |
651 | 648 |
652 } // namespace | 649 } // namespace |
653 } // namespace test | 650 } // namespace test |
654 } // namespace net | 651 } // namespace net |
OLD | NEW |