OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include "net/socket/ssl_client_socket.h" | 37 #include "net/socket/ssl_client_socket.h" |
38 #include "net/spdy/spdy_framer.h" | 38 #include "net/spdy/spdy_framer.h" |
39 #include "net/spdy/spdy_session.h" | 39 #include "net/spdy/spdy_session.h" |
40 #include "net/spdy/spdy_session_pool.h" | 40 #include "net/spdy/spdy_session_pool.h" |
41 #include "net/spdy/spdy_test_util.h" | 41 #include "net/spdy/spdy_test_util.h" |
42 #include "testing/gtest/include/gtest/gtest.h" | 42 #include "testing/gtest/include/gtest/gtest.h" |
43 #include "testing/platform_test.h" | 43 #include "testing/platform_test.h" |
44 | 44 |
45 //----------------------------------------------------------------------------- | 45 //----------------------------------------------------------------------------- |
46 | 46 |
| 47 namespace { |
| 48 |
| 49 const string16 kBar(ASCIIToUTF16("bar")); |
| 50 const string16 kBar2(ASCIIToUTF16("bar2")); |
| 51 const string16 kBar3(ASCIIToUTF16("bar3")); |
| 52 const string16 kBaz(ASCIIToUTF16("baz")); |
| 53 const string16 kFirst(ASCIIToUTF16("first")); |
| 54 const string16 kFoo(ASCIIToUTF16("foo")); |
| 55 const string16 kFoo2(ASCIIToUTF16("foo2")); |
| 56 const string16 kFoo3(ASCIIToUTF16("foo3")); |
| 57 const string16 kFou(ASCIIToUTF16("fou")); |
| 58 const string16 kSecond(ASCIIToUTF16("second")); |
| 59 const string16 kTestingNTLM(ASCIIToUTF16("testing-ntlm")); |
| 60 const string16 kWrongPassword(ASCIIToUTF16("wrongpassword")); |
| 61 |
| 62 } // namespace |
| 63 |
47 namespace net { | 64 namespace net { |
48 | 65 |
49 class HttpNetworkSessionPeer { | 66 class HttpNetworkSessionPeer { |
50 public: | 67 public: |
51 explicit HttpNetworkSessionPeer( | 68 explicit HttpNetworkSessionPeer( |
52 const scoped_refptr<HttpNetworkSession>& session) | 69 const scoped_refptr<HttpNetworkSession>& session) |
53 : session_(session) {} | 70 : session_(session) {} |
54 | 71 |
55 void SetTCPSocketPool(const scoped_refptr<TCPClientSocketPool>& pool) { | 72 void SetTCPSocketPool(const scoped_refptr<TCPClientSocketPool>& pool) { |
56 session_->tcp_socket_pool_ = pool; | 73 session_->tcp_socket_pool_ = pool; |
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 | 955 |
939 // The password prompt info should have been set in response->auth_challenge. | 956 // The password prompt info should have been set in response->auth_challenge. |
940 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 957 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
941 | 958 |
942 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); | 959 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); |
943 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); | 960 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); |
944 EXPECT_EQ(L"basic", response->auth_challenge->scheme); | 961 EXPECT_EQ(L"basic", response->auth_challenge->scheme); |
945 | 962 |
946 TestCompletionCallback callback2; | 963 TestCompletionCallback callback2; |
947 | 964 |
948 rv = trans->RestartWithAuth(L"foo", L"bar", &callback2); | 965 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); |
949 EXPECT_EQ(ERR_IO_PENDING, rv); | 966 EXPECT_EQ(ERR_IO_PENDING, rv); |
950 | 967 |
951 rv = callback2.WaitForResult(); | 968 rv = callback2.WaitForResult(); |
952 EXPECT_EQ(OK, rv); | 969 EXPECT_EQ(OK, rv); |
953 | 970 |
954 response = trans->GetResponseInfo(); | 971 response = trans->GetResponseInfo(); |
955 EXPECT_FALSE(response == NULL); | 972 EXPECT_FALSE(response == NULL); |
956 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 973 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
957 EXPECT_EQ(100, response->headers->GetContentLength()); | 974 EXPECT_EQ(100, response->headers->GetContentLength()); |
958 } | 975 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1054 | 1071 |
1055 // The password prompt info should have been set in response->auth_challenge. | 1072 // The password prompt info should have been set in response->auth_challenge. |
1056 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 1073 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
1057 | 1074 |
1058 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); | 1075 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); |
1059 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); | 1076 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); |
1060 EXPECT_EQ(L"basic", response->auth_challenge->scheme); | 1077 EXPECT_EQ(L"basic", response->auth_challenge->scheme); |
1061 | 1078 |
1062 TestCompletionCallback callback2; | 1079 TestCompletionCallback callback2; |
1063 | 1080 |
1064 rv = trans->RestartWithAuth(L"foo", L"bar", &callback2); | 1081 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); |
1065 EXPECT_EQ(ERR_IO_PENDING, rv); | 1082 EXPECT_EQ(ERR_IO_PENDING, rv); |
1066 | 1083 |
1067 rv = callback2.WaitForResult(); | 1084 rv = callback2.WaitForResult(); |
1068 EXPECT_EQ(OK, rv); | 1085 EXPECT_EQ(OK, rv); |
1069 | 1086 |
1070 response = trans->GetResponseInfo(); | 1087 response = trans->GetResponseInfo(); |
1071 EXPECT_FALSE(response == NULL); | 1088 EXPECT_FALSE(response == NULL); |
1072 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1089 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
1073 EXPECT_EQ(100, response->headers->GetContentLength()); | 1090 EXPECT_EQ(100, response->headers->GetContentLength()); |
1074 } | 1091 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 | 1144 |
1128 // The password prompt info should have been set in response->auth_challenge. | 1145 // The password prompt info should have been set in response->auth_challenge. |
1129 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 1146 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
1130 | 1147 |
1131 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); | 1148 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); |
1132 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); | 1149 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); |
1133 EXPECT_EQ(L"basic", response->auth_challenge->scheme); | 1150 EXPECT_EQ(L"basic", response->auth_challenge->scheme); |
1134 | 1151 |
1135 TestCompletionCallback callback2; | 1152 TestCompletionCallback callback2; |
1136 | 1153 |
1137 rv = trans->RestartWithAuth(L"foo", L"bar", &callback2); | 1154 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); |
1138 EXPECT_EQ(ERR_IO_PENDING, rv); | 1155 EXPECT_EQ(ERR_IO_PENDING, rv); |
1139 | 1156 |
1140 rv = callback2.WaitForResult(); | 1157 rv = callback2.WaitForResult(); |
1141 EXPECT_EQ(OK, rv); | 1158 EXPECT_EQ(OK, rv); |
1142 | 1159 |
1143 response = trans->GetResponseInfo(); | 1160 response = trans->GetResponseInfo(); |
1144 EXPECT_FALSE(response == NULL); | 1161 EXPECT_FALSE(response == NULL); |
1145 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1162 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
1146 EXPECT_EQ(100, response->headers->GetContentLength()); | 1163 EXPECT_EQ(100, response->headers->GetContentLength()); |
1147 } | 1164 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 | 1225 |
1209 // The password prompt info should have been set in response->auth_challenge. | 1226 // The password prompt info should have been set in response->auth_challenge. |
1210 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 1227 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
1211 | 1228 |
1212 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); | 1229 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); |
1213 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); | 1230 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); |
1214 EXPECT_EQ(L"basic", response->auth_challenge->scheme); | 1231 EXPECT_EQ(L"basic", response->auth_challenge->scheme); |
1215 | 1232 |
1216 TestCompletionCallback callback2; | 1233 TestCompletionCallback callback2; |
1217 | 1234 |
1218 rv = trans->RestartWithAuth(L"foo", L"bar", &callback2); | 1235 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); |
1219 EXPECT_EQ(ERR_IO_PENDING, rv); | 1236 EXPECT_EQ(ERR_IO_PENDING, rv); |
1220 | 1237 |
1221 rv = callback2.WaitForResult(); | 1238 rv = callback2.WaitForResult(); |
1222 EXPECT_EQ(OK, rv); | 1239 EXPECT_EQ(OK, rv); |
1223 | 1240 |
1224 response = trans->GetResponseInfo(); | 1241 response = trans->GetResponseInfo(); |
1225 EXPECT_FALSE(response == NULL); | 1242 EXPECT_FALSE(response == NULL); |
1226 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1243 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
1227 EXPECT_EQ(100, response->headers->GetContentLength()); | 1244 EXPECT_EQ(100, response->headers->GetContentLength()); |
1228 } | 1245 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 | 1316 |
1300 // The password prompt info should have been set in response->auth_challenge. | 1317 // The password prompt info should have been set in response->auth_challenge. |
1301 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 1318 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
1302 | 1319 |
1303 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); | 1320 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); |
1304 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); | 1321 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); |
1305 EXPECT_EQ(L"basic", response->auth_challenge->scheme); | 1322 EXPECT_EQ(L"basic", response->auth_challenge->scheme); |
1306 | 1323 |
1307 TestCompletionCallback callback2; | 1324 TestCompletionCallback callback2; |
1308 | 1325 |
1309 rv = trans->RestartWithAuth(L"foo", L"bar", &callback2); | 1326 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); |
1310 EXPECT_EQ(ERR_IO_PENDING, rv); | 1327 EXPECT_EQ(ERR_IO_PENDING, rv); |
1311 | 1328 |
1312 rv = callback2.WaitForResult(); | 1329 rv = callback2.WaitForResult(); |
1313 EXPECT_EQ(OK, rv); | 1330 EXPECT_EQ(OK, rv); |
1314 | 1331 |
1315 response = trans->GetResponseInfo(); | 1332 response = trans->GetResponseInfo(); |
1316 ASSERT_FALSE(response == NULL); | 1333 ASSERT_FALSE(response == NULL); |
1317 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1334 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
1318 EXPECT_EQ(100, response->headers->GetContentLength()); | 1335 EXPECT_EQ(100, response->headers->GetContentLength()); |
1319 } | 1336 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 // The password prompt info should have been set in response->auth_challenge. | 1414 // The password prompt info should have been set in response->auth_challenge. |
1398 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 1415 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
1399 | 1416 |
1400 EXPECT_EQ(L"myproxy:70", response->auth_challenge->host_and_port); | 1417 EXPECT_EQ(L"myproxy:70", response->auth_challenge->host_and_port); |
1401 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); | 1418 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); |
1402 EXPECT_EQ(L"basic", response->auth_challenge->scheme); | 1419 EXPECT_EQ(L"basic", response->auth_challenge->scheme); |
1403 | 1420 |
1404 TestCompletionCallback callback2; | 1421 TestCompletionCallback callback2; |
1405 | 1422 |
1406 // Wrong password (should be "bar"). | 1423 // Wrong password (should be "bar"). |
1407 rv = trans->RestartWithAuth(L"foo", L"baz", &callback2); | 1424 rv = trans->RestartWithAuth(kFoo, kBaz, &callback2); |
1408 EXPECT_EQ(ERR_IO_PENDING, rv); | 1425 EXPECT_EQ(ERR_IO_PENDING, rv); |
1409 | 1426 |
1410 rv = callback2.WaitForResult(); | 1427 rv = callback2.WaitForResult(); |
1411 EXPECT_EQ(OK, rv); | 1428 EXPECT_EQ(OK, rv); |
1412 | 1429 |
1413 response = trans->GetResponseInfo(); | 1430 response = trans->GetResponseInfo(); |
1414 EXPECT_FALSE(response == NULL); | 1431 EXPECT_FALSE(response == NULL); |
1415 | 1432 |
1416 EXPECT_TRUE(response->headers->IsKeepAlive()); | 1433 EXPECT_TRUE(response->headers->IsKeepAlive()); |
1417 EXPECT_EQ(407, response->headers->response_code()); | 1434 EXPECT_EQ(407, response->headers->response_code()); |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1835 | 1852 |
1836 // The password prompt info should have been set in response->auth_challenge. | 1853 // The password prompt info should have been set in response->auth_challenge. |
1837 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 1854 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
1838 | 1855 |
1839 EXPECT_EQ(L"myproxy:70", response->auth_challenge->host_and_port); | 1856 EXPECT_EQ(L"myproxy:70", response->auth_challenge->host_and_port); |
1840 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); | 1857 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); |
1841 EXPECT_EQ(L"basic", response->auth_challenge->scheme); | 1858 EXPECT_EQ(L"basic", response->auth_challenge->scheme); |
1842 | 1859 |
1843 TestCompletionCallback callback2; | 1860 TestCompletionCallback callback2; |
1844 | 1861 |
1845 rv = trans->RestartWithAuth(L"foo", L"bar", &callback2); | 1862 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); |
1846 EXPECT_EQ(ERR_IO_PENDING, rv); | 1863 EXPECT_EQ(ERR_IO_PENDING, rv); |
1847 | 1864 |
1848 rv = callback2.WaitForResult(); | 1865 rv = callback2.WaitForResult(); |
1849 EXPECT_EQ(OK, rv); | 1866 EXPECT_EQ(OK, rv); |
1850 | 1867 |
1851 response = trans->GetResponseInfo(); | 1868 response = trans->GetResponseInfo(); |
1852 EXPECT_FALSE(response == NULL); | 1869 EXPECT_FALSE(response == NULL); |
1853 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 1870 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
1854 | 1871 |
1855 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); | 1872 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); |
1856 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); | 1873 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); |
1857 EXPECT_EQ(L"basic", response->auth_challenge->scheme); | 1874 EXPECT_EQ(L"basic", response->auth_challenge->scheme); |
1858 | 1875 |
1859 TestCompletionCallback callback3; | 1876 TestCompletionCallback callback3; |
1860 | 1877 |
1861 rv = trans->RestartWithAuth(L"foo2", L"bar2", &callback3); | 1878 rv = trans->RestartWithAuth(kFoo2, kBar2, &callback3); |
1862 EXPECT_EQ(ERR_IO_PENDING, rv); | 1879 EXPECT_EQ(ERR_IO_PENDING, rv); |
1863 | 1880 |
1864 rv = callback3.WaitForResult(); | 1881 rv = callback3.WaitForResult(); |
1865 EXPECT_EQ(OK, rv); | 1882 EXPECT_EQ(OK, rv); |
1866 | 1883 |
1867 response = trans->GetResponseInfo(); | 1884 response = trans->GetResponseInfo(); |
1868 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 1885 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
1869 EXPECT_EQ(100, response->headers->GetContentLength()); | 1886 EXPECT_EQ(100, response->headers->GetContentLength()); |
1870 } | 1887 } |
1871 | 1888 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1965 TestCompletionCallback callback1; | 1982 TestCompletionCallback callback1; |
1966 | 1983 |
1967 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 1984 int rv = trans->Start(&request, &callback1, BoundNetLog()); |
1968 EXPECT_EQ(ERR_IO_PENDING, rv); | 1985 EXPECT_EQ(ERR_IO_PENDING, rv); |
1969 | 1986 |
1970 rv = callback1.WaitForResult(); | 1987 rv = callback1.WaitForResult(); |
1971 EXPECT_EQ(OK, rv); | 1988 EXPECT_EQ(OK, rv); |
1972 | 1989 |
1973 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 1990 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
1974 TestCompletionCallback callback2; | 1991 TestCompletionCallback callback2; |
1975 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); | 1992 rv = trans->RestartWithAuth(string16(), string16(), &callback2); |
1976 EXPECT_EQ(ERR_IO_PENDING, rv); | 1993 EXPECT_EQ(ERR_IO_PENDING, rv); |
1977 rv = callback2.WaitForResult(); | 1994 rv = callback2.WaitForResult(); |
1978 EXPECT_EQ(OK, rv); | 1995 EXPECT_EQ(OK, rv); |
1979 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 1996 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
1980 | 1997 |
1981 const HttpResponseInfo* response = trans->GetResponseInfo(); | 1998 const HttpResponseInfo* response = trans->GetResponseInfo(); |
1982 ASSERT_FALSE(response == NULL); | 1999 ASSERT_FALSE(response == NULL); |
1983 | 2000 |
1984 // The password prompt info should have been set in | 2001 // The password prompt info should have been set in |
1985 // response->auth_challenge. | 2002 // response->auth_challenge. |
1986 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 2003 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
1987 | 2004 |
1988 EXPECT_EQ(L"172.22.68.17:80", response->auth_challenge->host_and_port); | 2005 EXPECT_EQ(L"172.22.68.17:80", response->auth_challenge->host_and_port); |
1989 EXPECT_EQ(L"", response->auth_challenge->realm); | 2006 EXPECT_EQ(L"", response->auth_challenge->realm); |
1990 EXPECT_EQ(L"ntlm", response->auth_challenge->scheme); | 2007 EXPECT_EQ(L"ntlm", response->auth_challenge->scheme); |
1991 | 2008 |
1992 TestCompletionCallback callback3; | 2009 TestCompletionCallback callback3; |
1993 | 2010 |
1994 rv = trans->RestartWithAuth(L"testing-ntlm", L"testing-ntlm", &callback3); | 2011 rv = trans->RestartWithAuth(kTestingNTLM, kTestingNTLM, &callback3); |
1995 EXPECT_EQ(ERR_IO_PENDING, rv); | 2012 EXPECT_EQ(ERR_IO_PENDING, rv); |
1996 | 2013 |
1997 rv = callback3.WaitForResult(); | 2014 rv = callback3.WaitForResult(); |
1998 EXPECT_EQ(OK, rv); | 2015 EXPECT_EQ(OK, rv); |
1999 | 2016 |
2000 response = trans->GetResponseInfo(); | 2017 response = trans->GetResponseInfo(); |
2001 ASSERT_FALSE(response == NULL); | 2018 ASSERT_FALSE(response == NULL); |
2002 | 2019 |
2003 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 2020 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
2004 EXPECT_EQ(13, response->headers->GetContentLength()); | 2021 EXPECT_EQ(13, response->headers->GetContentLength()); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2143 TestCompletionCallback callback1; | 2160 TestCompletionCallback callback1; |
2144 | 2161 |
2145 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 2162 int rv = trans->Start(&request, &callback1, BoundNetLog()); |
2146 EXPECT_EQ(ERR_IO_PENDING, rv); | 2163 EXPECT_EQ(ERR_IO_PENDING, rv); |
2147 | 2164 |
2148 rv = callback1.WaitForResult(); | 2165 rv = callback1.WaitForResult(); |
2149 EXPECT_EQ(OK, rv); | 2166 EXPECT_EQ(OK, rv); |
2150 | 2167 |
2151 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 2168 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
2152 TestCompletionCallback callback2; | 2169 TestCompletionCallback callback2; |
2153 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); | 2170 rv = trans->RestartWithAuth(string16(), string16(), &callback2); |
2154 EXPECT_EQ(ERR_IO_PENDING, rv); | 2171 EXPECT_EQ(ERR_IO_PENDING, rv); |
2155 rv = callback2.WaitForResult(); | 2172 rv = callback2.WaitForResult(); |
2156 EXPECT_EQ(OK, rv); | 2173 EXPECT_EQ(OK, rv); |
2157 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 2174 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
2158 | 2175 |
2159 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2176 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2160 EXPECT_FALSE(response == NULL); | 2177 EXPECT_FALSE(response == NULL); |
2161 | 2178 |
2162 // The password prompt info should have been set in response->auth_challenge. | 2179 // The password prompt info should have been set in response->auth_challenge. |
2163 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 2180 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
2164 | 2181 |
2165 EXPECT_EQ(L"172.22.68.17:80", response->auth_challenge->host_and_port); | 2182 EXPECT_EQ(L"172.22.68.17:80", response->auth_challenge->host_and_port); |
2166 EXPECT_EQ(L"", response->auth_challenge->realm); | 2183 EXPECT_EQ(L"", response->auth_challenge->realm); |
2167 EXPECT_EQ(L"ntlm", response->auth_challenge->scheme); | 2184 EXPECT_EQ(L"ntlm", response->auth_challenge->scheme); |
2168 | 2185 |
2169 TestCompletionCallback callback3; | 2186 TestCompletionCallback callback3; |
2170 | 2187 |
2171 // Enter the wrong password. | 2188 // Enter the wrong password. |
2172 rv = trans->RestartWithAuth(L"testing-ntlm", L"wrongpassword", &callback3); | 2189 rv = trans->RestartWithAuth(kTestingNTLM, kWrongPassword, &callback3); |
2173 EXPECT_EQ(ERR_IO_PENDING, rv); | 2190 EXPECT_EQ(ERR_IO_PENDING, rv); |
2174 | 2191 |
2175 rv = callback3.WaitForResult(); | 2192 rv = callback3.WaitForResult(); |
2176 EXPECT_EQ(OK, rv); | 2193 EXPECT_EQ(OK, rv); |
2177 | 2194 |
2178 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 2195 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
2179 TestCompletionCallback callback4; | 2196 TestCompletionCallback callback4; |
2180 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback4); | 2197 rv = trans->RestartWithAuth(string16(), string16(), &callback4); |
2181 EXPECT_EQ(ERR_IO_PENDING, rv); | 2198 EXPECT_EQ(ERR_IO_PENDING, rv); |
2182 rv = callback4.WaitForResult(); | 2199 rv = callback4.WaitForResult(); |
2183 EXPECT_EQ(OK, rv); | 2200 EXPECT_EQ(OK, rv); |
2184 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 2201 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
2185 | 2202 |
2186 response = trans->GetResponseInfo(); | 2203 response = trans->GetResponseInfo(); |
2187 EXPECT_FALSE(response == NULL); | 2204 EXPECT_FALSE(response == NULL); |
2188 | 2205 |
2189 // The password prompt info should have been set in response->auth_challenge. | 2206 // The password prompt info should have been set in response->auth_challenge. |
2190 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 2207 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
2191 | 2208 |
2192 EXPECT_EQ(L"172.22.68.17:80", response->auth_challenge->host_and_port); | 2209 EXPECT_EQ(L"172.22.68.17:80", response->auth_challenge->host_and_port); |
2193 EXPECT_EQ(L"", response->auth_challenge->realm); | 2210 EXPECT_EQ(L"", response->auth_challenge->realm); |
2194 EXPECT_EQ(L"ntlm", response->auth_challenge->scheme); | 2211 EXPECT_EQ(L"ntlm", response->auth_challenge->scheme); |
2195 | 2212 |
2196 TestCompletionCallback callback5; | 2213 TestCompletionCallback callback5; |
2197 | 2214 |
2198 // Now enter the right password. | 2215 // Now enter the right password. |
2199 rv = trans->RestartWithAuth(L"testing-ntlm", L"testing-ntlm", &callback5); | 2216 rv = trans->RestartWithAuth(kTestingNTLM, kTestingNTLM, &callback5); |
2200 EXPECT_EQ(ERR_IO_PENDING, rv); | 2217 EXPECT_EQ(ERR_IO_PENDING, rv); |
2201 | 2218 |
2202 rv = callback5.WaitForResult(); | 2219 rv = callback5.WaitForResult(); |
2203 EXPECT_EQ(OK, rv); | 2220 EXPECT_EQ(OK, rv); |
2204 | 2221 |
2205 response = trans->GetResponseInfo(); | 2222 response = trans->GetResponseInfo(); |
2206 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 2223 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
2207 EXPECT_EQ(13, response->headers->GetContentLength()); | 2224 EXPECT_EQ(13, response->headers->GetContentLength()); |
2208 } | 2225 } |
2209 #endif // NTLM_PORTABLE | 2226 #endif // NTLM_PORTABLE |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2562 TestCompletionCallback callback1; | 2579 TestCompletionCallback callback1; |
2563 | 2580 |
2564 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 2581 int rv = trans->Start(&request, &callback1, BoundNetLog()); |
2565 EXPECT_EQ(ERR_IO_PENDING, rv); | 2582 EXPECT_EQ(ERR_IO_PENDING, rv); |
2566 | 2583 |
2567 rv = callback1.WaitForResult(); | 2584 rv = callback1.WaitForResult(); |
2568 EXPECT_EQ(OK, rv); | 2585 EXPECT_EQ(OK, rv); |
2569 | 2586 |
2570 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 2587 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
2571 TestCompletionCallback callback2; | 2588 TestCompletionCallback callback2; |
2572 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); | 2589 rv = trans->RestartWithAuth(string16(), string16(), &callback2); |
2573 EXPECT_EQ(ERR_IO_PENDING, rv); | 2590 EXPECT_EQ(ERR_IO_PENDING, rv); |
2574 rv = callback2.WaitForResult(); | 2591 rv = callback2.WaitForResult(); |
2575 EXPECT_EQ(OK, rv); | 2592 EXPECT_EQ(OK, rv); |
2576 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 2593 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
2577 | 2594 |
2578 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2595 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2579 EXPECT_FALSE(response == NULL); | 2596 EXPECT_FALSE(response == NULL); |
2580 | 2597 |
2581 // There is no challenge info, since the identity in URL worked. | 2598 // There is no challenge info, since the identity in URL worked. |
2582 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 2599 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2660 TestCompletionCallback callback1; | 2677 TestCompletionCallback callback1; |
2661 | 2678 |
2662 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 2679 int rv = trans->Start(&request, &callback1, BoundNetLog()); |
2663 EXPECT_EQ(ERR_IO_PENDING, rv); | 2680 EXPECT_EQ(ERR_IO_PENDING, rv); |
2664 | 2681 |
2665 rv = callback1.WaitForResult(); | 2682 rv = callback1.WaitForResult(); |
2666 EXPECT_EQ(OK, rv); | 2683 EXPECT_EQ(OK, rv); |
2667 | 2684 |
2668 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 2685 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
2669 TestCompletionCallback callback2; | 2686 TestCompletionCallback callback2; |
2670 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); | 2687 rv = trans->RestartWithAuth(string16(), string16(), &callback2); |
2671 EXPECT_EQ(ERR_IO_PENDING, rv); | 2688 EXPECT_EQ(ERR_IO_PENDING, rv); |
2672 rv = callback2.WaitForResult(); | 2689 rv = callback2.WaitForResult(); |
2673 EXPECT_EQ(OK, rv); | 2690 EXPECT_EQ(OK, rv); |
2674 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 2691 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
2675 | 2692 |
2676 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2693 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2677 EXPECT_FALSE(response == NULL); | 2694 EXPECT_FALSE(response == NULL); |
2678 // The password prompt info should have been set in response->auth_challenge. | 2695 // The password prompt info should have been set in response->auth_challenge. |
2679 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 2696 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
2680 | 2697 |
2681 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); | 2698 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); |
2682 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); | 2699 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); |
2683 EXPECT_EQ(L"basic", response->auth_challenge->scheme); | 2700 EXPECT_EQ(L"basic", response->auth_challenge->scheme); |
2684 | 2701 |
2685 TestCompletionCallback callback3; | 2702 TestCompletionCallback callback3; |
2686 rv = trans->RestartWithAuth(L"foo", L"bar", &callback3); | 2703 rv = trans->RestartWithAuth(kFoo, kBar, &callback3); |
2687 EXPECT_EQ(ERR_IO_PENDING, rv); | 2704 EXPECT_EQ(ERR_IO_PENDING, rv); |
2688 rv = callback3.WaitForResult(); | 2705 rv = callback3.WaitForResult(); |
2689 EXPECT_EQ(OK, rv); | 2706 EXPECT_EQ(OK, rv); |
2690 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 2707 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
2691 | 2708 |
2692 response = trans->GetResponseInfo(); | 2709 response = trans->GetResponseInfo(); |
2693 EXPECT_FALSE(response == NULL); | 2710 EXPECT_FALSE(response == NULL); |
2694 | 2711 |
2695 // There is no challenge info, since the identity worked. | 2712 // There is no challenge info, since the identity worked. |
2696 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 2713 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2764 // The password prompt info should have been set in | 2781 // The password prompt info should have been set in |
2765 // response->auth_challenge. | 2782 // response->auth_challenge. |
2766 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 2783 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
2767 | 2784 |
2768 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); | 2785 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); |
2769 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); | 2786 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); |
2770 EXPECT_EQ(L"basic", response->auth_challenge->scheme); | 2787 EXPECT_EQ(L"basic", response->auth_challenge->scheme); |
2771 | 2788 |
2772 TestCompletionCallback callback2; | 2789 TestCompletionCallback callback2; |
2773 | 2790 |
2774 rv = trans->RestartWithAuth(L"foo", L"bar", &callback2); | 2791 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); |
2775 EXPECT_EQ(ERR_IO_PENDING, rv); | 2792 EXPECT_EQ(ERR_IO_PENDING, rv); |
2776 | 2793 |
2777 rv = callback2.WaitForResult(); | 2794 rv = callback2.WaitForResult(); |
2778 EXPECT_EQ(OK, rv); | 2795 EXPECT_EQ(OK, rv); |
2779 | 2796 |
2780 response = trans->GetResponseInfo(); | 2797 response = trans->GetResponseInfo(); |
2781 EXPECT_FALSE(response == NULL); | 2798 EXPECT_FALSE(response == NULL); |
2782 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 2799 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
2783 EXPECT_EQ(100, response->headers->GetContentLength()); | 2800 EXPECT_EQ(100, response->headers->GetContentLength()); |
2784 } | 2801 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2849 // The password prompt info should have been set in | 2866 // The password prompt info should have been set in |
2850 // response->auth_challenge. | 2867 // response->auth_challenge. |
2851 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 2868 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
2852 | 2869 |
2853 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); | 2870 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); |
2854 EXPECT_EQ(L"MyRealm2", response->auth_challenge->realm); | 2871 EXPECT_EQ(L"MyRealm2", response->auth_challenge->realm); |
2855 EXPECT_EQ(L"basic", response->auth_challenge->scheme); | 2872 EXPECT_EQ(L"basic", response->auth_challenge->scheme); |
2856 | 2873 |
2857 TestCompletionCallback callback2; | 2874 TestCompletionCallback callback2; |
2858 | 2875 |
2859 rv = trans->RestartWithAuth(L"foo2", L"bar2", &callback2); | 2876 rv = trans->RestartWithAuth(kFoo2, kBar2, &callback2); |
2860 EXPECT_EQ(ERR_IO_PENDING, rv); | 2877 EXPECT_EQ(ERR_IO_PENDING, rv); |
2861 | 2878 |
2862 rv = callback2.WaitForResult(); | 2879 rv = callback2.WaitForResult(); |
2863 EXPECT_EQ(OK, rv); | 2880 EXPECT_EQ(OK, rv); |
2864 | 2881 |
2865 response = trans->GetResponseInfo(); | 2882 response = trans->GetResponseInfo(); |
2866 EXPECT_FALSE(response == NULL); | 2883 EXPECT_FALSE(response == NULL); |
2867 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 2884 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
2868 EXPECT_EQ(100, response->headers->GetContentLength()); | 2885 EXPECT_EQ(100, response->headers->GetContentLength()); |
2869 } | 2886 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2965 TestCompletionCallback callback1; | 2982 TestCompletionCallback callback1; |
2966 | 2983 |
2967 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 2984 int rv = trans->Start(&request, &callback1, BoundNetLog()); |
2968 EXPECT_EQ(ERR_IO_PENDING, rv); | 2985 EXPECT_EQ(ERR_IO_PENDING, rv); |
2969 | 2986 |
2970 rv = callback1.WaitForResult(); | 2987 rv = callback1.WaitForResult(); |
2971 EXPECT_EQ(OK, rv); | 2988 EXPECT_EQ(OK, rv); |
2972 | 2989 |
2973 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 2990 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
2974 TestCompletionCallback callback2; | 2991 TestCompletionCallback callback2; |
2975 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); | 2992 rv = trans->RestartWithAuth(string16(), string16(), &callback2); |
2976 EXPECT_EQ(ERR_IO_PENDING, rv); | 2993 EXPECT_EQ(ERR_IO_PENDING, rv); |
2977 rv = callback2.WaitForResult(); | 2994 rv = callback2.WaitForResult(); |
2978 EXPECT_EQ(OK, rv); | 2995 EXPECT_EQ(OK, rv); |
2979 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 2996 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
2980 | 2997 |
2981 const HttpResponseInfo* response = trans->GetResponseInfo(); | 2998 const HttpResponseInfo* response = trans->GetResponseInfo(); |
2982 EXPECT_FALSE(response == NULL); | 2999 EXPECT_FALSE(response == NULL); |
2983 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 3000 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
2984 EXPECT_EQ(100, response->headers->GetContentLength()); | 3001 EXPECT_EQ(100, response->headers->GetContentLength()); |
2985 } | 3002 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3054 TestCompletionCallback callback1; | 3071 TestCompletionCallback callback1; |
3055 | 3072 |
3056 int rv = trans->Start(&request, &callback1, BoundNetLog()); | 3073 int rv = trans->Start(&request, &callback1, BoundNetLog()); |
3057 EXPECT_EQ(ERR_IO_PENDING, rv); | 3074 EXPECT_EQ(ERR_IO_PENDING, rv); |
3058 | 3075 |
3059 rv = callback1.WaitForResult(); | 3076 rv = callback1.WaitForResult(); |
3060 EXPECT_EQ(OK, rv); | 3077 EXPECT_EQ(OK, rv); |
3061 | 3078 |
3062 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); | 3079 EXPECT_TRUE(trans->IsReadyToRestartForAuth()); |
3063 TestCompletionCallback callback2; | 3080 TestCompletionCallback callback2; |
3064 rv = trans->RestartWithAuth(std::wstring(), std::wstring(), &callback2); | 3081 rv = trans->RestartWithAuth(string16(), string16(), &callback2); |
3065 EXPECT_EQ(ERR_IO_PENDING, rv); | 3082 EXPECT_EQ(ERR_IO_PENDING, rv); |
3066 rv = callback2.WaitForResult(); | 3083 rv = callback2.WaitForResult(); |
3067 EXPECT_EQ(OK, rv); | 3084 EXPECT_EQ(OK, rv); |
3068 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); | 3085 EXPECT_FALSE(trans->IsReadyToRestartForAuth()); |
3069 | 3086 |
3070 const HttpResponseInfo* response = trans->GetResponseInfo(); | 3087 const HttpResponseInfo* response = trans->GetResponseInfo(); |
3071 EXPECT_FALSE(response == NULL); | 3088 EXPECT_FALSE(response == NULL); |
3072 | 3089 |
3073 // The password prompt info should have been set in | 3090 // The password prompt info should have been set in |
3074 // response->auth_challenge. | 3091 // response->auth_challenge. |
3075 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 3092 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
3076 | 3093 |
3077 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); | 3094 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); |
3078 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); | 3095 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); |
3079 EXPECT_EQ(L"basic", response->auth_challenge->scheme); | 3096 EXPECT_EQ(L"basic", response->auth_challenge->scheme); |
3080 | 3097 |
3081 TestCompletionCallback callback3; | 3098 TestCompletionCallback callback3; |
3082 | 3099 |
3083 rv = trans->RestartWithAuth(L"foo3", L"bar3", &callback3); | 3100 rv = trans->RestartWithAuth(kFoo3, kBar3, &callback3); |
3084 EXPECT_EQ(ERR_IO_PENDING, rv); | 3101 EXPECT_EQ(ERR_IO_PENDING, rv); |
3085 | 3102 |
3086 rv = callback3.WaitForResult(); | 3103 rv = callback3.WaitForResult(); |
3087 EXPECT_EQ(OK, rv); | 3104 EXPECT_EQ(OK, rv); |
3088 | 3105 |
3089 response = trans->GetResponseInfo(); | 3106 response = trans->GetResponseInfo(); |
3090 EXPECT_FALSE(response == NULL); | 3107 EXPECT_FALSE(response == NULL); |
3091 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 3108 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
3092 EXPECT_EQ(100, response->headers->GetContentLength()); | 3109 EXPECT_EQ(100, response->headers->GetContentLength()); |
3093 } | 3110 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3160 // The password prompt info should have been set in | 3177 // The password prompt info should have been set in |
3161 // response->auth_challenge. | 3178 // response->auth_challenge. |
3162 ASSERT_FALSE(response->auth_challenge.get() == NULL); | 3179 ASSERT_FALSE(response->auth_challenge.get() == NULL); |
3163 | 3180 |
3164 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); | 3181 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); |
3165 EXPECT_EQ(L"digestive", response->auth_challenge->realm); | 3182 EXPECT_EQ(L"digestive", response->auth_challenge->realm); |
3166 EXPECT_EQ(L"digest", response->auth_challenge->scheme); | 3183 EXPECT_EQ(L"digest", response->auth_challenge->scheme); |
3167 | 3184 |
3168 TestCompletionCallback callback2; | 3185 TestCompletionCallback callback2; |
3169 | 3186 |
3170 rv = trans->RestartWithAuth(L"foo", L"bar", &callback2); | 3187 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); |
3171 EXPECT_EQ(ERR_IO_PENDING, rv); | 3188 EXPECT_EQ(ERR_IO_PENDING, rv); |
3172 | 3189 |
3173 rv = callback2.WaitForResult(); | 3190 rv = callback2.WaitForResult(); |
3174 EXPECT_EQ(OK, rv); | 3191 EXPECT_EQ(OK, rv); |
3175 | 3192 |
3176 response = trans->GetResponseInfo(); | 3193 response = trans->GetResponseInfo(); |
3177 ASSERT_FALSE(response == NULL); | 3194 ASSERT_FALSE(response == NULL); |
3178 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 3195 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
3179 } | 3196 } |
3180 | 3197 |
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4521 | 4538 |
4522 // The password prompt info should have been set in response->auth_challenge. | 4539 // The password prompt info should have been set in response->auth_challenge. |
4523 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 4540 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
4524 | 4541 |
4525 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); | 4542 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); |
4526 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); | 4543 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); |
4527 EXPECT_EQ(L"basic", response->auth_challenge->scheme); | 4544 EXPECT_EQ(L"basic", response->auth_challenge->scheme); |
4528 | 4545 |
4529 TestCompletionCallback callback2; | 4546 TestCompletionCallback callback2; |
4530 | 4547 |
4531 rv = trans->RestartWithAuth(L"foo", L"bar", &callback2); | 4548 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); |
4532 EXPECT_EQ(ERR_IO_PENDING, rv); | 4549 EXPECT_EQ(ERR_IO_PENDING, rv); |
4533 | 4550 |
4534 rv = callback2.WaitForResult(); | 4551 rv = callback2.WaitForResult(); |
4535 EXPECT_EQ(OK, rv); | 4552 EXPECT_EQ(OK, rv); |
4536 | 4553 |
4537 response = trans->GetResponseInfo(); | 4554 response = trans->GetResponseInfo(); |
4538 EXPECT_FALSE(response == NULL); | 4555 EXPECT_FALSE(response == NULL); |
4539 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 4556 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
4540 EXPECT_EQ(100, response->headers->GetContentLength()); | 4557 EXPECT_EQ(100, response->headers->GetContentLength()); |
4541 } | 4558 } |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4789 EXPECT_TRUE(response->auth_challenge.get() != NULL); | 4806 EXPECT_TRUE(response->auth_challenge.get() != NULL); |
4790 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); | 4807 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); |
4791 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); | 4808 EXPECT_EQ(L"MyRealm1", response->auth_challenge->realm); |
4792 EXPECT_EQ(L"basic", response->auth_challenge->scheme); | 4809 EXPECT_EQ(L"basic", response->auth_challenge->scheme); |
4793 | 4810 |
4794 // Now make the file unreadable and try again. | 4811 // Now make the file unreadable and try again. |
4795 ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file)); | 4812 ASSERT_TRUE(file_util::MakeFileUnreadable(temp_file)); |
4796 | 4813 |
4797 TestCompletionCallback callback2; | 4814 TestCompletionCallback callback2; |
4798 | 4815 |
4799 rv = trans->RestartWithAuth(L"foo", L"bar", &callback2); | 4816 rv = trans->RestartWithAuth(kFoo, kBar, &callback2); |
4800 EXPECT_EQ(ERR_IO_PENDING, rv); | 4817 EXPECT_EQ(ERR_IO_PENDING, rv); |
4801 | 4818 |
4802 rv = callback2.WaitForResult(); | 4819 rv = callback2.WaitForResult(); |
4803 EXPECT_EQ(OK, rv); | 4820 EXPECT_EQ(OK, rv); |
4804 | 4821 |
4805 response = trans->GetResponseInfo(); | 4822 response = trans->GetResponseInfo(); |
4806 EXPECT_TRUE(response != NULL); | 4823 EXPECT_TRUE(response != NULL); |
4807 EXPECT_TRUE(response->headers != NULL); | 4824 EXPECT_TRUE(response->headers != NULL); |
4808 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 4825 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
4809 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); | 4826 EXPECT_EQ("HTTP/1.1 200 OK", response->headers->GetStatusLine()); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4908 ASSERT_FALSE(response == NULL); | 4925 ASSERT_FALSE(response == NULL); |
4909 ASSERT_FALSE(response->auth_challenge.get() == NULL); | 4926 ASSERT_FALSE(response->auth_challenge.get() == NULL); |
4910 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); | 4927 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); |
4911 EXPECT_EQ(L"first_realm", response->auth_challenge->realm); | 4928 EXPECT_EQ(L"first_realm", response->auth_challenge->realm); |
4912 EXPECT_EQ(L"basic", response->auth_challenge->scheme); | 4929 EXPECT_EQ(L"basic", response->auth_challenge->scheme); |
4913 | 4930 |
4914 // Issue the second request with an incorrect password. There should be a | 4931 // Issue the second request with an incorrect password. There should be a |
4915 // password prompt for second_realm waiting to be filled in after the | 4932 // password prompt for second_realm waiting to be filled in after the |
4916 // transaction completes. | 4933 // transaction completes. |
4917 TestCompletionCallback callback2; | 4934 TestCompletionCallback callback2; |
4918 rv = trans->RestartWithAuth(L"first", L"baz", &callback2); | 4935 rv = trans->RestartWithAuth(kFirst, kBaz, &callback2); |
4919 EXPECT_EQ(ERR_IO_PENDING, rv); | 4936 EXPECT_EQ(ERR_IO_PENDING, rv); |
4920 rv = callback2.WaitForResult(); | 4937 rv = callback2.WaitForResult(); |
4921 EXPECT_EQ(OK, rv); | 4938 EXPECT_EQ(OK, rv); |
4922 response = trans->GetResponseInfo(); | 4939 response = trans->GetResponseInfo(); |
4923 ASSERT_FALSE(response == NULL); | 4940 ASSERT_FALSE(response == NULL); |
4924 ASSERT_FALSE(response->auth_challenge.get() == NULL); | 4941 ASSERT_FALSE(response->auth_challenge.get() == NULL); |
4925 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); | 4942 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); |
4926 EXPECT_EQ(L"second_realm", response->auth_challenge->realm); | 4943 EXPECT_EQ(L"second_realm", response->auth_challenge->realm); |
4927 EXPECT_EQ(L"basic", response->auth_challenge->scheme); | 4944 EXPECT_EQ(L"basic", response->auth_challenge->scheme); |
4928 | 4945 |
4929 // Issue the third request with another incorrect password. There should be | 4946 // Issue the third request with another incorrect password. There should be |
4930 // a password prompt for first_realm waiting to be filled in. If the password | 4947 // a password prompt for first_realm waiting to be filled in. If the password |
4931 // prompt is not present, it indicates that the HttpAuthCacheEntry for | 4948 // prompt is not present, it indicates that the HttpAuthCacheEntry for |
4932 // first_realm was not correctly removed. | 4949 // first_realm was not correctly removed. |
4933 TestCompletionCallback callback3; | 4950 TestCompletionCallback callback3; |
4934 rv = trans->RestartWithAuth(L"second", L"fou", &callback3); | 4951 rv = trans->RestartWithAuth(kSecond, kFou, &callback3); |
4935 EXPECT_EQ(ERR_IO_PENDING, rv); | 4952 EXPECT_EQ(ERR_IO_PENDING, rv); |
4936 rv = callback3.WaitForResult(); | 4953 rv = callback3.WaitForResult(); |
4937 EXPECT_EQ(OK, rv); | 4954 EXPECT_EQ(OK, rv); |
4938 response = trans->GetResponseInfo(); | 4955 response = trans->GetResponseInfo(); |
4939 ASSERT_FALSE(response == NULL); | 4956 ASSERT_FALSE(response == NULL); |
4940 ASSERT_FALSE(response->auth_challenge.get() == NULL); | 4957 ASSERT_FALSE(response->auth_challenge.get() == NULL); |
4941 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); | 4958 EXPECT_EQ(L"www.google.com:80", response->auth_challenge->host_and_port); |
4942 EXPECT_EQ(L"first_realm", response->auth_challenge->realm); | 4959 EXPECT_EQ(L"first_realm", response->auth_challenge->realm); |
4943 EXPECT_EQ(L"basic", response->auth_challenge->scheme); | 4960 EXPECT_EQ(L"basic", response->auth_challenge->scheme); |
4944 | 4961 |
4945 // Issue the fourth request with the correct password and username. | 4962 // Issue the fourth request with the correct password and username. |
4946 TestCompletionCallback callback4; | 4963 TestCompletionCallback callback4; |
4947 rv = trans->RestartWithAuth(L"first", L"bar", &callback4); | 4964 rv = trans->RestartWithAuth(kFirst, kBar, &callback4); |
4948 EXPECT_EQ(ERR_IO_PENDING, rv); | 4965 EXPECT_EQ(ERR_IO_PENDING, rv); |
4949 rv = callback4.WaitForResult(); | 4966 rv = callback4.WaitForResult(); |
4950 EXPECT_EQ(OK, rv); | 4967 EXPECT_EQ(OK, rv); |
4951 response = trans->GetResponseInfo(); | 4968 response = trans->GetResponseInfo(); |
4952 ASSERT_FALSE(response == NULL); | 4969 ASSERT_FALSE(response == NULL); |
4953 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 4970 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
4954 } | 4971 } |
4955 | 4972 |
4956 TEST_F(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) { | 4973 TEST_F(HttpNetworkTransactionTest, HonorAlternateProtocolHeader) { |
4957 HttpNetworkTransaction::SetNextProtos("needs_to_be_set_for_this_test"); | 4974 HttpNetworkTransaction::SetNextProtos("needs_to_be_set_for_this_test"); |
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5889 if (round >= test_config.first_ssl_round) | 5906 if (round >= test_config.first_ssl_round) |
5890 session_deps.socket_factory.AddSSLSocketDataProvider( | 5907 session_deps.socket_factory.AddSSLSocketDataProvider( |
5891 &ssl_socket_data_provider); | 5908 &ssl_socket_data_provider); |
5892 | 5909 |
5893 // Start or restart the transaction. | 5910 // Start or restart the transaction. |
5894 TestCompletionCallback callback; | 5911 TestCompletionCallback callback; |
5895 int rv; | 5912 int rv; |
5896 if (round == 0) { | 5913 if (round == 0) { |
5897 rv = trans->Start(&request, &callback, BoundNetLog()); | 5914 rv = trans->Start(&request, &callback, BoundNetLog()); |
5898 } else { | 5915 } else { |
5899 rv = trans->RestartWithAuth(L"foo", L"bar", &callback); | 5916 rv = trans->RestartWithAuth(kFoo, kBar, &callback); |
5900 } | 5917 } |
5901 if (rv == ERR_IO_PENDING) | 5918 if (rv == ERR_IO_PENDING) |
5902 rv = callback.WaitForResult(); | 5919 rv = callback.WaitForResult(); |
5903 | 5920 |
5904 // Compare results with expected data. | 5921 // Compare results with expected data. |
5905 EXPECT_EQ(read_write_round.expected_rv, rv); | 5922 EXPECT_EQ(read_write_round.expected_rv, rv); |
5906 const HttpResponseInfo* response = trans->GetResponseInfo(); | 5923 const HttpResponseInfo* response = trans->GetResponseInfo(); |
5907 if (read_write_round.expected_rv == OK) { | 5924 if (read_write_round.expected_rv == OK) { |
5908 EXPECT_FALSE(response == NULL); | 5925 EXPECT_FALSE(response == NULL); |
5909 } else { | 5926 } else { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6001 rv = trans->Start(&request, &callback, BoundNetLog()); | 6018 rv = trans->Start(&request, &callback, BoundNetLog()); |
6002 if (rv == ERR_IO_PENDING) | 6019 if (rv == ERR_IO_PENDING) |
6003 rv = callback.WaitForResult(); | 6020 rv = callback.WaitForResult(); |
6004 EXPECT_EQ(OK, rv); | 6021 EXPECT_EQ(OK, rv); |
6005 response = trans->GetResponseInfo(); | 6022 response = trans->GetResponseInfo(); |
6006 ASSERT_FALSE(response == NULL); | 6023 ASSERT_FALSE(response == NULL); |
6007 EXPECT_FALSE(response->auth_challenge.get() == NULL); | 6024 EXPECT_FALSE(response->auth_challenge.get() == NULL); |
6008 | 6025 |
6009 // Second round | 6026 // Second round |
6010 auth_handler->SetGenerateExpectation(false, OK); | 6027 auth_handler->SetGenerateExpectation(false, OK); |
6011 rv = trans->RestartWithAuth(L"foo", L"bar", &callback); | 6028 rv = trans->RestartWithAuth(kFoo, kBar, &callback); |
6012 if (rv == ERR_IO_PENDING) | 6029 if (rv == ERR_IO_PENDING) |
6013 rv = callback.WaitForResult(); | 6030 rv = callback.WaitForResult(); |
6014 EXPECT_EQ(OK, rv); | 6031 EXPECT_EQ(OK, rv); |
6015 response = trans->GetResponseInfo(); | 6032 response = trans->GetResponseInfo(); |
6016 ASSERT_FALSE(response == NULL); | 6033 ASSERT_FALSE(response == NULL); |
6017 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 6034 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
6018 | 6035 |
6019 // Third round | 6036 // Third round |
6020 auth_handler->SetGenerateExpectation(false, OK); | 6037 auth_handler->SetGenerateExpectation(false, OK); |
6021 rv = trans->RestartWithAuth(L"", L"", &callback); | 6038 rv = trans->RestartWithAuth(string16(), string16(), &callback); |
6022 if (rv == ERR_IO_PENDING) | 6039 if (rv == ERR_IO_PENDING) |
6023 rv = callback.WaitForResult(); | 6040 rv = callback.WaitForResult(); |
6024 EXPECT_EQ(OK, rv); | 6041 EXPECT_EQ(OK, rv); |
6025 response = trans->GetResponseInfo(); | 6042 response = trans->GetResponseInfo(); |
6026 ASSERT_FALSE(response == NULL); | 6043 ASSERT_FALSE(response == NULL); |
6027 EXPECT_TRUE(response->auth_challenge.get() == NULL); | 6044 EXPECT_TRUE(response->auth_challenge.get() == NULL); |
6028 } | 6045 } |
6029 | 6046 |
6030 class TLSDecompressionFailureSocketDataProvider : public SocketDataProvider { | 6047 class TLSDecompressionFailureSocketDataProvider : public SocketDataProvider { |
6031 public: | 6048 public: |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6242 | 6259 |
6243 int rv = trans->Start(&request, &callback, BoundNetLog()); | 6260 int rv = trans->Start(&request, &callback, BoundNetLog()); |
6244 EXPECT_EQ(ERR_IO_PENDING, rv); | 6261 EXPECT_EQ(ERR_IO_PENDING, rv); |
6245 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult()); | 6262 EXPECT_EQ(ERR_CONNECTION_CLOSED, callback.WaitForResult()); |
6246 | 6263 |
6247 HttpNetworkTransaction::SetNextProtos(""); | 6264 HttpNetworkTransaction::SetNextProtos(""); |
6248 HttpNetworkTransaction::SetUseAlternateProtocols(false); | 6265 HttpNetworkTransaction::SetUseAlternateProtocols(false); |
6249 } | 6266 } |
6250 | 6267 |
6251 } // namespace net | 6268 } // namespace net |
OLD | NEW |