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

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

Issue 3091001: Revert 54528 - Digest authentication uses a uri field to prevent replay attac... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 4 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_network_transaction.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 "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 "net/base/net_errors.h" 8 #include "net/base/net_errors.h"
9 #include "net/http/http_request_info.h"
10 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
11 10
12 namespace net { 11 namespace net {
13 12
14 HttpAuthHandlerMock::HttpAuthHandlerMock() 13 HttpAuthHandlerMock::HttpAuthHandlerMock()
15 : resolve_(RESOLVE_INIT), user_callback_(NULL), 14 : resolve_(RESOLVE_INIT), user_callback_(NULL),
16 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), 15 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)),
17 generate_async_(false), generate_rv_(OK), 16 generate_async_(false), generate_rv_(OK),
18 auth_token_(NULL), 17 auth_token_(NULL),
19 first_round_(true), 18 first_round_(true),
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 properties_ = connection_based_ ? IS_CONNECTION_BASED : 0; 75 properties_ = connection_based_ ? IS_CONNECTION_BASED : 0;
77 return true; 76 return true;
78 } 77 }
79 78
80 int HttpAuthHandlerMock::GenerateAuthTokenImpl(const string16* username, 79 int HttpAuthHandlerMock::GenerateAuthTokenImpl(const string16* username,
81 const string16* password, 80 const string16* password,
82 const HttpRequestInfo* request, 81 const HttpRequestInfo* request,
83 CompletionCallback* callback, 82 CompletionCallback* callback,
84 std::string* auth_token) { 83 std::string* auth_token) {
85 first_round_ = false; 84 first_round_ = false;
86 request_url_ = request->url;
87 if (generate_async_) { 85 if (generate_async_) {
88 EXPECT_TRUE(user_callback_ == NULL); 86 EXPECT_TRUE(user_callback_ == NULL);
89 EXPECT_TRUE(auth_token_ == NULL); 87 EXPECT_TRUE(auth_token_ == NULL);
90 user_callback_ = callback; 88 user_callback_ = callback;
91 auth_token_ = auth_token; 89 auth_token_ = auth_token;
92 MessageLoop::current()->PostTask( 90 MessageLoop::current()->PostTask(
93 FROM_HERE, method_factory_.NewRunnableMethod( 91 FROM_HERE, method_factory_.NewRunnableMethod(
94 &HttpAuthHandlerMock::OnGenerateAuthToken)); 92 &HttpAuthHandlerMock::OnGenerateAuthToken));
95 return ERR_IO_PENDING; 93 return ERR_IO_PENDING;
96 } else { 94 } else {
(...skipping 16 matching lines...) Expand all
113 EXPECT_TRUE(generate_async_); 111 EXPECT_TRUE(generate_async_);
114 EXPECT_TRUE(user_callback_ != NULL); 112 EXPECT_TRUE(user_callback_ != NULL);
115 if (generate_rv_ == OK) 113 if (generate_rv_ == OK)
116 *auth_token_ = "auth_token"; 114 *auth_token_ = "auth_token";
117 auth_token_ = NULL; 115 auth_token_ = NULL;
118 CompletionCallback* callback = user_callback_; 116 CompletionCallback* callback = user_callback_;
119 user_callback_ = NULL; 117 user_callback_ = NULL;
120 callback->Run(generate_rv_); 118 callback->Run(generate_rv_);
121 } 119 }
122 120
123 HttpAuthHandlerMock::Factory::Factory()
124 : do_init_from_challenge_(false) {
125 // TODO(cbentzel): Default do_init_from_challenge_ to true.
126 }
127
128 HttpAuthHandlerMock::Factory::~Factory() {
129 }
130
131 void HttpAuthHandlerMock::Factory::set_mock_handler( 121 void HttpAuthHandlerMock::Factory::set_mock_handler(
132 HttpAuthHandler* handler, HttpAuth::Target target) { 122 HttpAuthHandler* handler, HttpAuth::Target target) {
133 EXPECT_TRUE(handlers_[target].get() == NULL); 123 EXPECT_TRUE(handlers_[target].get() == NULL);
134 handlers_[target].reset(handler); 124 handlers_[target].reset(handler);
135 } 125 }
136 126
137 int HttpAuthHandlerMock::Factory::CreateAuthHandler( 127 int HttpAuthHandlerMock::Factory::CreateAuthHandler(
138 HttpAuth::ChallengeTokenizer* challenge, 128 HttpAuth::ChallengeTokenizer* challenge,
139 HttpAuth::Target target, 129 HttpAuth::Target target,
140 const GURL& origin, 130 const GURL& origin,
141 CreateReason reason, 131 CreateReason reason,
142 int nonce_count, 132 int nonce_count,
143 const BoundNetLog& net_log, 133 const BoundNetLog& net_log,
144 scoped_ptr<HttpAuthHandler>* handler) { 134 scoped_ptr<HttpAuthHandler>* handler) {
145 if (!handlers_[target].get()) 135 if (!handlers_[target].get())
146 return ERR_UNEXPECTED; 136 return ERR_UNEXPECTED;
147 scoped_ptr<HttpAuthHandler> tmp_handler(handlers_[target].release()); 137 handler->swap(handlers_[target]);
148 if (do_init_from_challenge_ &&
149 !tmp_handler->InitFromChallenge(challenge, target, origin, net_log))
150 return ERR_INVALID_RESPONSE;
151 handler->swap(tmp_handler);
152 return OK; 138 return OK;
153 } 139 }
154 140
155 } // namespace net 141 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_auth_handler_mock.h ('k') | net/http/http_network_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698