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 | |
94 // Initializes HTTP request handlers. Should be called after switches | 89 // Initializes HTTP request handlers. Should be called after switches |
95 // for tweaking GaiaUrls are in place. | 90 // for tweaking GaiaUrls are in place. |
96 void Initialize(); | 91 void Initialize(); |
97 | 92 |
98 // Handles a request and returns a response if the request was recognized as a | 93 // Handles a request and returns a response if the request was recognized as a |
99 // GAIA request. Note that this respects the switches::kGaiaUrl and friends so | 94 // GAIA request. Note that this respects the switches::kGaiaUrl and friends so |
100 // that this can used with EmbeddedTestServer::RegisterRequestHandler(). | 95 // that this can used with EmbeddedTestServer::RegisterRequestHandler(). |
101 scoped_ptr<net::test_server::HttpResponse> HandleRequest( | 96 scoped_ptr<net::test_server::HttpResponse> HandleRequest( |
102 const net::test_server::HttpRequest& request); | 97 const net::test_server::HttpRequest& request); |
103 | 98 |
(...skipping 15 matching lines...) Expand all Loading... |
119 const std::string& key, | 114 const std::string& key, |
120 std::string* value); | 115 std::string* value); |
121 protected: | 116 protected: |
122 // HTTP handler for /MergeSession. | 117 // HTTP handler for /MergeSession. |
123 virtual void HandleMergeSession( | 118 virtual void HandleMergeSession( |
124 const net::test_server::HttpRequest& request, | 119 const net::test_server::HttpRequest& request, |
125 net::test_server::BasicHttpResponse* http_response); | 120 net::test_server::BasicHttpResponse* http_response); |
126 | 121 |
127 private: | 122 private: |
128 typedef std::multimap<std::string, AccessTokenInfo> AccessTokenInfoMap; | 123 typedef std::multimap<std::string, AccessTokenInfo> AccessTokenInfoMap; |
129 typedef std::map<std::string, std::string> EmailToGaiaIdMap; | |
130 typedef std::map<std::string, GURL> SamlAccountIdpMap; | 124 typedef std::map<std::string, GURL> SamlAccountIdpMap; |
131 | 125 |
132 std::string GetGaiaIdOfEmail(const std::string& email) const; | |
133 | |
134 void AddGoogleAccountsSigninHeader( | |
135 net::test_server::BasicHttpResponse* http_response, | |
136 const std::string& email) const; | |
137 | |
138 // Formats a JSON response with the data in |response_dict|. | 126 // Formats a JSON response with the data in |response_dict|. |
139 void FormatJSONResponse(const base::DictionaryValue& response_dict, | 127 void FormatJSONResponse(const base::DictionaryValue& response_dict, |
140 net::test_server::BasicHttpResponse* http_response); | 128 net::test_server::BasicHttpResponse* http_response); |
141 | 129 |
142 typedef base::Callback<void( | 130 typedef base::Callback<void( |
143 const net::test_server::HttpRequest& request, | 131 const net::test_server::HttpRequest& request, |
144 net::test_server::BasicHttpResponse* http_response)> | 132 net::test_server::BasicHttpResponse* http_response)> |
145 HttpRequestHandlerCallback; | 133 HttpRequestHandlerCallback; |
146 typedef std::map<std::string, HttpRequestHandlerCallback> RequestHandlerMap; | 134 typedef std::map<std::string, HttpRequestHandlerCallback> RequestHandlerMap; |
147 | 135 |
(...skipping 26 matching lines...) Expand all Loading... |
174 // Returns the access token associated with |auth_token| that matches the | 162 // Returns the access token associated with |auth_token| that matches the |
175 // given |client_id| and |scope_string|. If |scope_string| is empty, the first | 163 // given |client_id| and |scope_string|. If |scope_string| is empty, the first |
176 // token satisfying the other criteria is returned. Returns NULL if no token | 164 // token satisfying the other criteria is returned. Returns NULL if no token |
177 // matches. | 165 // matches. |
178 const AccessTokenInfo* FindAccessTokenInfo(const std::string& auth_token, | 166 const AccessTokenInfo* FindAccessTokenInfo(const std::string& auth_token, |
179 const std::string& client_id, | 167 const std::string& client_id, |
180 const std::string& scope_string) | 168 const std::string& scope_string) |
181 const; | 169 const; |
182 | 170 |
183 MergeSessionParams merge_session_params_; | 171 MergeSessionParams merge_session_params_; |
184 EmailToGaiaIdMap email_to_gaia_id_map_; | |
185 AccessTokenInfoMap access_token_info_map_; | 172 AccessTokenInfoMap access_token_info_map_; |
186 RequestHandlerMap request_handlers_; | 173 RequestHandlerMap request_handlers_; |
187 std::string service_login_response_; | 174 std::string service_login_response_; |
188 SamlAccountIdpMap saml_account_idp_map_; | 175 SamlAccountIdpMap saml_account_idp_map_; |
189 | 176 |
190 DISALLOW_COPY_AND_ASSIGN(FakeGaia); | 177 DISALLOW_COPY_AND_ASSIGN(FakeGaia); |
191 }; | 178 }; |
192 | 179 |
193 #endif // GOOGLE_APIS_GAIA_FAKE_GAIA_H_ | 180 #endif // GOOGLE_APIS_GAIA_FAKE_GAIA_H_ |
OLD | NEW |