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/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
6 | 6 |
7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
8 #include <stdarg.h> | 8 #include <stdarg.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 10313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10324 const char* const proxy_url; | 10324 const char* const proxy_url; |
10325 AuthTiming proxy_auth_timing; | 10325 AuthTiming proxy_auth_timing; |
10326 int proxy_auth_rv; | 10326 int proxy_auth_rv; |
10327 const char* const server_url; | 10327 const char* const server_url; |
10328 AuthTiming server_auth_timing; | 10328 AuthTiming server_auth_timing; |
10329 int server_auth_rv; | 10329 int server_auth_rv; |
10330 int num_auth_rounds; | 10330 int num_auth_rounds; |
10331 int first_ssl_round; | 10331 int first_ssl_round; |
10332 TestRound rounds[3]; | 10332 TestRound rounds[3]; |
10333 } test_configs[] = { | 10333 } test_configs[] = { |
10334 // Non-authenticating HTTP server with a direct connection. | 10334 // Non-authenticating HTTP server with a direct connection. |
10335 { NULL, AUTH_NONE, OK, kServer, AUTH_NONE, OK, 1, kNoSSL, | 10335 {NULL, |
10336 { TestRound(kGet, kSuccess, OK)}}, | 10336 AUTH_NONE, |
10337 // Authenticating HTTP server with a direct connection. | 10337 OK, |
10338 { NULL, AUTH_NONE, OK, kServer, AUTH_SYNC, OK, 2, kNoSSL, | 10338 kServer, |
10339 { TestRound(kGet, kServerChallenge, OK), | 10339 AUTH_NONE, |
10340 TestRound(kGetAuth, kSuccess, OK)}}, | 10340 OK, |
10341 { NULL, AUTH_NONE, OK, kServer, AUTH_SYNC, kAuthErr, 2, kNoSSL, | 10341 1, |
10342 { TestRound(kGet, kServerChallenge, OK), | 10342 kNoSSL, |
10343 TestRound(kGetAuth, kFailure, kAuthErr)}}, | 10343 {TestRound(kGet, kSuccess, OK)}}, |
10344 { NULL, AUTH_NONE, OK, kServer, AUTH_ASYNC, OK, 2, kNoSSL, | 10344 // Authenticating HTTP server with a direct connection. |
10345 { TestRound(kGet, kServerChallenge, OK), | 10345 {NULL, |
10346 TestRound(kGetAuth, kSuccess, OK)}}, | 10346 AUTH_NONE, |
10347 { NULL, AUTH_NONE, OK, kServer, AUTH_ASYNC, kAuthErr, 2, kNoSSL, | 10347 OK, |
10348 { TestRound(kGet, kServerChallenge, OK), | 10348 kServer, |
10349 TestRound(kGetAuth, kFailure, kAuthErr)}}, | 10349 AUTH_SYNC, |
10350 // Non-authenticating HTTP server through a non-authenticating proxy. | 10350 OK, |
10351 { kProxy, AUTH_NONE, OK, kServer, AUTH_NONE, OK, 1, kNoSSL, | 10351 2, |
10352 { TestRound(kGetProxy, kSuccess, OK)}}, | 10352 kNoSSL, |
10353 // Authenticating HTTP server through a non-authenticating proxy. | 10353 {TestRound(kGet, kServerChallenge, OK), |
10354 { kProxy, AUTH_NONE, OK, kServer, AUTH_SYNC, OK, 2, kNoSSL, | 10354 TestRound(kGetAuth, kSuccess, OK)}}, |
10355 { TestRound(kGetProxy, kServerChallenge, OK), | 10355 {NULL, |
| 10356 AUTH_NONE, |
| 10357 OK, |
| 10358 kServer, |
| 10359 AUTH_SYNC, |
| 10360 kAuthErr, |
| 10361 2, |
| 10362 kNoSSL, |
| 10363 {TestRound(kGet, kServerChallenge, OK), |
| 10364 TestRound(kGetAuth, kFailure, kAuthErr)}}, |
| 10365 {NULL, |
| 10366 AUTH_NONE, |
| 10367 OK, |
| 10368 kServer, |
| 10369 AUTH_ASYNC, |
| 10370 OK, |
| 10371 2, |
| 10372 kNoSSL, |
| 10373 {TestRound(kGet, kServerChallenge, OK), |
| 10374 TestRound(kGetAuth, kSuccess, OK)}}, |
| 10375 {NULL, |
| 10376 AUTH_NONE, |
| 10377 OK, |
| 10378 kServer, |
| 10379 AUTH_ASYNC, |
| 10380 kAuthErr, |
| 10381 2, |
| 10382 kNoSSL, |
| 10383 {TestRound(kGet, kServerChallenge, OK), |
| 10384 TestRound(kGetAuth, kFailure, kAuthErr)}}, |
| 10385 // Non-authenticating HTTP server through a non-authenticating proxy. |
| 10386 {kProxy, |
| 10387 AUTH_NONE, |
| 10388 OK, |
| 10389 kServer, |
| 10390 AUTH_NONE, |
| 10391 OK, |
| 10392 1, |
| 10393 kNoSSL, |
| 10394 {TestRound(kGetProxy, kSuccess, OK)}}, |
| 10395 // Authenticating HTTP server through a non-authenticating proxy. |
| 10396 {kProxy, |
| 10397 AUTH_NONE, |
| 10398 OK, |
| 10399 kServer, |
| 10400 AUTH_SYNC, |
| 10401 OK, |
| 10402 2, |
| 10403 kNoSSL, |
| 10404 {TestRound(kGetProxy, kServerChallenge, OK), |
10356 TestRound(kGetAuthThroughProxy, kSuccess, OK)}}, | 10405 TestRound(kGetAuthThroughProxy, kSuccess, OK)}}, |
10357 { kProxy, AUTH_NONE, OK, kServer, AUTH_SYNC, kAuthErr, 2, kNoSSL, | 10406 {kProxy, |
10358 { TestRound(kGetProxy, kServerChallenge, OK), | 10407 AUTH_NONE, |
| 10408 OK, |
| 10409 kServer, |
| 10410 AUTH_SYNC, |
| 10411 kAuthErr, |
| 10412 2, |
| 10413 kNoSSL, |
| 10414 {TestRound(kGetProxy, kServerChallenge, OK), |
10359 TestRound(kGetAuthThroughProxy, kFailure, kAuthErr)}}, | 10415 TestRound(kGetAuthThroughProxy, kFailure, kAuthErr)}}, |
10360 { kProxy, AUTH_NONE, OK, kServer, AUTH_ASYNC, OK, 2, kNoSSL, | 10416 {kProxy, |
10361 { TestRound(kGetProxy, kServerChallenge, OK), | 10417 AUTH_NONE, |
| 10418 OK, |
| 10419 kServer, |
| 10420 AUTH_ASYNC, |
| 10421 OK, |
| 10422 2, |
| 10423 kNoSSL, |
| 10424 {TestRound(kGetProxy, kServerChallenge, OK), |
10362 TestRound(kGetAuthThroughProxy, kSuccess, OK)}}, | 10425 TestRound(kGetAuthThroughProxy, kSuccess, OK)}}, |
10363 { kProxy, AUTH_NONE, OK, kServer, AUTH_ASYNC, kAuthErr, 2, kNoSSL, | 10426 {kProxy, |
10364 { TestRound(kGetProxy, kServerChallenge, OK), | 10427 AUTH_NONE, |
| 10428 OK, |
| 10429 kServer, |
| 10430 AUTH_ASYNC, |
| 10431 kAuthErr, |
| 10432 2, |
| 10433 kNoSSL, |
| 10434 {TestRound(kGetProxy, kServerChallenge, OK), |
10365 TestRound(kGetAuthThroughProxy, kFailure, kAuthErr)}}, | 10435 TestRound(kGetAuthThroughProxy, kFailure, kAuthErr)}}, |
10366 // Non-authenticating HTTP server through an authenticating proxy. | 10436 // Non-authenticating HTTP server through an authenticating proxy. |
10367 { kProxy, AUTH_SYNC, OK, kServer, AUTH_NONE, OK, 2, kNoSSL, | 10437 {kProxy, |
10368 { TestRound(kGetProxy, kProxyChallenge, OK), | 10438 AUTH_SYNC, |
| 10439 OK, |
| 10440 kServer, |
| 10441 AUTH_NONE, |
| 10442 OK, |
| 10443 2, |
| 10444 kNoSSL, |
| 10445 {TestRound(kGetProxy, kProxyChallenge, OK), |
10369 TestRound(kGetProxyAuth, kSuccess, OK)}}, | 10446 TestRound(kGetProxyAuth, kSuccess, OK)}}, |
10370 { kProxy, AUTH_SYNC, kAuthErr, kServer, AUTH_NONE, OK, 2, kNoSSL, | 10447 {kProxy, |
10371 { TestRound(kGetProxy, kProxyChallenge, OK), | 10448 AUTH_SYNC, |
| 10449 kAuthErr, |
| 10450 kServer, |
| 10451 AUTH_NONE, |
| 10452 OK, |
| 10453 2, |
| 10454 kNoSSL, |
| 10455 {TestRound(kGetProxy, kProxyChallenge, OK), |
10372 TestRound(kGetProxyAuth, kFailure, kAuthErr)}}, | 10456 TestRound(kGetProxyAuth, kFailure, kAuthErr)}}, |
10373 { kProxy, AUTH_ASYNC, OK, kServer, AUTH_NONE, OK, 2, kNoSSL, | 10457 {kProxy, |
10374 { TestRound(kGetProxy, kProxyChallenge, OK), | 10458 AUTH_ASYNC, |
| 10459 OK, |
| 10460 kServer, |
| 10461 AUTH_NONE, |
| 10462 OK, |
| 10463 2, |
| 10464 kNoSSL, |
| 10465 {TestRound(kGetProxy, kProxyChallenge, OK), |
10375 TestRound(kGetProxyAuth, kSuccess, OK)}}, | 10466 TestRound(kGetProxyAuth, kSuccess, OK)}}, |
10376 { kProxy, AUTH_ASYNC, kAuthErr, kServer, AUTH_NONE, OK, 2, kNoSSL, | 10467 {kProxy, |
10377 { TestRound(kGetProxy, kProxyChallenge, OK), | 10468 AUTH_ASYNC, |
| 10469 kAuthErr, |
| 10470 kServer, |
| 10471 AUTH_NONE, |
| 10472 OK, |
| 10473 2, |
| 10474 kNoSSL, |
| 10475 {TestRound(kGetProxy, kProxyChallenge, OK), |
10378 TestRound(kGetProxyAuth, kFailure, kAuthErr)}}, | 10476 TestRound(kGetProxyAuth, kFailure, kAuthErr)}}, |
10379 // Authenticating HTTP server through an authenticating proxy. | 10477 // Authenticating HTTP server through an authenticating proxy. |
10380 { kProxy, AUTH_SYNC, OK, kServer, AUTH_SYNC, OK, 3, kNoSSL, | 10478 {kProxy, |
10381 { TestRound(kGetProxy, kProxyChallenge, OK), | 10479 AUTH_SYNC, |
| 10480 OK, |
| 10481 kServer, |
| 10482 AUTH_SYNC, |
| 10483 OK, |
| 10484 3, |
| 10485 kNoSSL, |
| 10486 {TestRound(kGetProxy, kProxyChallenge, OK), |
10382 TestRound(kGetProxyAuth, kServerChallenge, OK), | 10487 TestRound(kGetProxyAuth, kServerChallenge, OK), |
10383 TestRound(kGetAuthWithProxyAuth, kSuccess, OK)}}, | 10488 TestRound(kGetAuthWithProxyAuth, kSuccess, OK)}}, |
10384 { kProxy, AUTH_SYNC, OK, kServer, AUTH_SYNC, kAuthErr, 3, kNoSSL, | 10489 {kProxy, |
10385 { TestRound(kGetProxy, kProxyChallenge, OK), | 10490 AUTH_SYNC, |
| 10491 OK, |
| 10492 kServer, |
| 10493 AUTH_SYNC, |
| 10494 kAuthErr, |
| 10495 3, |
| 10496 kNoSSL, |
| 10497 {TestRound(kGetProxy, kProxyChallenge, OK), |
10386 TestRound(kGetProxyAuth, kServerChallenge, OK), | 10498 TestRound(kGetProxyAuth, kServerChallenge, OK), |
10387 TestRound(kGetAuthWithProxyAuth, kFailure, kAuthErr)}}, | 10499 TestRound(kGetAuthWithProxyAuth, kFailure, kAuthErr)}}, |
10388 { kProxy, AUTH_ASYNC, OK, kServer, AUTH_SYNC, OK, 3, kNoSSL, | 10500 {kProxy, |
10389 { TestRound(kGetProxy, kProxyChallenge, OK), | 10501 AUTH_ASYNC, |
| 10502 OK, |
| 10503 kServer, |
| 10504 AUTH_SYNC, |
| 10505 OK, |
| 10506 3, |
| 10507 kNoSSL, |
| 10508 {TestRound(kGetProxy, kProxyChallenge, OK), |
10390 TestRound(kGetProxyAuth, kServerChallenge, OK), | 10509 TestRound(kGetProxyAuth, kServerChallenge, OK), |
10391 TestRound(kGetAuthWithProxyAuth, kSuccess, OK)}}, | 10510 TestRound(kGetAuthWithProxyAuth, kSuccess, OK)}}, |
10392 { kProxy, AUTH_ASYNC, OK, kServer, AUTH_SYNC, kAuthErr, 3, kNoSSL, | 10511 {kProxy, |
10393 { TestRound(kGetProxy, kProxyChallenge, OK), | 10512 AUTH_ASYNC, |
| 10513 OK, |
| 10514 kServer, |
| 10515 AUTH_SYNC, |
| 10516 kAuthErr, |
| 10517 3, |
| 10518 kNoSSL, |
| 10519 {TestRound(kGetProxy, kProxyChallenge, OK), |
10394 TestRound(kGetProxyAuth, kServerChallenge, OK), | 10520 TestRound(kGetProxyAuth, kServerChallenge, OK), |
10395 TestRound(kGetAuthWithProxyAuth, kFailure, kAuthErr)}}, | 10521 TestRound(kGetAuthWithProxyAuth, kFailure, kAuthErr)}}, |
10396 { kProxy, AUTH_SYNC, OK, kServer, AUTH_ASYNC, OK, 3, kNoSSL, | 10522 {kProxy, |
10397 { TestRound(kGetProxy, kProxyChallenge, OK), | 10523 AUTH_SYNC, |
| 10524 OK, |
| 10525 kServer, |
| 10526 AUTH_ASYNC, |
| 10527 OK, |
| 10528 3, |
| 10529 kNoSSL, |
| 10530 {TestRound(kGetProxy, kProxyChallenge, OK), |
10398 TestRound(kGetProxyAuth, kServerChallenge, OK), | 10531 TestRound(kGetProxyAuth, kServerChallenge, OK), |
10399 TestRound(kGetAuthWithProxyAuth, kSuccess, OK)}}, | 10532 TestRound(kGetAuthWithProxyAuth, kSuccess, OK)}}, |
10400 { kProxy, AUTH_SYNC, OK, kServer, AUTH_ASYNC, kAuthErr, 3, kNoSSL, | 10533 {kProxy, |
10401 { TestRound(kGetProxy, kProxyChallenge, OK), | 10534 AUTH_SYNC, |
| 10535 OK, |
| 10536 kServer, |
| 10537 AUTH_ASYNC, |
| 10538 kAuthErr, |
| 10539 3, |
| 10540 kNoSSL, |
| 10541 {TestRound(kGetProxy, kProxyChallenge, OK), |
10402 TestRound(kGetProxyAuth, kServerChallenge, OK), | 10542 TestRound(kGetProxyAuth, kServerChallenge, OK), |
10403 TestRound(kGetAuthWithProxyAuth, kFailure, kAuthErr)}}, | 10543 TestRound(kGetAuthWithProxyAuth, kFailure, kAuthErr)}}, |
10404 { kProxy, AUTH_ASYNC, OK, kServer, AUTH_ASYNC, OK, 3, kNoSSL, | 10544 {kProxy, |
10405 { TestRound(kGetProxy, kProxyChallenge, OK), | 10545 AUTH_ASYNC, |
| 10546 OK, |
| 10547 kServer, |
| 10548 AUTH_ASYNC, |
| 10549 OK, |
| 10550 3, |
| 10551 kNoSSL, |
| 10552 {TestRound(kGetProxy, kProxyChallenge, OK), |
10406 TestRound(kGetProxyAuth, kServerChallenge, OK), | 10553 TestRound(kGetProxyAuth, kServerChallenge, OK), |
10407 TestRound(kGetAuthWithProxyAuth, kSuccess, OK)}}, | 10554 TestRound(kGetAuthWithProxyAuth, kSuccess, OK)}}, |
10408 { kProxy, AUTH_ASYNC, OK, kServer, AUTH_ASYNC, kAuthErr, 3, kNoSSL, | 10555 {kProxy, |
10409 { TestRound(kGetProxy, kProxyChallenge, OK), | 10556 AUTH_ASYNC, |
| 10557 OK, |
| 10558 kServer, |
| 10559 AUTH_ASYNC, |
| 10560 kAuthErr, |
| 10561 3, |
| 10562 kNoSSL, |
| 10563 {TestRound(kGetProxy, kProxyChallenge, OK), |
10410 TestRound(kGetProxyAuth, kServerChallenge, OK), | 10564 TestRound(kGetProxyAuth, kServerChallenge, OK), |
10411 TestRound(kGetAuthWithProxyAuth, kFailure, kAuthErr)}}, | 10565 TestRound(kGetAuthWithProxyAuth, kFailure, kAuthErr)}}, |
10412 // Non-authenticating HTTPS server with a direct connection. | 10566 // Non-authenticating HTTPS server with a direct connection. |
10413 { NULL, AUTH_NONE, OK, kSecureServer, AUTH_NONE, OK, 1, 0, | 10567 {NULL, |
10414 { TestRound(kGet, kSuccess, OK)}}, | 10568 AUTH_NONE, |
10415 // Authenticating HTTPS server with a direct connection. | 10569 OK, |
10416 { NULL, AUTH_NONE, OK, kSecureServer, AUTH_SYNC, OK, 2, 0, | 10570 kSecureServer, |
10417 { TestRound(kGet, kServerChallenge, OK), | 10571 AUTH_NONE, |
10418 TestRound(kGetAuth, kSuccess, OK)}}, | 10572 OK, |
10419 { NULL, AUTH_NONE, OK, kSecureServer, AUTH_SYNC, kAuthErr, 2, 0, | 10573 1, |
10420 { TestRound(kGet, kServerChallenge, OK), | 10574 0, |
10421 TestRound(kGetAuth, kFailure, kAuthErr)}}, | 10575 {TestRound(kGet, kSuccess, OK)}}, |
10422 { NULL, AUTH_NONE, OK, kSecureServer, AUTH_ASYNC, OK, 2, 0, | 10576 // Authenticating HTTPS server with a direct connection. |
10423 { TestRound(kGet, kServerChallenge, OK), | 10577 {NULL, |
10424 TestRound(kGetAuth, kSuccess, OK)}}, | 10578 AUTH_NONE, |
10425 { NULL, AUTH_NONE, OK, kSecureServer, AUTH_ASYNC, kAuthErr, 2, 0, | 10579 OK, |
10426 { TestRound(kGet, kServerChallenge, OK), | 10580 kSecureServer, |
10427 TestRound(kGetAuth, kFailure, kAuthErr)}}, | 10581 AUTH_SYNC, |
10428 // Non-authenticating HTTPS server with a non-authenticating proxy. | 10582 OK, |
10429 { kProxy, AUTH_NONE, OK, kSecureServer, AUTH_NONE, OK, 1, 0, | 10583 2, |
10430 { TestRound(kConnect, kProxyConnected, OK, &kGet, &kSuccess)}}, | 10584 0, |
10431 // Authenticating HTTPS server through a non-authenticating proxy. | 10585 {TestRound(kGet, kServerChallenge, OK), |
10432 { kProxy, AUTH_NONE, OK, kSecureServer, AUTH_SYNC, OK, 2, 0, | 10586 TestRound(kGetAuth, kSuccess, OK)}}, |
10433 { TestRound(kConnect, kProxyConnected, OK, &kGet, &kServerChallenge), | 10587 {NULL, |
10434 TestRound(kGetAuth, kSuccess, OK)}}, | 10588 AUTH_NONE, |
10435 { kProxy, AUTH_NONE, OK, kSecureServer, AUTH_SYNC, kAuthErr, 2, 0, | 10589 OK, |
10436 { TestRound(kConnect, kProxyConnected, OK, &kGet, &kServerChallenge), | 10590 kSecureServer, |
10437 TestRound(kGetAuth, kFailure, kAuthErr)}}, | 10591 AUTH_SYNC, |
10438 { kProxy, AUTH_NONE, OK, kSecureServer, AUTH_ASYNC, OK, 2, 0, | 10592 kAuthErr, |
10439 { TestRound(kConnect, kProxyConnected, OK, &kGet, &kServerChallenge), | 10593 2, |
10440 TestRound(kGetAuth, kSuccess, OK)}}, | 10594 0, |
10441 { kProxy, AUTH_NONE, OK, kSecureServer, AUTH_ASYNC, kAuthErr, 2, 0, | 10595 {TestRound(kGet, kServerChallenge, OK), |
10442 { TestRound(kConnect, kProxyConnected, OK, &kGet, &kServerChallenge), | 10596 TestRound(kGetAuth, kFailure, kAuthErr)}}, |
10443 TestRound(kGetAuth, kFailure, kAuthErr)}}, | 10597 {NULL, |
10444 // Non-Authenticating HTTPS server through an authenticating proxy. | 10598 AUTH_NONE, |
10445 { kProxy, AUTH_SYNC, OK, kSecureServer, AUTH_NONE, OK, 2, 1, | 10599 OK, |
10446 { TestRound(kConnect, kProxyChallenge, OK), | 10600 kSecureServer, |
| 10601 AUTH_ASYNC, |
| 10602 OK, |
| 10603 2, |
| 10604 0, |
| 10605 {TestRound(kGet, kServerChallenge, OK), |
| 10606 TestRound(kGetAuth, kSuccess, OK)}}, |
| 10607 {NULL, |
| 10608 AUTH_NONE, |
| 10609 OK, |
| 10610 kSecureServer, |
| 10611 AUTH_ASYNC, |
| 10612 kAuthErr, |
| 10613 2, |
| 10614 0, |
| 10615 {TestRound(kGet, kServerChallenge, OK), |
| 10616 TestRound(kGetAuth, kFailure, kAuthErr)}}, |
| 10617 // Non-authenticating HTTPS server with a non-authenticating proxy. |
| 10618 {kProxy, |
| 10619 AUTH_NONE, |
| 10620 OK, |
| 10621 kSecureServer, |
| 10622 AUTH_NONE, |
| 10623 OK, |
| 10624 1, |
| 10625 0, |
| 10626 {TestRound(kConnect, kProxyConnected, OK, &kGet, &kSuccess)}}, |
| 10627 // Authenticating HTTPS server through a non-authenticating proxy. |
| 10628 {kProxy, |
| 10629 AUTH_NONE, |
| 10630 OK, |
| 10631 kSecureServer, |
| 10632 AUTH_SYNC, |
| 10633 OK, |
| 10634 2, |
| 10635 0, |
| 10636 {TestRound(kConnect, kProxyConnected, OK, &kGet, &kServerChallenge), |
| 10637 TestRound(kGetAuth, kSuccess, OK)}}, |
| 10638 {kProxy, |
| 10639 AUTH_NONE, |
| 10640 OK, |
| 10641 kSecureServer, |
| 10642 AUTH_SYNC, |
| 10643 kAuthErr, |
| 10644 2, |
| 10645 0, |
| 10646 {TestRound(kConnect, kProxyConnected, OK, &kGet, &kServerChallenge), |
| 10647 TestRound(kGetAuth, kFailure, kAuthErr)}}, |
| 10648 {kProxy, |
| 10649 AUTH_NONE, |
| 10650 OK, |
| 10651 kSecureServer, |
| 10652 AUTH_ASYNC, |
| 10653 OK, |
| 10654 2, |
| 10655 0, |
| 10656 {TestRound(kConnect, kProxyConnected, OK, &kGet, &kServerChallenge), |
| 10657 TestRound(kGetAuth, kSuccess, OK)}}, |
| 10658 {kProxy, |
| 10659 AUTH_NONE, |
| 10660 OK, |
| 10661 kSecureServer, |
| 10662 AUTH_ASYNC, |
| 10663 kAuthErr, |
| 10664 2, |
| 10665 0, |
| 10666 {TestRound(kConnect, kProxyConnected, OK, &kGet, &kServerChallenge), |
| 10667 TestRound(kGetAuth, kFailure, kAuthErr)}}, |
| 10668 // Non-Authenticating HTTPS server through an authenticating proxy. |
| 10669 {kProxy, |
| 10670 AUTH_SYNC, |
| 10671 OK, |
| 10672 kSecureServer, |
| 10673 AUTH_NONE, |
| 10674 OK, |
| 10675 2, |
| 10676 1, |
| 10677 {TestRound(kConnect, kProxyChallenge, OK), |
10447 TestRound(kConnectProxyAuth, kProxyConnected, OK, &kGet, &kSuccess)}}, | 10678 TestRound(kConnectProxyAuth, kProxyConnected, OK, &kGet, &kSuccess)}}, |
10448 { kProxy, AUTH_SYNC, kAuthErr, kSecureServer, AUTH_NONE, OK, 2, kNoSSL, | 10679 {kProxy, |
10449 { TestRound(kConnect, kProxyChallenge, OK), | 10680 AUTH_SYNC, |
| 10681 kAuthErr, |
| 10682 kSecureServer, |
| 10683 AUTH_NONE, |
| 10684 OK, |
| 10685 2, |
| 10686 kNoSSL, |
| 10687 {TestRound(kConnect, kProxyChallenge, OK), |
10450 TestRound(kConnectProxyAuth, kFailure, kAuthErr)}}, | 10688 TestRound(kConnectProxyAuth, kFailure, kAuthErr)}}, |
10451 { kProxy, AUTH_ASYNC, OK, kSecureServer, AUTH_NONE, OK, 2, 1, | 10689 {kProxy, |
10452 { TestRound(kConnect, kProxyChallenge, OK), | 10690 AUTH_ASYNC, |
| 10691 OK, |
| 10692 kSecureServer, |
| 10693 AUTH_NONE, |
| 10694 OK, |
| 10695 2, |
| 10696 1, |
| 10697 {TestRound(kConnect, kProxyChallenge, OK), |
10453 TestRound(kConnectProxyAuth, kProxyConnected, OK, &kGet, &kSuccess)}}, | 10698 TestRound(kConnectProxyAuth, kProxyConnected, OK, &kGet, &kSuccess)}}, |
10454 { kProxy, AUTH_ASYNC, kAuthErr, kSecureServer, AUTH_NONE, OK, 2, kNoSSL, | 10699 {kProxy, |
10455 { TestRound(kConnect, kProxyChallenge, OK), | 10700 AUTH_ASYNC, |
| 10701 kAuthErr, |
| 10702 kSecureServer, |
| 10703 AUTH_NONE, |
| 10704 OK, |
| 10705 2, |
| 10706 kNoSSL, |
| 10707 {TestRound(kConnect, kProxyChallenge, OK), |
10456 TestRound(kConnectProxyAuth, kFailure, kAuthErr)}}, | 10708 TestRound(kConnectProxyAuth, kFailure, kAuthErr)}}, |
10457 // Authenticating HTTPS server through an authenticating proxy. | 10709 // Authenticating HTTPS server through an authenticating proxy. |
10458 { kProxy, AUTH_SYNC, OK, kSecureServer, AUTH_SYNC, OK, 3, 1, | 10710 {kProxy, |
10459 { TestRound(kConnect, kProxyChallenge, OK), | 10711 AUTH_SYNC, |
10460 TestRound(kConnectProxyAuth, kProxyConnected, OK, | 10712 OK, |
10461 &kGet, &kServerChallenge), | 10713 kSecureServer, |
10462 TestRound(kGetAuth, kSuccess, OK)}}, | 10714 AUTH_SYNC, |
10463 { kProxy, AUTH_SYNC, OK, kSecureServer, AUTH_SYNC, kAuthErr, 3, 1, | 10715 OK, |
10464 { TestRound(kConnect, kProxyChallenge, OK), | 10716 3, |
10465 TestRound(kConnectProxyAuth, kProxyConnected, OK, | 10717 1, |
10466 &kGet, &kServerChallenge), | 10718 {TestRound(kConnect, kProxyChallenge, OK), |
10467 TestRound(kGetAuth, kFailure, kAuthErr)}}, | 10719 TestRound(kConnectProxyAuth, kProxyConnected, OK, &kGet, |
10468 { kProxy, AUTH_ASYNC, OK, kSecureServer, AUTH_SYNC, OK, 3, 1, | 10720 &kServerChallenge), |
10469 { TestRound(kConnect, kProxyChallenge, OK), | 10721 TestRound(kGetAuth, kSuccess, OK)}}, |
10470 TestRound(kConnectProxyAuth, kProxyConnected, OK, | 10722 {kProxy, |
10471 &kGet, &kServerChallenge), | 10723 AUTH_SYNC, |
10472 TestRound(kGetAuth, kSuccess, OK)}}, | 10724 OK, |
10473 { kProxy, AUTH_ASYNC, OK, kSecureServer, AUTH_SYNC, kAuthErr, 3, 1, | 10725 kSecureServer, |
10474 { TestRound(kConnect, kProxyChallenge, OK), | 10726 AUTH_SYNC, |
10475 TestRound(kConnectProxyAuth, kProxyConnected, OK, | 10727 kAuthErr, |
10476 &kGet, &kServerChallenge), | 10728 3, |
10477 TestRound(kGetAuth, kFailure, kAuthErr)}}, | 10729 1, |
10478 { kProxy, AUTH_SYNC, OK, kSecureServer, AUTH_ASYNC, OK, 3, 1, | 10730 {TestRound(kConnect, kProxyChallenge, OK), |
10479 { TestRound(kConnect, kProxyChallenge, OK), | 10731 TestRound(kConnectProxyAuth, kProxyConnected, OK, &kGet, |
10480 TestRound(kConnectProxyAuth, kProxyConnected, OK, | 10732 &kServerChallenge), |
10481 &kGet, &kServerChallenge), | 10733 TestRound(kGetAuth, kFailure, kAuthErr)}}, |
10482 TestRound(kGetAuth, kSuccess, OK)}}, | 10734 {kProxy, |
10483 { kProxy, AUTH_SYNC, OK, kSecureServer, AUTH_ASYNC, kAuthErr, 3, 1, | 10735 AUTH_ASYNC, |
10484 { TestRound(kConnect, kProxyChallenge, OK), | 10736 OK, |
10485 TestRound(kConnectProxyAuth, kProxyConnected, OK, | 10737 kSecureServer, |
10486 &kGet, &kServerChallenge), | 10738 AUTH_SYNC, |
10487 TestRound(kGetAuth, kFailure, kAuthErr)}}, | 10739 OK, |
10488 { kProxy, AUTH_ASYNC, OK, kSecureServer, AUTH_ASYNC, OK, 3, 1, | 10740 3, |
10489 { TestRound(kConnect, kProxyChallenge, OK), | 10741 1, |
10490 TestRound(kConnectProxyAuth, kProxyConnected, OK, | 10742 {TestRound(kConnect, kProxyChallenge, OK), |
10491 &kGet, &kServerChallenge), | 10743 TestRound(kConnectProxyAuth, kProxyConnected, OK, &kGet, |
10492 TestRound(kGetAuth, kSuccess, OK)}}, | 10744 &kServerChallenge), |
10493 { kProxy, AUTH_ASYNC, OK, kSecureServer, AUTH_ASYNC, kAuthErr, 3, 1, | 10745 TestRound(kGetAuth, kSuccess, OK)}}, |
10494 { TestRound(kConnect, kProxyChallenge, OK), | 10746 {kProxy, |
10495 TestRound(kConnectProxyAuth, kProxyConnected, OK, | 10747 AUTH_ASYNC, |
10496 &kGet, &kServerChallenge), | 10748 OK, |
| 10749 kSecureServer, |
| 10750 AUTH_SYNC, |
| 10751 kAuthErr, |
| 10752 3, |
| 10753 1, |
| 10754 {TestRound(kConnect, kProxyChallenge, OK), |
| 10755 TestRound(kConnectProxyAuth, kProxyConnected, OK, &kGet, |
| 10756 &kServerChallenge), |
| 10757 TestRound(kGetAuth, kFailure, kAuthErr)}}, |
| 10758 {kProxy, |
| 10759 AUTH_SYNC, |
| 10760 OK, |
| 10761 kSecureServer, |
| 10762 AUTH_ASYNC, |
| 10763 OK, |
| 10764 3, |
| 10765 1, |
| 10766 {TestRound(kConnect, kProxyChallenge, OK), |
| 10767 TestRound(kConnectProxyAuth, kProxyConnected, OK, &kGet, |
| 10768 &kServerChallenge), |
| 10769 TestRound(kGetAuth, kSuccess, OK)}}, |
| 10770 {kProxy, |
| 10771 AUTH_SYNC, |
| 10772 OK, |
| 10773 kSecureServer, |
| 10774 AUTH_ASYNC, |
| 10775 kAuthErr, |
| 10776 3, |
| 10777 1, |
| 10778 {TestRound(kConnect, kProxyChallenge, OK), |
| 10779 TestRound(kConnectProxyAuth, kProxyConnected, OK, &kGet, |
| 10780 &kServerChallenge), |
| 10781 TestRound(kGetAuth, kFailure, kAuthErr)}}, |
| 10782 {kProxy, |
| 10783 AUTH_ASYNC, |
| 10784 OK, |
| 10785 kSecureServer, |
| 10786 AUTH_ASYNC, |
| 10787 OK, |
| 10788 3, |
| 10789 1, |
| 10790 {TestRound(kConnect, kProxyChallenge, OK), |
| 10791 TestRound(kConnectProxyAuth, kProxyConnected, OK, &kGet, |
| 10792 &kServerChallenge), |
| 10793 TestRound(kGetAuth, kSuccess, OK)}}, |
| 10794 {kProxy, |
| 10795 AUTH_ASYNC, |
| 10796 OK, |
| 10797 kSecureServer, |
| 10798 AUTH_ASYNC, |
| 10799 kAuthErr, |
| 10800 3, |
| 10801 1, |
| 10802 {TestRound(kConnect, kProxyChallenge, OK), |
| 10803 TestRound(kConnectProxyAuth, kProxyConnected, OK, &kGet, |
| 10804 &kServerChallenge), |
10497 TestRound(kGetAuth, kFailure, kAuthErr)}}, | 10805 TestRound(kGetAuth, kFailure, kAuthErr)}}, |
10498 }; | 10806 }; |
10499 | 10807 |
10500 for (size_t i = 0; i < arraysize(test_configs); ++i) { | 10808 for (size_t i = 0; i < arraysize(test_configs); ++i) { |
10501 SCOPED_TRACE(::testing::Message() << "Test config " << i); | 10809 SCOPED_TRACE(::testing::Message() << "Test config " << i); |
10502 HttpAuthHandlerMock::Factory* auth_factory( | 10810 HttpAuthHandlerMock::Factory* auth_factory( |
10503 new HttpAuthHandlerMock::Factory()); | 10811 new HttpAuthHandlerMock::Factory()); |
10504 session_deps_.http_auth_handler_factory.reset(auth_factory); | 10812 session_deps_.http_auth_handler_factory.reset(auth_factory); |
10505 const TestConfig& test_config = test_configs[i]; | 10813 const TestConfig& test_config = test_configs[i]; |
10506 | 10814 |
10507 // Set up authentication handlers as necessary. | 10815 // Set up authentication handlers as necessary. |
10508 if (test_config.proxy_auth_timing != AUTH_NONE) { | 10816 if (test_config.proxy_auth_timing != AUTH_NONE) { |
10509 for (int n = 0; n < 2; n++) { | 10817 for (int n = 0; n < 2; n++) { |
10510 scoped_ptr<HttpAuthHandlerMock> auth_handler(new HttpAuthHandlerMock()); | 10818 scoped_ptr<HttpAuthHandlerMock> auth_handler(new HttpAuthHandlerMock()); |
10511 auth_handler->SetGenerateExpectation( | 10819 auth_handler->SetGenerateExpectation( |
10512 test_config.proxy_auth_timing == AUTH_ASYNC, | 10820 test_config.proxy_auth_timing == AUTH_ASYNC, |
10513 test_config.proxy_auth_rv); | 10821 test_config.proxy_auth_rv); |
10514 auth_factory->AddMockHandler( | 10822 auth_factory->AddMockHandler( |
10515 auth_handler.Pass(), n == 0 | 10823 auth_handler.Pass(), n == 0 |
10516 ? HttpAuthHandlerCreateReason::CHALLENGE | 10824 ? HttpAuthHandlerCreateReason::CHALLENGE |
10517 : HttpAuthHandlerCreateReason::PREEMPTIVE); | 10825 : HttpAuthHandlerCreateReason::PREEMPTIVE); |
10518 } | 10826 } |
10519 } | 10827 } |
10520 if (test_config.server_auth_timing != AUTH_NONE) { | 10828 if (test_config.server_auth_timing != AUTH_NONE) { |
10521 scoped_ptr<HttpAuthHandlerMock> auth_handler(new HttpAuthHandlerMock()); | 10829 scoped_ptr<HttpAuthHandlerMock> auth_handler(new HttpAuthHandlerMock()); |
| 10830 auth_handler->SetInitExpectation( |
| 10831 test_config.server_auth_timing == AUTH_ASYNC, OK); |
10522 auth_handler->SetGenerateExpectation( | 10832 auth_handler->SetGenerateExpectation( |
10523 test_config.server_auth_timing == AUTH_ASYNC, | 10833 test_config.server_auth_timing == AUTH_ASYNC, |
10524 test_config.server_auth_rv); | 10834 test_config.server_auth_rv); |
10525 auth_factory->AddMockHandler(auth_handler.Pass(), | 10835 auth_factory->AddMockHandler(auth_handler.Pass(), |
10526 HttpAuthHandlerCreateReason::CHALLENGE); | 10836 HttpAuthHandlerCreateReason::CHALLENGE); |
10527 } | 10837 } |
10528 if (test_config.proxy_url) { | 10838 if (test_config.proxy_url) { |
10529 session_deps_.proxy_service = | 10839 session_deps_.proxy_service = |
10530 ProxyService::CreateFixed(test_config.proxy_url); | 10840 ProxyService::CreateFixed(test_config.proxy_url); |
10531 } else { | 10841 } else { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10586 const TestRound& read_write_round = test_config.rounds[round]; | 10896 const TestRound& read_write_round = test_config.rounds[round]; |
10587 // Start or restart the transaction. | 10897 // Start or restart the transaction. |
10588 TestCompletionCallback callback; | 10898 TestCompletionCallback callback; |
10589 int rv; | 10899 int rv; |
10590 if (round == 0) { | 10900 if (round == 0) { |
10591 rv = trans.Start(&request, callback.callback(), BoundNetLog()); | 10901 rv = trans.Start(&request, callback.callback(), BoundNetLog()); |
10592 } else { | 10902 } else { |
10593 rv = trans.RestartWithAuth( | 10903 rv = trans.RestartWithAuth( |
10594 AuthCredentials(kFoo, kBar), callback.callback()); | 10904 AuthCredentials(kFoo, kBar), callback.callback()); |
10595 } | 10905 } |
10596 if (rv == ERR_IO_PENDING) | 10906 rv = callback.GetResult(rv); |
10597 rv = callback.WaitForResult(); | |
10598 | 10907 |
10599 // Compare results with expected data. | 10908 // Compare results with expected data. |
10600 EXPECT_EQ(read_write_round.expected_rv, rv); | 10909 EXPECT_EQ(read_write_round.expected_rv, rv); |
10601 const HttpResponseInfo* response = trans.GetResponseInfo(); | 10910 const HttpResponseInfo* response = trans.GetResponseInfo(); |
10602 if (read_write_round.expected_rv != OK) { | 10911 if (read_write_round.expected_rv != OK) { |
10603 EXPECT_EQ(round + 1, test_config.num_auth_rounds); | 10912 EXPECT_EQ(round + 1, test_config.num_auth_rounds); |
10604 continue; | 10913 continue; |
10605 } | 10914 } |
10606 if (round + 1 < test_config.num_auth_rounds) { | 10915 if (round + 1 < test_config.num_auth_rounds) { |
10607 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 10916 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10769 // release the socket back to the pool. | 11078 // release the socket back to the pool. |
10770 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(50)); | 11079 scoped_refptr<IOBufferWithSize> io_buf(new IOBufferWithSize(50)); |
10771 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); | 11080 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); |
10772 EXPECT_EQ(3, callback.GetResult(rv)); | 11081 EXPECT_EQ(3, callback.GetResult(rv)); |
10773 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); | 11082 rv = trans->Read(io_buf.get(), io_buf->size(), callback.callback()); |
10774 EXPECT_EQ(0, rv); | 11083 EXPECT_EQ(0, rv); |
10775 // There are still 0 idle sockets, since the trans_compete transaction | 11084 // There are still 0 idle sockets, since the trans_compete transaction |
10776 // will be handed it immediately after trans releases it to the group. | 11085 // will be handed it immediately after trans releases it to the group. |
10777 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 11086 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
10778 | 11087 |
10779 // The competing request can now finish. Wait for the headers and then | 11088 // The competing request can now finish. Wait for the headers and then read |
10780 // read the body. | 11089 // the body. Explicitly ignore the request to create a preemptive auth handler |
| 11090 // for the competing request. |
| 11091 auth_factory->AddMockHandler(scoped_ptr<HttpAuthHandler>(), |
| 11092 HttpAuthHandlerCreateReason::PREEMPTIVE); |
10781 rv = callback_compete.WaitForResult(); | 11093 rv = callback_compete.WaitForResult(); |
10782 EXPECT_EQ(OK, rv); | 11094 EXPECT_EQ(OK, rv); |
10783 rv = trans_compete->Read(io_buf.get(), io_buf->size(), callback.callback()); | 11095 rv = trans_compete->Read(io_buf.get(), io_buf->size(), callback.callback()); |
10784 EXPECT_EQ(3, callback.GetResult(rv)); | 11096 EXPECT_EQ(3, callback.GetResult(rv)); |
10785 rv = trans_compete->Read(io_buf.get(), io_buf->size(), callback.callback()); | 11097 rv = trans_compete->Read(io_buf.get(), io_buf->size(), callback.callback()); |
10786 EXPECT_EQ(0, rv); | 11098 EXPECT_EQ(0, rv); |
10787 | 11099 |
10788 // Finally, the socket is released to the group. | 11100 // Finally, the socket is released to the group. |
10789 EXPECT_EQ(1, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 11101 EXPECT_EQ(1, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
10790 } | 11102 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10926 TestNetLog net_log; | 11238 TestNetLog net_log; |
10927 session_deps_.net_log = &net_log; | 11239 session_deps_.net_log = &net_log; |
10928 GURL request_url; | 11240 GURL request_url; |
10929 { | 11241 { |
10930 HttpAuthHandlerMock::Factory* auth_factory = | 11242 HttpAuthHandlerMock::Factory* auth_factory = |
10931 new HttpAuthHandlerMock::Factory(); | 11243 new HttpAuthHandlerMock::Factory(); |
10932 scoped_ptr<UrlRecordingHttpAuthHandlerMock> auth_handler( | 11244 scoped_ptr<UrlRecordingHttpAuthHandlerMock> auth_handler( |
10933 new UrlRecordingHttpAuthHandlerMock(&request_url)); | 11245 new UrlRecordingHttpAuthHandlerMock(&request_url)); |
10934 auth_factory->AddMockHandler(auth_handler.Pass(), | 11246 auth_factory->AddMockHandler(auth_handler.Pass(), |
10935 HttpAuthHandlerCreateReason::CHALLENGE); | 11247 HttpAuthHandlerCreateReason::CHALLENGE); |
| 11248 |
| 11249 // Explicitly ignore the request to create a preemptive auth handler. |
| 11250 auth_factory->AddMockHandler(scoped_ptr<HttpAuthHandler>(), |
| 11251 HttpAuthHandlerCreateReason::PREEMPTIVE); |
10936 session_deps_.http_auth_handler_factory.reset(auth_factory); | 11252 session_deps_.http_auth_handler_factory.reset(auth_factory); |
10937 } | 11253 } |
10938 | 11254 |
10939 HttpRequestInfo request; | 11255 HttpRequestInfo request; |
10940 request.method = "GET"; | 11256 request.method = "GET"; |
10941 request.url = GURL("http://www.example.org"); | 11257 request.url = GURL("http://www.example.org"); |
10942 request.load_flags = 0; | 11258 request.load_flags = 0; |
10943 | 11259 |
10944 // First round goes unauthenticated through the proxy. | 11260 // First round goes unauthenticated through the proxy. |
10945 MockWrite data_writes_1[] = { | 11261 MockWrite data_writes_1[] = { |
(...skipping 3812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14758 std::string response_data; | 15074 std::string response_data; |
14759 EXPECT_EQ(OK, ReadTransaction(trans.get(), &response_data)); | 15075 EXPECT_EQ(OK, ReadTransaction(trans.get(), &response_data)); |
14760 | 15076 |
14761 EXPECT_EQ(CountWriteBytes(data_writes, arraysize(data_writes)), | 15077 EXPECT_EQ(CountWriteBytes(data_writes, arraysize(data_writes)), |
14762 trans->GetTotalSentBytes()); | 15078 trans->GetTotalSentBytes()); |
14763 EXPECT_EQ(CountReadBytes(data_reads, arraysize(data_reads)), | 15079 EXPECT_EQ(CountReadBytes(data_reads, arraysize(data_reads)), |
14764 trans->GetTotalReceivedBytes()); | 15080 trans->GetTotalReceivedBytes()); |
14765 } | 15081 } |
14766 | 15082 |
14767 } // namespace net | 15083 } // namespace net |
OLD | NEW |