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

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

Issue 9307093: Don't use IDENT_SRC_URL for HttpAuth challenges. IE hasn't supported it for years, and at worst ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 years, 10 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_controller.h" 5 #include "net/http/http_auth_controller.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "net/base/net_errors.h" 8 #include "net/base/net_errors.h"
9 #include "net/base/net_log.h" 9 #include "net/base/net_log.h"
10 #include "net/base/test_completion_callback.h" 10 #include "net/base/test_completion_callback.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 HttpAuthHandlerMock* auth_handler = new HttpAuthHandlerMock(); 64 HttpAuthHandlerMock* auth_handler = new HttpAuthHandlerMock();
65 auth_handler->SetGenerateExpectation((run_mode == RUN_HANDLER_ASYNC), 65 auth_handler->SetGenerateExpectation((run_mode == RUN_HANDLER_ASYNC),
66 handler_rv); 66 handler_rv);
67 auth_handler_factory.AddMockHandler(auth_handler, HttpAuth::AUTH_PROXY); 67 auth_handler_factory.AddMockHandler(auth_handler, HttpAuth::AUTH_PROXY);
68 auth_handler_factory.set_do_init_from_challenge(true); 68 auth_handler_factory.set_do_init_from_challenge(true);
69 69
70 scoped_refptr<HttpAuthController> controller( 70 scoped_refptr<HttpAuthController> controller(
71 new HttpAuthController(HttpAuth::AUTH_PROXY, 71 new HttpAuthController(HttpAuth::AUTH_PROXY,
72 GURL("http://example.com"), 72 GURL("http://example.com"),
73 &dummy_auth_cache, &auth_handler_factory)); 73 &dummy_auth_cache, &auth_handler_factory));
74 ASSERT_EQ(OK, 74 ASSERT_EQ(OK, controller->HandleAuthChallenge(
75 controller->HandleAuthChallenge(headers, false, false, dummy_log)); 75 headers, HttpAuthController::CHALLENGE_OPTION_SEND_SERVER_AUTH,
76 dummy_log));
76 ASSERT_TRUE(controller->HaveAuthHandler()); 77 ASSERT_TRUE(controller->HaveAuthHandler());
77 controller->ResetAuth(AuthCredentials()); 78 controller->ResetAuth(AuthCredentials());
78 EXPECT_TRUE(controller->HaveAuth()); 79 EXPECT_TRUE(controller->HaveAuth());
79 80
80 TestCompletionCallback callback; 81 TestCompletionCallback callback;
81 EXPECT_EQ((run_mode == RUN_HANDLER_ASYNC)? ERR_IO_PENDING: 82 EXPECT_EQ((run_mode == RUN_HANDLER_ASYNC)? ERR_IO_PENDING:
82 expected_controller_rv, 83 expected_controller_rv,
83 controller->MaybeGenerateAuthToken(&request, callback.callback(), 84 controller->MaybeGenerateAuthToken(&request, callback.callback(),
84 dummy_log)); 85 dummy_log));
85 if (run_mode == RUN_HANDLER_ASYNC) 86 if (run_mode == RUN_HANDLER_ASYNC)
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 HttpAuth::AUTH_SERVER); 202 HttpAuth::AUTH_SERVER);
202 auth_handler_factory.AddMockHandler( 203 auth_handler_factory.AddMockHandler(
203 new MockHandler(OK, HttpAuth::AUTH_SCHEME_BASIC), 204 new MockHandler(OK, HttpAuth::AUTH_SCHEME_BASIC),
204 HttpAuth::AUTH_SERVER); 205 HttpAuth::AUTH_SERVER);
205 auth_handler_factory.set_do_init_from_challenge(true); 206 auth_handler_factory.set_do_init_from_challenge(true);
206 207
207 scoped_refptr<HttpAuthController> controller( 208 scoped_refptr<HttpAuthController> controller(
208 new HttpAuthController(HttpAuth::AUTH_SERVER, 209 new HttpAuthController(HttpAuth::AUTH_SERVER,
209 GURL("http://example.com"), 210 GURL("http://example.com"),
210 &dummy_auth_cache, &auth_handler_factory)); 211 &dummy_auth_cache, &auth_handler_factory));
211 ASSERT_EQ(OK, 212 ASSERT_EQ(OK, controller->HandleAuthChallenge(
212 controller->HandleAuthChallenge(headers, false, false, dummy_log)); 213 headers, HttpAuthController::CHALLENGE_OPTION_SEND_SERVER_AUTH,
214 dummy_log));
213 ASSERT_TRUE(controller->HaveAuthHandler()); 215 ASSERT_TRUE(controller->HaveAuthHandler());
214 controller->ResetAuth(AuthCredentials()); 216 controller->ResetAuth(AuthCredentials());
215 EXPECT_TRUE(controller->HaveAuth()); 217 EXPECT_TRUE(controller->HaveAuth());
216 218
217 // Should only succeed if we are using the AUTH_SCHEME_MOCK MockHandler. 219 // Should only succeed if we are using the AUTH_SCHEME_MOCK MockHandler.
218 EXPECT_EQ(OK, controller->MaybeGenerateAuthToken( 220 EXPECT_EQ(OK, controller->MaybeGenerateAuthToken(
219 &request, CompletionCallback(), dummy_log)); 221 &request, CompletionCallback(), dummy_log));
220 controller->AddAuthorizationHeader(&request_headers); 222 controller->AddAuthorizationHeader(&request_headers);
221 223
222 // Once a token is generated, simulate the receipt of a server response 224 // Once a token is generated, simulate the receipt of a server response
223 // indicating that the authentication attempt was rejected. 225 // indicating that the authentication attempt was rejected.
224 ASSERT_EQ(OK, 226 ASSERT_EQ(OK, controller->HandleAuthChallenge(
225 controller->HandleAuthChallenge(headers, false, false, dummy_log)); 227 headers, HttpAuthController::CHALLENGE_OPTION_SEND_SERVER_AUTH,
228 dummy_log));
226 ASSERT_TRUE(controller->HaveAuthHandler()); 229 ASSERT_TRUE(controller->HaveAuthHandler());
227 controller->ResetAuth(AuthCredentials(ASCIIToUTF16("Hello"), string16())); 230 controller->ResetAuth(AuthCredentials(ASCIIToUTF16("Hello"), string16()));
228 EXPECT_TRUE(controller->HaveAuth()); 231 EXPECT_TRUE(controller->HaveAuth());
229 EXPECT_TRUE(controller->IsAuthSchemeDisabled(HttpAuth::AUTH_SCHEME_MOCK)); 232 EXPECT_TRUE(controller->IsAuthSchemeDisabled(HttpAuth::AUTH_SCHEME_MOCK));
230 EXPECT_FALSE(controller->IsAuthSchemeDisabled(HttpAuth::AUTH_SCHEME_BASIC)); 233 EXPECT_FALSE(controller->IsAuthSchemeDisabled(HttpAuth::AUTH_SCHEME_BASIC));
231 234
232 // Should only succeed if we are using the AUTH_SCHEME_BASIC MockHandler. 235 // Should only succeed if we are using the AUTH_SCHEME_BASIC MockHandler.
233 EXPECT_EQ(OK, controller->MaybeGenerateAuthToken( 236 EXPECT_EQ(OK, controller->MaybeGenerateAuthToken(
234 &request, CompletionCallback(), dummy_log)); 237 &request, CompletionCallback(), dummy_log));
235 } 238 }
236 239
237 } // namespace net 240 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698