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

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

Issue 1414313002: Allow dynamic updating of authentication policies (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix various build problems detected on bots. Created 5 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
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"
(...skipping 27 matching lines...) Expand all
38 void SetUp() override { 38 void SetUp() override {
39 auth_library_ = new MockAuthLibrary(); 39 auth_library_ = new MockAuthLibrary();
40 resolver_.reset(new MockHostResolver()); 40 resolver_.reset(new MockHostResolver());
41 resolver_->rules()->AddIPLiteralRule("alias", "10.0.0.2", 41 resolver_->rules()->AddIPLiteralRule("alias", "10.0.0.2",
42 "canonical.example.com"); 42 "canonical.example.com");
43 43
44 url_security_manager_.reset(new MockAllowURLSecurityManager()); 44 url_security_manager_.reset(new MockAllowURLSecurityManager());
45 factory_.reset(new HttpAuthHandlerNegotiate::Factory()); 45 factory_.reset(new HttpAuthHandlerNegotiate::Factory());
46 factory_->set_url_security_manager(url_security_manager_.get()); 46 factory_->set_url_security_manager(url_security_manager_.get());
47 #if defined(OS_ANDROID) 47 #if defined(OS_ANDROID)
48 std::string* authenticator = 48 scoped_ptr<std::string> authenticator(
49 new std::string("org.chromium.test.DummySpnegoAuthenticator"); 49 new std::string("org.chromium.test.DummySpnegoAuthenticator"));
50 factory_->set_library(authenticator); 50 factory_->set_library(authenticator.Pass());
51 MockAuthLibrary::EnsureTestAccountExists(); 51 MockAuthLibrary::EnsureTestAccountExists();
52 #endif 52 #endif
53 #if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_ANDROID)) 53 #if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_ANDROID))
54 factory_->set_library(auth_library_); 54 factory_->set_library(make_scoped_ptr(auth_library_));
asanka 2015/10/28 03:27:43 Preexisting: This is dangerous territory. Can we a
aberent 2015/11/02 18:52:50 Not without significant refactoring of the tests (
55 #endif 55 #endif
56 factory_->set_host_resolver(resolver_.get()); 56 factory_->set_host_resolver(resolver_.get());
57 } 57 }
58 58
59 #if defined(OS_ANDROID) 59 #if defined(OS_ANDROID)
60 void TearDown() override { MockAuthLibrary::RemoveTestAccounts(); } 60 void TearDown() override { MockAuthLibrary::RemoveTestAccounts(); }
61 #endif 61 #endif
62 62
63 void SetupMocks(MockAuthLibrary* mock_library) { 63 void SetupMocks(MockAuthLibrary* mock_library) {
64 #if defined(OS_WIN) 64 #if defined(OS_WIN)
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 handler->reset(negotiate_handler); 217 handler->reset(negotiate_handler);
218 return rv; 218 return rv;
219 } 219 }
220 220
221 MockAuthLibrary* AuthLibrary() { return auth_library_; } 221 MockAuthLibrary* AuthLibrary() { return auth_library_; }
222 222
223 private: 223 private:
224 #if defined(OS_WIN) 224 #if defined(OS_WIN)
225 scoped_ptr<SecPkgInfoW> security_package_; 225 scoped_ptr<SecPkgInfoW> security_package_;
226 #endif 226 #endif
227 // |auth_library_| is passed to |factory_|, which assumes ownership of it. 227 // |auth_library_| is passed to |factory_|, which assumes ownership of it, but
228 // can't be a scoped pointer to it since the tests need access when they set
229 // up the mocks after passing ownership.
228 MockAuthLibrary* auth_library_; 230 MockAuthLibrary* auth_library_;
229 scoped_ptr<MockHostResolver> resolver_; 231 scoped_ptr<MockHostResolver> resolver_;
230 scoped_ptr<URLSecurityManager> url_security_manager_; 232 scoped_ptr<URLSecurityManager> url_security_manager_;
231 scoped_ptr<HttpAuthHandlerNegotiate::Factory> factory_; 233 scoped_ptr<HttpAuthHandlerNegotiate::Factory> factory_;
232 }; 234 };
233 235
234 TEST_F(HttpAuthHandlerNegotiateTest, DisableCname) { 236 TEST_F(HttpAuthHandlerNegotiateTest, DisableCname) {
235 SetupMocks(AuthLibrary()); 237 SetupMocks(AuthLibrary());
236 scoped_ptr<HttpAuthHandlerNegotiate> auth_handler; 238 scoped_ptr<HttpAuthHandlerNegotiate> auth_handler;
237 EXPECT_EQ(OK, CreateHandler( 239 EXPECT_EQ(OK, CreateHandler(
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 361
360 #if defined(DLOPEN_KERBEROS) 362 #if defined(DLOPEN_KERBEROS)
361 TEST_F(HttpAuthHandlerNegotiateTest, MissingGSSAPI) { 363 TEST_F(HttpAuthHandlerNegotiateTest, MissingGSSAPI) {
362 scoped_ptr<HostResolver> host_resolver(new MockHostResolver()); 364 scoped_ptr<HostResolver> host_resolver(new MockHostResolver());
363 MockAllowURLSecurityManager url_security_manager; 365 MockAllowURLSecurityManager url_security_manager;
364 scoped_ptr<HttpAuthHandlerNegotiate::Factory> negotiate_factory( 366 scoped_ptr<HttpAuthHandlerNegotiate::Factory> negotiate_factory(
365 new HttpAuthHandlerNegotiate::Factory()); 367 new HttpAuthHandlerNegotiate::Factory());
366 negotiate_factory->set_host_resolver(host_resolver.get()); 368 negotiate_factory->set_host_resolver(host_resolver.get());
367 negotiate_factory->set_url_security_manager(&url_security_manager); 369 negotiate_factory->set_url_security_manager(&url_security_manager);
368 negotiate_factory->set_library( 370 negotiate_factory->set_library(
369 new GSSAPISharedLibrary("/this/library/does/not/exist")); 371 make_scoped_ptr(new GSSAPISharedLibrary("/this/library/does/not/exist")));
370 372
371 GURL gurl("http://www.example.com"); 373 GURL gurl("http://www.example.com");
372 scoped_ptr<HttpAuthHandler> generic_handler; 374 scoped_ptr<HttpAuthHandler> generic_handler;
373 int rv = negotiate_factory->CreateAuthHandlerFromString( 375 int rv = negotiate_factory->CreateAuthHandlerFromString(
374 "Negotiate", 376 "Negotiate",
375 HttpAuth::AUTH_SERVER, 377 HttpAuth::AUTH_SERVER,
376 gurl, 378 gurl,
377 BoundNetLog(), 379 BoundNetLog(),
378 &generic_handler); 380 &generic_handler);
379 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME, rv); 381 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME, rv);
380 EXPECT_TRUE(generic_handler.get() == NULL); 382 EXPECT_TRUE(generic_handler.get() == NULL);
381 } 383 }
382 #endif // defined(DLOPEN_KERBEROS) 384 #endif // defined(DLOPEN_KERBEROS)
383 385
384 #endif // defined(OS_POSIX) 386 #endif // defined(OS_POSIX)
385 387
386 } // namespace net 388 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698