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

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

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