Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: net/tools/quic/quic_server_session_test.cc

Issue 23691073: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compiler/unittests fix Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/tools/quic/quic_reliable_server_stream_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7
8 #include "net/quic/crypto/crypto_server_config.h" 8 #include "net/quic/crypto/crypto_server_config.h"
9 #include "net/quic/crypto/quic_random.h" 9 #include "net/quic/crypto/quic_random.h"
10 #include "net/quic/quic_connection.h" 10 #include "net/quic/quic_connection.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 TEST_F(QuicServerSessionTest, CloseStreamDueToReset) { 123 TEST_F(QuicServerSessionTest, CloseStreamDueToReset) {
124 // Open a stream, then reset it. 124 // Open a stream, then reset it.
125 // Send two bytes of payload to open it. 125 // Send two bytes of payload to open it.
126 QuicPacketHeader header; 126 QuicPacketHeader header;
127 header.public_header.guid = guid_; 127 header.public_header.guid = guid_;
128 header.public_header.reset_flag = false; 128 header.public_header.reset_flag = false;
129 header.public_header.version_flag = false; 129 header.public_header.version_flag = false;
130 QuicStreamFrame data1(3, false, 0, "HT"); 130 QuicStreamFrame data1(3, false, 0, "HT");
131 vector<QuicStreamFrame> frames; 131 vector<QuicStreamFrame> frames;
132 frames.push_back(data1); 132 frames.push_back(data1);
133 EXPECT_TRUE(visitor_->OnPacket(IPEndPoint(), IPEndPoint(), 133 EXPECT_TRUE(visitor_->OnStreamFrames(frames));
134 header, frames));
135 EXPECT_EQ(1u, session_->GetNumOpenStreams()); 134 EXPECT_EQ(1u, session_->GetNumOpenStreams());
136 135
137 // Pretend we got full headers, so we won't trigger the 'unrecoverable 136 // Pretend we got full headers, so we won't trigger the 'unrecoverable
138 // compression context' state. 137 // compression context' state.
139 MarkHeadersReadForStream(3); 138 MarkHeadersReadForStream(3);
140 139
141 // Send a reset. 140 // Send a reset.
142 QuicRstStreamFrame rst1(3, QUIC_STREAM_NO_ERROR); 141 QuicRstStreamFrame rst1(3, QUIC_STREAM_NO_ERROR);
143 visitor_->OnRstStream(rst1); 142 visitor_->OnRstStream(rst1);
144 EXPECT_EQ(0u, session_->GetNumOpenStreams()); 143 EXPECT_EQ(0u, session_->GetNumOpenStreams());
145 144
146 // Send the same two bytes of payload in a new packet. 145 // Send the same two bytes of payload in a new packet.
147 EXPECT_TRUE(visitor_->OnPacket(IPEndPoint(), IPEndPoint(), 146 EXPECT_TRUE(visitor_->OnStreamFrames(frames));
148 header, frames));
149 147
150 // The stream should not be re-opened. 148 // The stream should not be re-opened.
151 EXPECT_EQ(0u, session_->GetNumOpenStreams()); 149 EXPECT_EQ(0u, session_->GetNumOpenStreams());
152 } 150 }
153 151
154 TEST_F(QuicServerSessionTest, NeverOpenStreamDueToReset) { 152 TEST_F(QuicServerSessionTest, NeverOpenStreamDueToReset) {
155 // Send a reset. 153 // Send a reset.
156 QuicRstStreamFrame rst1(3, QUIC_STREAM_NO_ERROR); 154 QuicRstStreamFrame rst1(3, QUIC_STREAM_NO_ERROR);
157 visitor_->OnRstStream(rst1); 155 visitor_->OnRstStream(rst1);
158 EXPECT_EQ(0u, session_->GetNumOpenStreams()); 156 EXPECT_EQ(0u, session_->GetNumOpenStreams());
159 157
160 // Send two bytes of payload. 158 // Send two bytes of payload.
161 QuicPacketHeader header; 159 QuicPacketHeader header;
162 header.public_header.guid = guid_; 160 header.public_header.guid = guid_;
163 header.public_header.reset_flag = false; 161 header.public_header.reset_flag = false;
164 header.public_header.version_flag = false; 162 header.public_header.version_flag = false;
165 QuicStreamFrame data1(3, false, 0, "HT"); 163 QuicStreamFrame data1(3, false, 0, "HT");
166 vector<QuicStreamFrame> frames; 164 vector<QuicStreamFrame> frames;
167 frames.push_back(data1); 165 frames.push_back(data1);
168 166
169 // When we get data for the closed stream, it implies the far side has 167 // When we get data for the closed stream, it implies the far side has
170 // compressed some headers. As a result we're going to bail due to 168 // compressed some headers. As a result we're going to bail due to
171 // unrecoverable compression context state. 169 // unrecoverable compression context state.
172 EXPECT_CALL(*connection_, SendConnectionClose( 170 EXPECT_CALL(*connection_, SendConnectionClose(
173 QUIC_STREAM_RST_BEFORE_HEADERS_DECOMPRESSED)); 171 QUIC_STREAM_RST_BEFORE_HEADERS_DECOMPRESSED));
174 EXPECT_FALSE(visitor_->OnPacket(IPEndPoint(), IPEndPoint(), 172 EXPECT_FALSE(visitor_->OnStreamFrames(frames));
175 header, frames));
176 173
177 // The stream should never be opened, now that the reset is received. 174 // The stream should never be opened, now that the reset is received.
178 EXPECT_EQ(0u, session_->GetNumOpenStreams()); 175 EXPECT_EQ(0u, session_->GetNumOpenStreams());
179 } 176 }
180 177
181 TEST_F(QuicServerSessionTest, GoOverPrematureClosedStreamLimit) { 178 TEST_F(QuicServerSessionTest, GoOverPrematureClosedStreamLimit) {
182 QuicPacketHeader header; 179 QuicPacketHeader header;
183 header.public_header.guid = guid_; 180 header.public_header.guid = guid_;
184 header.public_header.reset_flag = false; 181 header.public_header.reset_flag = false;
185 header.public_header.version_flag = false; 182 header.public_header.version_flag = false;
186 QuicStreamFrame data1(3, false, 0, "H"); 183 QuicStreamFrame data1(3, false, 0, "H");
187 vector<QuicStreamFrame> frames; 184 vector<QuicStreamFrame> frames;
188 frames.push_back(data1); 185 frames.push_back(data1);
189 186
190 // Set up the stream such that it's open in OnPacket, but closes half way 187 // Set up the stream such that it's open in OnPacket, but closes half way
191 // through while on the decompression blocked list. 188 // through while on the decompression blocked list.
192 session_->CloseStreamOnData(); 189 session_->CloseStreamOnData();
193 190
194 EXPECT_CALL(*connection_, SendConnectionClose( 191 EXPECT_CALL(*connection_, SendConnectionClose(
195 QUIC_STREAM_RST_BEFORE_HEADERS_DECOMPRESSED)); 192 QUIC_STREAM_RST_BEFORE_HEADERS_DECOMPRESSED));
196 EXPECT_FALSE(visitor_->OnPacket(IPEndPoint(), IPEndPoint(), 193 EXPECT_FALSE(visitor_->OnStreamFrames(frames));
197 header, frames));
198 } 194 }
199 195
200 TEST_F(QuicServerSessionTest, AcceptClosedStream) { 196 TEST_F(QuicServerSessionTest, AcceptClosedStream) {
201 QuicPacketHeader header; 197 QuicPacketHeader header;
202 header.public_header.guid = guid_; 198 header.public_header.guid = guid_;
203 header.public_header.reset_flag = false; 199 header.public_header.reset_flag = false;
204 header.public_header.version_flag = false; 200 header.public_header.version_flag = false;
205 vector<QuicStreamFrame> frames; 201 vector<QuicStreamFrame> frames;
206 // Send (empty) compressed headers followed by two bytes of data. 202 // Send (empty) compressed headers followed by two bytes of data.
207 frames.push_back(QuicStreamFrame(3, false, 0, "\1\0\0\0\0\0\0\0HT")); 203 frames.push_back(QuicStreamFrame(3, false, 0, "\1\0\0\0\0\0\0\0HT"));
208 frames.push_back(QuicStreamFrame(5, false, 0, "\2\0\0\0\0\0\0\0HT")); 204 frames.push_back(QuicStreamFrame(5, false, 0, "\2\0\0\0\0\0\0\0HT"));
209 EXPECT_TRUE(visitor_->OnPacket(IPEndPoint(), IPEndPoint(), 205 EXPECT_TRUE(visitor_->OnStreamFrames(frames));
210 header, frames));
211 206
212 // Pretend we got full headers, so we won't trigger the 'unercoverable 207 // Pretend we got full headers, so we won't trigger the 'unercoverable
213 // compression context' state. 208 // compression context' state.
214 MarkHeadersReadForStream(3); 209 MarkHeadersReadForStream(3);
215 210
216 // Send a reset. 211 // Send a reset.
217 QuicRstStreamFrame rst(3, QUIC_STREAM_NO_ERROR); 212 QuicRstStreamFrame rst(3, QUIC_STREAM_NO_ERROR);
218 visitor_->OnRstStream(rst); 213 visitor_->OnRstStream(rst);
219 214
220 // If we were tracking, we'd probably want to reject this because it's data 215 // If we were tracking, we'd probably want to reject this because it's data
221 // past the reset point of stream 3. As it's a closed stream we just drop the 216 // past the reset point of stream 3. As it's a closed stream we just drop the
222 // data on the floor, but accept the packet because it has data for stream 5. 217 // data on the floor, but accept the packet because it has data for stream 5.
223 frames.clear(); 218 frames.clear();
224 frames.push_back(QuicStreamFrame(3, false, 2, "TP")); 219 frames.push_back(QuicStreamFrame(3, false, 2, "TP"));
225 frames.push_back(QuicStreamFrame(5, false, 2, "TP")); 220 frames.push_back(QuicStreamFrame(5, false, 2, "TP"));
226 EXPECT_TRUE(visitor_->OnPacket(IPEndPoint(), IPEndPoint(), 221 EXPECT_TRUE(visitor_->OnStreamFrames(frames));
227 header, frames));
228 } 222 }
229 223
230 TEST_F(QuicServerSessionTest, MaxNumConnections) { 224 TEST_F(QuicServerSessionTest, MaxNumConnections) {
231 EXPECT_EQ(0u, session_->GetNumOpenStreams()); 225 EXPECT_EQ(0u, session_->GetNumOpenStreams());
232 EXPECT_TRUE( 226 EXPECT_TRUE(
233 QuicServerSessionPeer::GetIncomingReliableStream(session_.get(), 3)); 227 QuicServerSessionPeer::GetIncomingReliableStream(session_.get(), 3));
234 EXPECT_TRUE( 228 EXPECT_TRUE(
235 QuicServerSessionPeer::GetIncomingReliableStream(session_.get(), 5)); 229 QuicServerSessionPeer::GetIncomingReliableStream(session_.get(), 5));
236 EXPECT_TRUE( 230 EXPECT_TRUE(
237 QuicServerSessionPeer::GetIncomingReliableStream(session_.get(), 7)); 231 QuicServerSessionPeer::GetIncomingReliableStream(session_.get(), 7));
(...skipping 14 matching lines...) Expand all
252 // Incoming streams on the server session must be odd. 246 // Incoming streams on the server session must be odd.
253 EXPECT_EQ(NULL, 247 EXPECT_EQ(NULL,
254 QuicServerSessionPeer::GetIncomingReliableStream( 248 QuicServerSessionPeer::GetIncomingReliableStream(
255 session_.get(), 2)); 249 session_.get(), 2));
256 } 250 }
257 251
258 } // namespace 252 } // namespace
259 } // namespace test 253 } // namespace test
260 } // namespace tools 254 } // namespace tools
261 } // namespace net 255 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_reliable_server_stream_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698