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

Unified Diff: net/http/http_auth_handler_mock.cc

Issue 1157333005: [net/http auth] Use strings to identify authentication schemes. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_auth_handler_mock.h ('k') | net/http/http_auth_handler_negotiate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_auth_handler_mock.cc
diff --git a/net/http/http_auth_handler_mock.cc b/net/http/http_auth_handler_mock.cc
index f800c192ac4060e12695b8cbb5cd22e3a17daee2..b879efe8db23e350c518fea6a5adcd93928a53fb 100644
--- a/net/http/http_auth_handler_mock.cc
+++ b/net/http/http_auth_handler_mock.cc
@@ -17,16 +17,7 @@
namespace net {
HttpAuthHandlerMock::HttpAuthHandlerMock()
- : resolve_(RESOLVE_INIT),
- generate_async_(false),
- generate_rv_(OK),
- auth_token_(NULL),
- first_round_(true),
- connection_based_(false),
- allows_default_credentials_(false),
- allows_explicit_credentials_(true),
- weak_factory_(this) {
-}
+ : generate_rv_(OK), weak_factory_(this) {}
HttpAuthHandlerMock::~HttpAuthHandlerMock() {
}
@@ -80,11 +71,12 @@ void HttpAuthHandlerMock::SetGenerateExpectation(bool async, int rv) {
HttpAuth::AuthorizationResult HttpAuthHandlerMock::HandleAnotherChallenge(
HttpAuthChallengeTokenizer* challenge) {
- // If we receive an empty challenge for a connection based scheme, or a second
- // challenge for a non connection based scheme, assume it's a rejection.
- if (!is_connection_based() || challenge->base64_param().empty())
+ // If we receive a second challenge for a regular scheme, assume it's a
+ // rejection. Receiving an empty second challenge when expecting multiple
+ // rounds is also considered a rejection.
+ if (!expect_multiple_challenges() || challenge->base64_param().empty())
return HttpAuth::AUTHORIZATION_RESULT_REJECT;
- if (!base::LowerCaseEqualsASCII(challenge->scheme(), "mock"))
+ if (!challenge->SchemeIs("mock"))
return HttpAuth::AUTHORIZATION_RESULT_INVALID;
return HttpAuth::AUTHORIZATION_RESULT_ACCEPT;
}
@@ -102,9 +94,7 @@ bool HttpAuthHandlerMock::AllowsExplicitCredentials() {
}
bool HttpAuthHandlerMock::Init(HttpAuthChallengeTokenizer* challenge) {
- auth_scheme_ = HttpAuth::AUTH_SCHEME_MOCK;
- score_ = 1;
- properties_ = connection_based_ ? IS_CONNECTION_BASED : 0;
+ auth_scheme_ = "mock";
return true;
}
@@ -164,6 +154,11 @@ void HttpAuthHandlerMock::Factory::AddMockHandler(
handlers_[target].push_back(handler);
}
+bool HttpAuthHandlerMock::Factory::HaveAuthHandlers(
+ HttpAuth::Target target) const {
+ return !handlers_[target].empty();
+}
+
int HttpAuthHandlerMock::Factory::CreateAuthHandler(
HttpAuthChallengeTokenizer* challenge,
HttpAuth::Target target,
« no previous file with comments | « net/http/http_auth_handler_mock.h ('k') | net/http/http_auth_handler_negotiate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698