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

Unified Diff: net/http/http_auth_handler_mock.h

Issue 1381493004: [net/http auth] Generalize HttpAuthHandlerMock. Base URL: https://chromium.googlesource.com/chromium/src.git@http-auth-scheme-properties
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_controller_unittest.cc ('k') | net/http/http_auth_handler_mock.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.h
diff --git a/net/http/http_auth_handler_mock.h b/net/http/http_auth_handler_mock.h
index 72653b010b6b76138e7168ec0dcfb6358045477c..3518638f9a9f04cfb3c67c5621bcdbb9cd6d9453 100644
--- a/net/http/http_auth_handler_mock.h
+++ b/net/http/http_auth_handler_mock.h
@@ -7,8 +7,10 @@
#include <string>
+#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h"
#include "base/memory/weak_ptr.h"
+#include "net/http/http_auth.h"
#include "net/http/http_auth_handler.h"
#include "net/http/http_auth_handler_factory.h"
#include "url/gurl.h"
@@ -20,14 +22,6 @@ class HostResolver;
// MockAuthHandler is used in tests to reliably trigger edge cases.
class HttpAuthHandlerMock : public HttpAuthHandler {
public:
- enum Resolve {
- RESOLVE_INIT,
- RESOLVE_SKIP,
- RESOLVE_SYNC,
- RESOLVE_ASYNC,
- RESOLVE_TESTED,
- };
-
// The Factory class returns handlers in the order they were added via
// AddMockHandler.
class Factory : public HttpAuthHandlerFactory {
@@ -35,14 +29,12 @@ class HttpAuthHandlerMock : public HttpAuthHandler {
Factory();
~Factory() override;
- void AddMockHandler(HttpAuthHandler* handler, HttpAuth::Target target);
+ void AddMockHandler(scoped_ptr<HttpAuthHandler> handler,
+ CreateReason reason,
+ HttpAuth::Target target);
bool HaveAuthHandlers(HttpAuth::Target) const;
- void set_do_init_from_challenge(bool do_init_from_challenge) {
- do_init_from_challenge_ = do_init_from_challenge;
- }
-
// HttpAuthHandlerFactory:
int CreateAuthHandler(HttpAuthChallengeTokenizer* challenge,
HttpAuth::Target target,
@@ -53,24 +45,22 @@ class HttpAuthHandlerMock : public HttpAuthHandler {
scoped_ptr<HttpAuthHandler>* handler) override;
private:
- ScopedVector<HttpAuthHandler> handlers_[HttpAuth::AUTH_NUM_TARGETS];
- bool do_init_from_challenge_;
+ ScopedVector<HttpAuthHandler>
+ challenge_handlers_[HttpAuth::AUTH_NUM_TARGETS];
+ ScopedVector<HttpAuthHandler>
+ preemptive_handlers_[HttpAuth::AUTH_NUM_TARGETS];
};
HttpAuthHandlerMock();
~HttpAuthHandlerMock() override;
- void SetResolveExpectation(Resolve resolve);
-
- virtual bool NeedsCanonicalName();
-
- virtual int ResolveCanonicalName(HostResolver* host_resolver,
- const CompletionCallback& callback);
-
-
void SetGenerateExpectation(bool async, int rv);
+ void set_expected_auth_scheme(const std::string& scheme) {
+ expected_auth_scheme_ = scheme;
+ }
+
void set_expect_multiple_challenges(bool expect_multiple_challenges) {
expect_multiple_challenges_ = expect_multiple_challenges;
}
@@ -79,14 +69,14 @@ class HttpAuthHandlerMock : public HttpAuthHandler {
allows_default_credentials_ = allows_default_credentials;
}
- bool expect_multiple_challenges() const {
- return expect_multiple_challenges_;
- }
-
void set_allows_explicit_credentials(bool allows_explicit_credentials) {
allows_explicit_credentials_ = allows_explicit_credentials;
}
+ void set_auth_token(const std::string& auth_token) {
+ auth_token_ = auth_token;
+ }
+
const GURL& request_url() const {
return request_url_;
}
@@ -107,15 +97,14 @@ class HttpAuthHandlerMock : public HttpAuthHandler {
std::string* auth_token) override;
private:
- void OnResolveCanonicalName();
-
void OnGenerateAuthToken();
- Resolve resolve_ = RESOLVE_INIT;
CompletionCallback callback_;
+ std::string expected_auth_scheme_;
bool generate_async_ = false;
- int generate_rv_;
- std::string* auth_token_ = nullptr;
+ int generate_rv_ = 0;
+ std::string auth_token_;
+ std::string* generate_auth_token_buffer_ = nullptr;
bool first_round_ = true;
bool allows_default_credentials_ = false;
bool allows_explicit_credentials_ = true;
« no previous file with comments | « net/http/http_auth_controller_unittest.cc ('k') | net/http/http_auth_handler_mock.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698