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

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

Issue 4560001: Support specifying the GSSAPI library that will be used. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: fix library handling on Windows; port to ToT Created 10 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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 "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "net/base/mock_host_resolver.h" 9 #include "net/base/mock_host_resolver.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 13 matching lines...) Expand all
24 #elif defined(OS_POSIX) 24 #elif defined(OS_POSIX)
25 typedef net::test::MockGSSAPILibrary MockAuthLibrary; 25 typedef net::test::MockGSSAPILibrary MockAuthLibrary;
26 #endif 26 #endif
27 27
28 28
29 namespace net { 29 namespace net {
30 30
31 class HttpAuthHandlerNegotiateTest : public PlatformTest { 31 class HttpAuthHandlerNegotiateTest : public PlatformTest {
32 public: 32 public:
33 virtual void SetUp() { 33 virtual void SetUp() {
34 auth_library_.reset(new MockAuthLibrary()); 34 auth_library_ = new MockAuthLibrary();
35 resolver_.reset(new MockHostResolver()); 35 resolver_.reset(new MockHostResolver());
36 resolver_->rules()->AddIPLiteralRule("alias", "10.0.0.2", 36 resolver_->rules()->AddIPLiteralRule("alias", "10.0.0.2",
37 "canonical.example.com"); 37 "canonical.example.com");
38 38
39 url_security_manager_.reset(new URLSecurityManagerAllow()); 39 url_security_manager_.reset(new URLSecurityManagerAllow());
40 factory_.reset(new HttpAuthHandlerNegotiate::Factory()); 40 factory_.reset(new HttpAuthHandlerNegotiate::Factory());
41 factory_->set_url_security_manager(url_security_manager_.get()); 41 factory_->set_url_security_manager(url_security_manager_.get());
42 factory_->set_library(auth_library_.get()); 42 factory_->set_library(auth_library_);
43 factory_->set_host_resolver(resolver_.get()); 43 factory_->set_host_resolver(resolver_.get());
44 } 44 }
45 45
46 void SetupMocks(MockAuthLibrary* mock_library) { 46 void SetupMocks(MockAuthLibrary* mock_library) {
47 #if defined(OS_WIN) 47 #if defined(OS_WIN)
48 security_package_.reset(new SecPkgInfoW); 48 security_package_.reset(new SecPkgInfoW);
49 memset(security_package_.get(), 0x0, sizeof(SecPkgInfoW)); 49 memset(security_package_.get(), 0x0, sizeof(SecPkgInfoW));
50 security_package_->cbMaxToken = 1337; 50 security_package_->cbMaxToken = 1337;
51 mock_library->ExpectQuerySecurityPackageInfo( 51 mock_library->ExpectQuerySecurityPackageInfo(
52 L"Negotiate", SEC_E_OK, security_package_.get()); 52 L"Negotiate", SEC_E_OK, security_package_.get());
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 BoundNetLog(), 198 BoundNetLog(),
199 &generic_handler); 199 &generic_handler);
200 if (rv != OK) 200 if (rv != OK)
201 return rv; 201 return rv;
202 HttpAuthHandlerNegotiate* negotiate_handler = 202 HttpAuthHandlerNegotiate* negotiate_handler =
203 static_cast<HttpAuthHandlerNegotiate*>(generic_handler.release()); 203 static_cast<HttpAuthHandlerNegotiate*>(generic_handler.release());
204 handler->reset(negotiate_handler); 204 handler->reset(negotiate_handler);
205 return rv; 205 return rv;
206 } 206 }
207 207
208 MockAuthLibrary* AuthLibrary() { return auth_library_.get(); } 208 MockAuthLibrary* AuthLibrary() { return auth_library_; }
209 209
210 private: 210 private:
211 #if defined(OS_WIN) 211 #if defined(OS_WIN)
212 scoped_ptr<SecPkgInfoW> security_package_; 212 scoped_ptr<SecPkgInfoW> security_package_;
213 #endif 213 #endif
214 scoped_ptr<MockAuthLibrary> auth_library_; 214 // |auth_library_| will be passed to |factory_| and will then be owned by it.
danno 2010/11/10 16:52:01 |auth_library_| is passed to |factory_|, which ass
Jakob Kummerow (corp) 2010/11/10 17:48:39 Done.
215 MockAuthLibrary* auth_library_;
215 scoped_ptr<MockHostResolver> resolver_; 216 scoped_ptr<MockHostResolver> resolver_;
216 scoped_ptr<URLSecurityManager> url_security_manager_; 217 scoped_ptr<URLSecurityManager> url_security_manager_;
217 scoped_ptr<HttpAuthHandlerNegotiate::Factory> factory_; 218 scoped_ptr<HttpAuthHandlerNegotiate::Factory> factory_;
218 }; 219 };
219 220
220 TEST_F(HttpAuthHandlerNegotiateTest, DisableCname) { 221 TEST_F(HttpAuthHandlerNegotiateTest, DisableCname) {
221 SetupMocks(AuthLibrary()); 222 SetupMocks(AuthLibrary());
222 scoped_ptr<HttpAuthHandlerNegotiate> auth_handler; 223 scoped_ptr<HttpAuthHandlerNegotiate> auth_handler;
223 EXPECT_EQ(OK, CreateHandler( 224 EXPECT_EQ(OK, CreateHandler(
224 true, false, true, "http://alias:500", &auth_handler)); 225 true, false, true, "http://alias:500", &auth_handler));
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 HttpRequestInfo request_info; 343 HttpRequestInfo request_info;
343 std::string token; 344 std::string token;
344 EXPECT_EQ(ERR_IO_PENDING, auth_handler->GenerateAuthToken( 345 EXPECT_EQ(ERR_IO_PENDING, auth_handler->GenerateAuthToken(
345 NULL, NULL, &request_info, &callback, &token)); 346 NULL, NULL, &request_info, &callback, &token));
346 EXPECT_EQ(ERR_MISSING_AUTH_CREDENTIALS, callback.WaitForResult()); 347 EXPECT_EQ(ERR_MISSING_AUTH_CREDENTIALS, callback.WaitForResult());
347 } 348 }
348 349
349 #endif // defined(OS_POSIX) 350 #endif // defined(OS_POSIX)
350 351
351 } // namespace net 352 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698