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

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

Issue 3013003: Don't do Negotiate with GSSAPI if default credentials are not allowed. (Closed)
Patch Set: Remove anonymous namespace to make OSX build. Created 10 years, 5 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
« no previous file with comments | « no previous file | net/http/http_auth_handler_negotiate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/scoped_ptr.h" 5 #include "base/scoped_ptr.h"
6 #include "net/base/net_errors.h" 6 #include "net/base/net_errors.h"
7 #include "net/http/http_auth_handler.h" 7 #include "net/http/http_auth_handler.h"
8 #include "net/http/http_auth_handler_factory.h" 8 #include "net/http/http_auth_handler_factory.h"
9 #include "net/http/url_security_manager.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 11
11 namespace net { 12 namespace net {
12 13
14 namespace {
15
13 class MockHttpAuthHandlerFactory : public HttpAuthHandlerFactory { 16 class MockHttpAuthHandlerFactory : public HttpAuthHandlerFactory {
14 public: 17 public:
15 explicit MockHttpAuthHandlerFactory(int return_code) : 18 explicit MockHttpAuthHandlerFactory(int return_code) :
16 return_code_(return_code) {} 19 return_code_(return_code) {}
17 virtual ~MockHttpAuthHandlerFactory() {} 20 virtual ~MockHttpAuthHandlerFactory() {}
18 21
19 virtual int CreateAuthHandler(HttpAuth::ChallengeTokenizer* challenge, 22 virtual int CreateAuthHandler(HttpAuth::ChallengeTokenizer* challenge,
20 HttpAuth::Target target, 23 HttpAuth::Target target,
21 const GURL& origin, 24 const GURL& origin,
22 CreateReason reason, 25 CreateReason reason,
23 int nonce_count, 26 int nonce_count,
24 const BoundNetLog& net_log, 27 const BoundNetLog& net_log,
25 scoped_ptr<HttpAuthHandler>* handler) { 28 scoped_ptr<HttpAuthHandler>* handler) {
26 handler->reset(); 29 handler->reset();
27 return return_code_; 30 return return_code_;
28 } 31 }
29 32
30 private: 33 private:
31 int return_code_; 34 int return_code_;
32 }; 35 };
33 36
37 } // namespace
38
34 TEST(HttpAuthHandlerFactoryTest, RegistryFactory) { 39 TEST(HttpAuthHandlerFactoryTest, RegistryFactory) {
35 HttpAuthHandlerRegistryFactory registry_factory; 40 HttpAuthHandlerRegistryFactory registry_factory;
36 GURL gurl("www.google.com"); 41 GURL gurl("www.google.com");
37 const int kBasicReturnCode = ERR_INVALID_SPDY_STREAM; 42 const int kBasicReturnCode = ERR_INVALID_SPDY_STREAM;
38 MockHttpAuthHandlerFactory* mock_factory_basic = 43 MockHttpAuthHandlerFactory* mock_factory_basic =
39 new MockHttpAuthHandlerFactory(kBasicReturnCode); 44 new MockHttpAuthHandlerFactory(kBasicReturnCode);
40 45
41 const int kDigestReturnCode = ERR_PAC_SCRIPT_FAILED; 46 const int kDigestReturnCode = ERR_PAC_SCRIPT_FAILED;
42 MockHttpAuthHandlerFactory* mock_factory_digest = 47 MockHttpAuthHandlerFactory* mock_factory_digest =
43 new MockHttpAuthHandlerFactory(kDigestReturnCode); 48 new MockHttpAuthHandlerFactory(kDigestReturnCode);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 EXPECT_EQ(kBasicReturnCode, 88 EXPECT_EQ(kBasicReturnCode,
84 registry_factory.CreateAuthHandlerFromString( 89 registry_factory.CreateAuthHandlerFromString(
85 "Basic", HttpAuth::AUTH_SERVER, gurl, BoundNetLog(), &handler)); 90 "Basic", HttpAuth::AUTH_SERVER, gurl, BoundNetLog(), &handler));
86 EXPECT_EQ(kDigestReturnCodeReplace, 91 EXPECT_EQ(kDigestReturnCodeReplace,
87 registry_factory.CreateAuthHandlerFromString( 92 registry_factory.CreateAuthHandlerFromString(
88 "Digest", HttpAuth::AUTH_SERVER, gurl, BoundNetLog(), 93 "Digest", HttpAuth::AUTH_SERVER, gurl, BoundNetLog(),
89 &handler)); 94 &handler));
90 } 95 }
91 96
92 TEST(HttpAuthHandlerFactoryTest, DefaultFactory) { 97 TEST(HttpAuthHandlerFactoryTest, DefaultFactory) {
93 scoped_ptr<HttpAuthHandlerFactory> http_auth_handler_factory( 98 URLSecurityManagerAllow url_security_manager;
99 scoped_ptr<HttpAuthHandlerRegistryFactory> http_auth_handler_factory(
94 HttpAuthHandlerFactory::CreateDefault()); 100 HttpAuthHandlerFactory::CreateDefault());
95 101 http_auth_handler_factory->SetURLSecurityManager(
102 "negotiate", &url_security_manager);
96 GURL server_origin("http://www.example.com"); 103 GURL server_origin("http://www.example.com");
97 GURL proxy_origin("http://cache.example.com:3128"); 104 GURL proxy_origin("http://cache.example.com:3128");
98 { 105 {
99 scoped_ptr<HttpAuthHandler> handler; 106 scoped_ptr<HttpAuthHandler> handler;
100 int rv = http_auth_handler_factory->CreateAuthHandlerFromString( 107 int rv = http_auth_handler_factory->CreateAuthHandlerFromString(
101 "Basic realm=\"FooBar\"", 108 "Basic realm=\"FooBar\"",
102 HttpAuth::AUTH_SERVER, 109 HttpAuth::AUTH_SERVER,
103 server_origin, 110 server_origin,
104 BoundNetLog(), 111 BoundNetLog(),
105 &handler); 112 &handler);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 EXPECT_FALSE(handler.get() == NULL); 173 EXPECT_FALSE(handler.get() == NULL);
167 EXPECT_STREQ("negotiate", handler->scheme().c_str()); 174 EXPECT_STREQ("negotiate", handler->scheme().c_str());
168 EXPECT_STREQ("", handler->realm().c_str()); 175 EXPECT_STREQ("", handler->realm().c_str());
169 EXPECT_EQ(HttpAuth::AUTH_SERVER, handler->target()); 176 EXPECT_EQ(HttpAuth::AUTH_SERVER, handler->target());
170 EXPECT_TRUE(handler->encrypts_identity()); 177 EXPECT_TRUE(handler->encrypts_identity());
171 EXPECT_TRUE(handler->is_connection_based()); 178 EXPECT_TRUE(handler->is_connection_based());
172 } 179 }
173 } 180 }
174 181
175 } // namespace net 182 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/http/http_auth_handler_negotiate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698