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

Side by Side Diff: chrome/browser/sync/test/integration/sync_auth_test.cc

Issue 472403002: Prevent invalidating refresh token on transient errors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix integration tests Created 6 years, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "base/strings/stringprintf.h" 5 #include "base/strings/stringprintf.h"
6 #include "base/threading/platform_thread.h" 6 #include "base/threading/platform_thread.h"
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 8 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
9 #include "chrome/browser/sync/profile_sync_service.h" 9 #include "chrome/browser/sync/profile_sync_service.h"
10 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" 10 #include "chrome/browser/sync/test/integration/bookmarks_helper.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 GetFakeServer()->SetUnauthenticated(); 199 GetFakeServer()->SetUnauthenticated();
200 DisableTokenFetchRetries(); 200 DisableTokenFetchRetries();
201 SetOAuth2TokenResponse(kInvalidGrantOAuth2Token, 201 SetOAuth2TokenResponse(kInvalidGrantOAuth2Token,
202 net::HTTP_BAD_REQUEST, 202 net::HTTP_BAD_REQUEST,
203 net::URLRequestStatus::SUCCESS); 203 net::URLRequestStatus::SUCCESS);
204 ASSERT_TRUE(AttemptToTriggerAuthError()); 204 ASSERT_TRUE(AttemptToTriggerAuthError());
205 ASSERT_EQ(GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS, 205 ASSERT_EQ(GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS,
206 GetSyncService((0))->GetAuthError().state()); 206 GetSyncService((0))->GetAuthError().state());
207 } 207 }
208 208
209 // Verify that ProfileSyncService ends up with an SERVICE_ERROR auth error when 209 // Verify that ProfileSyncService retries after SERVICE_ERROR auth error when
210 // an invalid_client error is returned by OAuth2TokenService with an 210 // an invalid_client error is returned by OAuth2TokenService with an
211 // HTTP_BAD_REQUEST (400) response code. 211 // HTTP_BAD_REQUEST (400) response code.
212 IN_PROC_BROWSER_TEST_F(SyncAuthTest, InvalidClient) { 212 IN_PROC_BROWSER_TEST_F(SyncAuthTest, RetryInvalidClient) {
213 ASSERT_TRUE(SetupSync()); 213 ASSERT_TRUE(SetupSync());
214 ASSERT_FALSE(AttemptToTriggerAuthError()); 214 ASSERT_FALSE(AttemptToTriggerAuthError());
215 GetFakeServer()->SetUnauthenticated(); 215 GetFakeServer()->SetUnauthenticated();
216 DisableTokenFetchRetries(); 216 DisableTokenFetchRetries();
217 SetOAuth2TokenResponse(kInvalidClientOAuth2Token, 217 SetOAuth2TokenResponse(kInvalidClientOAuth2Token,
218 net::HTTP_BAD_REQUEST, 218 net::HTTP_BAD_REQUEST,
219 net::URLRequestStatus::SUCCESS); 219 net::URLRequestStatus::SUCCESS);
220 ASSERT_TRUE(AttemptToTriggerAuthError()); 220 ASSERT_TRUE(AttemptToTriggerAuthError());
221 ASSERT_EQ(GoogleServiceAuthError::SERVICE_ERROR, 221 ASSERT_TRUE(GetSyncService((0))->IsRetryingAccessTokenFetchForTest());
222 GetSyncService((0))->GetAuthError().state());
223 } 222 }
224 223
225 // Verify that ProfileSyncService ends up with a REQUEST_CANCELED auth error 224 // Verify that ProfileSyncService retries after REQUEST_CANCELED auth error
226 // when when OAuth2TokenService has encountered a URLRequestStatus of CANCELED. 225 // when OAuth2TokenService has encountered a URLRequestStatus of CANCELED.
227 IN_PROC_BROWSER_TEST_F(SyncAuthTest, RequestCanceled) { 226 IN_PROC_BROWSER_TEST_F(SyncAuthTest, RetryRequestCanceled) {
228 ASSERT_TRUE(SetupSync()); 227 ASSERT_TRUE(SetupSync());
229 ASSERT_FALSE(AttemptToTriggerAuthError()); 228 ASSERT_FALSE(AttemptToTriggerAuthError());
230 GetFakeServer()->SetUnauthenticated(); 229 GetFakeServer()->SetUnauthenticated();
231 DisableTokenFetchRetries(); 230 DisableTokenFetchRetries();
232 SetOAuth2TokenResponse(kEmptyOAuth2Token, 231 SetOAuth2TokenResponse(kEmptyOAuth2Token,
233 net::HTTP_INTERNAL_SERVER_ERROR, 232 net::HTTP_INTERNAL_SERVER_ERROR,
234 net::URLRequestStatus::CANCELED); 233 net::URLRequestStatus::CANCELED);
235 ASSERT_TRUE(AttemptToTriggerAuthError()); 234 ASSERT_TRUE(AttemptToTriggerAuthError());
236 ASSERT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, 235 ASSERT_TRUE(GetSyncService((0))->IsRetryingAccessTokenFetchForTest());
237 GetSyncService((0))->GetAuthError().state());
238 } 236 }
239 237
240 // Verify that ProfileSyncService fails initial sync setup during backend 238 // Verify that ProfileSyncService fails initial sync setup during backend
241 // initialization and ends up with an INVALID_GAIA_CREDENTIALS auth error when 239 // initialization and ends up with an INVALID_GAIA_CREDENTIALS auth error when
242 // an invalid_grant error is returned by OAuth2TokenService with an 240 // an invalid_grant error is returned by OAuth2TokenService with an
243 // HTTP_BAD_REQUEST (400) response code. 241 // HTTP_BAD_REQUEST (400) response code.
244 IN_PROC_BROWSER_TEST_F(SyncAuthTest, FailInitialSetupWithPersistentError) { 242 IN_PROC_BROWSER_TEST_F(SyncAuthTest, FailInitialSetupWithPersistentError) {
245 ASSERT_TRUE(SetupClients()); 243 ASSERT_TRUE(SetupClients());
246 GetFakeServer()->SetUnauthenticated(); 244 GetFakeServer()->SetUnauthenticated();
247 DisableTokenFetchRetries(); 245 DisableTokenFetchRetries();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 GetFakeServer()->SetAuthenticated(); 298 GetFakeServer()->SetAuthenticated();
301 SetOAuth2TokenResponse(kValidOAuth2Token, 299 SetOAuth2TokenResponse(kValidOAuth2Token,
302 net::HTTP_OK, 300 net::HTTP_OK,
303 net::URLRequestStatus::SUCCESS); 301 net::URLRequestStatus::SUCCESS);
304 302
305 // Verify that the next sync cycle is successful, and uses the new auth token. 303 // Verify that the next sync cycle is successful, and uses the new auth token.
306 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0)))); 304 ASSERT_TRUE(AwaitCommitActivityCompletion(GetSyncService((0))));
307 std::string new_token = GetSyncService((0))->GetAccessTokenForTest(); 305 std::string new_token = GetSyncService((0))->GetAccessTokenForTest();
308 ASSERT_NE(old_token, new_token); 306 ASSERT_NE(old_token, new_token);
309 } 307 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | google_apis/gaia/oauth2_access_token_fetcher_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698