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 #include "google_apis/gaia/fake_gaia.h" | 5 #include "google_apis/gaia/fake_gaia.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 base::FilePath source_root_dir; | 135 base::FilePath source_root_dir; |
136 PathService::Get(base::DIR_SOURCE_ROOT, &source_root_dir); | 136 PathService::Get(base::DIR_SOURCE_ROOT, &source_root_dir); |
137 CHECK(base::ReadFileToString( | 137 CHECK(base::ReadFileToString( |
138 source_root_dir.Append(base::FilePath(kServiceLogin)), | 138 source_root_dir.Append(base::FilePath(kServiceLogin)), |
139 &service_login_response_)); | 139 &service_login_response_)); |
140 } | 140 } |
141 | 141 |
142 FakeGaia::~FakeGaia() {} | 142 FakeGaia::~FakeGaia() {} |
143 | 143 |
144 void FakeGaia::SetFakeMergeSessionParams( | 144 void FakeGaia::SetFakeMergeSessionParams( |
145 const std::string& gaia_id, | |
145 const std::string& email, | 146 const std::string& email, |
146 const std::string& auth_sid_cookie, | 147 const std::string& auth_sid_cookie, |
147 const std::string& auth_lsid_cookie) { | 148 const std::string& auth_lsid_cookie) { |
148 FakeGaia::MergeSessionParams params; | 149 FakeGaia::MergeSessionParams params; |
149 params.auth_sid_cookie = auth_sid_cookie; | 150 params.auth_sid_cookie = auth_sid_cookie; |
150 params.auth_lsid_cookie = auth_lsid_cookie; | 151 params.auth_lsid_cookie = auth_lsid_cookie; |
151 params.auth_code = kTestAuthCode; | 152 params.auth_code = kTestAuthCode; |
152 params.refresh_token = kTestRefreshToken; | 153 params.refresh_token = kTestRefreshToken; |
153 params.access_token = kTestAuthLoginAccessToken; | 154 params.access_token = kTestAuthLoginAccessToken; |
154 params.gaia_uber_token = kTestGaiaUberToken; | 155 params.gaia_uber_token = kTestGaiaUberToken; |
155 params.session_sid_cookie = kTestSessionSIDCookie; | 156 params.session_sid_cookie = kTestSessionSIDCookie; |
156 params.session_lsid_cookie = kTestSessionLSIDCookie; | 157 params.session_lsid_cookie = kTestSessionLSIDCookie; |
157 params.email = email; | 158 params.email = email; |
159 params.gaia_id = gaia_id; | |
158 SetMergeSessionParams(params); | 160 SetMergeSessionParams(params); |
159 } | 161 } |
160 | 162 |
161 void FakeGaia::SetMergeSessionParams( | 163 void FakeGaia::SetMergeSessionParams( |
162 const MergeSessionParams& params) { | 164 const MergeSessionParams& params) { |
163 merge_session_params_ = params; | 165 merge_session_params_ = params; |
164 } | 166 } |
165 | 167 |
166 void FakeGaia::Initialize() { | 168 void FakeGaia::Initialize() { |
167 GaiaUrls* gaia_urls = GaiaUrls::GetInstance(); | 169 GaiaUrls* gaia_urls = GaiaUrls::GetInstance(); |
(...skipping 27 matching lines...) Expand all Loading... | |
195 // Handles /oauth2/v2/tokeninfo GAIA call. | 197 // Handles /oauth2/v2/tokeninfo GAIA call. |
196 REGISTER_RESPONSE_HANDLER( | 198 REGISTER_RESPONSE_HANDLER( |
197 gaia_urls->oauth2_token_info_url(), HandleTokenInfo); | 199 gaia_urls->oauth2_token_info_url(), HandleTokenInfo); |
198 | 200 |
199 // Handles /oauth2/v2/IssueToken GAIA call. | 201 // Handles /oauth2/v2/IssueToken GAIA call. |
200 REGISTER_RESPONSE_HANDLER( | 202 REGISTER_RESPONSE_HANDLER( |
201 gaia_urls->oauth2_issue_token_url(), HandleIssueToken); | 203 gaia_urls->oauth2_issue_token_url(), HandleIssueToken); |
202 | 204 |
203 // Handles /ListAccounts GAIA call. | 205 // Handles /ListAccounts GAIA call. |
204 REGISTER_RESPONSE_HANDLER( | 206 REGISTER_RESPONSE_HANDLER( |
205 gaia_urls->ListAccountsURLWithSource(std::string()), HandleListAccounts); | 207 gaia_urls->ListAccountsURLWithSource(std::string()), HandleListAccounts); |
bartfab (slow)
2014/10/17 09:54:56
I think the Chrome OS login code may have been the
Roger Tawa OOO till Jul 10th
2014/10/20 16:04:01
Best done in a separate CL.
bartfab (slow)
2014/10/21 14:47:46
Sure. If you are not planning to do this clean-up
| |
206 | 208 |
207 // Handles /GetUserInfo GAIA call. | 209 // Handles /GetUserInfo GAIA call. |
208 REGISTER_RESPONSE_HANDLER( | 210 REGISTER_RESPONSE_HANDLER( |
209 gaia_urls->get_user_info_url(), HandleGetUserInfo); | 211 gaia_urls->get_user_info_url(), HandleGetUserInfo); |
210 } | 212 } |
211 | 213 |
212 scoped_ptr<HttpResponse> FakeGaia::HandleRequest(const HttpRequest& request) { | 214 scoped_ptr<HttpResponse> FakeGaia::HandleRequest(const HttpRequest& request) { |
213 // The scheme and host of the URL is actually not important but required to | 215 // The scheme and host of the URL is actually not important but required to |
214 // get a valid GURL in order to parse |request.relative_url|. | 216 // get a valid GURL in order to parse |request.relative_url|. |
215 GURL request_url = GURL("http://localhost").Resolve(request.relative_url); | 217 GURL request_url = GURL("http://localhost").Resolve(request.relative_url); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
424 http_response->AddCustomHeader("Google-Accounts-SAML", "Start"); | 426 http_response->AddCustomHeader("Google-Accounts-SAML", "Start"); |
425 } else if (!merge_session_params_.auth_sid_cookie.empty() && | 427 } else if (!merge_session_params_.auth_sid_cookie.empty() && |
426 !merge_session_params_.auth_lsid_cookie.empty()) { | 428 !merge_session_params_.auth_lsid_cookie.empty()) { |
427 SetCookies(http_response, | 429 SetCookies(http_response, |
428 merge_session_params_.auth_sid_cookie, | 430 merge_session_params_.auth_sid_cookie, |
429 merge_session_params_.auth_lsid_cookie); | 431 merge_session_params_.auth_lsid_cookie); |
430 } | 432 } |
431 | 433 |
432 http_response->set_code(net::HTTP_TEMPORARY_REDIRECT); | 434 http_response->set_code(net::HTTP_TEMPORARY_REDIRECT); |
433 http_response->AddCustomHeader("Location", redirect_url); | 435 http_response->AddCustomHeader("Location", redirect_url); |
434 http_response->AddCustomHeader("google-accounts-signin", | 436 http_response->AddCustomHeader("google-accounts-signin", |
bartfab (slow)
2014/10/17 09:54:56
This line is actually wrong - and was wrong before
Roger Tawa OOO till Jul 10th
2014/10/20 16:04:01
Done.
| |
435 base::StringPrintf("email=\"%s\", sessionindex=0", email.c_str())); | 437 base::StringPrintf( |
438 "email=\"%s\", obfuscatedid=\"%s\", sessionindex=0", | |
439 email.c_str(), merge_session_params_.gaia_id.c_str())); | |
bartfab (slow)
2014/10/17 09:54:56
We have tests that set up multiple accounts and ve
Roger Tawa OOO till Jul 10th
2014/10/20 16:04:01
Not sure you can do that, or that it's needed. To
| |
436 } | 440 } |
437 | 441 |
438 void FakeGaia::HandleSSO(const HttpRequest& request, | 442 void FakeGaia::HandleSSO(const HttpRequest& request, |
439 BasicHttpResponse* http_response) { | 443 BasicHttpResponse* http_response) { |
440 if (!merge_session_params_.auth_sid_cookie.empty() && | 444 if (!merge_session_params_.auth_sid_cookie.empty() && |
441 !merge_session_params_.auth_lsid_cookie.empty()) { | 445 !merge_session_params_.auth_lsid_cookie.empty()) { |
442 SetCookies(http_response, | 446 SetCookies(http_response, |
443 merge_session_params_.auth_sid_cookie, | 447 merge_session_params_.auth_sid_cookie, |
444 merge_session_params_.auth_lsid_cookie); | 448 merge_session_params_.auth_lsid_cookie); |
445 } | 449 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
573 } | 577 } |
574 | 578 |
575 void FakeGaia::HandleGetUserInfo(const HttpRequest& request, | 579 void FakeGaia::HandleGetUserInfo(const HttpRequest& request, |
576 BasicHttpResponse* http_response) { | 580 BasicHttpResponse* http_response) { |
577 http_response->set_content(base::StringPrintf( | 581 http_response->set_content(base::StringPrintf( |
578 "email=%s\ndisplayEmail=%s", | 582 "email=%s\ndisplayEmail=%s", |
579 merge_session_params_.email.c_str(), | 583 merge_session_params_.email.c_str(), |
580 merge_session_params_.email.c_str())); | 584 merge_session_params_.email.c_str())); |
581 http_response->set_code(net::HTTP_OK); | 585 http_response->set_code(net::HTTP_OK); |
582 } | 586 } |
OLD | NEW |