Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(557)

Side by Side Diff: net/http/http_auth_handler_negotiate_unittest.cc

Issue 1408433006: Support tls-server-end-point channel bindings for HTTP authentication. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Narrower dependencies, update comments, address review comments. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <string> 7 #include <string>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
12 #include "net/base/test_completion_callback.h" 12 #include "net/base/test_completion_callback.h"
13 #include "net/dns/mock_host_resolver.h" 13 #include "net/dns/mock_host_resolver.h"
14 #include "net/http/http_request_info.h" 14 #include "net/http/http_request_info.h"
15 #include "net/http/mock_allow_http_auth_preferences.h" 15 #include "net/http/mock_allow_http_auth_preferences.h"
16 #include "net/ssl/ssl_info.h"
17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "testing/platform_test.h"
19
16 #if defined(OS_ANDROID) 20 #if defined(OS_ANDROID)
17 #include "net/android/dummy_spnego_authenticator.h" 21 #include "net/android/dummy_spnego_authenticator.h"
18 #elif defined(OS_WIN) 22 #elif defined(OS_WIN)
19 #include "net/http/mock_sspi_library_win.h" 23 #include "net/http/mock_sspi_library_win.h"
20 #elif defined(OS_POSIX) 24 #elif defined(OS_POSIX)
21 #include "net/http/mock_gssapi_library_posix.h" 25 #include "net/http/mock_gssapi_library_posix.h"
22 #endif 26 #endif
23 #include "testing/gtest/include/gtest/gtest.h"
24 #include "testing/platform_test.h"
25 27
26 namespace net { 28 namespace net {
27 29
28 #if defined(OS_ANDROID) 30 #if defined(OS_ANDROID)
29 typedef net::android::DummySpnegoAuthenticator MockAuthLibrary; 31 typedef net::android::DummySpnegoAuthenticator MockAuthLibrary;
30 #elif defined(OS_WIN) 32 #elif defined(OS_WIN)
31 typedef MockSSPILibrary MockAuthLibrary; 33 typedef MockSSPILibrary MockAuthLibrary;
32 #elif defined(OS_POSIX) 34 #elif defined(OS_POSIX)
33 typedef test::MockGSSAPILibrary MockAuthLibrary; 35 typedef test::MockGSSAPILibrary MockAuthLibrary;
34 #endif 36 #endif
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 mock_library->ExpectSecurityContext(query.expected_package, 184 mock_library->ExpectSecurityContext(query.expected_package,
183 query.response_code, 185 query.response_code,
184 query.minor_response_code, 186 query.minor_response_code,
185 query.context_info, 187 query.context_info,
186 query.expected_input_token, 188 query.expected_input_token,
187 query.output_token); 189 query.output_token);
188 } 190 }
189 191
190 #endif // defined(OS_POSIX) 192 #endif // defined(OS_POSIX)
191 193
192 int CreateHandler(bool disable_cname_lookup, bool use_port, 194 int CreateHandler(bool disable_cname_lookup,
193 bool synchronous_resolve_mode, 195 bool use_port,
194 const std::string& url_string, 196 bool synchronous_resolve_mode,
195 scoped_ptr<HttpAuthHandlerNegotiate>* handler) { 197 const std::string& url_string,
198 scoped_ptr<HttpAuthHandlerNegotiate>* handler) {
196 http_auth_preferences_->set_negotiate_disable_cname_lookup( 199 http_auth_preferences_->set_negotiate_disable_cname_lookup(
197 disable_cname_lookup); 200 disable_cname_lookup);
198 http_auth_preferences_->set_negotiate_enable_port(use_port); 201 http_auth_preferences_->set_negotiate_enable_port(use_port);
199 resolver_->set_synchronous_mode(synchronous_resolve_mode); 202 resolver_->set_synchronous_mode(synchronous_resolve_mode);
200 GURL gurl(url_string); 203 GURL gurl(url_string);
201 204
202 // Note: This is a little tricky because CreateAuthHandlerFromString 205 // Note: This is a little tricky because CreateAuthHandlerFromString
203 // expects a scoped_ptr<HttpAuthHandler>* rather than a 206 // expects a scoped_ptr<HttpAuthHandler>* rather than a
204 // scoped_ptr<HttpAuthHandlerNegotiate>*. This needs to do the cast 207 // scoped_ptr<HttpAuthHandlerNegotiate>*. This needs to do the cast
205 // after creating the handler, and make sure that generic_handler 208 // after creating the handler, and make sure that generic_handler
206 // no longer holds on to the HttpAuthHandlerNegotiate object. 209 // no longer holds on to the HttpAuthHandlerNegotiate object.
207 scoped_ptr<HttpAuthHandler> generic_handler; 210 scoped_ptr<HttpAuthHandler> generic_handler;
208 int rv = factory_->CreateAuthHandlerFromString("Negotiate", 211 SSLInfo null_ssl_info;
209 HttpAuth::AUTH_SERVER, 212 int rv = factory_->CreateAuthHandlerFromString(
210 gurl, 213 "Negotiate", HttpAuth::AUTH_SERVER, null_ssl_info, gurl, BoundNetLog(),
211 BoundNetLog(), 214 &generic_handler);
212 &generic_handler);
213 if (rv != OK) 215 if (rv != OK)
214 return rv; 216 return rv;
215 HttpAuthHandlerNegotiate* negotiate_handler = 217 HttpAuthHandlerNegotiate* negotiate_handler =
216 static_cast<HttpAuthHandlerNegotiate*>(generic_handler.release()); 218 static_cast<HttpAuthHandlerNegotiate*>(generic_handler.release());
217 handler->reset(negotiate_handler); 219 handler->reset(negotiate_handler);
218 return rv; 220 return rv;
219 } 221 }
220 222
221 MockAuthLibrary* AuthLibrary() { return auth_library_; } 223 MockAuthLibrary* AuthLibrary() { return auth_library_; }
222 224
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 BoundNetLog(), 381 BoundNetLog(),
380 &generic_handler); 382 &generic_handler);
381 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME, rv); 383 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME, rv);
382 EXPECT_TRUE(generic_handler.get() == NULL); 384 EXPECT_TRUE(generic_handler.get() == NULL);
383 } 385 }
384 #endif // defined(DLOPEN_KERBEROS) 386 #endif // defined(DLOPEN_KERBEROS)
385 387
386 #endif // defined(OS_POSIX) 388 #endif // defined(OS_POSIX)
387 389
388 } // namespace net 390 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698