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

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

Issue 3028021: Alternate-Protocol was failing when going through Digest authenticating proxy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Make unit test happy after merge. 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 | « no previous file | net/http/http_auth_handler_mock.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 #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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/string16.h" 11 #include "base/string16.h"
12 #include "base/task.h" 12 #include "base/task.h"
13 #include "googleurl/src/gurl.h"
13 #include "net/http/http_auth_handler.h" 14 #include "net/http/http_auth_handler.h"
14 #include "net/http/http_auth_handler_factory.h" 15 #include "net/http/http_auth_handler_factory.h"
15 16
16 namespace net { 17 namespace net {
17 18
18 // MockAuthHandler is used in tests to reliably trigger edge cases. 19 // MockAuthHandler is used in tests to reliably trigger edge cases.
19 class HttpAuthHandlerMock : public HttpAuthHandler { 20 class HttpAuthHandlerMock : public HttpAuthHandler {
20 public: 21 public:
21 enum Resolve { 22 enum Resolve {
22 RESOLVE_INIT, 23 RESOLVE_INIT,
(...skipping 16 matching lines...) Expand all
39 40
40 virtual bool NeedsIdentity() { return first_round_; } 41 virtual bool NeedsIdentity() { return first_round_; }
41 virtual bool IsFinalRound() { return false; } 42 virtual bool IsFinalRound() { return false; }
42 43
43 void SetGenerateExpectation(bool async, int rv); 44 void SetGenerateExpectation(bool async, int rv);
44 45
45 void set_connection_based(bool connection_based) { 46 void set_connection_based(bool connection_based) {
46 connection_based_ = connection_based; 47 connection_based_ = connection_based;
47 } 48 }
48 49
50 const GURL& request_url() const {
51 return request_url_;
52 }
53
49 // The Factory class simply returns the same handler each time 54 // The Factory class simply returns the same handler each time
50 // CreateAuthHandler is called. 55 // CreateAuthHandler is called.
51 class Factory : public HttpAuthHandlerFactory { 56 class Factory : public HttpAuthHandlerFactory {
52 public: 57 public:
53 Factory() {} 58 Factory();
54 virtual ~Factory() {} 59 virtual ~Factory();
55 60
56 void set_mock_handler(HttpAuthHandler* handler, HttpAuth::Target target); 61 void set_mock_handler(HttpAuthHandler* handler, HttpAuth::Target target);
57 62
63 void set_do_init_from_challenge(bool do_init_from_challenge) {
64 do_init_from_challenge_ = do_init_from_challenge;
65 }
66
58 virtual int CreateAuthHandler(HttpAuth::ChallengeTokenizer* challenge, 67 virtual int CreateAuthHandler(HttpAuth::ChallengeTokenizer* challenge,
59 HttpAuth::Target target, 68 HttpAuth::Target target,
60 const GURL& origin, 69 const GURL& origin,
61 CreateReason reason, 70 CreateReason reason,
62 int nonce_count, 71 int nonce_count,
63 const BoundNetLog& net_log, 72 const BoundNetLog& net_log,
64 scoped_ptr<HttpAuthHandler>* handler); 73 scoped_ptr<HttpAuthHandler>* handler);
65 74
66 private: 75 private:
67 scoped_ptr<HttpAuthHandler> handlers_[HttpAuth::AUTH_NUM_TARGETS]; 76 scoped_ptr<HttpAuthHandler> handlers_[HttpAuth::AUTH_NUM_TARGETS];
77 bool do_init_from_challenge_;
68 }; 78 };
69 79
70 protected: 80 protected:
71 virtual bool Init(HttpAuth::ChallengeTokenizer* challenge); 81 virtual bool Init(HttpAuth::ChallengeTokenizer* challenge);
72 82
73 virtual int GenerateAuthTokenImpl(const string16* username, 83 virtual int GenerateAuthTokenImpl(const string16* username,
74 const string16* password, 84 const string16* password,
75 const HttpRequestInfo* request, 85 const HttpRequestInfo* request,
76 CompletionCallback* callback, 86 CompletionCallback* callback,
77 std::string* auth_token); 87 std::string* auth_token);
78 88
79 private: 89 private:
80 void OnResolveCanonicalName(); 90 void OnResolveCanonicalName();
81 91
82 void OnGenerateAuthToken(); 92 void OnGenerateAuthToken();
83 93
84 Resolve resolve_; 94 Resolve resolve_;
85 CompletionCallback* user_callback_; 95 CompletionCallback* user_callback_;
86 ScopedRunnableMethodFactory<HttpAuthHandlerMock> method_factory_; 96 ScopedRunnableMethodFactory<HttpAuthHandlerMock> method_factory_;
87 bool generate_async_; 97 bool generate_async_;
88 int generate_rv_; 98 int generate_rv_;
89 std::string* auth_token_; 99 std::string* auth_token_;
90 bool first_round_; 100 bool first_round_;
91 bool connection_based_; 101 bool connection_based_;
102 GURL request_url_;
92 }; 103 };
93 104
94 } // namespace net 105 } // namespace net
95 106
96 #endif // NET_HTTP_HTTP_AUTH_HANDLER_MOCK_H_ 107 #endif // NET_HTTP_HTTP_AUTH_HANDLER_MOCK_H_
OLDNEW
« no previous file with comments | « no previous file | net/http/http_auth_handler_mock.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698