OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 GOOGLE_APIS_GAIA_FAKE_GAIA_H_ | 5 #ifndef GOOGLE_APIS_GAIA_FAKE_GAIA_H_ |
6 #define GOOGLE_APIS_GAIA_FAKE_GAIA_H_ | 6 #define GOOGLE_APIS_GAIA_FAKE_GAIA_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 FakeGaia(); | 79 FakeGaia(); |
80 virtual ~FakeGaia(); | 80 virtual ~FakeGaia(); |
81 | 81 |
82 void SetFakeMergeSessionParams(const std::string& email, | 82 void SetFakeMergeSessionParams(const std::string& email, |
83 const std::string& auth_sid_cookie, | 83 const std::string& auth_sid_cookie, |
84 const std::string& auth_lsid_cookie); | 84 const std::string& auth_lsid_cookie); |
85 | 85 |
86 // Sets the initial value of tokens and cookies. | 86 // Sets the initial value of tokens and cookies. |
87 void SetMergeSessionParams(const MergeSessionParams& params); | 87 void SetMergeSessionParams(const MergeSessionParams& params); |
88 | 88 |
89 // Sets the specified |gaia_id| as corresponding to the given |email| | |
90 // address when setting GAIA response headers. If no mapping is given for | |
91 // an email address, a default GAIA Id is used. | |
92 void MapEmailToGaiaId(const std::string& email, const std::string& gaia_id); | |
93 | |
89 // Initializes HTTP request handlers. Should be called after switches | 94 // Initializes HTTP request handlers. Should be called after switches |
90 // for tweaking GaiaUrls are in place. | 95 // for tweaking GaiaUrls are in place. |
91 void Initialize(); | 96 void Initialize(); |
92 | 97 |
93 // Handles a request and returns a response if the request was recognized as a | 98 // Handles a request and returns a response if the request was recognized as a |
94 // GAIA request. Note that this respects the switches::kGaiaUrl and friends so | 99 // GAIA request. Note that this respects the switches::kGaiaUrl and friends so |
95 // that this can used with EmbeddedTestServer::RegisterRequestHandler(). | 100 // that this can used with EmbeddedTestServer::RegisterRequestHandler(). |
96 scoped_ptr<net::test_server::HttpResponse> HandleRequest( | 101 scoped_ptr<net::test_server::HttpResponse> HandleRequest( |
97 const net::test_server::HttpRequest& request); | 102 const net::test_server::HttpRequest& request); |
98 | 103 |
(...skipping 15 matching lines...) Expand all Loading... | |
114 const std::string& key, | 119 const std::string& key, |
115 std::string* value); | 120 std::string* value); |
116 protected: | 121 protected: |
117 // HTTP handler for /MergeSession. | 122 // HTTP handler for /MergeSession. |
118 virtual void HandleMergeSession( | 123 virtual void HandleMergeSession( |
119 const net::test_server::HttpRequest& request, | 124 const net::test_server::HttpRequest& request, |
120 net::test_server::BasicHttpResponse* http_response); | 125 net::test_server::BasicHttpResponse* http_response); |
121 | 126 |
122 private: | 127 private: |
123 typedef std::multimap<std::string, AccessTokenInfo> AccessTokenInfoMap; | 128 typedef std::multimap<std::string, AccessTokenInfo> AccessTokenInfoMap; |
129 typedef std::map<std::string, std::string> EmailToGaiaIdMap; | |
124 typedef std::map<std::string, GURL> SamlAccountIdpMap; | 130 typedef std::map<std::string, GURL> SamlAccountIdpMap; |
125 | 131 |
132 std::string GetGaiaIdOfEmail(const std::string& email); | |
bartfab (slow)
2014/10/21 14:47:47
Nit: Make the method const.
Roger Tawa OOO till Jul 10th
2014/10/21 19:15:31
Done.
| |
133 | |
126 // Formats a JSON response with the data in |response_dict|. | 134 // Formats a JSON response with the data in |response_dict|. |
127 void FormatJSONResponse(const base::DictionaryValue& response_dict, | 135 void FormatJSONResponse(const base::DictionaryValue& response_dict, |
128 net::test_server::BasicHttpResponse* http_response); | 136 net::test_server::BasicHttpResponse* http_response); |
129 | 137 |
130 typedef base::Callback<void( | 138 typedef base::Callback<void( |
131 const net::test_server::HttpRequest& request, | 139 const net::test_server::HttpRequest& request, |
132 net::test_server::BasicHttpResponse* http_response)> | 140 net::test_server::BasicHttpResponse* http_response)> |
133 HttpRequestHandlerCallback; | 141 HttpRequestHandlerCallback; |
134 typedef std::map<std::string, HttpRequestHandlerCallback> RequestHandlerMap; | 142 typedef std::map<std::string, HttpRequestHandlerCallback> RequestHandlerMap; |
135 | 143 |
(...skipping 26 matching lines...) Expand all Loading... | |
162 // Returns the access token associated with |auth_token| that matches the | 170 // Returns the access token associated with |auth_token| that matches the |
163 // given |client_id| and |scope_string|. If |scope_string| is empty, the first | 171 // given |client_id| and |scope_string|. If |scope_string| is empty, the first |
164 // token satisfying the other criteria is returned. Returns NULL if no token | 172 // token satisfying the other criteria is returned. Returns NULL if no token |
165 // matches. | 173 // matches. |
166 const AccessTokenInfo* FindAccessTokenInfo(const std::string& auth_token, | 174 const AccessTokenInfo* FindAccessTokenInfo(const std::string& auth_token, |
167 const std::string& client_id, | 175 const std::string& client_id, |
168 const std::string& scope_string) | 176 const std::string& scope_string) |
169 const; | 177 const; |
170 | 178 |
171 MergeSessionParams merge_session_params_; | 179 MergeSessionParams merge_session_params_; |
180 EmailToGaiaIdMap email_to_gaia_id_map_; | |
172 AccessTokenInfoMap access_token_info_map_; | 181 AccessTokenInfoMap access_token_info_map_; |
173 RequestHandlerMap request_handlers_; | 182 RequestHandlerMap request_handlers_; |
174 std::string service_login_response_; | 183 std::string service_login_response_; |
175 SamlAccountIdpMap saml_account_idp_map_; | 184 SamlAccountIdpMap saml_account_idp_map_; |
176 | 185 |
177 DISALLOW_COPY_AND_ASSIGN(FakeGaia); | 186 DISALLOW_COPY_AND_ASSIGN(FakeGaia); |
178 }; | 187 }; |
179 | 188 |
180 #endif // GOOGLE_APIS_GAIA_FAKE_GAIA_H_ | 189 #endif // GOOGLE_APIS_GAIA_FAKE_GAIA_H_ |
OLD | NEW |