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/proto/cached_network_parameters.pb.h" | 9 #include "net/quic/proto/cached_network_parameters.pb.h" |
10 #include "net/quic/quic_connection.h" | 10 #include "net/quic/quic_connection.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 ::testing::ValuesIn(QuicSupportedVersions())); | 127 ::testing::ValuesIn(QuicSupportedVersions())); |
128 | 128 |
129 TEST_P(QuicServerSessionTest, CloseStreamDueToReset) { | 129 TEST_P(QuicServerSessionTest, CloseStreamDueToReset) { |
130 // Open a stream, then reset it. | 130 // Open a stream, then reset it. |
131 // Send two bytes of payload to open it. | 131 // Send two bytes of payload to open it. |
132 QuicStreamFrame data1(kClientDataStreamId1, false, 0, StringPiece("HT")); | 132 QuicStreamFrame data1(kClientDataStreamId1, false, 0, StringPiece("HT")); |
133 session_->OnStreamFrame(data1); | 133 session_->OnStreamFrame(data1); |
134 EXPECT_EQ(1u, session_->GetNumOpenStreams()); | 134 EXPECT_EQ(1u, session_->GetNumOpenStreams()); |
135 | 135 |
136 // Send a reset (and expect the peer to send a RST in response). | 136 // Send a reset (and expect the peer to send a RST in response). |
137 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_STREAM_NO_ERROR, 0); | 137 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, |
| 138 0); |
138 EXPECT_CALL(*connection_, | 139 EXPECT_CALL(*connection_, |
139 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); | 140 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); |
140 visitor_->OnRstStream(rst1); | 141 visitor_->OnRstStream(rst1); |
141 EXPECT_EQ(0u, session_->GetNumOpenStreams()); | 142 EXPECT_EQ(0u, session_->GetNumOpenStreams()); |
142 | 143 |
143 // Send the same two bytes of payload in a new packet. | 144 // Send the same two bytes of payload in a new packet. |
144 visitor_->OnStreamFrame(data1); | 145 visitor_->OnStreamFrame(data1); |
145 | 146 |
146 // The stream should not be re-opened. | 147 // The stream should not be re-opened. |
147 EXPECT_EQ(0u, session_->GetNumOpenStreams()); | 148 EXPECT_EQ(0u, session_->GetNumOpenStreams()); |
148 EXPECT_TRUE(connection_->connected()); | 149 EXPECT_TRUE(connection_->connected()); |
149 } | 150 } |
150 | 151 |
151 TEST_P(QuicServerSessionTest, NeverOpenStreamDueToReset) { | 152 TEST_P(QuicServerSessionTest, NeverOpenStreamDueToReset) { |
152 // Send a reset (and expect the peer to send a RST in response). | 153 // Send a reset (and expect the peer to send a RST in response). |
153 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_STREAM_NO_ERROR, 0); | 154 QuicRstStreamFrame rst1(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, |
| 155 0); |
154 EXPECT_CALL(*connection_, | 156 EXPECT_CALL(*connection_, |
155 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); | 157 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); |
156 visitor_->OnRstStream(rst1); | 158 visitor_->OnRstStream(rst1); |
157 EXPECT_EQ(0u, session_->GetNumOpenStreams()); | 159 EXPECT_EQ(0u, session_->GetNumOpenStreams()); |
158 | 160 |
159 // Send two bytes of payload. | 161 // Send two bytes of payload. |
160 QuicStreamFrame data1(kClientDataStreamId1, false, 0, StringPiece("HT")); | 162 QuicStreamFrame data1(kClientDataStreamId1, false, 0, StringPiece("HT")); |
161 visitor_->OnStreamFrame(data1); | 163 visitor_->OnStreamFrame(data1); |
162 | 164 |
163 // The stream should never be opened, now that the reset is received. | 165 // The stream should never be opened, now that the reset is received. |
164 EXPECT_EQ(0u, session_->GetNumOpenStreams()); | 166 EXPECT_EQ(0u, session_->GetNumOpenStreams()); |
165 EXPECT_TRUE(connection_->connected()); | 167 EXPECT_TRUE(connection_->connected()); |
166 } | 168 } |
167 | 169 |
168 TEST_P(QuicServerSessionTest, AcceptClosedStream) { | 170 TEST_P(QuicServerSessionTest, AcceptClosedStream) { |
169 // Send (empty) compressed headers followed by two bytes of data. | 171 // Send (empty) compressed headers followed by two bytes of data. |
170 QuicStreamFrame frame1(kClientDataStreamId1, false, 0, | 172 QuicStreamFrame frame1(kClientDataStreamId1, false, 0, |
171 StringPiece("\1\0\0\0\0\0\0\0HT")); | 173 StringPiece("\1\0\0\0\0\0\0\0HT")); |
172 QuicStreamFrame frame2(kClientDataStreamId2, false, 0, | 174 QuicStreamFrame frame2(kClientDataStreamId2, false, 0, |
173 StringPiece("\2\0\0\0\0\0\0\0HT")); | 175 StringPiece("\2\0\0\0\0\0\0\0HT")); |
174 visitor_->OnStreamFrame(frame1); | 176 visitor_->OnStreamFrame(frame1); |
175 visitor_->OnStreamFrame(frame2); | 177 visitor_->OnStreamFrame(frame2); |
176 EXPECT_EQ(2u, session_->GetNumOpenStreams()); | 178 EXPECT_EQ(2u, session_->GetNumOpenStreams()); |
177 | 179 |
178 // Send a reset (and expect the peer to send a RST in response). | 180 // Send a reset (and expect the peer to send a RST in response). |
179 QuicRstStreamFrame rst(kClientDataStreamId1, QUIC_STREAM_NO_ERROR, 0); | 181 QuicRstStreamFrame rst(kClientDataStreamId1, QUIC_ERROR_PROCESSING_STREAM, 0); |
180 EXPECT_CALL(*connection_, | 182 EXPECT_CALL(*connection_, |
181 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); | 183 SendRstStream(kClientDataStreamId1, QUIC_RST_ACKNOWLEDGEMENT, 0)); |
182 visitor_->OnRstStream(rst); | 184 visitor_->OnRstStream(rst); |
183 | 185 |
184 // If we were tracking, we'd probably want to reject this because it's data | 186 // If we were tracking, we'd probably want to reject this because it's data |
185 // past the reset point of stream 3. As it's a closed stream we just drop the | 187 // past the reset point of stream 3. As it's a closed stream we just drop the |
186 // data on the floor, but accept the packet because it has data for stream 5. | 188 // data on the floor, but accept the packet because it has data for stream 5. |
187 QuicStreamFrame frame3(kClientDataStreamId1, false, 2, StringPiece("TP")); | 189 QuicStreamFrame frame3(kClientDataStreamId1, false, 2, StringPiece("TP")); |
188 QuicStreamFrame frame4(kClientDataStreamId2, false, 2, StringPiece("TP")); | 190 QuicStreamFrame frame4(kClientDataStreamId2, false, 2, StringPiece("TP")); |
189 visitor_->OnStreamFrame(frame3); | 191 visitor_->OnStreamFrame(frame3); |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 QuicServerSessionPeer::IsBandwidthResumptionEnabled(session_.get())); | 492 QuicServerSessionPeer::IsBandwidthResumptionEnabled(session_.get())); |
491 session_->OnConfigNegotiated(); | 493 session_->OnConfigNegotiated(); |
492 EXPECT_FALSE( | 494 EXPECT_FALSE( |
493 QuicServerSessionPeer::IsBandwidthResumptionEnabled(session_.get())); | 495 QuicServerSessionPeer::IsBandwidthResumptionEnabled(session_.get())); |
494 } | 496 } |
495 | 497 |
496 } // namespace | 498 } // namespace |
497 } // namespace test | 499 } // namespace test |
498 } // namespace tools | 500 } // namespace tools |
499 } // namespace net | 501 } // namespace net |
OLD | NEW |