OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <math.h> // ceil | 5 #include <math.h> // ceil |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "net/base/client_socket_factory.h" | 8 #include "net/base/client_socket_factory.h" |
9 #include "net/base/test_completion_callback.h" | 9 #include "net/base/test_completion_callback.h" |
10 #include "net/base/upload_data.h" | 10 #include "net/base/upload_data.h" |
(...skipping 1589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1600 MockRead("WWW-Authenticate: NTLM\r\n"), | 1600 MockRead("WWW-Authenticate: NTLM\r\n"), |
1601 MockRead("Connection: close\r\n"), | 1601 MockRead("Connection: close\r\n"), |
1602 MockRead("Content-Length: 42\r\n"), | 1602 MockRead("Content-Length: 42\r\n"), |
1603 MockRead("Content-Type: text/html\r\n"), | 1603 MockRead("Content-Type: text/html\r\n"), |
1604 MockRead("Proxy-Support: Session-Based-Authentication\r\n\r\n"), | 1604 MockRead("Proxy-Support: Session-Based-Authentication\r\n\r\n"), |
1605 // Missing content -- won't matter, as connection will be reset. | 1605 // Missing content -- won't matter, as connection will be reset. |
1606 MockRead(false, net::ERR_UNEXPECTED), | 1606 MockRead(false, net::ERR_UNEXPECTED), |
1607 }; | 1607 }; |
1608 | 1608 |
1609 MockWrite data_writes2[] = { | 1609 MockWrite data_writes2[] = { |
1610 // After automatically restarting with a null identity, this is the | 1610 // After restarting with a null identity, this is the |
1611 // request we should be issuing -- the final header line contains a Type | 1611 // request we should be issuing -- the final header line contains a Type |
1612 // 1 message. | 1612 // 1 message. |
1613 MockWrite("GET /kids/login.aspx HTTP/1.1\r\n" | 1613 MockWrite("GET /kids/login.aspx HTTP/1.1\r\n" |
1614 "Host: 172.22.68.17\r\n" | 1614 "Host: 172.22.68.17\r\n" |
1615 "Connection: keep-alive\r\n" | 1615 "Connection: keep-alive\r\n" |
1616 "Authorization: NTLM " | 1616 "Authorization: NTLM " |
1617 "TlRMTVNTUAABAAAAB4IIAAAAAAAAAAAAAAAAAAAAAAA=\r\n\r\n"), | 1617 "TlRMTVNTUAABAAAAB4IIAAAAAAAAAAAAAAAAAAAAAAA=\r\n\r\n"), |
1618 | 1618 |
1619 // After calling trans->RestartWithAuth(), we should send a Type 3 message | 1619 // After calling trans->RestartWithAuth(), we should send a Type 3 message |
1620 // (the credentials for the origin server). The second request continues | 1620 // (the credentials for the origin server). The second request continues |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1664 mock_sockets[2] = NULL; | 1664 mock_sockets[2] = NULL; |
1665 | 1665 |
1666 TestCompletionCallback callback1; | 1666 TestCompletionCallback callback1; |
1667 | 1667 |
1668 int rv = trans->Start(&request, &callback1); | 1668 int rv = trans->Start(&request, &callback1); |
1669 EXPECT_EQ(net::ERR_IO_PENDING, rv); | 1669 EXPECT_EQ(net::ERR_IO_PENDING, rv); |
1670 | 1670 |
1671 rv = callback1.WaitForResult(); | 1671 rv = callback1.WaitForResult(); |
1672 EXPECT_EQ(net::OK, rv); | 1672 EXPECT_EQ(net::OK, rv); |
1673 | 1673 |
| 1674 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| 1675 TestCompletionCallback callback2; |
| 1676 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); |
| 1677 EXPECT_EQ(net::ERR_IO_PENDING, rv); |
| 1678 rv = callback2.WaitForResult(); |
| 1679 EXPECT_EQ(net::OK, rv); |
| 1680 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 1681 |
1674 const net::HttpResponseInfo* response = trans->GetResponseInfo(); | 1682 const net::HttpResponseInfo* response = trans->GetResponseInfo(); |
1675 EXPECT_FALSE(response == NULL); | 1683 EXPECT_FALSE(response == NULL); |
1676 | 1684 |
1677 // The password prompt info should have been set in response->auth_challenge. | 1685 // The password prompt info should have been set in response->auth_challenge. |
1678 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 1686 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
1679 | 1687 |
1680 // TODO(eroman): this should really include the effective port (80) | 1688 // TODO(eroman): this should really include the effective port (80) |
1681 EXPECT_EQ(L"172.22.68.17", response->auth_challenge->host); | 1689 EXPECT_EQ(L"172.22.68.17", response->auth_challenge->host); |
1682 EXPECT_EQ(L"", response->auth_challenge->realm); | 1690 EXPECT_EQ(L"", response->auth_challenge->realm); |
1683 EXPECT_EQ(L"ntlm", response->auth_challenge->scheme); | 1691 EXPECT_EQ(L"ntlm", response->auth_challenge->scheme); |
1684 | 1692 |
1685 TestCompletionCallback callback2; | 1693 TestCompletionCallback callback3; |
1686 | 1694 |
1687 rv = trans->RestartWithAuth(L"testing-ntlm", L"testing-ntlm", &callback2); | 1695 rv = trans->RestartWithAuth(L"testing-ntlm", L"testing-ntlm", &callback3); |
1688 EXPECT_EQ(net::ERR_IO_PENDING, rv); | 1696 EXPECT_EQ(net::ERR_IO_PENDING, rv); |
1689 | 1697 |
1690 rv = callback2.WaitForResult(); | 1698 rv = callback3.WaitForResult(); |
1691 EXPECT_EQ(net::OK, rv); | 1699 EXPECT_EQ(net::OK, rv); |
1692 | 1700 |
1693 response = trans->GetResponseInfo(); | 1701 response = trans->GetResponseInfo(); |
1694 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1702 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
1695 EXPECT_EQ(13, response->headers->GetContentLength()); | 1703 EXPECT_EQ(13, response->headers->GetContentLength()); |
1696 } | 1704 } |
1697 | 1705 |
1698 // Enter a wrong password, and then the correct one. | 1706 // Enter a wrong password, and then the correct one. |
1699 TEST_F(HttpNetworkTransactionTest, NTLMAuth2) { | 1707 TEST_F(HttpNetworkTransactionTest, NTLMAuth2) { |
1700 net::HttpAuthHandlerNTLM::ScopedProcSetter proc_setter(MockGenerateRandom2, | 1708 net::HttpAuthHandlerNTLM::ScopedProcSetter proc_setter(MockGenerateRandom2, |
(...skipping 21 matching lines...) Expand all Loading... |
1722 MockRead("WWW-Authenticate: NTLM\r\n"), | 1730 MockRead("WWW-Authenticate: NTLM\r\n"), |
1723 MockRead("Connection: close\r\n"), | 1731 MockRead("Connection: close\r\n"), |
1724 MockRead("Content-Length: 42\r\n"), | 1732 MockRead("Content-Length: 42\r\n"), |
1725 MockRead("Content-Type: text/html\r\n"), | 1733 MockRead("Content-Type: text/html\r\n"), |
1726 MockRead("Proxy-Support: Session-Based-Authentication\r\n\r\n"), | 1734 MockRead("Proxy-Support: Session-Based-Authentication\r\n\r\n"), |
1727 // Missing content -- won't matter, as connection will be reset. | 1735 // Missing content -- won't matter, as connection will be reset. |
1728 MockRead(false, net::ERR_UNEXPECTED), | 1736 MockRead(false, net::ERR_UNEXPECTED), |
1729 }; | 1737 }; |
1730 | 1738 |
1731 MockWrite data_writes2[] = { | 1739 MockWrite data_writes2[] = { |
1732 // After automatically restarting with a null identity, this is the | 1740 // After restarting with a null identity, this is the |
1733 // request we should be issuing -- the final header line contains a Type | 1741 // request we should be issuing -- the final header line contains a Type |
1734 // 1 message. | 1742 // 1 message. |
1735 MockWrite("GET /kids/login.aspx HTTP/1.1\r\n" | 1743 MockWrite("GET /kids/login.aspx HTTP/1.1\r\n" |
1736 "Host: 172.22.68.17\r\n" | 1744 "Host: 172.22.68.17\r\n" |
1737 "Connection: keep-alive\r\n" | 1745 "Connection: keep-alive\r\n" |
1738 "Authorization: NTLM " | 1746 "Authorization: NTLM " |
1739 "TlRMTVNTUAABAAAAB4IIAAAAAAAAAAAAAAAAAAAAAAA=\r\n\r\n"), | 1747 "TlRMTVNTUAABAAAAB4IIAAAAAAAAAAAAAAAAAAAAAAA=\r\n\r\n"), |
1740 | 1748 |
1741 // After calling trans->RestartWithAuth(), we should send a Type 3 message | 1749 // After calling trans->RestartWithAuth(), we should send a Type 3 message |
1742 // (the credentials for the origin server). The second request continues | 1750 // (the credentials for the origin server). The second request continues |
(...skipping 30 matching lines...) Expand all Loading... |
1773 MockRead("WWW-Authenticate: NTLM\r\n"), | 1781 MockRead("WWW-Authenticate: NTLM\r\n"), |
1774 MockRead("Connection: close\r\n"), | 1782 MockRead("Connection: close\r\n"), |
1775 MockRead("Content-Length: 42\r\n"), | 1783 MockRead("Content-Length: 42\r\n"), |
1776 MockRead("Content-Type: text/html\r\n"), | 1784 MockRead("Content-Type: text/html\r\n"), |
1777 MockRead("Proxy-Support: Session-Based-Authentication\r\n\r\n"), | 1785 MockRead("Proxy-Support: Session-Based-Authentication\r\n\r\n"), |
1778 // Missing content -- won't matter, as connection will be reset. | 1786 // Missing content -- won't matter, as connection will be reset. |
1779 MockRead(false, net::ERR_UNEXPECTED), | 1787 MockRead(false, net::ERR_UNEXPECTED), |
1780 }; | 1788 }; |
1781 | 1789 |
1782 MockWrite data_writes3[] = { | 1790 MockWrite data_writes3[] = { |
1783 // After automatically restarting with a null identity, this is the | 1791 // After restarting with a null identity, this is the |
1784 // request we should be issuing -- the final header line contains a Type | 1792 // request we should be issuing -- the final header line contains a Type |
1785 // 1 message. | 1793 // 1 message. |
1786 MockWrite("GET /kids/login.aspx HTTP/1.1\r\n" | 1794 MockWrite("GET /kids/login.aspx HTTP/1.1\r\n" |
1787 "Host: 172.22.68.17\r\n" | 1795 "Host: 172.22.68.17\r\n" |
1788 "Connection: keep-alive\r\n" | 1796 "Connection: keep-alive\r\n" |
1789 "Authorization: NTLM " | 1797 "Authorization: NTLM " |
1790 "TlRMTVNTUAABAAAAB4IIAAAAAAAAAAAAAAAAAAAAAAA=\r\n\r\n"), | 1798 "TlRMTVNTUAABAAAAB4IIAAAAAAAAAAAAAAAAAAAAAAA=\r\n\r\n"), |
1791 | 1799 |
1792 // After calling trans->RestartWithAuth(), we should send a Type 3 message | 1800 // After calling trans->RestartWithAuth(), we should send a Type 3 message |
1793 // (the credentials for the origin server). The second request continues | 1801 // (the credentials for the origin server). The second request continues |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1841 mock_sockets[3] = NULL; | 1849 mock_sockets[3] = NULL; |
1842 | 1850 |
1843 TestCompletionCallback callback1; | 1851 TestCompletionCallback callback1; |
1844 | 1852 |
1845 int rv = trans->Start(&request, &callback1); | 1853 int rv = trans->Start(&request, &callback1); |
1846 EXPECT_EQ(net::ERR_IO_PENDING, rv); | 1854 EXPECT_EQ(net::ERR_IO_PENDING, rv); |
1847 | 1855 |
1848 rv = callback1.WaitForResult(); | 1856 rv = callback1.WaitForResult(); |
1849 EXPECT_EQ(net::OK, rv); | 1857 EXPECT_EQ(net::OK, rv); |
1850 | 1858 |
| 1859 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| 1860 TestCompletionCallback callback2; |
| 1861 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); |
| 1862 EXPECT_EQ(net::ERR_IO_PENDING, rv); |
| 1863 rv = callback2.WaitForResult(); |
| 1864 EXPECT_EQ(net::OK, rv); |
| 1865 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 1866 |
1851 const net::HttpResponseInfo* response = trans->GetResponseInfo(); | 1867 const net::HttpResponseInfo* response = trans->GetResponseInfo(); |
1852 EXPECT_FALSE(response == NULL); | 1868 EXPECT_FALSE(response == NULL); |
1853 | 1869 |
1854 // The password prompt info should have been set in response->auth_challenge. | 1870 // The password prompt info should have been set in response->auth_challenge. |
1855 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 1871 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
1856 | 1872 |
1857 // TODO(eroman): this should really include the effective port (80) | 1873 // TODO(eroman): this should really include the effective port (80) |
1858 EXPECT_EQ(L"172.22.68.17", response->auth_challenge->host); | 1874 EXPECT_EQ(L"172.22.68.17", response->auth_challenge->host); |
1859 EXPECT_EQ(L"", response->auth_challenge->realm); | 1875 EXPECT_EQ(L"", response->auth_challenge->realm); |
1860 EXPECT_EQ(L"ntlm", response->auth_challenge->scheme); | 1876 EXPECT_EQ(L"ntlm", response->auth_challenge->scheme); |
1861 | 1877 |
1862 TestCompletionCallback callback2; | 1878 TestCompletionCallback callback3; |
1863 | 1879 |
1864 // Enter the wrong password. | 1880 // Enter the wrong password. |
1865 rv = trans->RestartWithAuth(L"testing-ntlm", L"wrongpassword", &callback2); | 1881 rv = trans->RestartWithAuth(L"testing-ntlm", L"wrongpassword", &callback3); |
1866 EXPECT_EQ(net::ERR_IO_PENDING, rv); | 1882 EXPECT_EQ(net::ERR_IO_PENDING, rv); |
1867 | 1883 |
1868 rv = callback2.WaitForResult(); | 1884 rv = callback3.WaitForResult(); |
1869 EXPECT_EQ(net::OK, rv); | 1885 EXPECT_EQ(net::OK, rv); |
1870 | 1886 |
| 1887 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| 1888 TestCompletionCallback callback4; |
| 1889 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback4); |
| 1890 EXPECT_EQ(net::ERR_IO_PENDING, rv); |
| 1891 rv = callback4.WaitForResult(); |
| 1892 EXPECT_EQ(net::OK, rv); |
| 1893 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 1894 |
1871 response = trans->GetResponseInfo(); | 1895 response = trans->GetResponseInfo(); |
1872 EXPECT_FALSE(response == NULL); | 1896 EXPECT_FALSE(response == NULL); |
1873 | 1897 |
1874 // The password prompt info should have been set in response->auth_challenge. | 1898 // The password prompt info should have been set in response->auth_challenge. |
1875 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 1899 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
1876 | 1900 |
1877 // TODO(eroman): this should really include the effective port (80) | 1901 // TODO(eroman): this should really include the effective port (80) |
1878 EXPECT_EQ(L"172.22.68.17", response->auth_challenge->host); | 1902 EXPECT_EQ(L"172.22.68.17", response->auth_challenge->host); |
1879 EXPECT_EQ(L"", response->auth_challenge->realm); | 1903 EXPECT_EQ(L"", response->auth_challenge->realm); |
1880 EXPECT_EQ(L"ntlm", response->auth_challenge->scheme); | 1904 EXPECT_EQ(L"ntlm", response->auth_challenge->scheme); |
1881 | 1905 |
1882 TestCompletionCallback callback3; | 1906 TestCompletionCallback callback5; |
1883 | 1907 |
1884 // Now enter the right password. | 1908 // Now enter the right password. |
1885 rv = trans->RestartWithAuth(L"testing-ntlm", L"testing-ntlm", &callback3); | 1909 rv = trans->RestartWithAuth(L"testing-ntlm", L"testing-ntlm", &callback5); |
1886 EXPECT_EQ(net::ERR_IO_PENDING, rv); | 1910 EXPECT_EQ(net::ERR_IO_PENDING, rv); |
1887 | 1911 |
1888 rv = callback3.WaitForResult(); | 1912 rv = callback5.WaitForResult(); |
1889 EXPECT_EQ(net::OK, rv); | 1913 EXPECT_EQ(net::OK, rv); |
1890 | 1914 |
1891 response = trans->GetResponseInfo(); | 1915 response = trans->GetResponseInfo(); |
1892 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1916 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
1893 EXPECT_EQ(13, response->headers->GetContentLength()); | 1917 EXPECT_EQ(13, response->headers->GetContentLength()); |
1894 } | 1918 } |
1895 | 1919 |
1896 // Test reading a server response which has only headers, and no body. | 1920 // Test reading a server response which has only headers, and no body. |
1897 // After some maximum number of bytes is consumed, the transaction should | 1921 // After some maximum number of bytes is consumed, the transaction should |
1898 // fail with ERR_RESPONSE_HEADERS_TOO_BIG. | 1922 // fail with ERR_RESPONSE_HEADERS_TOO_BIG. |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2136 mock_sockets[2] = NULL; | 2160 mock_sockets[2] = NULL; |
2137 | 2161 |
2138 TestCompletionCallback callback1; | 2162 TestCompletionCallback callback1; |
2139 | 2163 |
2140 int rv = trans->Start(&request, &callback1); | 2164 int rv = trans->Start(&request, &callback1); |
2141 EXPECT_EQ(net::ERR_IO_PENDING, rv); | 2165 EXPECT_EQ(net::ERR_IO_PENDING, rv); |
2142 | 2166 |
2143 rv = callback1.WaitForResult(); | 2167 rv = callback1.WaitForResult(); |
2144 EXPECT_EQ(net::OK, rv); | 2168 EXPECT_EQ(net::OK, rv); |
2145 | 2169 |
| 2170 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| 2171 TestCompletionCallback callback2; |
| 2172 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); |
| 2173 EXPECT_EQ(net::ERR_IO_PENDING, rv); |
| 2174 rv = callback2.WaitForResult(); |
| 2175 EXPECT_EQ(net::OK, rv); |
| 2176 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 2177 |
2146 const net::HttpResponseInfo* response = trans->GetResponseInfo(); | 2178 const net::HttpResponseInfo* response = trans->GetResponseInfo(); |
2147 EXPECT_FALSE(response == NULL); | 2179 EXPECT_FALSE(response == NULL); |
2148 | 2180 |
2149 // There is no challenge info, since the identity in URL worked. | 2181 // There is no challenge info, since the identity in URL worked. |
2150 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 2182 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
2151 | 2183 |
2152 EXPECT_EQ(100, response->headers->GetContentLength()); | 2184 EXPECT_EQ(100, response->headers->GetContentLength()); |
2153 | 2185 |
2154 // Empty the current queue. | 2186 // Empty the current queue. |
2155 MessageLoop::current()->RunAllPending(); | 2187 MessageLoop::current()->RunAllPending(); |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2439 mock_sockets[2] = NULL; | 2471 mock_sockets[2] = NULL; |
2440 | 2472 |
2441 TestCompletionCallback callback1; | 2473 TestCompletionCallback callback1; |
2442 | 2474 |
2443 int rv = trans->Start(&request, &callback1); | 2475 int rv = trans->Start(&request, &callback1); |
2444 EXPECT_EQ(net::ERR_IO_PENDING, rv); | 2476 EXPECT_EQ(net::ERR_IO_PENDING, rv); |
2445 | 2477 |
2446 rv = callback1.WaitForResult(); | 2478 rv = callback1.WaitForResult(); |
2447 EXPECT_EQ(net::OK, rv); | 2479 EXPECT_EQ(net::OK, rv); |
2448 | 2480 |
| 2481 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| 2482 TestCompletionCallback callback2; |
| 2483 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); |
| 2484 EXPECT_EQ(net::ERR_IO_PENDING, rv); |
| 2485 rv = callback2.WaitForResult(); |
| 2486 EXPECT_EQ(net::OK, rv); |
| 2487 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 2488 |
2449 const net::HttpResponseInfo* response = trans->GetResponseInfo(); | 2489 const net::HttpResponseInfo* response = trans->GetResponseInfo(); |
2450 EXPECT_FALSE(response == NULL); | 2490 EXPECT_FALSE(response == NULL); |
2451 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 2491 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
2452 EXPECT_EQ(100, response->headers->GetContentLength()); | 2492 EXPECT_EQ(100, response->headers->GetContentLength()); |
2453 } | 2493 } |
2454 | 2494 |
2455 // ------------------------------------------------------------------------ | 2495 // ------------------------------------------------------------------------ |
2456 | 2496 |
2457 // Transaction 5: request a URL in MyRealm, but the server rejects the | 2497 // Transaction 5: request a URL in MyRealm, but the server rejects the |
2458 // cached identity. Should invalidate and re-prompt. | 2498 // cached identity. Should invalidate and re-prompt. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2526 mock_sockets[3] = NULL; | 2566 mock_sockets[3] = NULL; |
2527 | 2567 |
2528 TestCompletionCallback callback1; | 2568 TestCompletionCallback callback1; |
2529 | 2569 |
2530 int rv = trans->Start(&request, &callback1); | 2570 int rv = trans->Start(&request, &callback1); |
2531 EXPECT_EQ(net::ERR_IO_PENDING, rv); | 2571 EXPECT_EQ(net::ERR_IO_PENDING, rv); |
2532 | 2572 |
2533 rv = callback1.WaitForResult(); | 2573 rv = callback1.WaitForResult(); |
2534 EXPECT_EQ(net::OK, rv); | 2574 EXPECT_EQ(net::OK, rv); |
2535 | 2575 |
| 2576 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
| 2577 TestCompletionCallback callback2; |
| 2578 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); |
| 2579 EXPECT_EQ(net::ERR_IO_PENDING, rv); |
| 2580 rv = callback2.WaitForResult(); |
| 2581 EXPECT_EQ(net::OK, rv); |
| 2582 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
| 2583 |
2536 const net::HttpResponseInfo* response = trans->GetResponseInfo(); | 2584 const net::HttpResponseInfo* response = trans->GetResponseInfo(); |
2537 EXPECT_FALSE(response == NULL); | 2585 EXPECT_FALSE(response == NULL); |
2538 | 2586 |
2539 // The password prompt info should have been set in | 2587 // The password prompt info should have been set in |
2540 // response->auth_challenge. | 2588 // response->auth_challenge. |
2541 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 2589 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
2542 | 2590 |
2543 // TODO(eroman): this should really include the effective port (80) | 2591 // TODO(eroman): this should really include the effective port (80) |
2544 EXPECT_EQ(L"www.google.com", response->auth_challenge->host); | 2592 EXPECT_EQ(L"www.google.com", response->auth_challenge->host); |
2545 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); | 2593 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); |
2546 EXPECT_EQ(L"basic", response->auth_challenge->scheme); | 2594 EXPECT_EQ(L"basic", response->auth_challenge->scheme); |
2547 | 2595 |
2548 TestCompletionCallback callback2; | 2596 TestCompletionCallback callback3; |
2549 | 2597 |
2550 rv = trans->RestartWithAuth(L"foo3", L"bar3", &callback2); | 2598 rv = trans->RestartWithAuth(L"foo3", L"bar3", &callback3); |
2551 EXPECT_EQ(net::ERR_IO_PENDING, rv); | 2599 EXPECT_EQ(net::ERR_IO_PENDING, rv); |
2552 | 2600 |
2553 rv = callback2.WaitForResult(); | 2601 rv = callback3.WaitForResult(); |
2554 EXPECT_EQ(net::OK, rv); | 2602 EXPECT_EQ(net::OK, rv); |
2555 | 2603 |
2556 response = trans->GetResponseInfo(); | 2604 response = trans->GetResponseInfo(); |
2557 EXPECT_FALSE(response == NULL); | 2605 EXPECT_FALSE(response == NULL); |
2558 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 2606 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
2559 EXPECT_EQ(100, response->headers->GetContentLength()); | 2607 EXPECT_EQ(100, response->headers->GetContentLength()); |
2560 } | 2608 } |
2561 } | 2609 } |
2562 | 2610 |
2563 // Test the ResetStateForRestart() private method. | 2611 // Test the ResetStateForRestart() private method. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2613 EXPECT_EQ(NULL, trans->response_.auth_challenge.get()); | 2661 EXPECT_EQ(NULL, trans->response_.auth_challenge.get()); |
2614 EXPECT_EQ(NULL, trans->response_.headers.get()); | 2662 EXPECT_EQ(NULL, trans->response_.headers.get()); |
2615 EXPECT_EQ(false, trans->response_.was_cached); | 2663 EXPECT_EQ(false, trans->response_.was_cached); |
2616 EXPECT_EQ(base::kInvalidPlatformFileValue, | 2664 EXPECT_EQ(base::kInvalidPlatformFileValue, |
2617 trans->response_.response_data_file); | 2665 trans->response_.response_data_file); |
2618 EXPECT_EQ(0, trans->response_.ssl_info.cert_status); | 2666 EXPECT_EQ(0, trans->response_.ssl_info.cert_status); |
2619 EXPECT_FALSE(trans->response_.vary_data.is_valid()); | 2667 EXPECT_FALSE(trans->response_.vary_data.is_valid()); |
2620 } | 2668 } |
2621 | 2669 |
2622 } // namespace net | 2670 } // namespace net |
OLD | NEW |