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

Side by Side Diff: google_apis/gaia/fake_gaia.cc

Issue 2668043002: Reland cros: Test for overlapping ContinueSessionRestore calls (Closed)
Patch Set: for comments in #4 Created 3 years, 10 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
« no previous file with comments | « google_apis/gaia/fake_gaia.h ('k') | no next file » | 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) 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 <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base_paths.h" 10 #include "base/base_paths.h"
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 REGISTER_RESPONSE_HANDLER( 291 REGISTER_RESPONSE_HANDLER(
292 gaia_urls->ListAccountsURLWithSource(std::string()), HandleListAccounts); 292 gaia_urls->ListAccountsURLWithSource(std::string()), HandleListAccounts);
293 293
294 // Handles /GetUserInfo GAIA call. 294 // Handles /GetUserInfo GAIA call.
295 REGISTER_RESPONSE_HANDLER( 295 REGISTER_RESPONSE_HANDLER(
296 gaia_urls->get_user_info_url(), HandleGetUserInfo); 296 gaia_urls->get_user_info_url(), HandleGetUserInfo);
297 297
298 // Handles /oauth2/v1/userinfo call. 298 // Handles /oauth2/v1/userinfo call.
299 REGISTER_RESPONSE_HANDLER( 299 REGISTER_RESPONSE_HANDLER(
300 gaia_urls->oauth_user_info_url(), HandleOAuthUserInfo); 300 gaia_urls->oauth_user_info_url(), HandleOAuthUserInfo);
301
302 // Handles /GetCheckConnectionInfo GAIA call.
303 REGISTER_RESPONSE_HANDLER(
304 gaia_urls->GetCheckConnectionInfoURLWithSource(std::string()),
305 HandleGetCheckConnectionInfo);
301 } 306 }
302 307
303 std::unique_ptr<HttpResponse> FakeGaia::HandleRequest( 308 std::unique_ptr<HttpResponse> FakeGaia::HandleRequest(
304 const HttpRequest& request) { 309 const HttpRequest& request) {
305 // The scheme and host of the URL is actually not important but required to 310 // The scheme and host of the URL is actually not important but required to
306 // get a valid GURL in order to parse |request.relative_url|. 311 // get a valid GURL in order to parse |request.relative_url|.
307 GURL request_url = GURL("http://localhost").Resolve(request.relative_url); 312 GURL request_url = GURL("http://localhost").Resolve(request.relative_url);
308 std::string request_path = request_url.path(); 313 std::string request_path = request_url.path();
309 std::unique_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); 314 std::unique_ptr<BasicHttpResponse> http_response(new BasicHttpResponse());
310 RequestHandlerMap::iterator iter = request_handlers_.find(request_path); 315 RequestHandlerMap::iterator iter = request_handlers_.find(request_path);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 441
437 http_response->AddCustomHeader( 442 http_response->AddCustomHeader(
438 "Set-Cookie", 443 "Set-Cookie",
439 base::StringPrintf( 444 base::StringPrintf(
440 "oauth_code=%s; Path=/o/GetOAuth2Token; Secure; HttpOnly;", 445 "oauth_code=%s; Path=/o/GetOAuth2Token; Secure; HttpOnly;",
441 merge_session_params_.auth_code.c_str())); 446 merge_session_params_.auth_code.c_str()));
442 http_response->set_code(net::HTTP_OK); 447 http_response->set_code(net::HTTP_OK);
443 http_response->set_content_type("text/html"); 448 http_response->set_content_type("text/html");
444 } 449 }
445 450
446 void FakeGaia::FormatJSONResponse(const base::DictionaryValue& response_dict, 451 void FakeGaia::FormatJSONResponse(const base::Value& value,
447 BasicHttpResponse* http_response) { 452 BasicHttpResponse* http_response) {
448 std::string response_json; 453 std::string response_json;
449 base::JSONWriter::Write(response_dict, &response_json); 454 base::JSONWriter::Write(value, &response_json);
450 http_response->set_content(response_json); 455 http_response->set_content(response_json);
451 http_response->set_code(net::HTTP_OK); 456 http_response->set_code(net::HTTP_OK);
452 } 457 }
453 458
454 const FakeGaia::AccessTokenInfo* FakeGaia::FindAccessTokenInfo( 459 const FakeGaia::AccessTokenInfo* FakeGaia::FindAccessTokenInfo(
455 const std::string& auth_token, 460 const std::string& auth_token,
456 const std::string& client_id, 461 const std::string& client_id,
457 const std::string& scope_string) const { 462 const std::string& scope_string) const {
458 if (auth_token.empty() || client_id.empty()) 463 if (auth_token.empty() || client_id.empty())
459 return NULL; 464 return NULL;
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 url = net::AppendQueryParameter(url, "RelayState", 838 url = net::AppendQueryParameter(url, "RelayState",
834 GaiaUrls::GetInstance() 839 GaiaUrls::GetInstance()
835 ->gaia_url() 840 ->gaia_url()
836 .Resolve(kDummySAMLContinuePath) 841 .Resolve(kDummySAMLContinuePath)
837 .spec()); 842 .spec());
838 std::string redirect_url = url.spec(); 843 std::string redirect_url = url.spec();
839 http_response->set_code(net::HTTP_TEMPORARY_REDIRECT); 844 http_response->set_code(net::HTTP_TEMPORARY_REDIRECT);
840 http_response->AddCustomHeader("Google-Accounts-SAML", "Start"); 845 http_response->AddCustomHeader("Google-Accounts-SAML", "Start");
841 http_response->AddCustomHeader("Location", redirect_url); 846 http_response->AddCustomHeader("Location", redirect_url);
842 } 847 }
848
849 void FakeGaia::HandleGetCheckConnectionInfo(
850 const net::test_server::HttpRequest& request,
851 net::test_server::BasicHttpResponse* http_response) {
852 base::ListValue connection_list;
853 FormatJSONResponse(connection_list, http_response);
854 }
OLDNEW
« no previous file with comments | « google_apis/gaia/fake_gaia.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698