OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef NET_HTTP_HTTP_AUTH_HANDLER_MOCK_H_ | 5 #ifndef NET_HTTP_HTTP_AUTH_HANDLER_MOCK_H_ |
6 #define NET_HTTP_HTTP_AUTH_HANDLER_MOCK_H_ | 6 #define NET_HTTP_HTTP_AUTH_HANDLER_MOCK_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 Factory(); | 29 Factory(); |
30 ~Factory() override; | 30 ~Factory() override; |
31 | 31 |
32 void AddMockHandler(scoped_ptr<HttpAuthHandler> handler, | 32 void AddMockHandler(scoped_ptr<HttpAuthHandler> handler, |
33 CreateReason reason, | 33 CreateReason reason, |
34 HttpAuth::Target target); | 34 HttpAuth::Target target); |
35 | 35 |
36 bool HaveAuthHandlers(HttpAuth::Target) const; | 36 bool HaveAuthHandlers(HttpAuth::Target) const; |
37 | 37 |
38 // HttpAuthHandlerFactory: | 38 // HttpAuthHandlerFactory: |
39 int CreateAuthHandler(HttpAuthChallengeTokenizer* challenge, | 39 int CreateAuthHandler(const HttpAuthChallengeTokenizer& challenge, |
40 HttpAuth::Target target, | 40 HttpAuth::Target target, |
41 const GURL& origin, | 41 const GURL& origin, |
42 CreateReason reason, | 42 CreateReason reason, |
43 int nonce_count, | 43 int nonce_count, |
44 const BoundNetLog& net_log, | 44 const BoundNetLog& net_log, |
45 scoped_ptr<HttpAuthHandler>* handler) override; | 45 scoped_ptr<HttpAuthHandler>* handler) override; |
46 | 46 |
47 private: | 47 private: |
48 ScopedVector<HttpAuthHandler> | 48 ScopedVector<HttpAuthHandler> |
49 challenge_handlers_[HttpAuth::AUTH_NUM_TARGETS]; | 49 challenge_handlers_[HttpAuth::AUTH_NUM_TARGETS]; |
(...skipping 26 matching lines...) Expand all Loading... |
76 void set_auth_token(const std::string& auth_token) { | 76 void set_auth_token(const std::string& auth_token) { |
77 auth_token_ = auth_token; | 77 auth_token_ = auth_token; |
78 } | 78 } |
79 | 79 |
80 const GURL& request_url() const { | 80 const GURL& request_url() const { |
81 return request_url_; | 81 return request_url_; |
82 } | 82 } |
83 | 83 |
84 // HttpAuthHandler: | 84 // HttpAuthHandler: |
85 HttpAuth::AuthorizationResult HandleAnotherChallenge( | 85 HttpAuth::AuthorizationResult HandleAnotherChallenge( |
86 HttpAuthChallengeTokenizer* challenge) override; | 86 const HttpAuthChallengeTokenizer& challenge) override; |
87 bool NeedsIdentity() override; | 87 bool NeedsIdentity() override; |
88 bool AllowsDefaultCredentials() override; | 88 bool AllowsDefaultCredentials() override; |
89 bool AllowsExplicitCredentials() override; | 89 bool AllowsExplicitCredentials() override; |
90 | 90 |
91 protected: | 91 protected: |
92 bool Init(HttpAuthChallengeTokenizer* challenge) override; | 92 int Init(const HttpAuthChallengeTokenizer& challenge) override; |
93 | 93 |
94 int GenerateAuthTokenImpl(const AuthCredentials* credentials, | 94 int GenerateAuthTokenImpl(const AuthCredentials* credentials, |
95 const HttpRequestInfo* request, | 95 const HttpRequestInfo& request, |
96 const CompletionCallback& callback, | 96 const CompletionCallback& callback, |
97 std::string* auth_token) override; | 97 std::string* auth_token) override; |
98 | 98 |
99 private: | 99 private: |
100 void OnGenerateAuthToken(); | 100 void OnGenerateAuthToken(); |
101 | 101 |
102 CompletionCallback callback_; | 102 CompletionCallback callback_; |
103 std::string expected_auth_scheme_; | 103 std::string expected_auth_scheme_; |
104 bool generate_async_ = false; | 104 bool generate_async_ = false; |
105 int generate_rv_ = 0; | 105 int generate_rv_ = 0; |
106 std::string auth_token_; | 106 std::string auth_token_; |
107 std::string* generate_auth_token_buffer_ = nullptr; | 107 std::string* generate_auth_token_buffer_ = nullptr; |
108 bool first_round_ = true; | 108 bool first_round_ = true; |
109 bool allows_default_credentials_ = false; | 109 bool allows_default_credentials_ = false; |
110 bool allows_explicit_credentials_ = true; | 110 bool allows_explicit_credentials_ = true; |
111 bool expect_multiple_challenges_ = false; | 111 bool expect_multiple_challenges_ = false; |
112 GURL request_url_; | 112 GURL request_url_; |
113 base::WeakPtrFactory<HttpAuthHandlerMock> weak_factory_; | 113 base::WeakPtrFactory<HttpAuthHandlerMock> weak_factory_; |
114 }; | 114 }; |
115 | 115 |
116 } // namespace net | 116 } // namespace net |
117 | 117 |
118 #endif // NET_HTTP_HTTP_AUTH_HANDLER_MOCK_H_ | 118 #endif // NET_HTTP_HTTP_AUTH_HANDLER_MOCK_H_ |
OLD | NEW |