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

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

Issue 6191001: Cleanup: Use AUTH_SCHEME enum instead of a string. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Merge with trunk Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_auth_handler_digest.cc ('k') | net/http/http_auth_handler_mock.cc » ('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/mock_host_resolver.h" 6 #include "net/base/mock_host_resolver.h"
7 #include "net/base/net_errors.h" 7 #include "net/base/net_errors.h"
8 #include "net/http/http_auth_handler.h" 8 #include "net/http/http_auth_handler.h"
9 #include "net/http/http_auth_handler_factory.h" 9 #include "net/http/http_auth_handler_factory.h"
10 #include "net/http/url_security_manager.h" 10 #include "net/http/url_security_manager.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 { 107 {
108 scoped_ptr<HttpAuthHandler> handler; 108 scoped_ptr<HttpAuthHandler> handler;
109 int rv = http_auth_handler_factory->CreateAuthHandlerFromString( 109 int rv = http_auth_handler_factory->CreateAuthHandlerFromString(
110 "Basic realm=\"FooBar\"", 110 "Basic realm=\"FooBar\"",
111 HttpAuth::AUTH_SERVER, 111 HttpAuth::AUTH_SERVER,
112 server_origin, 112 server_origin,
113 BoundNetLog(), 113 BoundNetLog(),
114 &handler); 114 &handler);
115 EXPECT_EQ(OK, rv); 115 EXPECT_EQ(OK, rv);
116 ASSERT_FALSE(handler.get() == NULL); 116 ASSERT_FALSE(handler.get() == NULL);
117 EXPECT_STREQ("basic", handler->scheme().c_str()); 117 EXPECT_EQ(HttpAuth::AUTH_SCHEME_BASIC, handler->auth_scheme());
118 EXPECT_STREQ("FooBar", handler->realm().c_str()); 118 EXPECT_STREQ("FooBar", handler->realm().c_str());
119 EXPECT_EQ(HttpAuth::AUTH_SERVER, handler->target()); 119 EXPECT_EQ(HttpAuth::AUTH_SERVER, handler->target());
120 EXPECT_FALSE(handler->encrypts_identity()); 120 EXPECT_FALSE(handler->encrypts_identity());
121 EXPECT_FALSE(handler->is_connection_based()); 121 EXPECT_FALSE(handler->is_connection_based());
122 } 122 }
123 { 123 {
124 scoped_ptr<HttpAuthHandler> handler; 124 scoped_ptr<HttpAuthHandler> handler;
125 int rv = http_auth_handler_factory->CreateAuthHandlerFromString( 125 int rv = http_auth_handler_factory->CreateAuthHandlerFromString(
126 "UNSUPPORTED realm=\"FooBar\"", 126 "UNSUPPORTED realm=\"FooBar\"",
127 HttpAuth::AUTH_SERVER, 127 HttpAuth::AUTH_SERVER,
128 server_origin, 128 server_origin,
129 BoundNetLog(), 129 BoundNetLog(),
130 &handler); 130 &handler);
131 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME, rv); 131 EXPECT_EQ(ERR_UNSUPPORTED_AUTH_SCHEME, rv);
132 EXPECT_TRUE(handler.get() == NULL); 132 EXPECT_TRUE(handler.get() == NULL);
133 } 133 }
134 { 134 {
135 scoped_ptr<HttpAuthHandler> handler; 135 scoped_ptr<HttpAuthHandler> handler;
136 int rv = http_auth_handler_factory->CreateAuthHandlerFromString( 136 int rv = http_auth_handler_factory->CreateAuthHandlerFromString(
137 "Digest realm=\"FooBar\", nonce=\"xyz\"", 137 "Digest realm=\"FooBar\", nonce=\"xyz\"",
138 HttpAuth::AUTH_PROXY, 138 HttpAuth::AUTH_PROXY,
139 proxy_origin, 139 proxy_origin,
140 BoundNetLog(), 140 BoundNetLog(),
141 &handler); 141 &handler);
142 EXPECT_EQ(OK, rv); 142 EXPECT_EQ(OK, rv);
143 ASSERT_FALSE(handler.get() == NULL); 143 ASSERT_FALSE(handler.get() == NULL);
144 EXPECT_STREQ("digest", handler->scheme().c_str()); 144 EXPECT_EQ(HttpAuth::AUTH_SCHEME_DIGEST, handler->auth_scheme());
145 EXPECT_STREQ("FooBar", handler->realm().c_str()); 145 EXPECT_STREQ("FooBar", handler->realm().c_str());
146 EXPECT_EQ(HttpAuth::AUTH_PROXY, handler->target()); 146 EXPECT_EQ(HttpAuth::AUTH_PROXY, handler->target());
147 EXPECT_TRUE(handler->encrypts_identity()); 147 EXPECT_TRUE(handler->encrypts_identity());
148 EXPECT_FALSE(handler->is_connection_based()); 148 EXPECT_FALSE(handler->is_connection_based());
149 } 149 }
150 { 150 {
151 scoped_ptr<HttpAuthHandler> handler; 151 scoped_ptr<HttpAuthHandler> handler;
152 int rv = http_auth_handler_factory->CreateAuthHandlerFromString( 152 int rv = http_auth_handler_factory->CreateAuthHandlerFromString(
153 "NTLM", 153 "NTLM",
154 HttpAuth::AUTH_SERVER, 154 HttpAuth::AUTH_SERVER,
155 server_origin, 155 server_origin,
156 BoundNetLog(), 156 BoundNetLog(),
157 &handler); 157 &handler);
158 EXPECT_EQ(OK, rv); 158 EXPECT_EQ(OK, rv);
159 ASSERT_FALSE(handler.get() == NULL); 159 ASSERT_FALSE(handler.get() == NULL);
160 EXPECT_STREQ("ntlm", handler->scheme().c_str()); 160 EXPECT_EQ(HttpAuth::AUTH_SCHEME_NTLM, handler->auth_scheme());
161 EXPECT_STREQ("", handler->realm().c_str()); 161 EXPECT_STREQ("", handler->realm().c_str());
162 EXPECT_EQ(HttpAuth::AUTH_SERVER, handler->target()); 162 EXPECT_EQ(HttpAuth::AUTH_SERVER, handler->target());
163 EXPECT_TRUE(handler->encrypts_identity()); 163 EXPECT_TRUE(handler->encrypts_identity());
164 EXPECT_TRUE(handler->is_connection_based()); 164 EXPECT_TRUE(handler->is_connection_based());
165 } 165 }
166 { 166 {
167 scoped_ptr<HttpAuthHandler> handler; 167 scoped_ptr<HttpAuthHandler> handler;
168 int rv = http_auth_handler_factory->CreateAuthHandlerFromString( 168 int rv = http_auth_handler_factory->CreateAuthHandlerFromString(
169 "Negotiate", 169 "Negotiate",
170 HttpAuth::AUTH_SERVER, 170 HttpAuth::AUTH_SERVER,
171 server_origin, 171 server_origin,
172 BoundNetLog(), 172 BoundNetLog(),
173 &handler); 173 &handler);
174 EXPECT_EQ(OK, rv); 174 EXPECT_EQ(OK, rv);
175 ASSERT_FALSE(handler.get() == NULL); 175 ASSERT_FALSE(handler.get() == NULL);
176 EXPECT_STREQ("negotiate", handler->scheme().c_str()); 176 EXPECT_EQ(HttpAuth::AUTH_SCHEME_NEGOTIATE, handler->auth_scheme());
177 EXPECT_STREQ("", handler->realm().c_str()); 177 EXPECT_STREQ("", handler->realm().c_str());
178 EXPECT_EQ(HttpAuth::AUTH_SERVER, handler->target()); 178 EXPECT_EQ(HttpAuth::AUTH_SERVER, handler->target());
179 EXPECT_TRUE(handler->encrypts_identity()); 179 EXPECT_TRUE(handler->encrypts_identity());
180 EXPECT_TRUE(handler->is_connection_based()); 180 EXPECT_TRUE(handler->is_connection_based());
181 } 181 }
182 } 182 }
183 183
184 } // namespace net 184 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_handler_digest.cc ('k') | net/http/http_auth_handler_mock.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698