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

Unified Diff: google_apis/gaia/oauth2_access_token_fetcher_unittest.cc

Issue 57993006: signin: record http response codes and net errors in OAuth2AccessTokenFetcher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: eof Created 7 years, 1 month 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/oauth2_access_token_fetcher.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: google_apis/gaia/oauth2_access_token_fetcher_unittest.cc
diff --git a/google_apis/gaia/oauth2_access_token_fetcher_unittest.cc b/google_apis/gaia/oauth2_access_token_fetcher_unittest.cc
index 6b12da3fbd02fc67dde62df136d27533f9d5030b..135e292d7c0ca1da0ed816eefcf8abead41c65bb 100644
--- a/google_apis/gaia/oauth2_access_token_fetcher_unittest.cc
+++ b/google_apis/gaia/oauth2_access_token_fetcher_unittest.cc
@@ -50,6 +50,11 @@ static const char kTokenResponseNoAccessToken[] =
" \"token_type\": \"Bearer\""
"}";
+static const char kValidFailureTokenResponse[] =
+ "{"
+ " \"error\": \"invalid_grant\""
+ "}";
+
class MockUrlFetcherFactory : public ScopedURLFetcherFactory,
public URLFetcherFactory {
public:
@@ -195,7 +200,7 @@ TEST_F(OAuth2AccessTokenFetcherTest, MAYBE_ParseGetAccessTokenResponse) {
std::string at;
int expires_in;
- EXPECT_FALSE(OAuth2AccessTokenFetcher::ParseGetAccessTokenResponse(
+ EXPECT_FALSE(OAuth2AccessTokenFetcher::ParseGetAccessTokenSuccessResponse(
&url_fetcher, &at, &expires_in));
EXPECT_TRUE(at.empty());
}
@@ -205,7 +210,7 @@ TEST_F(OAuth2AccessTokenFetcherTest, MAYBE_ParseGetAccessTokenResponse) {
std::string at;
int expires_in;
- EXPECT_FALSE(OAuth2AccessTokenFetcher::ParseGetAccessTokenResponse(
+ EXPECT_FALSE(OAuth2AccessTokenFetcher::ParseGetAccessTokenSuccessResponse(
&url_fetcher, &at, &expires_in));
EXPECT_TRUE(at.empty());
}
@@ -215,7 +220,7 @@ TEST_F(OAuth2AccessTokenFetcherTest, MAYBE_ParseGetAccessTokenResponse) {
std::string at;
int expires_in;
- EXPECT_FALSE(OAuth2AccessTokenFetcher::ParseGetAccessTokenResponse(
+ EXPECT_FALSE(OAuth2AccessTokenFetcher::ParseGetAccessTokenSuccessResponse(
&url_fetcher, &at, &expires_in));
EXPECT_TRUE(at.empty());
}
@@ -225,9 +230,27 @@ TEST_F(OAuth2AccessTokenFetcherTest, MAYBE_ParseGetAccessTokenResponse) {
std::string at;
int expires_in;
- EXPECT_TRUE(OAuth2AccessTokenFetcher::ParseGetAccessTokenResponse(
+ EXPECT_TRUE(OAuth2AccessTokenFetcher::ParseGetAccessTokenSuccessResponse(
&url_fetcher, &at, &expires_in));
EXPECT_EQ("at1", at);
EXPECT_EQ(3600, expires_in);
}
+ { // Valid json: invalid error response.
+ TestURLFetcher url_fetcher(0, GURL("www.google.com"), NULL);
+ url_fetcher.SetResponseString(kTokenResponseNoAccessToken);
+
+ std::string error;
+ EXPECT_FALSE(OAuth2AccessTokenFetcher::ParseGetAccessTokenFailureResponse(
+ &url_fetcher, &error));
+ EXPECT_TRUE(error.empty());
+ }
+ { // Valid json: error response.
+ TestURLFetcher url_fetcher(0, GURL("www.google.com"), NULL);
+ url_fetcher.SetResponseString(kValidFailureTokenResponse);
+
+ std::string error;
+ EXPECT_TRUE(OAuth2AccessTokenFetcher::ParseGetAccessTokenFailureResponse(
+ &url_fetcher, &error));
+ EXPECT_EQ("invalid_grant", error);
+ }
}
« no previous file with comments | « google_apis/gaia/oauth2_access_token_fetcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698