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

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

Issue 3360017: Fix multi-round authentication.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: SocketStream fix Created 10 years, 3 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_mock.h ('k') | 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 "net/http/http_auth_handler_mock.h" 5 #include "net/http/http_auth_handler_mock.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string_util.h"
8 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
9 #include "net/http/http_request_info.h" 10 #include "net/http/http_request_info.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace net { 13 namespace net {
13 14
14 HttpAuthHandlerMock::HttpAuthHandlerMock() 15 HttpAuthHandlerMock::HttpAuthHandlerMock()
15 : resolve_(RESOLVE_INIT), user_callback_(NULL), 16 : resolve_(RESOLVE_INIT), user_callback_(NULL),
16 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), 17 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
17 generate_async_(false), generate_rv_(OK), 18 generate_async_(false), generate_rv_(OK),
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 generate_rv_ = rv; 71 generate_rv_ = rv;
71 } 72 }
72 73
73 bool HttpAuthHandlerMock::Init(HttpAuth::ChallengeTokenizer* challenge) { 74 bool HttpAuthHandlerMock::Init(HttpAuth::ChallengeTokenizer* challenge) {
74 scheme_ = "mock"; 75 scheme_ = "mock";
75 score_ = 1; 76 score_ = 1;
76 properties_ = connection_based_ ? IS_CONNECTION_BASED : 0; 77 properties_ = connection_based_ ? IS_CONNECTION_BASED : 0;
77 return true; 78 return true;
78 } 79 }
79 80
81 HttpAuth::AuthorizationResult HttpAuthHandlerMock::HandleAnotherChallenge(
82 HttpAuth::ChallengeTokenizer* challenge) {
83 if (!is_connection_based())
84 return HttpAuth::AUTHORIZATION_RESULT_REJECT;
85 if (!challenge->valid() ||
86 !LowerCaseEqualsASCII(challenge->scheme(), "mock"))
87 return HttpAuth::AUTHORIZATION_RESULT_INVALID;
88 return HttpAuth::AUTHORIZATION_RESULT_ACCEPT;
89 }
90
80 int HttpAuthHandlerMock::GenerateAuthTokenImpl(const string16* username, 91 int HttpAuthHandlerMock::GenerateAuthTokenImpl(const string16* username,
81 const string16* password, 92 const string16* password,
82 const HttpRequestInfo* request, 93 const HttpRequestInfo* request,
83 CompletionCallback* callback, 94 CompletionCallback* callback,
84 std::string* auth_token) { 95 std::string* auth_token) {
85 first_round_ = false; 96 first_round_ = false;
86 request_url_ = request->url; 97 request_url_ = request->url;
87 if (generate_async_) { 98 if (generate_async_) {
88 EXPECT_TRUE(user_callback_ == NULL); 99 EXPECT_TRUE(user_callback_ == NULL);
89 EXPECT_TRUE(auth_token_ == NULL); 100 EXPECT_TRUE(auth_token_ == NULL);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 return ERR_UNEXPECTED; 157 return ERR_UNEXPECTED;
147 scoped_ptr<HttpAuthHandler> tmp_handler(handlers_[target].release()); 158 scoped_ptr<HttpAuthHandler> tmp_handler(handlers_[target].release());
148 if (do_init_from_challenge_ && 159 if (do_init_from_challenge_ &&
149 !tmp_handler->InitFromChallenge(challenge, target, origin, net_log)) 160 !tmp_handler->InitFromChallenge(challenge, target, origin, net_log))
150 return ERR_INVALID_RESPONSE; 161 return ERR_INVALID_RESPONSE;
151 handler->swap(tmp_handler); 162 handler->swap(tmp_handler);
152 return OK; 163 return OK;
153 } 164 }
154 165
155 } // namespace net 166 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_handler_mock.h ('k') | net/http/http_auth_handler_negotiate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698