| 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;
|
|
|