diff options
author | xiyuan <xiyuan@chromium.org> | 2015-03-06 12:44:45 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-06 20:46:25 +0000 |
commit | 3237cef8ee0f21d0c65277baacfd4ba1c22fdec6 (patch) | |
tree | 0b68762280f8e87ed5c7c0d9295584f57554db4a /google_apis | |
parent | 97c50ace3ee858cdd15aac5631a62d6d5a198415 (diff) | |
download | chromium_src-3237cef8ee0f21d0c65277baacfd4ba1c22fdec6.zip chromium_src-3237cef8ee0f21d0c65277baacfd4ba1c22fdec6.tar.gz chromium_src-3237cef8ee0f21d0c65277baacfd4ba1c22fdec6.tar.bz2 |
- Ctrl-Alt-Shift-B to toggle Easy bootstrap on Gaia screen;
- Use EAFE to get auth code for Easy bootstrap;
- BootstrapInitializer to fetch user info for adding a user;
- BootstrapUserFlow to perform Smart lock pairing since no password
is present;
- BootstrapManager to track pending bootstrapping user;
BUG=433133,435202
TEST=BootstrapTest.*
Review URL: https://codereview.chromium.org/825683006
Cr-Commit-Position: refs/heads/master@{#319494}
Diffstat (limited to 'google_apis')
-rw-r--r-- | google_apis/gaia/fake_gaia.cc | 62 | ||||
-rw-r--r-- | google_apis/gaia/fake_gaia.h | 14 |
2 files changed, 52 insertions, 24 deletions
diff --git a/google_apis/gaia/fake_gaia.cc b/google_apis/gaia/fake_gaia.cc index b1a3942..a740232 100644 --- a/google_apis/gaia/fake_gaia.cc +++ b/google_apis/gaia/fake_gaia.cc @@ -233,6 +233,10 @@ void FakeGaia::Initialize() { // Handles /GetUserInfo GAIA call. REGISTER_RESPONSE_HANDLER( gaia_urls->get_user_info_url(), HandleGetUserInfo); + + // Handles /oauth2/v1/userinfo call. + REGISTER_RESPONSE_HANDLER( + gaia_urls->oauth_user_info_url(), HandleOAuthUserInfo); } scoped_ptr<HttpResponse> FakeGaia::HandleRequest(const HttpRequest& request) { @@ -386,6 +390,19 @@ const FakeGaia::AccessTokenInfo* FakeGaia::FindAccessTokenInfo( return NULL; } +const FakeGaia::AccessTokenInfo* FakeGaia::GetAccessTokenInfo( + const std::string& access_token) const { + for (AccessTokenInfoMap::const_iterator entry( + access_token_info_map_.begin()); + entry != access_token_info_map_.end(); + ++entry) { + if (entry->second.token == access_token) + return &(entry->second); + } + + return NULL; +} + void FakeGaia::HandleServiceLogin(const HttpRequest& request, BasicHttpResponse* http_response) { http_response->set_code(net::HTTP_OK); @@ -489,9 +506,6 @@ void FakeGaia::HandleSSO(const HttpRequest& request, void FakeGaia::HandleAuthToken(const HttpRequest& request, BasicHttpResponse* http_response) { - std::string scope; - GetQueryParameter(request.content, "scope", &scope); - std::string grant_type; if (!GetQueryParameter(request.content, "grant_type", &grant_type)) { http_response->set_code(net::HTTP_BAD_REQUEST); @@ -508,12 +522,6 @@ void FakeGaia::HandleAuthToken(const HttpRequest& request, return; } - if (GaiaConstants::kOAuth1LoginScope != scope) { - http_response->set_code(net::HTTP_BAD_REQUEST); - LOG(ERROR) << "Invalid scope for /o/oauth2/token - " << scope; - return; - } - base::DictionaryValue response_dict; response_dict.SetString("refresh_token", merge_session_params_.refresh_token); @@ -524,6 +532,9 @@ void FakeGaia::HandleAuthToken(const HttpRequest& request, return; } + std::string scope; + GetQueryParameter(request.content, "scope", &scope); + std::string refresh_token; std::string client_id; if (GetQueryParameter(request.content, "refresh_token", &refresh_token) && @@ -550,17 +561,8 @@ void FakeGaia::HandleTokenInfo(const HttpRequest& request, BasicHttpResponse* http_response) { const AccessTokenInfo* token_info = NULL; std::string access_token; - if (GetQueryParameter(request.content, "access_token", &access_token)) { - for (AccessTokenInfoMap::const_iterator entry( - access_token_info_map_.begin()); - entry != access_token_info_map_.end(); - ++entry) { - if (entry->second.token == access_token) { - token_info = &(entry->second); - break; - } - } - } + if (GetQueryParameter(request.content, "access_token", &access_token)) + token_info = GetAccessTokenInfo(access_token); if (token_info) { base::DictionaryValue response_dict; @@ -617,3 +619,23 @@ void FakeGaia::HandleGetUserInfo(const HttpRequest& request, http_response->set_code(net::HTTP_OK); } +void FakeGaia::HandleOAuthUserInfo( + const net::test_server::HttpRequest& request, + net::test_server::BasicHttpResponse* http_response) { + const AccessTokenInfo* token_info = NULL; + std::string access_token; + if (GetAccessToken(request, kAuthHeaderBearer, &access_token) || + GetAccessToken(request, kAuthHeaderOAuth, &access_token)) { + token_info = GetAccessTokenInfo(access_token); + } + + if (token_info) { + base::DictionaryValue response_dict; + response_dict.SetString("id", GetGaiaIdOfEmail(token_info->email)); + response_dict.SetString("email", token_info->email); + response_dict.SetString("verified_email", token_info->email); + FormatJSONResponse(response_dict, http_response); + } else { + http_response->set_code(net::HTTP_BAD_REQUEST); + } +} diff --git a/google_apis/gaia/fake_gaia.h b/google_apis/gaia/fake_gaia.h index e00a80a..ec9ee16 100644 --- a/google_apis/gaia/fake_gaia.h +++ b/google_apis/gaia/fake_gaia.h @@ -170,15 +170,21 @@ class FakeGaia { net::test_server::BasicHttpResponse* http_response); void HandleGetUserInfo(const net::test_server::HttpRequest& request, net::test_server::BasicHttpResponse* http_response); + void HandleOAuthUserInfo(const net::test_server::HttpRequest& request, + net::test_server::BasicHttpResponse* http_response); // Returns the access token associated with |auth_token| that matches the // given |client_id| and |scope_string|. If |scope_string| is empty, the first // token satisfying the other criteria is returned. Returns NULL if no token // matches. - const AccessTokenInfo* FindAccessTokenInfo(const std::string& auth_token, - const std::string& client_id, - const std::string& scope_string) - const; + const AccessTokenInfo* FindAccessTokenInfo( + const std::string& auth_token, + const std::string& client_id, + const std::string& scope_string) const; + + // Returns the access token identified by |access_token| or NULL if not found. + const AccessTokenInfo* GetAccessTokenInfo( + const std::string& access_token) const; MergeSessionParams merge_session_params_; EmailToGaiaIdMap email_to_gaia_id_map_; |