OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 | 1279 |
1280 rv = callback1.WaitForResult(); | 1280 rv = callback1.WaitForResult(); |
1281 EXPECT_EQ(OK, rv); | 1281 EXPECT_EQ(OK, rv); |
1282 | 1282 |
1283 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1283 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1284 ASSERT_TRUE(response != NULL); | 1284 ASSERT_TRUE(response != NULL); |
1285 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 1285 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
1286 | 1286 |
1287 TestOldCompletionCallback callback2; | 1287 TestOldCompletionCallback callback2; |
1288 | 1288 |
1289 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); | 1289 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); |
1290 EXPECT_EQ(ERR_IO_PENDING, rv); | 1290 EXPECT_EQ(ERR_IO_PENDING, rv); |
1291 | 1291 |
1292 rv = callback2.WaitForResult(); | 1292 rv = callback2.WaitForResult(); |
1293 EXPECT_EQ(OK, rv); | 1293 EXPECT_EQ(OK, rv); |
1294 | 1294 |
1295 response = trans->GetResponseInfo(); | 1295 response = trans->GetResponseInfo(); |
1296 ASSERT_TRUE(response != NULL); | 1296 ASSERT_TRUE(response != NULL); |
1297 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1297 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
1298 EXPECT_EQ(100, response->headers->GetContentLength()); | 1298 EXPECT_EQ(100, response->headers->GetContentLength()); |
1299 } | 1299 } |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 | 1398 |
1399 rv = callback1.WaitForResult(); | 1399 rv = callback1.WaitForResult(); |
1400 EXPECT_EQ(OK, rv); | 1400 EXPECT_EQ(OK, rv); |
1401 | 1401 |
1402 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1402 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1403 ASSERT_TRUE(response != NULL); | 1403 ASSERT_TRUE(response != NULL); |
1404 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 1404 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
1405 | 1405 |
1406 TestOldCompletionCallback callback2; | 1406 TestOldCompletionCallback callback2; |
1407 | 1407 |
1408 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); | 1408 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); |
1409 EXPECT_EQ(ERR_IO_PENDING, rv); | 1409 EXPECT_EQ(ERR_IO_PENDING, rv); |
1410 | 1410 |
1411 rv = callback2.WaitForResult(); | 1411 rv = callback2.WaitForResult(); |
1412 EXPECT_EQ(OK, rv); | 1412 EXPECT_EQ(OK, rv); |
1413 | 1413 |
1414 response = trans->GetResponseInfo(); | 1414 response = trans->GetResponseInfo(); |
1415 ASSERT_TRUE(response != NULL); | 1415 ASSERT_TRUE(response != NULL); |
1416 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1416 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
1417 EXPECT_EQ(5, response->headers->GetContentLength()); | 1417 EXPECT_EQ(5, response->headers->GetContentLength()); |
1418 } | 1418 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1473 | 1473 |
1474 rv = callback1.WaitForResult(); | 1474 rv = callback1.WaitForResult(); |
1475 EXPECT_EQ(OK, rv); | 1475 EXPECT_EQ(OK, rv); |
1476 | 1476 |
1477 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1477 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1478 ASSERT_TRUE(response != NULL); | 1478 ASSERT_TRUE(response != NULL); |
1479 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 1479 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
1480 | 1480 |
1481 TestOldCompletionCallback callback2; | 1481 TestOldCompletionCallback callback2; |
1482 | 1482 |
1483 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); | 1483 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); |
1484 EXPECT_EQ(ERR_IO_PENDING, rv); | 1484 EXPECT_EQ(ERR_IO_PENDING, rv); |
1485 | 1485 |
1486 rv = callback2.WaitForResult(); | 1486 rv = callback2.WaitForResult(); |
1487 EXPECT_EQ(OK, rv); | 1487 EXPECT_EQ(OK, rv); |
1488 | 1488 |
1489 response = trans->GetResponseInfo(); | 1489 response = trans->GetResponseInfo(); |
1490 ASSERT_TRUE(response != NULL); | 1490 ASSERT_TRUE(response != NULL); |
1491 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1491 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
1492 EXPECT_EQ(5, response->headers->GetContentLength()); | 1492 EXPECT_EQ(5, response->headers->GetContentLength()); |
1493 } | 1493 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1556 | 1556 |
1557 rv = callback1.WaitForResult(); | 1557 rv = callback1.WaitForResult(); |
1558 EXPECT_EQ(OK, rv); | 1558 EXPECT_EQ(OK, rv); |
1559 | 1559 |
1560 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1560 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1561 ASSERT_TRUE(response != NULL); | 1561 ASSERT_TRUE(response != NULL); |
1562 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 1562 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
1563 | 1563 |
1564 TestOldCompletionCallback callback2; | 1564 TestOldCompletionCallback callback2; |
1565 | 1565 |
1566 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); | 1566 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); |
1567 EXPECT_EQ(ERR_IO_PENDING, rv); | 1567 EXPECT_EQ(ERR_IO_PENDING, rv); |
1568 | 1568 |
1569 rv = callback2.WaitForResult(); | 1569 rv = callback2.WaitForResult(); |
1570 EXPECT_EQ(OK, rv); | 1570 EXPECT_EQ(OK, rv); |
1571 | 1571 |
1572 response = trans->GetResponseInfo(); | 1572 response = trans->GetResponseInfo(); |
1573 ASSERT_TRUE(response != NULL); | 1573 ASSERT_TRUE(response != NULL); |
1574 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1574 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
1575 EXPECT_EQ(5, response->headers->GetContentLength()); | 1575 EXPECT_EQ(5, response->headers->GetContentLength()); |
1576 } | 1576 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1641 | 1641 |
1642 rv = callback1.WaitForResult(); | 1642 rv = callback1.WaitForResult(); |
1643 EXPECT_EQ(OK, rv); | 1643 EXPECT_EQ(OK, rv); |
1644 | 1644 |
1645 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1645 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1646 ASSERT_TRUE(response != NULL); | 1646 ASSERT_TRUE(response != NULL); |
1647 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 1647 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
1648 | 1648 |
1649 TestOldCompletionCallback callback2; | 1649 TestOldCompletionCallback callback2; |
1650 | 1650 |
1651 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); | 1651 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); |
1652 EXPECT_EQ(ERR_IO_PENDING, rv); | 1652 EXPECT_EQ(ERR_IO_PENDING, rv); |
1653 | 1653 |
1654 rv = callback2.WaitForResult(); | 1654 rv = callback2.WaitForResult(); |
1655 EXPECT_EQ(OK, rv); | 1655 EXPECT_EQ(OK, rv); |
1656 | 1656 |
1657 response = trans->GetResponseInfo(); | 1657 response = trans->GetResponseInfo(); |
1658 ASSERT_TRUE(response != NULL); | 1658 ASSERT_TRUE(response != NULL); |
1659 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1659 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
1660 EXPECT_EQ(5, response->headers->GetContentLength()); | 1660 EXPECT_EQ(5, response->headers->GetContentLength()); |
1661 } | 1661 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1736 | 1736 |
1737 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1737 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1738 ASSERT_TRUE(response != NULL); | 1738 ASSERT_TRUE(response != NULL); |
1739 ASSERT_FALSE(response->headers == NULL); | 1739 ASSERT_FALSE(response->headers == NULL); |
1740 EXPECT_EQ(407, response->headers->response_code()); | 1740 EXPECT_EQ(407, response->headers->response_code()); |
1741 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 1741 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
1742 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 1742 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
1743 | 1743 |
1744 TestOldCompletionCallback callback2; | 1744 TestOldCompletionCallback callback2; |
1745 | 1745 |
1746 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); | 1746 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); |
1747 EXPECT_EQ(ERR_IO_PENDING, rv); | 1747 EXPECT_EQ(ERR_IO_PENDING, rv); |
1748 | 1748 |
1749 rv = callback2.WaitForResult(); | 1749 rv = callback2.WaitForResult(); |
1750 EXPECT_EQ(OK, rv); | 1750 EXPECT_EQ(OK, rv); |
1751 | 1751 |
1752 response = trans->GetResponseInfo(); | 1752 response = trans->GetResponseInfo(); |
1753 ASSERT_TRUE(response != NULL); | 1753 ASSERT_TRUE(response != NULL); |
1754 | 1754 |
1755 EXPECT_TRUE(response->headers->IsKeepAlive()); | 1755 EXPECT_TRUE(response->headers->IsKeepAlive()); |
1756 EXPECT_EQ(200, response->headers->response_code()); | 1756 EXPECT_EQ(200, response->headers->response_code()); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1839 ASSERT_FALSE(response->headers == NULL); | 1839 ASSERT_FALSE(response->headers == NULL); |
1840 EXPECT_TRUE(response->headers->IsKeepAlive()); | 1840 EXPECT_TRUE(response->headers->IsKeepAlive()); |
1841 EXPECT_EQ(407, response->headers->response_code()); | 1841 EXPECT_EQ(407, response->headers->response_code()); |
1842 EXPECT_EQ(10, response->headers->GetContentLength()); | 1842 EXPECT_EQ(10, response->headers->GetContentLength()); |
1843 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 1843 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
1844 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 1844 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
1845 | 1845 |
1846 TestOldCompletionCallback callback2; | 1846 TestOldCompletionCallback callback2; |
1847 | 1847 |
1848 // Wrong password (should be "bar"). | 1848 // Wrong password (should be "bar"). |
1849 rv = trans->RestartWithAuth(kFoo, kBaz, &callback2); | 1849 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBaz), &callback2); |
1850 EXPECT_EQ(ERR_IO_PENDING, rv); | 1850 EXPECT_EQ(ERR_IO_PENDING, rv); |
1851 | 1851 |
1852 rv = callback2.WaitForResult(); | 1852 rv = callback2.WaitForResult(); |
1853 EXPECT_EQ(OK, rv); | 1853 EXPECT_EQ(OK, rv); |
1854 | 1854 |
1855 response = trans->GetResponseInfo(); | 1855 response = trans->GetResponseInfo(); |
1856 ASSERT_TRUE(response != NULL); | 1856 ASSERT_TRUE(response != NULL); |
1857 ASSERT_FALSE(response->headers == NULL); | 1857 ASSERT_FALSE(response->headers == NULL); |
1858 EXPECT_TRUE(response->headers->IsKeepAlive()); | 1858 EXPECT_TRUE(response->headers->IsKeepAlive()); |
1859 EXPECT_EQ(407, response->headers->response_code()); | 1859 EXPECT_EQ(407, response->headers->response_code()); |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2221 const HttpResponseInfo* const response = trans->GetResponseInfo(); | 2221 const HttpResponseInfo* const response = trans->GetResponseInfo(); |
2222 | 2222 |
2223 ASSERT_TRUE(response != NULL); | 2223 ASSERT_TRUE(response != NULL); |
2224 ASSERT_TRUE(response->headers != NULL); | 2224 ASSERT_TRUE(response->headers != NULL); |
2225 EXPECT_EQ(407, response->headers->response_code()); | 2225 EXPECT_EQ(407, response->headers->response_code()); |
2226 EXPECT_TRUE(response->was_fetched_via_spdy); | 2226 EXPECT_TRUE(response->was_fetched_via_spdy); |
2227 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 2227 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
2228 | 2228 |
2229 TestOldCompletionCallback callback2; | 2229 TestOldCompletionCallback callback2; |
2230 | 2230 |
2231 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); | 2231 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); |
2232 EXPECT_EQ(ERR_IO_PENDING, rv); | 2232 EXPECT_EQ(ERR_IO_PENDING, rv); |
2233 | 2233 |
2234 rv = callback2.WaitForResult(); | 2234 rv = callback2.WaitForResult(); |
2235 EXPECT_EQ(OK, rv); | 2235 EXPECT_EQ(OK, rv); |
2236 | 2236 |
2237 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); | 2237 const HttpResponseInfo* const response_restart = trans->GetResponseInfo(); |
2238 | 2238 |
2239 ASSERT_TRUE(response_restart != NULL); | 2239 ASSERT_TRUE(response_restart != NULL); |
2240 ASSERT_TRUE(response_restart->headers != NULL); | 2240 ASSERT_TRUE(response_restart->headers != NULL); |
2241 EXPECT_EQ(200, response_restart->headers->response_code()); | 2241 EXPECT_EQ(200, response_restart->headers->response_code()); |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2521 | 2521 |
2522 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2522 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2523 ASSERT_TRUE(response != NULL); | 2523 ASSERT_TRUE(response != NULL); |
2524 ASSERT_FALSE(response->headers == NULL); | 2524 ASSERT_FALSE(response->headers == NULL); |
2525 EXPECT_EQ(407, response->headers->response_code()); | 2525 EXPECT_EQ(407, response->headers->response_code()); |
2526 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); | 2526 EXPECT_TRUE(HttpVersion(1, 1) == response->headers->GetHttpVersion()); |
2527 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 2527 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
2528 | 2528 |
2529 TestOldCompletionCallback callback2; | 2529 TestOldCompletionCallback callback2; |
2530 | 2530 |
2531 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); | 2531 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); |
2532 EXPECT_EQ(ERR_IO_PENDING, rv); | 2532 EXPECT_EQ(ERR_IO_PENDING, rv); |
2533 | 2533 |
2534 rv = callback2.WaitForResult(); | 2534 rv = callback2.WaitForResult(); |
2535 EXPECT_EQ(OK, rv); | 2535 EXPECT_EQ(OK, rv); |
2536 | 2536 |
2537 response = trans->GetResponseInfo(); | 2537 response = trans->GetResponseInfo(); |
2538 ASSERT_TRUE(response != NULL); | 2538 ASSERT_TRUE(response != NULL); |
2539 | 2539 |
2540 EXPECT_TRUE(response->headers->IsKeepAlive()); | 2540 EXPECT_TRUE(response->headers->IsKeepAlive()); |
2541 EXPECT_EQ(200, response->headers->response_code()); | 2541 EXPECT_EQ(200, response->headers->response_code()); |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2847 | 2847 |
2848 rv = callback1.WaitForResult(); | 2848 rv = callback1.WaitForResult(); |
2849 EXPECT_EQ(OK, rv); | 2849 EXPECT_EQ(OK, rv); |
2850 | 2850 |
2851 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2851 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2852 ASSERT_TRUE(response != NULL); | 2852 ASSERT_TRUE(response != NULL); |
2853 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); | 2853 EXPECT_TRUE(CheckBasicProxyAuth(response->auth_challenge.get())); |
2854 | 2854 |
2855 TestOldCompletionCallback callback2; | 2855 TestOldCompletionCallback callback2; |
2856 | 2856 |
2857 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); | 2857 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); |
2858 EXPECT_EQ(ERR_IO_PENDING, rv); | 2858 EXPECT_EQ(ERR_IO_PENDING, rv); |
2859 | 2859 |
2860 rv = callback2.WaitForResult(); | 2860 rv = callback2.WaitForResult(); |
2861 EXPECT_EQ(OK, rv); | 2861 EXPECT_EQ(OK, rv); |
2862 | 2862 |
2863 response = trans->GetResponseInfo(); | 2863 response = trans->GetResponseInfo(); |
2864 ASSERT_TRUE(response != NULL); | 2864 ASSERT_TRUE(response != NULL); |
2865 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 2865 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
2866 | 2866 |
2867 TestOldCompletionCallback callback3; | 2867 TestOldCompletionCallback callback3; |
2868 | 2868 |
2869 rv = trans->RestartWithAuth(kFoo2, kBar2, &callback3); | 2869 rv = trans->RestartWithAuth(AuthCredentials(kFoo2, kBar2), &callback3); |
2870 EXPECT_EQ(ERR_IO_PENDING, rv); | 2870 EXPECT_EQ(ERR_IO_PENDING, rv); |
2871 | 2871 |
2872 rv = callback3.WaitForResult(); | 2872 rv = callback3.WaitForResult(); |
2873 EXPECT_EQ(OK, rv); | 2873 EXPECT_EQ(OK, rv); |
2874 | 2874 |
2875 response = trans->GetResponseInfo(); | 2875 response = trans->GetResponseInfo(); |
2876 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 2876 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
2877 EXPECT_EQ(100, response->headers->GetContentLength()); | 2877 EXPECT_EQ(100, response->headers->GetContentLength()); |
2878 } | 2878 } |
2879 | 2879 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2980 EXPECT_EQ(OK, rv); | 2980 EXPECT_EQ(OK, rv); |
2981 | 2981 |
2982 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 2982 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
2983 | 2983 |
2984 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2984 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2985 ASSERT_FALSE(response == NULL); | 2985 ASSERT_FALSE(response == NULL); |
2986 EXPECT_TRUE(CheckNTLMServerAuth(response->auth_challenge.get())); | 2986 EXPECT_TRUE(CheckNTLMServerAuth(response->auth_challenge.get())); |
2987 | 2987 |
2988 TestOldCompletionCallback callback2; | 2988 TestOldCompletionCallback callback2; |
2989 | 2989 |
2990 rv = trans->RestartWithAuth(kTestingNTLM, kTestingNTLM, &callback2); | 2990 rv = trans->RestartWithAuth(AuthCredentials(kTestingNTLM, kTestingNTLM), |
| 2991 &callback2); |
2991 EXPECT_EQ(ERR_IO_PENDING, rv); | 2992 EXPECT_EQ(ERR_IO_PENDING, rv); |
2992 | 2993 |
2993 rv = callback2.WaitForResult(); | 2994 rv = callback2.WaitForResult(); |
2994 EXPECT_EQ(OK, rv); | 2995 EXPECT_EQ(OK, rv); |
2995 | 2996 |
2996 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 2997 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
2997 | 2998 |
2998 response = trans->GetResponseInfo(); | 2999 response = trans->GetResponseInfo(); |
2999 ASSERT_TRUE(response != NULL); | 3000 ASSERT_TRUE(response != NULL); |
3000 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 3001 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
3001 | 3002 |
3002 TestOldCompletionCallback callback3; | 3003 TestOldCompletionCallback callback3; |
3003 | 3004 |
3004 rv = trans->RestartWithAuth(string16(), string16(), &callback3); | 3005 rv = trans->RestartWithAuth(AuthCredentials(), &callback3); |
3005 EXPECT_EQ(ERR_IO_PENDING, rv); | 3006 EXPECT_EQ(ERR_IO_PENDING, rv); |
3006 | 3007 |
3007 rv = callback3.WaitForResult(); | 3008 rv = callback3.WaitForResult(); |
3008 EXPECT_EQ(OK, rv); | 3009 EXPECT_EQ(OK, rv); |
3009 | 3010 |
3010 response = trans->GetResponseInfo(); | 3011 response = trans->GetResponseInfo(); |
3011 ASSERT_TRUE(response != NULL); | 3012 ASSERT_TRUE(response != NULL); |
3012 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 3013 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
3013 EXPECT_EQ(13, response->headers->GetContentLength()); | 3014 EXPECT_EQ(13, response->headers->GetContentLength()); |
3014 } | 3015 } |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3160 | 3161 |
3161 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 3162 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
3162 | 3163 |
3163 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3164 const HttpResponseInfo* response = trans->GetResponseInfo(); |
3164 ASSERT_TRUE(response != NULL); | 3165 ASSERT_TRUE(response != NULL); |
3165 EXPECT_TRUE(CheckNTLMServerAuth(response->auth_challenge.get())); | 3166 EXPECT_TRUE(CheckNTLMServerAuth(response->auth_challenge.get())); |
3166 | 3167 |
3167 TestOldCompletionCallback callback2; | 3168 TestOldCompletionCallback callback2; |
3168 | 3169 |
3169 // Enter the wrong password. | 3170 // Enter the wrong password. |
3170 rv = trans->RestartWithAuth(kTestingNTLM, kWrongPassword, &callback2); | 3171 rv = trans->RestartWithAuth(AuthCredentials(kTestingNTLM, kWrongPassword), |
| 3172 &callback2); |
3171 EXPECT_EQ(ERR_IO_PENDING, rv); | 3173 EXPECT_EQ(ERR_IO_PENDING, rv); |
3172 | 3174 |
3173 rv = callback2.WaitForResult(); | 3175 rv = callback2.WaitForResult(); |
3174 EXPECT_EQ(OK, rv); | 3176 EXPECT_EQ(OK, rv); |
3175 | 3177 |
3176 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 3178 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
3177 TestOldCompletionCallback callback3; | 3179 TestOldCompletionCallback callback3; |
3178 rv = trans->RestartWithAuth(string16(), string16(), &callback3); | 3180 rv = trans->RestartWithAuth(AuthCredentials(), &callback3); |
3179 EXPECT_EQ(ERR_IO_PENDING, rv); | 3181 EXPECT_EQ(ERR_IO_PENDING, rv); |
3180 rv = callback3.WaitForResult(); | 3182 rv = callback3.WaitForResult(); |
3181 EXPECT_EQ(OK, rv); | 3183 EXPECT_EQ(OK, rv); |
3182 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 3184 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
3183 | 3185 |
3184 response = trans->GetResponseInfo(); | 3186 response = trans->GetResponseInfo(); |
3185 ASSERT_FALSE(response == NULL); | 3187 ASSERT_FALSE(response == NULL); |
3186 EXPECT_TRUE(CheckNTLMServerAuth(response->auth_challenge.get())); | 3188 EXPECT_TRUE(CheckNTLMServerAuth(response->auth_challenge.get())); |
3187 | 3189 |
3188 TestOldCompletionCallback callback4; | 3190 TestOldCompletionCallback callback4; |
3189 | 3191 |
3190 // Now enter the right password. | 3192 // Now enter the right password. |
3191 rv = trans->RestartWithAuth(kTestingNTLM, kTestingNTLM, &callback4); | 3193 rv = trans->RestartWithAuth(AuthCredentials(kTestingNTLM, kTestingNTLM), |
| 3194 &callback4); |
3192 EXPECT_EQ(ERR_IO_PENDING, rv); | 3195 EXPECT_EQ(ERR_IO_PENDING, rv); |
3193 | 3196 |
3194 rv = callback4.WaitForResult(); | 3197 rv = callback4.WaitForResult(); |
3195 EXPECT_EQ(OK, rv); | 3198 EXPECT_EQ(OK, rv); |
3196 | 3199 |
3197 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 3200 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
3198 | 3201 |
3199 TestOldCompletionCallback callback5; | 3202 TestOldCompletionCallback callback5; |
3200 | 3203 |
3201 // One more roundtrip | 3204 // One more roundtrip |
3202 rv = trans->RestartWithAuth(string16(), string16(), &callback5); | 3205 rv = trans->RestartWithAuth(AuthCredentials(), &callback5); |
3203 EXPECT_EQ(ERR_IO_PENDING, rv); | 3206 EXPECT_EQ(ERR_IO_PENDING, rv); |
3204 | 3207 |
3205 rv = callback5.WaitForResult(); | 3208 rv = callback5.WaitForResult(); |
3206 EXPECT_EQ(OK, rv); | 3209 EXPECT_EQ(OK, rv); |
3207 | 3210 |
3208 response = trans->GetResponseInfo(); | 3211 response = trans->GetResponseInfo(); |
3209 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 3212 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
3210 EXPECT_EQ(13, response->headers->GetContentLength()); | 3213 EXPECT_EQ(13, response->headers->GetContentLength()); |
3211 } | 3214 } |
3212 #endif // NTLM_PORTABLE | 3215 #endif // NTLM_PORTABLE |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3719 TestOldCompletionCallback callback1; | 3722 TestOldCompletionCallback callback1; |
3720 | 3723 |
3721 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 3724 int rv = trans->Start(&request, &callback1, BoundNetLog()); |
3722 EXPECT_EQ(ERR_IO_PENDING, rv); | 3725 EXPECT_EQ(ERR_IO_PENDING, rv); |
3723 | 3726 |
3724 rv = callback1.WaitForResult(); | 3727 rv = callback1.WaitForResult(); |
3725 EXPECT_EQ(OK, rv); | 3728 EXPECT_EQ(OK, rv); |
3726 | 3729 |
3727 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 3730 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
3728 TestOldCompletionCallback callback2; | 3731 TestOldCompletionCallback callback2; |
3729 rv = trans->RestartWithAuth(string16(), string16(), &callback2); | 3732 rv = trans->RestartWithAuth(AuthCredentials(), &callback2); |
3730 EXPECT_EQ(ERR_IO_PENDING, rv); | 3733 EXPECT_EQ(ERR_IO_PENDING, rv); |
3731 rv = callback2.WaitForResult(); | 3734 rv = callback2.WaitForResult(); |
3732 EXPECT_EQ(OK, rv); | 3735 EXPECT_EQ(OK, rv); |
3733 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 3736 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
3734 | 3737 |
3735 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3738 const HttpResponseInfo* response = trans->GetResponseInfo(); |
3736 ASSERT_TRUE(response != NULL); | 3739 ASSERT_TRUE(response != NULL); |
3737 | 3740 |
3738 // There is no challenge info, since the identity in URL worked. | 3741 // There is no challenge info, since the identity in URL worked. |
3739 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 3742 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3817 TestOldCompletionCallback callback1; | 3820 TestOldCompletionCallback callback1; |
3818 | 3821 |
3819 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 3822 int rv = trans->Start(&request, &callback1, BoundNetLog()); |
3820 EXPECT_EQ(ERR_IO_PENDING, rv); | 3823 EXPECT_EQ(ERR_IO_PENDING, rv); |
3821 | 3824 |
3822 rv = callback1.WaitForResult(); | 3825 rv = callback1.WaitForResult(); |
3823 EXPECT_EQ(OK, rv); | 3826 EXPECT_EQ(OK, rv); |
3824 | 3827 |
3825 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 3828 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
3826 TestOldCompletionCallback callback2; | 3829 TestOldCompletionCallback callback2; |
3827 rv = trans->RestartWithAuth(string16(), string16(), &callback2); | 3830 rv = trans->RestartWithAuth(AuthCredentials(), &callback2); |
3828 EXPECT_EQ(ERR_IO_PENDING, rv); | 3831 EXPECT_EQ(ERR_IO_PENDING, rv); |
3829 rv = callback2.WaitForResult(); | 3832 rv = callback2.WaitForResult(); |
3830 EXPECT_EQ(OK, rv); | 3833 EXPECT_EQ(OK, rv); |
3831 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 3834 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
3832 | 3835 |
3833 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3836 const HttpResponseInfo* response = trans->GetResponseInfo(); |
3834 ASSERT_TRUE(response != NULL); | 3837 ASSERT_TRUE(response != NULL); |
3835 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 3838 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
3836 | 3839 |
3837 TestOldCompletionCallback callback3; | 3840 TestOldCompletionCallback callback3; |
3838 rv = trans->RestartWithAuth(kFoo, kBar, &callback3); | 3841 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback3); |
3839 EXPECT_EQ(ERR_IO_PENDING, rv); | 3842 EXPECT_EQ(ERR_IO_PENDING, rv); |
3840 rv = callback3.WaitForResult(); | 3843 rv = callback3.WaitForResult(); |
3841 EXPECT_EQ(OK, rv); | 3844 EXPECT_EQ(OK, rv); |
3842 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 3845 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
3843 | 3846 |
3844 response = trans->GetResponseInfo(); | 3847 response = trans->GetResponseInfo(); |
3845 ASSERT_TRUE(response != NULL); | 3848 ASSERT_TRUE(response != NULL); |
3846 | 3849 |
3847 // There is no challenge info, since the identity worked. | 3850 // There is no challenge info, since the identity worked. |
3848 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 3851 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3909 | 3912 |
3910 rv = callback1.WaitForResult(); | 3913 rv = callback1.WaitForResult(); |
3911 EXPECT_EQ(OK, rv); | 3914 EXPECT_EQ(OK, rv); |
3912 | 3915 |
3913 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3916 const HttpResponseInfo* response = trans->GetResponseInfo(); |
3914 ASSERT_TRUE(response != NULL); | 3917 ASSERT_TRUE(response != NULL); |
3915 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 3918 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
3916 | 3919 |
3917 TestOldCompletionCallback callback2; | 3920 TestOldCompletionCallback callback2; |
3918 | 3921 |
3919 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); | 3922 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); |
3920 EXPECT_EQ(ERR_IO_PENDING, rv); | 3923 EXPECT_EQ(ERR_IO_PENDING, rv); |
3921 | 3924 |
3922 rv = callback2.WaitForResult(); | 3925 rv = callback2.WaitForResult(); |
3923 EXPECT_EQ(OK, rv); | 3926 EXPECT_EQ(OK, rv); |
3924 | 3927 |
3925 response = trans->GetResponseInfo(); | 3928 response = trans->GetResponseInfo(); |
3926 ASSERT_TRUE(response != NULL); | 3929 ASSERT_TRUE(response != NULL); |
3927 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 3930 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
3928 EXPECT_EQ(100, response->headers->GetContentLength()); | 3931 EXPECT_EQ(100, response->headers->GetContentLength()); |
3929 } | 3932 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3992 ASSERT_TRUE(response != NULL); | 3995 ASSERT_TRUE(response != NULL); |
3993 ASSERT_TRUE(response->auth_challenge.get()); | 3996 ASSERT_TRUE(response->auth_challenge.get()); |
3994 EXPECT_FALSE(response->auth_challenge->is_proxy); | 3997 EXPECT_FALSE(response->auth_challenge->is_proxy); |
3995 EXPECT_EQ("www.google.com:80", | 3998 EXPECT_EQ("www.google.com:80", |
3996 response->auth_challenge->challenger.ToString()); | 3999 response->auth_challenge->challenger.ToString()); |
3997 EXPECT_EQ("MyRealm2", response->auth_challenge->realm); | 4000 EXPECT_EQ("MyRealm2", response->auth_challenge->realm); |
3998 EXPECT_EQ("basic", response->auth_challenge->scheme); | 4001 EXPECT_EQ("basic", response->auth_challenge->scheme); |
3999 | 4002 |
4000 TestOldCompletionCallback callback2; | 4003 TestOldCompletionCallback callback2; |
4001 | 4004 |
4002 rv = trans->RestartWithAuth(kFoo2, kBar2, &callback2); | 4005 rv = trans->RestartWithAuth(AuthCredentials(kFoo2, kBar2), &callback2); |
4003 EXPECT_EQ(ERR_IO_PENDING, rv); | 4006 EXPECT_EQ(ERR_IO_PENDING, rv); |
4004 | 4007 |
4005 rv = callback2.WaitForResult(); | 4008 rv = callback2.WaitForResult(); |
4006 EXPECT_EQ(OK, rv); | 4009 EXPECT_EQ(OK, rv); |
4007 | 4010 |
4008 response = trans->GetResponseInfo(); | 4011 response = trans->GetResponseInfo(); |
4009 ASSERT_TRUE(response != NULL); | 4012 ASSERT_TRUE(response != NULL); |
4010 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 4013 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
4011 EXPECT_EQ(100, response->headers->GetContentLength()); | 4014 EXPECT_EQ(100, response->headers->GetContentLength()); |
4012 } | 4015 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4108 TestOldCompletionCallback callback1; | 4111 TestOldCompletionCallback callback1; |
4109 | 4112 |
4110 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 4113 int rv = trans->Start(&request, &callback1, BoundNetLog()); |
4111 EXPECT_EQ(ERR_IO_PENDING, rv); | 4114 EXPECT_EQ(ERR_IO_PENDING, rv); |
4112 | 4115 |
4113 rv = callback1.WaitForResult(); | 4116 rv = callback1.WaitForResult(); |
4114 EXPECT_EQ(OK, rv); | 4117 EXPECT_EQ(OK, rv); |
4115 | 4118 |
4116 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 4119 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
4117 TestOldCompletionCallback callback2; | 4120 TestOldCompletionCallback callback2; |
4118 rv = trans->RestartWithAuth(string16(), string16(), &callback2); | 4121 rv = trans->RestartWithAuth(AuthCredentials(), &callback2); |
4119 EXPECT_EQ(ERR_IO_PENDING, rv); | 4122 EXPECT_EQ(ERR_IO_PENDING, rv); |
4120 rv = callback2.WaitForResult(); | 4123 rv = callback2.WaitForResult(); |
4121 EXPECT_EQ(OK, rv); | 4124 EXPECT_EQ(OK, rv); |
4122 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 4125 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
4123 | 4126 |
4124 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4127 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4125 ASSERT_TRUE(response != NULL); | 4128 ASSERT_TRUE(response != NULL); |
4126 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 4129 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
4127 EXPECT_EQ(100, response->headers->GetContentLength()); | 4130 EXPECT_EQ(100, response->headers->GetContentLength()); |
4128 } | 4131 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4197 TestOldCompletionCallback callback1; | 4200 TestOldCompletionCallback callback1; |
4198 | 4201 |
4199 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 4202 int rv = trans->Start(&request, &callback1, BoundNetLog()); |
4200 EXPECT_EQ(ERR_IO_PENDING, rv); | 4203 EXPECT_EQ(ERR_IO_PENDING, rv); |
4201 | 4204 |
4202 rv = callback1.WaitForResult(); | 4205 rv = callback1.WaitForResult(); |
4203 EXPECT_EQ(OK, rv); | 4206 EXPECT_EQ(OK, rv); |
4204 | 4207 |
4205 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 4208 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
4206 TestOldCompletionCallback callback2; | 4209 TestOldCompletionCallback callback2; |
4207 rv = trans->RestartWithAuth(string16(), string16(), &callback2); | 4210 rv = trans->RestartWithAuth(AuthCredentials(), &callback2); |
4208 EXPECT_EQ(ERR_IO_PENDING, rv); | 4211 EXPECT_EQ(ERR_IO_PENDING, rv); |
4209 rv = callback2.WaitForResult(); | 4212 rv = callback2.WaitForResult(); |
4210 EXPECT_EQ(OK, rv); | 4213 EXPECT_EQ(OK, rv); |
4211 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 4214 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
4212 | 4215 |
4213 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4216 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4214 ASSERT_TRUE(response != NULL); | 4217 ASSERT_TRUE(response != NULL); |
4215 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 4218 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
4216 | 4219 |
4217 TestOldCompletionCallback callback3; | 4220 TestOldCompletionCallback callback3; |
4218 | 4221 |
4219 rv = trans->RestartWithAuth(kFoo3, kBar3, &callback3); | 4222 rv = trans->RestartWithAuth(AuthCredentials(kFoo3, kBar3), &callback3); |
4220 EXPECT_EQ(ERR_IO_PENDING, rv); | 4223 EXPECT_EQ(ERR_IO_PENDING, rv); |
4221 | 4224 |
4222 rv = callback3.WaitForResult(); | 4225 rv = callback3.WaitForResult(); |
4223 EXPECT_EQ(OK, rv); | 4226 EXPECT_EQ(OK, rv); |
4224 | 4227 |
4225 response = trans->GetResponseInfo(); | 4228 response = trans->GetResponseInfo(); |
4226 ASSERT_TRUE(response != NULL); | 4229 ASSERT_TRUE(response != NULL); |
4227 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 4230 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
4228 EXPECT_EQ(100, response->headers->GetContentLength()); | 4231 EXPECT_EQ(100, response->headers->GetContentLength()); |
4229 } | 4232 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4294 | 4297 |
4295 rv = callback1.WaitForResult(); | 4298 rv = callback1.WaitForResult(); |
4296 EXPECT_EQ(OK, rv); | 4299 EXPECT_EQ(OK, rv); |
4297 | 4300 |
4298 const HttpResponseInfo* response = trans->GetResponseInfo(); | 4301 const HttpResponseInfo* response = trans->GetResponseInfo(); |
4299 ASSERT_TRUE(response != NULL); | 4302 ASSERT_TRUE(response != NULL); |
4300 EXPECT_TRUE(CheckDigestServerAuth(response->auth_challenge.get())); | 4303 EXPECT_TRUE(CheckDigestServerAuth(response->auth_challenge.get())); |
4301 | 4304 |
4302 TestOldCompletionCallback callback2; | 4305 TestOldCompletionCallback callback2; |
4303 | 4306 |
4304 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); | 4307 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); |
4305 EXPECT_EQ(ERR_IO_PENDING, rv); | 4308 EXPECT_EQ(ERR_IO_PENDING, rv); |
4306 | 4309 |
4307 rv = callback2.WaitForResult(); | 4310 rv = callback2.WaitForResult(); |
4308 EXPECT_EQ(OK, rv); | 4311 EXPECT_EQ(OK, rv); |
4309 | 4312 |
4310 response = trans->GetResponseInfo(); | 4313 response = trans->GetResponseInfo(); |
4311 ASSERT_TRUE(response != NULL); | 4314 ASSERT_TRUE(response != NULL); |
4312 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 4315 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
4313 } | 4316 } |
4314 | 4317 |
(...skipping 1753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6068 | 6071 |
6069 rv = callback1.WaitForResult(); | 6072 rv = callback1.WaitForResult(); |
6070 EXPECT_EQ(OK, rv); | 6073 EXPECT_EQ(OK, rv); |
6071 | 6074 |
6072 const HttpResponseInfo* response = trans->GetResponseInfo(); | 6075 const HttpResponseInfo* response = trans->GetResponseInfo(); |
6073 ASSERT_TRUE(response != NULL); | 6076 ASSERT_TRUE(response != NULL); |
6074 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 6077 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
6075 | 6078 |
6076 TestOldCompletionCallback callback2; | 6079 TestOldCompletionCallback callback2; |
6077 | 6080 |
6078 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); | 6081 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); |
6079 EXPECT_EQ(ERR_IO_PENDING, rv); | 6082 EXPECT_EQ(ERR_IO_PENDING, rv); |
6080 | 6083 |
6081 rv = callback2.WaitForResult(); | 6084 rv = callback2.WaitForResult(); |
6082 EXPECT_EQ(OK, rv); | 6085 EXPECT_EQ(OK, rv); |
6083 | 6086 |
6084 response = trans->GetResponseInfo(); | 6087 response = trans->GetResponseInfo(); |
6085 ASSERT_TRUE(response != NULL); | 6088 ASSERT_TRUE(response != NULL); |
6086 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 6089 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
6087 EXPECT_EQ(100, response->headers->GetContentLength()); | 6090 EXPECT_EQ(100, response->headers->GetContentLength()); |
6088 } | 6091 } |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6331 ASSERT_TRUE(response != NULL); | 6334 ASSERT_TRUE(response != NULL); |
6332 ASSERT_TRUE(response->headers != NULL); | 6335 ASSERT_TRUE(response->headers != NULL); |
6333 EXPECT_EQ("HTTP/1.1 401 Unauthorized", response->headers->GetStatusLine()); | 6336 EXPECT_EQ("HTTP/1.1 401 Unauthorized", response->headers->GetStatusLine()); |
6334 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); | 6337 EXPECT_TRUE(CheckBasicServerAuth(response->auth_challenge.get())); |
6335 | 6338 |
6336 // Now make the file unreadable and try again. | 6339 // Now make the file unreadable and try again. |
6337 ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file)); | 6340 ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file)); |
6338 | 6341 |
6339 TestOldCompletionCallback callback2; | 6342 TestOldCompletionCallback callback2; |
6340 | 6343 |
6341 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); | 6344 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback2); |
6342 EXPECT_EQ(ERR_IO_PENDING, rv); | 6345 EXPECT_EQ(ERR_IO_PENDING, rv); |
6343 | 6346 |
6344 rv = callback2.WaitForResult(); | 6347 rv = callback2.WaitForResult(); |
6345 EXPECT_EQ(OK, rv); | 6348 EXPECT_EQ(OK, rv); |
6346 | 6349 |
6347 response = trans->GetResponseInfo(); | 6350 response = trans->GetResponseInfo(); |
6348 ASSERT_TRUE(response != NULL); | 6351 ASSERT_TRUE(response != NULL); |
6349 EXPECT_TRUE(response->headers != NULL); | 6352 EXPECT_TRUE(response->headers != NULL); |
6350 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 6353 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
6351 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 6354 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6454 ASSERT_FALSE(challenge == NULL); | 6457 ASSERT_FALSE(challenge == NULL); |
6455 EXPECT_FALSE(challenge->is_proxy); | 6458 EXPECT_FALSE(challenge->is_proxy); |
6456 EXPECT_EQ("www.google.com:80", challenge->challenger.ToString()); | 6459 EXPECT_EQ("www.google.com:80", challenge->challenger.ToString()); |
6457 EXPECT_EQ("first_realm", challenge->realm); | 6460 EXPECT_EQ("first_realm", challenge->realm); |
6458 EXPECT_EQ("basic", challenge->scheme); | 6461 EXPECT_EQ("basic", challenge->scheme); |
6459 | 6462 |
6460 // Issue the second request with an incorrect password. There should be a | 6463 // Issue the second request with an incorrect password. There should be a |
6461 // password prompt for second_realm waiting to be filled in after the | 6464 // password prompt for second_realm waiting to be filled in after the |
6462 // transaction completes. | 6465 // transaction completes. |
6463 TestOldCompletionCallback callback2; | 6466 TestOldCompletionCallback callback2; |
6464 rv = trans->RestartWithAuth(kFirst, kBaz, &callback2); | 6467 rv = trans->RestartWithAuth(AuthCredentials(kFirst, kBaz), &callback2); |
6465 EXPECT_EQ(ERR_IO_PENDING, rv); | 6468 EXPECT_EQ(ERR_IO_PENDING, rv); |
6466 rv = callback2.WaitForResult(); | 6469 rv = callback2.WaitForResult(); |
6467 EXPECT_EQ(OK, rv); | 6470 EXPECT_EQ(OK, rv); |
6468 response = trans->GetResponseInfo(); | 6471 response = trans->GetResponseInfo(); |
6469 ASSERT_TRUE(response != NULL); | 6472 ASSERT_TRUE(response != NULL); |
6470 challenge = response->auth_challenge.get(); | 6473 challenge = response->auth_challenge.get(); |
6471 ASSERT_FALSE(challenge == NULL); | 6474 ASSERT_FALSE(challenge == NULL); |
6472 EXPECT_FALSE(challenge->is_proxy); | 6475 EXPECT_FALSE(challenge->is_proxy); |
6473 EXPECT_EQ("www.google.com:80", challenge->challenger.ToString()); | 6476 EXPECT_EQ("www.google.com:80", challenge->challenger.ToString()); |
6474 EXPECT_EQ("second_realm", challenge->realm); | 6477 EXPECT_EQ("second_realm", challenge->realm); |
6475 EXPECT_EQ("basic", challenge->scheme); | 6478 EXPECT_EQ("basic", challenge->scheme); |
6476 | 6479 |
6477 // Issue the third request with another incorrect password. There should be | 6480 // Issue the third request with another incorrect password. There should be |
6478 // a password prompt for first_realm waiting to be filled in. If the password | 6481 // a password prompt for first_realm waiting to be filled in. If the password |
6479 // prompt is not present, it indicates that the HttpAuthCacheEntry for | 6482 // prompt is not present, it indicates that the HttpAuthCacheEntry for |
6480 // first_realm was not correctly removed. | 6483 // first_realm was not correctly removed. |
6481 TestOldCompletionCallback callback3; | 6484 TestOldCompletionCallback callback3; |
6482 rv = trans->RestartWithAuth(kSecond, kFou, &callback3); | 6485 rv = trans->RestartWithAuth(AuthCredentials(kSecond, kFou), &callback3); |
6483 EXPECT_EQ(ERR_IO_PENDING, rv); | 6486 EXPECT_EQ(ERR_IO_PENDING, rv); |
6484 rv = callback3.WaitForResult(); | 6487 rv = callback3.WaitForResult(); |
6485 EXPECT_EQ(OK, rv); | 6488 EXPECT_EQ(OK, rv); |
6486 response = trans->GetResponseInfo(); | 6489 response = trans->GetResponseInfo(); |
6487 ASSERT_TRUE(response != NULL); | 6490 ASSERT_TRUE(response != NULL); |
6488 challenge = response->auth_challenge.get(); | 6491 challenge = response->auth_challenge.get(); |
6489 ASSERT_FALSE(challenge == NULL); | 6492 ASSERT_FALSE(challenge == NULL); |
6490 EXPECT_FALSE(challenge->is_proxy); | 6493 EXPECT_FALSE(challenge->is_proxy); |
6491 EXPECT_EQ("www.google.com:80", challenge->challenger.ToString()); | 6494 EXPECT_EQ("www.google.com:80", challenge->challenger.ToString()); |
6492 EXPECT_EQ("first_realm", challenge->realm); | 6495 EXPECT_EQ("first_realm", challenge->realm); |
6493 EXPECT_EQ("basic", challenge->scheme); | 6496 EXPECT_EQ("basic", challenge->scheme); |
6494 | 6497 |
6495 // Issue the fourth request with the correct password and username. | 6498 // Issue the fourth request with the correct password and username. |
6496 TestOldCompletionCallback callback4; | 6499 TestOldCompletionCallback callback4; |
6497 rv = trans->RestartWithAuth(kFirst, kBar, &callback4); | 6500 rv = trans->RestartWithAuth(AuthCredentials(kFirst, kBar), &callback4); |
6498 EXPECT_EQ(ERR_IO_PENDING, rv); | 6501 EXPECT_EQ(ERR_IO_PENDING, rv); |
6499 rv = callback4.WaitForResult(); | 6502 rv = callback4.WaitForResult(); |
6500 EXPECT_EQ(OK, rv); | 6503 EXPECT_EQ(OK, rv); |
6501 response = trans->GetResponseInfo(); | 6504 response = trans->GetResponseInfo(); |
6502 ASSERT_TRUE(response != NULL); | 6505 ASSERT_TRUE(response != NULL); |
6503 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 6506 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
6504 } | 6507 } |
6505 | 6508 |
6506 TEST_F(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) { | 6509 TEST_F(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) { |
6507 HttpStreamFactory::set_next_protos(MakeNextProtos("foo", "bar", NULL)); | 6510 HttpStreamFactory::set_next_protos(MakeNextProtos("foo", "bar", NULL)); |
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7753 if (round >= test_config.first_ssl_round) | 7756 if (round >= test_config.first_ssl_round) |
7754 session_deps.socket_factory.AddSSLSocketDataProvider( | 7757 session_deps.socket_factory.AddSSLSocketDataProvider( |
7755 &ssl_socket_data_provider); | 7758 &ssl_socket_data_provider); |
7756 | 7759 |
7757 // Start or restart the transaction. | 7760 // Start or restart the transaction. |
7758 TestOldCompletionCallback callback; | 7761 TestOldCompletionCallback callback; |
7759 int rv; | 7762 int rv; |
7760 if (round == 0) { | 7763 if (round == 0) { |
7761 rv = trans.Start(&request, &callback, BoundNetLog()); | 7764 rv = trans.Start(&request, &callback, BoundNetLog()); |
7762 } else { | 7765 } else { |
7763 rv = trans.RestartWithAuth(kFoo, kBar, &callback); | 7766 rv = trans.RestartWithAuth(AuthCredentials(kFoo, kBar), &callback); |
7764 } | 7767 } |
7765 if (rv == ERR_IO_PENDING) | 7768 if (rv == ERR_IO_PENDING) |
7766 rv = callback.WaitForResult(); | 7769 rv = callback.WaitForResult(); |
7767 | 7770 |
7768 // Compare results with expected data. | 7771 // Compare results with expected data. |
7769 EXPECT_EQ(read_write_round.expected_rv, rv); | 7772 EXPECT_EQ(read_write_round.expected_rv, rv); |
7770 const HttpResponseInfo* response = trans.GetResponseInfo(); | 7773 const HttpResponseInfo* response = trans.GetResponseInfo(); |
7771 if (read_write_round.expected_rv == OK) { | 7774 if (read_write_round.expected_rv == OK) { |
7772 ASSERT_TRUE(response != NULL); | 7775 ASSERT_TRUE(response != NULL); |
7773 } else { | 7776 } else { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7900 new HttpNetworkTransaction(session)); | 7903 new HttpNetworkTransaction(session)); |
7901 TestOldCompletionCallback callback_compete; | 7904 TestOldCompletionCallback callback_compete; |
7902 rv = trans_compete->Start(&request, &callback_compete, BoundNetLog()); | 7905 rv = trans_compete->Start(&request, &callback_compete, BoundNetLog()); |
7903 EXPECT_EQ(ERR_IO_PENDING, rv); | 7906 EXPECT_EQ(ERR_IO_PENDING, rv); |
7904 // callback_compete.WaitForResult at this point would stall forever, | 7907 // callback_compete.WaitForResult at this point would stall forever, |
7905 // since the HttpNetworkTransaction does not release the request back to | 7908 // since the HttpNetworkTransaction does not release the request back to |
7906 // the pool until after authentication completes. | 7909 // the pool until after authentication completes. |
7907 | 7910 |
7908 // Second round of authentication. | 7911 // Second round of authentication. |
7909 auth_handler->SetGenerateExpectation(false, OK); | 7912 auth_handler->SetGenerateExpectation(false, OK); |
7910 rv = trans->RestartWithAuth(kFoo, kBar, &callback); | 7913 rv = trans->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback); |
7911 if (rv == ERR_IO_PENDING) | 7914 if (rv == ERR_IO_PENDING) |
7912 rv = callback.WaitForResult(); | 7915 rv = callback.WaitForResult(); |
7913 EXPECT_EQ(OK, rv); | 7916 EXPECT_EQ(OK, rv); |
7914 response = trans->GetResponseInfo(); | 7917 response = trans->GetResponseInfo(); |
7915 ASSERT_TRUE(response != NULL); | 7918 ASSERT_TRUE(response != NULL); |
7916 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 7919 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
7917 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 7920 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
7918 | 7921 |
7919 // Third round of authentication. | 7922 // Third round of authentication. |
7920 auth_handler->SetGenerateExpectation(false, OK); | 7923 auth_handler->SetGenerateExpectation(false, OK); |
7921 rv = trans->RestartWithAuth(string16(), string16(), &callback); | 7924 rv = trans->RestartWithAuth(AuthCredentials(), &callback); |
7922 if (rv == ERR_IO_PENDING) | 7925 if (rv == ERR_IO_PENDING) |
7923 rv = callback.WaitForResult(); | 7926 rv = callback.WaitForResult(); |
7924 EXPECT_EQ(OK, rv); | 7927 EXPECT_EQ(OK, rv); |
7925 response = trans->GetResponseInfo(); | 7928 response = trans->GetResponseInfo(); |
7926 ASSERT_TRUE(response != NULL); | 7929 ASSERT_TRUE(response != NULL); |
7927 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 7930 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
7928 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 7931 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
7929 | 7932 |
7930 // Fourth round of authentication, which completes successfully. | 7933 // Fourth round of authentication, which completes successfully. |
7931 auth_handler->SetGenerateExpectation(false, OK); | 7934 auth_handler->SetGenerateExpectation(false, OK); |
7932 rv = trans->RestartWithAuth(string16(), string16(), &callback); | 7935 rv = trans->RestartWithAuth(AuthCredentials(), &callback); |
7933 if (rv == ERR_IO_PENDING) | 7936 if (rv == ERR_IO_PENDING) |
7934 rv = callback.WaitForResult(); | 7937 rv = callback.WaitForResult(); |
7935 EXPECT_EQ(OK, rv); | 7938 EXPECT_EQ(OK, rv); |
7936 response = trans->GetResponseInfo(); | 7939 response = trans->GetResponseInfo(); |
7937 ASSERT_TRUE(response != NULL); | 7940 ASSERT_TRUE(response != NULL); |
7938 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 7941 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
7939 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); | 7942 EXPECT_EQ(0, transport_pool->IdleSocketCountInGroup(kSocketGroup)); |
7940 | 7943 |
7941 // Read the body since the fourth round was successful. This will also | 7944 // Read the body since the fourth round was successful. This will also |
7942 // release the socket back to the pool. | 7945 // release the socket back to the pool. |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8315 scoped_ptr<HttpTransaction> trans_2(new HttpNetworkTransaction(session)); | 8318 scoped_ptr<HttpTransaction> trans_2(new HttpNetworkTransaction(session)); |
8316 rv = trans_2->Start(&request, &callback_2, BoundNetLog()); | 8319 rv = trans_2->Start(&request, &callback_2, BoundNetLog()); |
8317 EXPECT_EQ(ERR_IO_PENDING, rv); | 8320 EXPECT_EQ(ERR_IO_PENDING, rv); |
8318 EXPECT_EQ(OK, callback_2.WaitForResult()); | 8321 EXPECT_EQ(OK, callback_2.WaitForResult()); |
8319 const HttpResponseInfo* response = trans_2->GetResponseInfo(); | 8322 const HttpResponseInfo* response = trans_2->GetResponseInfo(); |
8320 ASSERT_TRUE(response != NULL); | 8323 ASSERT_TRUE(response != NULL); |
8321 ASSERT_FALSE(response->auth_challenge.get() == NULL); | 8324 ASSERT_FALSE(response->auth_challenge.get() == NULL); |
8322 | 8325 |
8323 // Restart with auth. Tunnel should work and response received. | 8326 // Restart with auth. Tunnel should work and response received. |
8324 TestOldCompletionCallback callback_3; | 8327 TestOldCompletionCallback callback_3; |
8325 rv = trans_2->RestartWithAuth(kFoo, kBar, &callback_3); | 8328 rv = trans_2->RestartWithAuth(AuthCredentials(kFoo, kBar), &callback_3); |
8326 EXPECT_EQ(ERR_IO_PENDING, rv); | 8329 EXPECT_EQ(ERR_IO_PENDING, rv); |
8327 EXPECT_EQ(OK, callback_3.WaitForResult()); | 8330 EXPECT_EQ(OK, callback_3.WaitForResult()); |
8328 | 8331 |
8329 // After all that work, these two lines (or actually, just the scheme) are | 8332 // After all that work, these two lines (or actually, just the scheme) are |
8330 // what this test is all about. Make sure it happens correctly. | 8333 // what this test is all about. Make sure it happens correctly. |
8331 const GURL& request_url = auth_handler->request_url(); | 8334 const GURL& request_url = auth_handler->request_url(); |
8332 EXPECT_EQ("https", request_url.scheme()); | 8335 EXPECT_EQ("https", request_url.scheme()); |
8333 EXPECT_EQ("www.google.com", request_url.host()); | 8336 EXPECT_EQ("www.google.com", request_url.host()); |
8334 | 8337 |
8335 HttpStreamFactory::set_next_protos(std::vector<std::string>()); | 8338 HttpStreamFactory::set_next_protos(std::vector<std::string>()); |
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9294 StaticSocketDataProvider* data[] = { &data1, &data2 }; | 9297 StaticSocketDataProvider* data[] = { &data1, &data2 }; |
9295 | 9298 |
9296 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data)); | 9299 SimpleGetHelperResult out = SimpleGetHelperForData(data, arraysize(data)); |
9297 | 9300 |
9298 EXPECT_EQ(OK, out.rv); | 9301 EXPECT_EQ(OK, out.rv); |
9299 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); | 9302 EXPECT_EQ("HTTP/1.0 200 OK", out.status_line); |
9300 EXPECT_EQ("hello world", out.response_data); | 9303 EXPECT_EQ("hello world", out.response_data); |
9301 } | 9304 } |
9302 | 9305 |
9303 } // namespace net | 9306 } // namespace net |
OLD | NEW |