| 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 HandleEmbeddedLookupAccountLookup); | 259 HandleEmbeddedLookupAccountLookup); |
| 260 | 260 |
| 261 // Handles /_/embedded/signin/challenge for /embedded/setup/chromeos | 261 // Handles /_/embedded/signin/challenge for /embedded/setup/chromeos |
| 262 // authentication request. | 262 // authentication request. |
| 263 REGISTER_PATH_RESPONSE_HANDLER("/_/embedded/signin/challenge", | 263 REGISTER_PATH_RESPONSE_HANDLER("/_/embedded/signin/challenge", |
| 264 HandleEmbeddedSigninChallenge); | 264 HandleEmbeddedSigninChallenge); |
| 265 | 265 |
| 266 // Handles /SSO GAIA call (not GAIA, made up for SAML tests). | 266 // Handles /SSO GAIA call (not GAIA, made up for SAML tests). |
| 267 REGISTER_PATH_RESPONSE_HANDLER("/SSO", HandleSSO); | 267 REGISTER_PATH_RESPONSE_HANDLER("/SSO", HandleSSO); |
| 268 | 268 |
| 269 // Handles /o/oauth2/token GAIA call. | 269 // Handles /oauth2/v4/token GAIA call. |
| 270 REGISTER_RESPONSE_HANDLER( | 270 REGISTER_RESPONSE_HANDLER( |
| 271 gaia_urls->oauth2_token_url(), HandleAuthToken); | 271 gaia_urls->oauth2_token_url(), HandleAuthToken); |
| 272 | 272 |
| 273 // Handles /oauth2/v2/tokeninfo GAIA call. | 273 // Handles /oauth2/v2/tokeninfo GAIA call. |
| 274 REGISTER_RESPONSE_HANDLER( | 274 REGISTER_RESPONSE_HANDLER( |
| 275 gaia_urls->oauth2_token_info_url(), HandleTokenInfo); | 275 gaia_urls->oauth2_token_info_url(), HandleTokenInfo); |
| 276 | 276 |
| 277 // Handles /oauth2/v2/IssueToken GAIA call. | 277 // Handles /oauth2/v2/IssueToken GAIA call. |
| 278 REGISTER_RESPONSE_HANDLER( | 278 REGISTER_RESPONSE_HANDLER( |
| 279 gaia_urls->oauth2_issue_token_url(), HandleIssueToken); | 279 gaia_urls->oauth2_issue_token_url(), HandleIssueToken); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 | 617 |
| 618 if (issue_oauth_code_cookie_) | 618 if (issue_oauth_code_cookie_) |
| 619 SetOAuthCodeCookie(http_response); | 619 SetOAuthCodeCookie(http_response); |
| 620 } | 620 } |
| 621 | 621 |
| 622 void FakeGaia::HandleAuthToken(const HttpRequest& request, | 622 void FakeGaia::HandleAuthToken(const HttpRequest& request, |
| 623 BasicHttpResponse* http_response) { | 623 BasicHttpResponse* http_response) { |
| 624 std::string grant_type; | 624 std::string grant_type; |
| 625 if (!GetQueryParameter(request.content, "grant_type", &grant_type)) { | 625 if (!GetQueryParameter(request.content, "grant_type", &grant_type)) { |
| 626 http_response->set_code(net::HTTP_BAD_REQUEST); | 626 http_response->set_code(net::HTTP_BAD_REQUEST); |
| 627 LOG(ERROR) << "No 'grant_type' param in /o/oauth2/token"; | 627 LOG(ERROR) << "No 'grant_type' param in /oauth2/v4/token"; |
| 628 return; | 628 return; |
| 629 } | 629 } |
| 630 | 630 |
| 631 if (grant_type == "authorization_code") { | 631 if (grant_type == "authorization_code") { |
| 632 std::string auth_code; | 632 std::string auth_code; |
| 633 if (!GetQueryParameter(request.content, "code", &auth_code) || | 633 if (!GetQueryParameter(request.content, "code", &auth_code) || |
| 634 auth_code != merge_session_params_.auth_code) { | 634 auth_code != merge_session_params_.auth_code) { |
| 635 http_response->set_code(net::HTTP_BAD_REQUEST); | 635 http_response->set_code(net::HTTP_BAD_REQUEST); |
| 636 LOG(ERROR) << "No 'code' param in /o/oauth2/token"; | 636 LOG(ERROR) << "No 'code' param in /oauth2/v4/token"; |
| 637 return; | 637 return; |
| 638 } | 638 } |
| 639 | 639 |
| 640 std::string device_id; | 640 std::string device_id; |
| 641 if (GetQueryParameter(request.content, "device_id", &device_id)) { | 641 if (GetQueryParameter(request.content, "device_id", &device_id)) { |
| 642 std::string device_type; | 642 std::string device_type; |
| 643 if (!GetQueryParameter(request.content, "device_type", &device_type)) { | 643 if (!GetQueryParameter(request.content, "device_type", &device_type)) { |
| 644 http_response->set_code(net::HTTP_BAD_REQUEST); | 644 http_response->set_code(net::HTTP_BAD_REQUEST); |
| 645 LOG(ERROR) << "'device_type' should be set if 'device_id' is set."; | 645 LOG(ERROR) << "'device_type' should be set if 'device_id' is set."; |
| 646 return; | 646 return; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 676 FindAccessTokenInfo(refresh_token, client_id, scope); | 676 FindAccessTokenInfo(refresh_token, client_id, scope); |
| 677 if (token_info) { | 677 if (token_info) { |
| 678 base::DictionaryValue response_dict; | 678 base::DictionaryValue response_dict; |
| 679 response_dict.SetString("access_token", token_info->token); | 679 response_dict.SetString("access_token", token_info->token); |
| 680 response_dict.SetInteger("expires_in", 3600); | 680 response_dict.SetInteger("expires_in", 3600); |
| 681 FormatJSONResponse(response_dict, http_response); | 681 FormatJSONResponse(response_dict, http_response); |
| 682 return; | 682 return; |
| 683 } | 683 } |
| 684 } | 684 } |
| 685 | 685 |
| 686 LOG(ERROR) << "Bad request for /o/oauth2/token - " | 686 LOG(ERROR) << "Bad request for /oauth2/v4/token - " |
| 687 << "refresh_token = " << refresh_token | 687 << "refresh_token = " << refresh_token |
| 688 << ", scope = " << scope | 688 << ", scope = " << scope |
| 689 << ", client_id = " << client_id; | 689 << ", client_id = " << client_id; |
| 690 http_response->set_code(net::HTTP_BAD_REQUEST); | 690 http_response->set_code(net::HTTP_BAD_REQUEST); |
| 691 } | 691 } |
| 692 | 692 |
| 693 void FakeGaia::HandleTokenInfo(const HttpRequest& request, | 693 void FakeGaia::HandleTokenInfo(const HttpRequest& request, |
| 694 BasicHttpResponse* http_response) { | 694 BasicHttpResponse* http_response) { |
| 695 const AccessTokenInfo* token_info = NULL; | 695 const AccessTokenInfo* token_info = NULL; |
| 696 std::string access_token; | 696 std::string access_token; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 if (token_info) { | 765 if (token_info) { |
| 766 base::DictionaryValue response_dict; | 766 base::DictionaryValue response_dict; |
| 767 response_dict.SetString("id", GetGaiaIdOfEmail(token_info->email)); | 767 response_dict.SetString("id", GetGaiaIdOfEmail(token_info->email)); |
| 768 response_dict.SetString("email", token_info->email); | 768 response_dict.SetString("email", token_info->email); |
| 769 response_dict.SetString("verified_email", token_info->email); | 769 response_dict.SetString("verified_email", token_info->email); |
| 770 FormatJSONResponse(response_dict, http_response); | 770 FormatJSONResponse(response_dict, http_response); |
| 771 } else { | 771 } else { |
| 772 http_response->set_code(net::HTTP_BAD_REQUEST); | 772 http_response->set_code(net::HTTP_BAD_REQUEST); |
| 773 } | 773 } |
| 774 } | 774 } |
| OLD | NEW |