| 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/quic_connection.h" | 9 #include "net/quic/quic_connection.h" |
| 10 #include "net/quic/quic_utils.h" | 10 #include "net/quic/quic_utils.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 QuicStreamFrame data1(stream_id, false, 0, MakeIOVector("HT")); | 78 QuicStreamFrame data1(stream_id, false, 0, MakeIOVector("HT")); |
| 79 vector<QuicStreamFrame> frames; | 79 vector<QuicStreamFrame> frames; |
| 80 frames.push_back(data1); | 80 frames.push_back(data1); |
| 81 EXPECT_TRUE(visitor_->OnStreamFrames(frames)); | 81 EXPECT_TRUE(visitor_->OnStreamFrames(frames)); |
| 82 EXPECT_EQ(1u, session_->GetNumOpenStreams()); | 82 EXPECT_EQ(1u, session_->GetNumOpenStreams()); |
| 83 | 83 |
| 84 // Send a reset (and expect the peer to send a RST in response). | 84 // Send a reset (and expect the peer to send a RST in response). |
| 85 QuicRstStreamFrame rst1(stream_id, QUIC_STREAM_NO_ERROR, 0); | 85 QuicRstStreamFrame rst1(stream_id, QUIC_STREAM_NO_ERROR, 0); |
| 86 if (version() > QUIC_VERSION_13) { | 86 if (version() > QUIC_VERSION_13) { |
| 87 EXPECT_CALL(*connection_, | 87 EXPECT_CALL(*connection_, |
| 88 SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 0)); | 88 SendRstStream(stream_id, QUIC_RST_FLOW_CONTROL_ACCOUNTING, 0)); |
| 89 } | 89 } |
| 90 visitor_->OnRstStream(rst1); | 90 visitor_->OnRstStream(rst1); |
| 91 EXPECT_EQ(0u, session_->GetNumOpenStreams()); | 91 EXPECT_EQ(0u, session_->GetNumOpenStreams()); |
| 92 | 92 |
| 93 // Send the same two bytes of payload in a new packet. | 93 // Send the same two bytes of payload in a new packet. |
| 94 EXPECT_TRUE(visitor_->OnStreamFrames(frames)); | 94 EXPECT_TRUE(visitor_->OnStreamFrames(frames)); |
| 95 | 95 |
| 96 // The stream should not be re-opened. | 96 // The stream should not be re-opened. |
| 97 EXPECT_EQ(0u, session_->GetNumOpenStreams()); | 97 EXPECT_EQ(0u, session_->GetNumOpenStreams()); |
| 98 } | 98 } |
| 99 | 99 |
| 100 TEST_P(QuicServerSessionTest, NeverOpenStreamDueToReset) { | 100 TEST_P(QuicServerSessionTest, NeverOpenStreamDueToReset) { |
| 101 QuicStreamId stream_id = 5; | 101 QuicStreamId stream_id = 5; |
| 102 | 102 |
| 103 // Send a reset (and expect the peer to send a RST in response). | 103 // Send a reset (and expect the peer to send a RST in response). |
| 104 QuicRstStreamFrame rst1(stream_id, QUIC_STREAM_NO_ERROR, 0); | 104 QuicRstStreamFrame rst1(stream_id, QUIC_STREAM_NO_ERROR, 0); |
| 105 if (version() > QUIC_VERSION_13) { | 105 if (version() > QUIC_VERSION_13) { |
| 106 EXPECT_CALL(*connection_, | 106 EXPECT_CALL(*connection_, |
| 107 SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 0)); | 107 SendRstStream(stream_id, QUIC_RST_FLOW_CONTROL_ACCOUNTING, 0)); |
| 108 } | 108 } |
| 109 visitor_->OnRstStream(rst1); | 109 visitor_->OnRstStream(rst1); |
| 110 EXPECT_EQ(0u, session_->GetNumOpenStreams()); | 110 EXPECT_EQ(0u, session_->GetNumOpenStreams()); |
| 111 | 111 |
| 112 // Send two bytes of payload. | 112 // Send two bytes of payload. |
| 113 QuicStreamFrame data1(stream_id, false, 0, MakeIOVector("HT")); | 113 QuicStreamFrame data1(stream_id, false, 0, MakeIOVector("HT")); |
| 114 vector<QuicStreamFrame> frames; | 114 vector<QuicStreamFrame> frames; |
| 115 frames.push_back(data1); | 115 frames.push_back(data1); |
| 116 | 116 |
| 117 EXPECT_TRUE(visitor_->OnStreamFrames(frames)); | 117 EXPECT_TRUE(visitor_->OnStreamFrames(frames)); |
| 118 | 118 |
| 119 // The stream should never be opened, now that the reset is received. | 119 // The stream should never be opened, now that the reset is received. |
| 120 EXPECT_EQ(0u, session_->GetNumOpenStreams()); | 120 EXPECT_EQ(0u, session_->GetNumOpenStreams()); |
| 121 } | 121 } |
| 122 | 122 |
| 123 TEST_P(QuicServerSessionTest, AcceptClosedStream) { | 123 TEST_P(QuicServerSessionTest, AcceptClosedStream) { |
| 124 QuicStreamId stream_id = 5; | 124 QuicStreamId stream_id = 5; |
| 125 vector<QuicStreamFrame> frames; | 125 vector<QuicStreamFrame> frames; |
| 126 // Send (empty) compressed headers followed by two bytes of data. | 126 // Send (empty) compressed headers followed by two bytes of data. |
| 127 frames.push_back(QuicStreamFrame(stream_id, false, 0, | 127 frames.push_back(QuicStreamFrame(stream_id, false, 0, |
| 128 MakeIOVector("\1\0\0\0\0\0\0\0HT"))); | 128 MakeIOVector("\1\0\0\0\0\0\0\0HT"))); |
| 129 frames.push_back(QuicStreamFrame(stream_id + 2, false, 0, | 129 frames.push_back(QuicStreamFrame(stream_id + 2, false, 0, |
| 130 MakeIOVector("\2\0\0\0\0\0\0\0HT"))); | 130 MakeIOVector("\2\0\0\0\0\0\0\0HT"))); |
| 131 EXPECT_TRUE(visitor_->OnStreamFrames(frames)); | 131 EXPECT_TRUE(visitor_->OnStreamFrames(frames)); |
| 132 | 132 |
| 133 // Send a reset (and expect the peer to send a RST in response). | 133 // Send a reset (and expect the peer to send a RST in response). |
| 134 QuicRstStreamFrame rst(stream_id, QUIC_STREAM_NO_ERROR, 0); | 134 QuicRstStreamFrame rst(stream_id, QUIC_STREAM_NO_ERROR, 0); |
| 135 if (version() > QUIC_VERSION_13) { | 135 if (version() > QUIC_VERSION_13) { |
| 136 EXPECT_CALL(*connection_, | 136 EXPECT_CALL(*connection_, |
| 137 SendRstStream(stream_id, QUIC_STREAM_NO_ERROR, 0)); | 137 SendRstStream(stream_id, QUIC_RST_FLOW_CONTROL_ACCOUNTING, 0)); |
| 138 } | 138 } |
| 139 visitor_->OnRstStream(rst); | 139 visitor_->OnRstStream(rst); |
| 140 | 140 |
| 141 // If we were tracking, we'd probably want to reject this because it's data | 141 // If we were tracking, we'd probably want to reject this because it's data |
| 142 // past the reset point of stream 3. As it's a closed stream we just drop the | 142 // past the reset point of stream 3. As it's a closed stream we just drop the |
| 143 // data on the floor, but accept the packet because it has data for stream 5. | 143 // data on the floor, but accept the packet because it has data for stream 5. |
| 144 frames.clear(); | 144 frames.clear(); |
| 145 frames.push_back(QuicStreamFrame(stream_id, false, 2, MakeIOVector("TP"))); | 145 frames.push_back(QuicStreamFrame(stream_id, false, 2, MakeIOVector("TP"))); |
| 146 frames.push_back(QuicStreamFrame(stream_id + 2, false, 2, | 146 frames.push_back(QuicStreamFrame(stream_id + 2, false, 2, |
| 147 MakeIOVector("TP"))); | 147 MakeIOVector("TP"))); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 177 // Incoming streams on the server session must be odd. | 177 // Incoming streams on the server session must be odd. |
| 178 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_INVALID_STREAM_ID)); | 178 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_INVALID_STREAM_ID)); |
| 179 EXPECT_EQ(NULL, | 179 EXPECT_EQ(NULL, |
| 180 QuicServerSessionPeer::GetIncomingDataStream(session_.get(), 4)); | 180 QuicServerSessionPeer::GetIncomingDataStream(session_.get(), 4)); |
| 181 } | 181 } |
| 182 | 182 |
| 183 } // namespace | 183 } // namespace |
| 184 } // namespace test | 184 } // namespace test |
| 185 } // namespace tools | 185 } // namespace tools |
| 186 } // namespace net | 186 } // namespace net |
| OLD | NEW |