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

Unified Diff: google_apis/gaia/gaia_auth_fetcher_unittest.cc

Issue 1644713002: Allow gaia auth fetcher to work with arbitrary clients. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 4 years, 11 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_auth_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/gaia_auth_fetcher_unittest.cc
diff --git a/google_apis/gaia/gaia_auth_fetcher_unittest.cc b/google_apis/gaia/gaia_auth_fetcher_unittest.cc
index 19ae5df2f1293a5d12f0ab8cd0610d850bc0d02a..f281f233e741e156bad22ca69fb085f17a4c20f1 100644
--- a/google_apis/gaia/gaia_auth_fetcher_unittest.cc
+++ b/google_apis/gaia/gaia_auth_fetcher_unittest.cc
@@ -171,6 +171,7 @@ class MockGaiaConsumer : public GaiaAuthConsumer {
MOCK_METHOD1(OnClientLoginSuccess, void(const ClientLoginResult& result));
MOCK_METHOD2(OnIssueAuthTokenSuccess, void(const std::string& service,
const std::string& token));
+ MOCK_METHOD1(OnClientOAuthCode, void(const std::string& data));
MOCK_METHOD1(OnClientOAuthSuccess,
void(const GaiaAuthConsumer::ClientOAuthResult& result));
MOCK_METHOD1(OnMergeSessionSuccess, void(const std::string& data));
@@ -395,6 +396,7 @@ TEST_F(GaiaAuthFetcherTest, FullTokenFailure) {
TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenSuccess) {
MockGaiaConsumer consumer;
+ EXPECT_CALL(consumer, OnClientOAuthCode("test-code")).Times(0);
EXPECT_CALL(consumer, OnClientOAuthSuccess(
GaiaAuthConsumer::ClientOAuthResult("rt1", "at1", 3600))).Times(1);
@@ -429,6 +431,37 @@ TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenSuccess) {
EXPECT_FALSE(auth.HasPendingFetch());
}
+TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenSuccessNoTokenFetch) {
+ MockGaiaConsumer consumer;
+ EXPECT_CALL(consumer, OnClientOAuthCode("test-code")).Times(1);
+ EXPECT_CALL(consumer, OnClientOAuthSuccess(
+ GaiaAuthConsumer::ClientOAuthResult("", "", 0))).Times(0);
+
+ net::TestURLFetcherFactory factory;
+ GaiaAuthFetcher auth(&consumer, std::string(), GetRequestContext());
+ auth.StartCookieForOAuthLoginTokenExchange(
+ false, "0", "ABCDE_12345", "");
+ net::TestURLFetcher* fetcher = factory.GetFetcherByID(0);
+ EXPECT_TRUE(NULL != fetcher);
+ EXPECT_EQ(net::LOAD_NORMAL, fetcher->GetLoadFlags());
+ EXPECT_EQ(std::string::npos,
+ fetcher->GetOriginalURL().query().find("device_type=chrome"));
+
+ net::ResponseCookies cookies;
+ cookies.push_back(kGetAuthCodeValidCookie);
+ EXPECT_TRUE(auth.HasPendingFetch());
+ MockFetcher mock_fetcher1(
+ client_login_to_oauth2_source_,
+ net::URLRequestStatus(net::URLRequestStatus::SUCCESS, 0),
+ net::HTTP_OK,
+ cookies,
+ std::string(),
+ net::URLFetcher::POST,
+ &auth);
+ auth.OnURLFetchComplete(&mock_fetcher1);
+ EXPECT_FALSE(auth.HasPendingFetch());
+}
+
TEST_F(GaiaAuthFetcherTest, OAuthLoginTokenWithCookies_DeviceId) {
MockGaiaConsumer consumer;
net::TestURLFetcherFactory factory;
« no previous file with comments | « google_apis/gaia/gaia_auth_fetcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698