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

Unified Diff: google_apis/gaia/gaia_oauth_client_unittest.cc

Issue 257773002: Use new people.get api instead of oauth2/v1/userinfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix user image manager tests Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « google_apis/gaia/gaia_oauth_client.cc ('k') | google_apis/gaia/gaia_urls.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: google_apis/gaia/gaia_oauth_client_unittest.cc
diff --git a/google_apis/gaia/gaia_oauth_client_unittest.cc b/google_apis/gaia/gaia_oauth_client_unittest.cc
index d4014f736794bb4bf45a6aba448b9c04794a0e80..338578e5dee25f49594c839ddeabc708017b9647 100644
--- a/google_apis/gaia/gaia_oauth_client_unittest.cc
+++ b/google_apis/gaia/gaia_oauth_client_unittest.cc
@@ -134,25 +134,22 @@ const std::string kTestUserId = "8675309";
const int kTestExpiresIn = 3920;
const std::string kDummyGetTokensResult =
- "{\"access_token\":\"" + kTestAccessToken + "\","
- "\"expires_in\":" + base::IntToString(kTestExpiresIn) + ","
- "\"refresh_token\":\"" + kTestRefreshToken + "\"}";
+ "{\"access_token\":\"" + kTestAccessToken + "\","
+ "\"expires_in\":" + base::IntToString(kTestExpiresIn) + ","
+ "\"refresh_token\":\"" + kTestRefreshToken + "\"}";
const std::string kDummyRefreshTokenResult =
- "{\"access_token\":\"" + kTestAccessToken + "\","
- "\"expires_in\":" + base::IntToString(kTestExpiresIn) + "}";
-
-const std::string kDummyUserInfoResult =
- "{\"email\":\"" + kTestUserEmail + "\"}";
+ "{\"access_token\":\"" + kTestAccessToken + "\","
+ "\"expires_in\":" + base::IntToString(kTestExpiresIn) + "}";
const std::string kDummyUserIdResult =
- "{\"id\":\"" + kTestUserId + "\"}";
+ "{\"id\":\"" + kTestUserId + "\"}";
const std::string kDummyTokenInfoResult =
- "{\"issued_to\": \"1234567890.apps.googleusercontent.com\","
- "\"audience\": \"1234567890.apps.googleusercontent.com\","
- "\"scope\": \"https://googleapis.com/oauth2/v2/tokeninfo\","
- "\"expires_in\":" + base::IntToString(kTestExpiresIn) + "}";
+ "{\"issued_to\": \"1234567890.apps.googleusercontent.com\","
+ "\"audience\": \"1234567890.apps.googleusercontent.com\","
+ "\"scope\": \"https://googleapis.com/oauth2/v2/tokeninfo\","
+ "\"expires_in\":" + base::IntToString(kTestExpiresIn) + "}";
}
namespace gaia {
@@ -304,11 +301,45 @@ TEST_F(GaiaOAuthClientTest, RefreshTokenDownscopingSuccess) {
factory.get_url_fetcher()->Finish();
}
-
TEST_F(GaiaOAuthClientTest, GetUserEmail) {
MockGaiaOAuthClientDelegate delegate;
EXPECT_CALL(delegate, OnGetUserEmailResponse(kTestUserEmail)).Times(1);
+ const std::string kDummyUserInfoResult =
+ "{\"emails\": [{\"value\":\"" + kTestUserEmail +
+ "\", \"type\":\"account\"}]}";
+
+ MockOAuthFetcherFactory factory;
+ factory.set_results(kDummyUserInfoResult);
+
+ GaiaOAuthClient auth(GetRequestContext());
+ auth.GetUserEmail("access_token", 1, &delegate);
+}
+
+TEST_F(GaiaOAuthClientTest, GetUserEmailSecondItemValid) {
+ MockGaiaOAuthClientDelegate delegate;
+ EXPECT_CALL(delegate, OnGetUserEmailResponse(kTestUserEmail)).Times(1);
+
+ const std::string kDummyUserInfoResult =
+ "{\"emails\": [{\"value\":\"foo\"},"
+ "{\"value\":\"" + kTestUserEmail +
+ "\", \"type\":\"account\"}]}";
+
+ MockOAuthFetcherFactory factory;
+ factory.set_results(kDummyUserInfoResult);
+
+ GaiaOAuthClient auth(GetRequestContext());
+ auth.GetUserEmail("access_token", 1, &delegate);
+}
+
+TEST_F(GaiaOAuthClientTest, GetUserEmailNoValidItems) {
+ MockGaiaOAuthClientDelegate delegate;
+ EXPECT_CALL(delegate, OnNetworkError(_)).Times(1);
+
+ const std::string kDummyUserInfoResult =
+ "{\"emails\": [{\"value\":\"" + kTestUserEmail +
+ "\", \"type\":\"foo\"}]}";
+
MockOAuthFetcherFactory factory;
factory.set_results(kDummyUserInfoResult);
« no previous file with comments | « google_apis/gaia/gaia_oauth_client.cc ('k') | google_apis/gaia/gaia_urls.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698