OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 WaitableEvent listening_; | 100 WaitableEvent listening_; |
101 WaitableEvent quit_; | 101 WaitableEvent quit_; |
102 base::Lock port_lock_; | 102 base::Lock port_lock_; |
103 QuicServer server_; | 103 QuicServer server_; |
104 IPEndPoint address_; | 104 IPEndPoint address_; |
105 int port_; | 105 int port_; |
106 | 106 |
107 DISALLOW_COPY_AND_ASSIGN(ServerThread); | 107 DISALLOW_COPY_AND_ASSIGN(ServerThread); |
108 }; | 108 }; |
109 | 109 |
110 class EndToEndTest : public ::testing::Test { | 110 class EndToEndTest : public ::testing::TestWithParam<QuicVersion> { |
| 111 public: |
| 112 static void SetUpTestCase() { |
| 113 QuicInMemoryCache::GetInstance()->ResetForTests(); |
| 114 } |
| 115 |
111 protected: | 116 protected: |
112 EndToEndTest() | 117 EndToEndTest() |
113 : server_hostname_("example.com"), | 118 : server_hostname_("example.com"), |
114 server_started_(false) { | 119 server_started_(false) { |
115 net::IPAddressNumber ip; | 120 net::IPAddressNumber ip; |
116 CHECK(net::ParseIPLiteralToNumber("127.0.0.1", &ip)); | 121 CHECK(net::ParseIPLiteralToNumber("127.0.0.1", &ip)); |
117 server_address_ = IPEndPoint(ip, 0); | 122 server_address_ = IPEndPoint(ip, 0); |
118 client_config_.SetDefaults(); | 123 client_config_.SetDefaults(); |
119 server_config_.SetDefaults(); | 124 server_config_.SetDefaults(); |
120 | 125 |
121 AddToCache("GET", kLargeRequest, "HTTP/1.1", "200", "OK", kFooResponseBody); | 126 AddToCache("GET", kLargeRequest, "HTTP/1.1", "200", "OK", kFooResponseBody); |
122 AddToCache("GET", "https://www.google.com/foo", | 127 AddToCache("GET", "https://www.google.com/foo", |
123 "HTTP/1.1", "200", "OK", kFooResponseBody); | 128 "HTTP/1.1", "200", "OK", kFooResponseBody); |
124 AddToCache("GET", "https://www.google.com/bar", | 129 AddToCache("GET", "https://www.google.com/bar", |
125 "HTTP/1.1", "200", "OK", kBarResponseBody); | 130 "HTTP/1.1", "200", "OK", kBarResponseBody); |
126 } | 131 version_ = GetParam(); |
127 | |
128 static void SetUpTestCase() { | |
129 QuicInMemoryCache::GetInstance()->ResetForTests(); | |
130 } | 132 } |
131 | 133 |
132 virtual QuicTestClient* CreateQuicClient() { | 134 virtual QuicTestClient* CreateQuicClient() { |
133 QuicTestClient* client = new QuicTestClient(server_address_, | 135 QuicTestClient* client = new QuicTestClient(server_address_, |
134 server_hostname_, | 136 server_hostname_, |
135 client_config_); | 137 client_config_, |
| 138 version_); |
136 client->Connect(); | 139 client->Connect(); |
137 return client; | 140 return client; |
138 } | 141 } |
139 | 142 |
140 virtual bool Initialize() { | 143 virtual bool Initialize() { |
141 // Start the server first, because CreateQuicClient() attempts | 144 // Start the server first, because CreateQuicClient() attempts |
142 // to connect to the server. | 145 // to connect to the server. |
143 StartServer(); | 146 StartServer(); |
144 client_.reset(CreateQuicClient()); | 147 client_.reset(CreateQuicClient()); |
145 return client_->client()->connected(); | 148 return client_->client()->connected(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 cache->AddResponse(request_headers, response_headers, body); | 201 cache->AddResponse(request_headers, response_headers, body); |
199 } | 202 } |
200 | 203 |
201 IPEndPoint server_address_; | 204 IPEndPoint server_address_; |
202 string server_hostname_; | 205 string server_hostname_; |
203 scoped_ptr<ServerThread> server_thread_; | 206 scoped_ptr<ServerThread> server_thread_; |
204 scoped_ptr<QuicTestClient> client_; | 207 scoped_ptr<QuicTestClient> client_; |
205 bool server_started_; | 208 bool server_started_; |
206 QuicConfig client_config_; | 209 QuicConfig client_config_; |
207 QuicConfig server_config_; | 210 QuicConfig server_config_; |
| 211 QuicVersion version_; |
208 }; | 212 }; |
209 | 213 |
210 TEST_F(EndToEndTest, SimpleRequestResponse) { | 214 // Run all end to end tests with QUIC version 6. |
| 215 INSTANTIATE_TEST_CASE_P(EndToEndTests, |
| 216 EndToEndTest, |
| 217 ::testing::Values(QUIC_VERSION_6)); |
| 218 |
| 219 TEST_P(EndToEndTest, SimpleRequestResponse) { |
211 // TODO(rtenneti): Delete this when NSS is supported. | 220 // TODO(rtenneti): Delete this when NSS is supported. |
212 if (!Aes128Gcm12Encrypter::IsSupported()) { | 221 if (!Aes128Gcm12Encrypter::IsSupported()) { |
213 LOG(INFO) << "AES GCM not supported. Test skipped."; | 222 LOG(INFO) << "AES GCM not supported. Test skipped."; |
214 return; | 223 return; |
215 } | 224 } |
216 | 225 |
217 ASSERT_TRUE(Initialize()); | 226 ASSERT_TRUE(Initialize()); |
218 | 227 |
219 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 228 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
220 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 229 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
221 } | 230 } |
222 | 231 |
223 TEST_F(EndToEndTest, SimpleRequestResponsev6) { | 232 TEST_P(EndToEndTest, SimpleRequestResponsev6) { |
224 // TODO(rtenneti): Delete this when NSS is supported. | 233 // TODO(rtenneti): Delete this when NSS is supported. |
225 if (!Aes128Gcm12Encrypter::IsSupported()) { | 234 if (!Aes128Gcm12Encrypter::IsSupported()) { |
226 LOG(INFO) << "AES GCM not supported. Test skipped."; | 235 LOG(INFO) << "AES GCM not supported. Test skipped."; |
227 return; | 236 return; |
228 } | 237 } |
229 | 238 |
230 IPAddressNumber ip; | 239 IPAddressNumber ip; |
231 CHECK(net::ParseIPLiteralToNumber("::1", &ip)); | 240 CHECK(net::ParseIPLiteralToNumber("::1", &ip)); |
232 server_address_ = IPEndPoint(ip, server_address_.port()); | 241 server_address_ = IPEndPoint(ip, server_address_.port()); |
233 ASSERT_TRUE(Initialize()); | 242 ASSERT_TRUE(Initialize()); |
234 | 243 |
235 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 244 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
236 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 245 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
237 } | 246 } |
238 | 247 |
239 TEST_F(EndToEndTest, SeparateFinPacket) { | 248 TEST_P(EndToEndTest, SeparateFinPacket) { |
240 // TODO(rtenneti): Delete this when NSS is supported. | 249 // TODO(rtenneti): Delete this when NSS is supported. |
241 if (!Aes128Gcm12Encrypter::IsSupported()) { | 250 if (!Aes128Gcm12Encrypter::IsSupported()) { |
242 LOG(INFO) << "AES GCM not supported. Test skipped."; | 251 LOG(INFO) << "AES GCM not supported. Test skipped."; |
243 return; | 252 return; |
244 } | 253 } |
245 | 254 |
246 ASSERT_TRUE(Initialize()); | 255 ASSERT_TRUE(Initialize()); |
247 | 256 |
248 HTTPMessage request(HttpConstants::HTTP_1_1, | 257 HTTPMessage request(HttpConstants::HTTP_1_1, |
249 HttpConstants::POST, "/foo"); | 258 HttpConstants::POST, "/foo"); |
250 request.set_has_complete_message(false); | 259 request.set_has_complete_message(false); |
251 | 260 |
252 client_->SendMessage(request); | 261 client_->SendMessage(request); |
253 | 262 |
254 client_->SendData(string(), true); | 263 client_->SendData(string(), true); |
255 | 264 |
256 client_->WaitForResponse(); | 265 client_->WaitForResponse(); |
257 EXPECT_EQ(kFooResponseBody, client_->response_body()); | 266 EXPECT_EQ(kFooResponseBody, client_->response_body()); |
258 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 267 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
259 | 268 |
260 request.AddBody("foo", true); | 269 request.AddBody("foo", true); |
261 | 270 |
262 client_->SendMessage(request); | 271 client_->SendMessage(request); |
263 client_->SendData(string(), true); | 272 client_->SendData(string(), true); |
264 client_->WaitForResponse(); | 273 client_->WaitForResponse(); |
265 EXPECT_EQ(kFooResponseBody, client_->response_body()); | 274 EXPECT_EQ(kFooResponseBody, client_->response_body()); |
266 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 275 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
267 } | 276 } |
268 | 277 |
269 TEST_F(EndToEndTest, MultipleRequestResponse) { | 278 TEST_P(EndToEndTest, MultipleRequestResponse) { |
270 // TODO(rtenneti): Delete this when NSS is supported. | 279 // TODO(rtenneti): Delete this when NSS is supported. |
271 if (!Aes128Gcm12Encrypter::IsSupported()) { | 280 if (!Aes128Gcm12Encrypter::IsSupported()) { |
272 LOG(INFO) << "AES GCM not supported. Test skipped."; | 281 LOG(INFO) << "AES GCM not supported. Test skipped."; |
273 return; | 282 return; |
274 } | 283 } |
275 | 284 |
276 ASSERT_TRUE(Initialize()); | 285 ASSERT_TRUE(Initialize()); |
277 | 286 |
278 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 287 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
279 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 288 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
280 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); | 289 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); |
281 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 290 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
282 } | 291 } |
283 | 292 |
284 TEST_F(EndToEndTest, MultipleClients) { | 293 TEST_P(EndToEndTest, MultipleClients) { |
285 // TODO(rtenneti): Delete this when NSS is supported. | 294 // TODO(rtenneti): Delete this when NSS is supported. |
286 if (!Aes128Gcm12Encrypter::IsSupported()) { | 295 if (!Aes128Gcm12Encrypter::IsSupported()) { |
287 LOG(INFO) << "AES GCM not supported. Test skipped."; | 296 LOG(INFO) << "AES GCM not supported. Test skipped."; |
288 return; | 297 return; |
289 } | 298 } |
290 | 299 |
291 ASSERT_TRUE(Initialize()); | 300 ASSERT_TRUE(Initialize()); |
292 scoped_ptr<QuicTestClient> client2(CreateQuicClient()); | 301 scoped_ptr<QuicTestClient> client2(CreateQuicClient()); |
293 | 302 |
294 HTTPMessage request(HttpConstants::HTTP_1_1, | 303 HTTPMessage request(HttpConstants::HTTP_1_1, |
295 HttpConstants::POST, "/foo"); | 304 HttpConstants::POST, "/foo"); |
296 request.AddHeader("content-length", "3"); | 305 request.AddHeader("content-length", "3"); |
297 request.set_has_complete_message(false); | 306 request.set_has_complete_message(false); |
298 | 307 |
299 client_->SendMessage(request); | 308 client_->SendMessage(request); |
300 client2->SendMessage(request); | 309 client2->SendMessage(request); |
301 | 310 |
302 client_->SendData("bar", true); | 311 client_->SendData("bar", true); |
303 client_->WaitForResponse(); | 312 client_->WaitForResponse(); |
304 EXPECT_EQ(kFooResponseBody, client_->response_body()); | 313 EXPECT_EQ(kFooResponseBody, client_->response_body()); |
305 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 314 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
306 | 315 |
307 client2->SendData("eep", true); | 316 client2->SendData("eep", true); |
308 client2->WaitForResponse(); | 317 client2->WaitForResponse(); |
309 EXPECT_EQ(kFooResponseBody, client2->response_body()); | 318 EXPECT_EQ(kFooResponseBody, client2->response_body()); |
310 EXPECT_EQ(200u, client2->response_headers()->parsed_response_code()); | 319 EXPECT_EQ(200u, client2->response_headers()->parsed_response_code()); |
311 } | 320 } |
312 | 321 |
313 TEST_F(EndToEndTest, RequestOverMultiplePackets) { | 322 TEST_P(EndToEndTest, RequestOverMultiplePackets) { |
314 // TODO(rtenneti): Delete this when NSS is supported. | 323 // TODO(rtenneti): Delete this when NSS is supported. |
315 if (!Aes128Gcm12Encrypter::IsSupported()) { | 324 if (!Aes128Gcm12Encrypter::IsSupported()) { |
316 LOG(INFO) << "AES GCM not supported. Test skipped."; | 325 LOG(INFO) << "AES GCM not supported. Test skipped."; |
317 return; | 326 return; |
318 } | 327 } |
319 | 328 |
320 ASSERT_TRUE(Initialize()); | 329 ASSERT_TRUE(Initialize()); |
321 // Set things up so we have a small payload, to guarantee fragmentation. | 330 // Set things up so we have a small payload, to guarantee fragmentation. |
322 // A congestion feedback frame can't be split into multiple packets, make sure | 331 // A congestion feedback frame can't be split into multiple packets, make sure |
323 // that our packet have room for at least this amount after the normal headers | 332 // that our packet have room for at least this amount after the normal headers |
(...skipping 11 matching lines...) Expand all Loading... |
335 GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, | 344 GetPacketHeaderSize(PACKET_8BYTE_GUID, !kIncludeVersion, |
336 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP) + | 345 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP) + |
337 ciphertext_size; | 346 ciphertext_size; |
338 | 347 |
339 // Make sure our request is too large to fit in one packet. | 348 // Make sure our request is too large to fit in one packet. |
340 EXPECT_GT(strlen(kLargeRequest), min_payload_size); | 349 EXPECT_GT(strlen(kLargeRequest), min_payload_size); |
341 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest(kLargeRequest)); | 350 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest(kLargeRequest)); |
342 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 351 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
343 } | 352 } |
344 | 353 |
345 TEST_F(EndToEndTest, MultipleFramesRandomOrder) { | 354 TEST_P(EndToEndTest, MultipleFramesRandomOrder) { |
346 // TODO(rtenneti): Delete this when NSS is supported. | 355 // TODO(rtenneti): Delete this when NSS is supported. |
347 if (!Aes128Gcm12Encrypter::IsSupported()) { | 356 if (!Aes128Gcm12Encrypter::IsSupported()) { |
348 LOG(INFO) << "AES GCM not supported. Test skipped."; | 357 LOG(INFO) << "AES GCM not supported. Test skipped."; |
349 return; | 358 return; |
350 } | 359 } |
351 | 360 |
352 ASSERT_TRUE(Initialize()); | 361 ASSERT_TRUE(Initialize()); |
353 // Set things up so we have a small payload, to guarantee fragmentation. | 362 // Set things up so we have a small payload, to guarantee fragmentation. |
354 // A congestion feedback frame can't be split into multiple packets, make sure | 363 // A congestion feedback frame can't be split into multiple packets, make sure |
355 // that our packet have room for at least this amount after the normal headers | 364 // that our packet have room for at least this amount after the normal headers |
(...skipping 12 matching lines...) Expand all Loading... |
368 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP) + | 377 PACKET_6BYTE_SEQUENCE_NUMBER, NOT_IN_FEC_GROUP) + |
369 ciphertext_size; | 378 ciphertext_size; |
370 client_->options()->random_reorder = true; | 379 client_->options()->random_reorder = true; |
371 | 380 |
372 // Make sure our request is too large to fit in one packet. | 381 // Make sure our request is too large to fit in one packet. |
373 EXPECT_GT(strlen(kLargeRequest), min_payload_size); | 382 EXPECT_GT(strlen(kLargeRequest), min_payload_size); |
374 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest(kLargeRequest)); | 383 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest(kLargeRequest)); |
375 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 384 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
376 } | 385 } |
377 | 386 |
378 TEST_F(EndToEndTest, PostMissingBytes) { | 387 TEST_P(EndToEndTest, PostMissingBytes) { |
379 // TODO(rtenneti): Delete this when NSS is supported. | 388 // TODO(rtenneti): Delete this when NSS is supported. |
380 if (!Aes128Gcm12Encrypter::IsSupported()) { | 389 if (!Aes128Gcm12Encrypter::IsSupported()) { |
381 LOG(INFO) << "AES GCM not supported. Test skipped."; | 390 LOG(INFO) << "AES GCM not supported. Test skipped."; |
382 return; | 391 return; |
383 } | 392 } |
384 | 393 |
385 ASSERT_TRUE(Initialize()); | 394 ASSERT_TRUE(Initialize()); |
386 | 395 |
387 // Add a content length header with no body. | 396 // Add a content length header with no body. |
388 HTTPMessage request(HttpConstants::HTTP_1_1, | 397 HTTPMessage request(HttpConstants::HTTP_1_1, |
389 HttpConstants::POST, "/foo"); | 398 HttpConstants::POST, "/foo"); |
390 request.AddHeader("content-length", "3"); | 399 request.AddHeader("content-length", "3"); |
391 request.set_skip_message_validation(true); | 400 request.set_skip_message_validation(true); |
392 | 401 |
393 // This should be detected as stream fin without complete request, | 402 // This should be detected as stream fin without complete request, |
394 // triggering an error response. | 403 // triggering an error response. |
395 client_->SendCustomSynchronousRequest(request); | 404 client_->SendCustomSynchronousRequest(request); |
396 EXPECT_EQ("bad", client_->response_body()); | 405 EXPECT_EQ("bad", client_->response_body()); |
397 EXPECT_EQ(500u, client_->response_headers()->parsed_response_code()); | 406 EXPECT_EQ(500u, client_->response_headers()->parsed_response_code()); |
398 } | 407 } |
399 | 408 |
400 TEST_F(EndToEndTest, LargePost) { | 409 TEST_P(EndToEndTest, LargePost) { |
401 // TODO(rtenneti): Delete this when NSS is supported. | 410 // TODO(rtenneti): Delete this when NSS is supported. |
402 if (!Aes128Gcm12Encrypter::IsSupported()) { | 411 if (!Aes128Gcm12Encrypter::IsSupported()) { |
403 LOG(INFO) << "AES GCM not supported. Test skipped."; | 412 LOG(INFO) << "AES GCM not supported. Test skipped."; |
404 return; | 413 return; |
405 } | 414 } |
406 | 415 |
407 // FLAGS_fake_packet_loss_percentage = 30; | 416 // FLAGS_fake_packet_loss_percentage = 30; |
408 ASSERT_TRUE(Initialize()); | 417 ASSERT_TRUE(Initialize()); |
409 | 418 |
410 string body; | 419 string body; |
411 GenerateBody(&body, 10240); | 420 GenerateBody(&body, 10240); |
412 | 421 |
413 HTTPMessage request(HttpConstants::HTTP_1_1, | 422 HTTPMessage request(HttpConstants::HTTP_1_1, |
414 HttpConstants::POST, "/foo"); | 423 HttpConstants::POST, "/foo"); |
415 request.AddBody(body, true); | 424 request.AddBody(body, true); |
416 | 425 |
417 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | 426 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
418 } | 427 } |
419 | 428 |
420 // TODO(ianswett): Enable once b/9295090 is fixed. | 429 // TODO(ianswett): Enable once b/9295090 is fixed. |
421 TEST_F(EndToEndTest, DISABLED_LargePostFEC) { | 430 TEST_P(EndToEndTest, DISABLED_LargePostFEC) { |
422 // FLAGS_fake_packet_loss_percentage = 30; | 431 // FLAGS_fake_packet_loss_percentage = 30; |
423 ASSERT_TRUE(Initialize()); | 432 ASSERT_TRUE(Initialize()); |
424 client_->options()->max_packets_per_fec_group = 6; | 433 client_->options()->max_packets_per_fec_group = 6; |
425 | 434 |
426 // TODO(rtenneti): Delete this when NSS is supported. | 435 // TODO(rtenneti): Delete this when NSS is supported. |
427 if (!Aes128Gcm12Encrypter::IsSupported()) { | 436 if (!Aes128Gcm12Encrypter::IsSupported()) { |
428 LOG(INFO) << "AES GCM not supported. Test skipped."; | 437 LOG(INFO) << "AES GCM not supported. Test skipped."; |
429 return; | 438 return; |
430 } | 439 } |
431 | 440 |
432 // FLAGS_fake_packet_loss_percentage = 30; | 441 // FLAGS_fake_packet_loss_percentage = 30; |
433 ASSERT_TRUE(Initialize()); | 442 ASSERT_TRUE(Initialize()); |
434 client_->options()->max_packets_per_fec_group = 6; | 443 client_->options()->max_packets_per_fec_group = 6; |
435 | 444 |
436 string body; | 445 string body; |
437 GenerateBody(&body, 10240); | 446 GenerateBody(&body, 10240); |
438 | 447 |
439 HTTPMessage request(HttpConstants::HTTP_1_1, | 448 HTTPMessage request(HttpConstants::HTTP_1_1, |
440 HttpConstants::POST, "/foo"); | 449 HttpConstants::POST, "/foo"); |
441 request.AddBody(body, true); | 450 request.AddBody(body, true); |
442 | 451 |
443 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | 452 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
444 } | 453 } |
445 | 454 |
446 /*TEST_F(EndToEndTest, PacketTooLarge) { | 455 /*TEST_P(EndToEndTest, PacketTooLarge) { |
447 FLAGS_quic_allow_oversized_packets_for_test = true; | 456 FLAGS_quic_allow_oversized_packets_for_test = true; |
448 ASSERT_TRUE(Initialize()); | 457 ASSERT_TRUE(Initialize()); |
449 | 458 |
450 string body; | 459 string body; |
451 GenerateBody(&body, kMaxPacketSize); | 460 GenerateBody(&body, kMaxPacketSize); |
452 | 461 |
453 HTTPMessage request(HttpConstants::HTTP_1_1, | 462 HTTPMessage request(HttpConstants::HTTP_1_1, |
454 HttpConstants::POST, "/foo"); | 463 HttpConstants::POST, "/foo"); |
455 request.AddBody(body, true); | 464 request.AddBody(body, true); |
456 client_->options()->max_packet_length = 20480; | 465 client_->options()->max_packet_length = 20480; |
457 | 466 |
458 EXPECT_EQ("", client_->SendCustomSynchronousRequest(request)); | 467 EXPECT_EQ("", client_->SendCustomSynchronousRequest(request)); |
459 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); | 468 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); |
460 EXPECT_EQ(QUIC_PACKET_TOO_LARGE, client_->connection_error()); | 469 EXPECT_EQ(QUIC_PACKET_TOO_LARGE, client_->connection_error()); |
461 }*/ | 470 }*/ |
462 | 471 |
463 TEST_F(EndToEndTest, InvalidStream) { | 472 TEST_P(EndToEndTest, InvalidStream) { |
464 // TODO(rtenneti): Delete this when NSS is supported. | 473 // TODO(rtenneti): Delete this when NSS is supported. |
465 if (!Aes128Gcm12Encrypter::IsSupported()) { | 474 if (!Aes128Gcm12Encrypter::IsSupported()) { |
466 LOG(INFO) << "AES GCM not supported. Test skipped."; | 475 LOG(INFO) << "AES GCM not supported. Test skipped."; |
467 return; | 476 return; |
468 } | 477 } |
469 | 478 |
470 ASSERT_TRUE(Initialize()); | 479 ASSERT_TRUE(Initialize()); |
471 | 480 |
472 string body; | 481 string body; |
473 GenerateBody(&body, kMaxPacketSize); | 482 GenerateBody(&body, kMaxPacketSize); |
474 | 483 |
475 HTTPMessage request(HttpConstants::HTTP_1_1, | 484 HTTPMessage request(HttpConstants::HTTP_1_1, |
476 HttpConstants::POST, "/foo"); | 485 HttpConstants::POST, "/foo"); |
477 request.AddBody(body, true); | 486 request.AddBody(body, true); |
478 // Force the client to write with a stream ID belonging to a nonexistant | 487 // Force the client to write with a stream ID belonging to a nonexistant |
479 // server-side stream. | 488 // server-side stream. |
480 QuicSessionPeer::SetNextStreamId(client_->client()->session(), 2); | 489 QuicSessionPeer::SetNextStreamId(client_->client()->session(), 2); |
481 | 490 |
482 client_->SendCustomSynchronousRequest(request); | 491 client_->SendCustomSynchronousRequest(request); |
483 // EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); | 492 // EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); |
484 EXPECT_EQ(QUIC_PACKET_FOR_NONEXISTENT_STREAM, client_->connection_error()); | 493 EXPECT_EQ(QUIC_PACKET_FOR_NONEXISTENT_STREAM, client_->connection_error()); |
485 } | 494 } |
486 | 495 |
487 TEST_F(EndToEndTest, MultipleTermination) { | 496 TEST_P(EndToEndTest, MultipleTermination) { |
488 // TODO(rtenneti): Delete this when NSS is supported. | 497 // TODO(rtenneti): Delete this when NSS is supported. |
489 if (!Aes128Gcm12Encrypter::IsSupported()) { | 498 if (!Aes128Gcm12Encrypter::IsSupported()) { |
490 LOG(INFO) << "AES GCM not supported. Test skipped."; | 499 LOG(INFO) << "AES GCM not supported. Test skipped."; |
491 return; | 500 return; |
492 } | 501 } |
493 | 502 |
494 ASSERT_TRUE(Initialize()); | 503 ASSERT_TRUE(Initialize()); |
495 scoped_ptr<QuicTestClient> client2(CreateQuicClient()); | 504 scoped_ptr<QuicTestClient> client2(CreateQuicClient()); |
496 | 505 |
497 HTTPMessage request(HttpConstants::HTTP_1_1, | 506 HTTPMessage request(HttpConstants::HTTP_1_1, |
(...skipping 15 matching lines...) Expand all Loading... |
513 ReliableQuicStreamPeer::SetWriteSideClosed( | 522 ReliableQuicStreamPeer::SetWriteSideClosed( |
514 false, client_->GetOrCreateStream()); | 523 false, client_->GetOrCreateStream()); |
515 EXPECT_DEBUG_DEATH({ | 524 EXPECT_DEBUG_DEATH({ |
516 client_->SendData("eep", true); | 525 client_->SendData("eep", true); |
517 client_->WaitForResponse(); | 526 client_->WaitForResponse(); |
518 EXPECT_EQ(QUIC_MULTIPLE_TERMINATION_OFFSETS, client_->stream_error()); | 527 EXPECT_EQ(QUIC_MULTIPLE_TERMINATION_OFFSETS, client_->stream_error()); |
519 }, | 528 }, |
520 "Check failed: !fin_buffered_"); | 529 "Check failed: !fin_buffered_"); |
521 } | 530 } |
522 | 531 |
523 TEST_F(EndToEndTest, Timeout) { | 532 TEST_P(EndToEndTest, Timeout) { |
524 client_config_.set_idle_connection_state_lifetime( | 533 client_config_.set_idle_connection_state_lifetime( |
525 QuicTime::Delta::FromMicroseconds(500), | 534 QuicTime::Delta::FromMicroseconds(500), |
526 QuicTime::Delta::FromMicroseconds(500)); | 535 QuicTime::Delta::FromMicroseconds(500)); |
527 // Note: we do NOT ASSERT_TRUE: we may time out during initial handshake: | 536 // Note: we do NOT ASSERT_TRUE: we may time out during initial handshake: |
528 // that's enough to validate timeout in this case. | 537 // that's enough to validate timeout in this case. |
529 Initialize(); | 538 Initialize(); |
530 while (client_->client()->connected()) { | 539 while (client_->client()->connected()) { |
531 client_->client()->WaitForEvents(); | 540 client_->client()->WaitForEvents(); |
532 } | 541 } |
533 } | 542 } |
534 | 543 |
535 TEST_F(EndToEndTest, LimitMaxOpenStreams) { | 544 TEST_P(EndToEndTest, LimitMaxOpenStreams) { |
536 // Server limits the number of max streams to 2. | 545 // Server limits the number of max streams to 2. |
537 server_config_.set_max_streams_per_connection(2, 2); | 546 server_config_.set_max_streams_per_connection(2, 2); |
538 // Client tries to negotiate for 10. | 547 // Client tries to negotiate for 10. |
539 client_config_.set_max_streams_per_connection(10, 5); | 548 client_config_.set_max_streams_per_connection(10, 5); |
540 | 549 |
541 ASSERT_TRUE(Initialize()); | 550 ASSERT_TRUE(Initialize()); |
542 client_->client()->WaitForCryptoHandshakeConfirmed(); | 551 client_->client()->WaitForCryptoHandshakeConfirmed(); |
543 QuicConfig* client_negotiated_config = client_->client()->session()->config(); | 552 QuicConfig* client_negotiated_config = client_->client()->session()->config(); |
544 EXPECT_EQ(2u, client_negotiated_config->max_streams_per_connection()); | 553 EXPECT_EQ(2u, client_negotiated_config->max_streams_per_connection()); |
545 } | 554 } |
546 | 555 |
547 TEST_F(EndToEndTest, ResetConnection) { | 556 TEST_P(EndToEndTest, ResetConnection) { |
548 // TODO(rtenneti): Delete this when NSS is supported. | 557 // TODO(rtenneti): Delete this when NSS is supported. |
549 if (!Aes128Gcm12Encrypter::IsSupported()) { | 558 if (!Aes128Gcm12Encrypter::IsSupported()) { |
550 LOG(INFO) << "AES GCM not supported. Test skipped."; | 559 LOG(INFO) << "AES GCM not supported. Test skipped."; |
551 return; | 560 return; |
552 } | 561 } |
553 | 562 |
554 ASSERT_TRUE(Initialize()); | 563 ASSERT_TRUE(Initialize()); |
555 | 564 |
556 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 565 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
557 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 566 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
(...skipping 17 matching lines...) Expand all Loading... |
575 int* error) OVERRIDE { | 584 int* error) OVERRIDE { |
576 return QuicSocketUtils::WritePacket(fd_, buffer, buf_len, | 585 return QuicSocketUtils::WritePacket(fd_, buffer, buf_len, |
577 self_address_.address(), peer_address, | 586 self_address_.address(), peer_address, |
578 error); | 587 error); |
579 } | 588 } |
580 | 589 |
581 IPEndPoint self_address_; | 590 IPEndPoint self_address_; |
582 int fd_; | 591 int fd_; |
583 }; | 592 }; |
584 | 593 |
585 TEST_F(EndToEndTest, ConnectionMigration) { | 594 TEST_P(EndToEndTest, ConnectionMigration) { |
586 // TODO(rtenneti): Delete this when NSS is supported. | 595 // TODO(rtenneti): Delete this when NSS is supported. |
587 if (!Aes128Gcm12Encrypter::IsSupported()) { | 596 if (!Aes128Gcm12Encrypter::IsSupported()) { |
588 LOG(INFO) << "AES GCM not supported. Test skipped."; | 597 LOG(INFO) << "AES GCM not supported. Test skipped."; |
589 return; | 598 return; |
590 } | 599 } |
591 | 600 |
592 ASSERT_TRUE(Initialize()); | 601 ASSERT_TRUE(Initialize()); |
593 | 602 |
594 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 603 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
595 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 604 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
596 | 605 |
597 WrongAddressWriter writer(QuicClientPeer::GetFd(client_->client())); | 606 WrongAddressWriter writer(QuicClientPeer::GetFd(client_->client())); |
598 QuicEpollConnectionHelper* helper = | 607 QuicEpollConnectionHelper* helper = |
599 reinterpret_cast<QuicEpollConnectionHelper*>( | 608 reinterpret_cast<QuicEpollConnectionHelper*>( |
600 QuicConnectionPeer::GetHelper( | 609 QuicConnectionPeer::GetHelper( |
601 client_->client()->session()->connection())); | 610 client_->client()->session()->connection())); |
602 QuicEpollConnectionHelperPeer::SetWriter(helper, &writer); | 611 QuicEpollConnectionHelperPeer::SetWriter(helper, &writer); |
603 | 612 |
604 client_->SendSynchronousRequest("/bar"); | 613 client_->SendSynchronousRequest("/bar"); |
605 QuicEpollConnectionHelperPeer::SetWriter(helper, NULL); | 614 QuicEpollConnectionHelperPeer::SetWriter(helper, NULL); |
606 | 615 |
607 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); | 616 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); |
608 EXPECT_EQ(QUIC_ERROR_MIGRATING_ADDRESS, client_->connection_error()); | 617 EXPECT_EQ(QUIC_ERROR_MIGRATING_ADDRESS, client_->connection_error()); |
609 } | 618 } |
610 | 619 |
611 } // namespace | 620 } // namespace |
612 } // namespace test | 621 } // namespace test |
613 } // namespace tools | 622 } // namespace tools |
614 } // namespace net | 623 } // namespace net |
OLD | NEW |