| 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_auth_handler_negotiate.h" | 5 #include "net/http/http_auth_handler_negotiate.h" |
| 6 | 6 |
| 7 #include "net/base/mock_host_resolver.h" | 7 #include "net/base/mock_host_resolver.h" |
| 8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
| 9 #include "net/base/test_completion_callback.h" | 9 #include "net/base/test_completion_callback.h" |
| 10 #include "net/http/http_request_info.h" | 10 #include "net/http/http_request_info.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 &mock_library, &auth_handler); | 163 &mock_library, &auth_handler); |
| 164 ASSERT_TRUE(auth_handler.get() != NULL); | 164 ASSERT_TRUE(auth_handler.get() != NULL); |
| 165 TestCompletionCallback callback; | 165 TestCompletionCallback callback; |
| 166 HttpRequestInfo request_info; | 166 HttpRequestInfo request_info; |
| 167 std::string token; | 167 std::string token; |
| 168 std::wstring username = L"foo"; | 168 std::wstring username = L"foo"; |
| 169 std::wstring password = L"bar"; | 169 std::wstring password = L"bar"; |
| 170 EXPECT_EQ(OK, auth_handler->GenerateAuthToken(&username, &password, | 170 EXPECT_EQ(OK, auth_handler->GenerateAuthToken(&username, &password, |
| 171 &request_info, | 171 &request_info, |
| 172 &callback, &token)); | 172 &callback, &token)); |
| 173 #if defined(OS_WIN) |
| 173 EXPECT_EQ(L"HTTP/alias", auth_handler->spn()); | 174 EXPECT_EQ(L"HTTP/alias", auth_handler->spn()); |
| 175 #elif defined(OS_POSIX) |
| 176 EXPECT_EQ(L"HTTP@alias", auth_handler->spn()); |
| 177 #endif |
| 174 } | 178 } |
| 175 | 179 |
| 176 TEST(HttpAuthHandlerNegotiateTest, DisableCnameStandardPort) { | 180 TEST(HttpAuthHandlerNegotiateTest, DisableCnameStandardPort) { |
| 177 MockSecureServicesLibrary mock_library; | 181 MockSecureServicesLibrary mock_library; |
| 178 SetupTransactions(&mock_library); | 182 SetupTransactions(&mock_library); |
| 179 scoped_ptr<HttpAuthHandlerNegotiate> auth_handler; | 183 scoped_ptr<HttpAuthHandlerNegotiate> auth_handler; |
| 180 CreateHandler(true, true, true, | 184 CreateHandler(true, true, true, |
| 181 "http://alias:80", &mock_library, &auth_handler); | 185 "http://alias:80", &mock_library, &auth_handler); |
| 182 ASSERT_TRUE(auth_handler.get() != NULL); | 186 ASSERT_TRUE(auth_handler.get() != NULL); |
| 183 TestCompletionCallback callback; | 187 TestCompletionCallback callback; |
| 184 HttpRequestInfo request_info; | 188 HttpRequestInfo request_info; |
| 185 std::string token; | 189 std::string token; |
| 186 std::wstring username = L"foo"; | 190 std::wstring username = L"foo"; |
| 187 std::wstring password = L"bar"; | 191 std::wstring password = L"bar"; |
| 188 EXPECT_EQ(OK, auth_handler->GenerateAuthToken(&username, &password, | 192 EXPECT_EQ(OK, auth_handler->GenerateAuthToken(&username, &password, |
| 189 &request_info, | 193 &request_info, |
| 190 &callback, &token)); | 194 &callback, &token)); |
| 195 #if defined(OS_WIN) |
| 191 EXPECT_EQ(L"HTTP/alias", auth_handler->spn()); | 196 EXPECT_EQ(L"HTTP/alias", auth_handler->spn()); |
| 197 #elif defined(OS_POSIX) |
| 198 EXPECT_EQ(L"HTTP@alias", auth_handler->spn()); |
| 199 #endif |
| 192 } | 200 } |
| 193 | 201 |
| 194 TEST(HttpAuthHandlerNegotiateTest, DisableCnameNonstandardPort) { | 202 TEST(HttpAuthHandlerNegotiateTest, DisableCnameNonstandardPort) { |
| 195 MockSecureServicesLibrary mock_library; | 203 MockSecureServicesLibrary mock_library; |
| 196 SetupTransactions(&mock_library); | 204 SetupTransactions(&mock_library); |
| 197 scoped_ptr<HttpAuthHandlerNegotiate> auth_handler; | 205 scoped_ptr<HttpAuthHandlerNegotiate> auth_handler; |
| 198 CreateHandler(true, true, true, | 206 CreateHandler(true, true, true, |
| 199 "http://alias:500", &mock_library, &auth_handler); | 207 "http://alias:500", &mock_library, &auth_handler); |
| 200 ASSERT_TRUE(auth_handler.get() != NULL); | 208 ASSERT_TRUE(auth_handler.get() != NULL); |
| 201 TestCompletionCallback callback; | 209 TestCompletionCallback callback; |
| 202 HttpRequestInfo request_info; | 210 HttpRequestInfo request_info; |
| 203 std::string token; | 211 std::string token; |
| 204 std::wstring username = L"foo"; | 212 std::wstring username = L"foo"; |
| 205 std::wstring password = L"bar"; | 213 std::wstring password = L"bar"; |
| 206 EXPECT_EQ(OK, auth_handler->GenerateAuthToken(&username, &password, | 214 EXPECT_EQ(OK, auth_handler->GenerateAuthToken(&username, &password, |
| 207 &request_info, | 215 &request_info, |
| 208 &callback, &token)); | 216 &callback, &token)); |
| 217 #if defined(OS_WIN) |
| 209 EXPECT_EQ(L"HTTP/alias:500", auth_handler->spn()); | 218 EXPECT_EQ(L"HTTP/alias:500", auth_handler->spn()); |
| 219 #elif defined(OS_POSIX) |
| 220 EXPECT_EQ(L"HTTP@alias:500", auth_handler->spn()); |
| 221 #endif |
| 210 } | 222 } |
| 211 | 223 |
| 212 TEST(HttpAuthHandlerNegotiateTest, CnameSync) { | 224 TEST(HttpAuthHandlerNegotiateTest, CnameSync) { |
| 213 MockSecureServicesLibrary mock_library; | 225 MockSecureServicesLibrary mock_library; |
| 214 SetupTransactions(&mock_library); | 226 SetupTransactions(&mock_library); |
| 215 scoped_ptr<HttpAuthHandlerNegotiate> auth_handler; | 227 scoped_ptr<HttpAuthHandlerNegotiate> auth_handler; |
| 216 CreateHandler(false, false, true, | 228 CreateHandler(false, false, true, |
| 217 "http://alias:500", &mock_library, &auth_handler); | 229 "http://alias:500", &mock_library, &auth_handler); |
| 218 ASSERT_TRUE(auth_handler.get() != NULL); | 230 ASSERT_TRUE(auth_handler.get() != NULL); |
| 219 TestCompletionCallback callback; | 231 TestCompletionCallback callback; |
| 220 HttpRequestInfo request_info; | 232 HttpRequestInfo request_info; |
| 221 std::string token; | 233 std::string token; |
| 222 std::wstring username = L"foo"; | 234 std::wstring username = L"foo"; |
| 223 std::wstring password = L"bar"; | 235 std::wstring password = L"bar"; |
| 224 EXPECT_EQ(OK, auth_handler->GenerateAuthToken(&username, &password, | 236 EXPECT_EQ(OK, auth_handler->GenerateAuthToken(&username, &password, |
| 225 &request_info, | 237 &request_info, |
| 226 &callback, &token)); | 238 &callback, &token)); |
| 239 #if defined(OS_WIN) |
| 227 EXPECT_EQ(L"HTTP/canonical.example.com", auth_handler->spn()); | 240 EXPECT_EQ(L"HTTP/canonical.example.com", auth_handler->spn()); |
| 241 #elif defined(OS_POSIX) |
| 242 EXPECT_EQ(L"HTTP@canonical.example.com", auth_handler->spn()); |
| 243 #endif |
| 228 } | 244 } |
| 229 | 245 |
| 230 TEST(HttpAuthHandlerNegotiateTest, CnameAsync) { | 246 TEST(HttpAuthHandlerNegotiateTest, CnameAsync) { |
| 231 MockSecureServicesLibrary mock_library; | 247 MockSecureServicesLibrary mock_library; |
| 232 SetupTransactions(&mock_library); | 248 SetupTransactions(&mock_library); |
| 233 scoped_ptr<HttpAuthHandlerNegotiate> auth_handler; | 249 scoped_ptr<HttpAuthHandlerNegotiate> auth_handler; |
| 234 CreateHandler(false, false, false, | 250 CreateHandler(false, false, false, |
| 235 "http://alias:500", &mock_library, &auth_handler); | 251 "http://alias:500", &mock_library, &auth_handler); |
| 236 ASSERT_TRUE(auth_handler.get() != NULL); | 252 ASSERT_TRUE(auth_handler.get() != NULL); |
| 237 TestCompletionCallback callback; | 253 TestCompletionCallback callback; |
| 238 HttpRequestInfo request_info; | 254 HttpRequestInfo request_info; |
| 239 std::string token; | 255 std::string token; |
| 240 std::wstring username = L"foo"; | 256 std::wstring username = L"foo"; |
| 241 std::wstring password = L"bar"; | 257 std::wstring password = L"bar"; |
| 242 EXPECT_EQ(ERR_IO_PENDING, auth_handler->GenerateAuthToken( | 258 EXPECT_EQ(ERR_IO_PENDING, auth_handler->GenerateAuthToken( |
| 243 &username, &password, &request_info, &callback, &token)); | 259 &username, &password, &request_info, &callback, &token)); |
| 244 EXPECT_EQ(OK, callback.WaitForResult()); | 260 EXPECT_EQ(OK, callback.WaitForResult()); |
| 261 #if defined(OS_WIN) |
| 245 EXPECT_EQ(L"HTTP/canonical.example.com", auth_handler->spn()); | 262 EXPECT_EQ(L"HTTP/canonical.example.com", auth_handler->spn()); |
| 263 #elif defined(OS_POSIX) |
| 264 EXPECT_EQ(L"HTTP@canonical.example.com", auth_handler->spn()); |
| 265 #endif |
| 246 } | 266 } |
| 247 | 267 |
| 248 } // namespace net | 268 } // namespace net |
| OLD | NEW |