| OLD | NEW |
| 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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "chrome/browser/signin/account_reconcilor_factory.h" | 8 #include "chrome/browser/signin/account_reconcilor_factory.h" |
| 9 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 9 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
| 10 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 10 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 signin_manager()->SetAuthenticatedUsername(kTestEmail); | 255 signin_manager()->SetAuthenticatedUsername(kTestEmail); |
| 256 token_service()->UpdateCredentials(kTestEmail, "refresh_token"); | 256 token_service()->UpdateCredentials(kTestEmail, "refresh_token"); |
| 257 | 257 |
| 258 AccountReconcilor* reconcilor = | 258 AccountReconcilor* reconcilor = |
| 259 AccountReconcilorFactory::GetForProfile(profile()); | 259 AccountReconcilorFactory::GetForProfile(profile()); |
| 260 ASSERT_TRUE(reconcilor); | 260 ASSERT_TRUE(reconcilor); |
| 261 | 261 |
| 262 reconcilor->ValidateAccountsFromTokenService(); | 262 reconcilor->ValidateAccountsFromTokenService(); |
| 263 ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked()); | 263 ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked()); |
| 264 | 264 |
| 265 SetFakeResponse("https://www.googleapis.com/oauth2/v1/userinfo", | 265 SetFakeResponse(GaiaUrls::GetInstance()->people_get_url().spec(), |
| 266 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 266 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 267 token_service()->IssueTokenForAllPendingRequests("access_token", | 267 token_service()->IssueTokenForAllPendingRequests("access_token", |
| 268 base::Time::Now() + base::TimeDelta::FromHours(1)); | 268 base::Time::Now() + base::TimeDelta::FromHours(1)); |
| 269 | 269 |
| 270 base::RunLoop().RunUntilIdle(); | 270 base::RunLoop().RunUntilIdle(); |
| 271 ASSERT_TRUE(reconcilor->AreAllRefreshTokensChecked()); | 271 ASSERT_TRUE(reconcilor->AreAllRefreshTokensChecked()); |
| 272 ASSERT_EQ(1u, reconcilor->GetValidChromeAccountsForTesting().size()); | 272 ASSERT_EQ(1u, reconcilor->GetValidChromeAccountsForTesting().size()); |
| 273 ASSERT_EQ(0u, reconcilor->GetInvalidChromeAccountsForTesting().size()); | 273 ASSERT_EQ(0u, reconcilor->GetInvalidChromeAccountsForTesting().size()); |
| 274 } | 274 } |
| 275 | 275 |
| 276 TEST_F(AccountReconcilorTest, ValidateAccountsFromTokensFailedUserInfo) { | 276 TEST_F(AccountReconcilorTest, ValidateAccountsFromTokensFailedUserInfo) { |
| 277 signin_manager()->SetAuthenticatedUsername(kTestEmail); | 277 signin_manager()->SetAuthenticatedUsername(kTestEmail); |
| 278 token_service()->UpdateCredentials(kTestEmail, "refresh_token"); | 278 token_service()->UpdateCredentials(kTestEmail, "refresh_token"); |
| 279 | 279 |
| 280 AccountReconcilor* reconcilor = | 280 AccountReconcilor* reconcilor = |
| 281 AccountReconcilorFactory::GetForProfile(profile()); | 281 AccountReconcilorFactory::GetForProfile(profile()); |
| 282 ASSERT_TRUE(reconcilor); | 282 ASSERT_TRUE(reconcilor); |
| 283 | 283 |
| 284 reconcilor->ValidateAccountsFromTokenService(); | 284 reconcilor->ValidateAccountsFromTokenService(); |
| 285 ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked()); | 285 ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked()); |
| 286 | 286 |
| 287 SetFakeResponse("https://www.googleapis.com/oauth2/v1/userinfo", | 287 SetFakeResponse(GaiaUrls::GetInstance()->people_get_url().spec(), |
| 288 "", net::HTTP_NOT_FOUND, net::URLRequestStatus::SUCCESS); | 288 "", net::HTTP_NOT_FOUND, net::URLRequestStatus::SUCCESS); |
| 289 token_service()->IssueTokenForAllPendingRequests("access_token", | 289 token_service()->IssueTokenForAllPendingRequests("access_token", |
| 290 base::Time::Now() + base::TimeDelta::FromHours(1)); | 290 base::Time::Now() + base::TimeDelta::FromHours(1)); |
| 291 | 291 |
| 292 base::RunLoop().RunUntilIdle(); | 292 base::RunLoop().RunUntilIdle(); |
| 293 ASSERT_TRUE(reconcilor->AreAllRefreshTokensChecked()); | 293 ASSERT_TRUE(reconcilor->AreAllRefreshTokensChecked()); |
| 294 ASSERT_EQ(0u, reconcilor->GetValidChromeAccountsForTesting().size()); | 294 ASSERT_EQ(0u, reconcilor->GetValidChromeAccountsForTesting().size()); |
| 295 ASSERT_EQ(1u, reconcilor->GetInvalidChromeAccountsForTesting().size()); | 295 ASSERT_EQ(1u, reconcilor->GetInvalidChromeAccountsForTesting().size()); |
| 296 } | 296 } |
| 297 | 297 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 319 signin_manager()->SetAuthenticatedUsername(kTestEmail); | 319 signin_manager()->SetAuthenticatedUsername(kTestEmail); |
| 320 token_service()->UpdateCredentials(kTestEmail, "refresh_token"); | 320 token_service()->UpdateCredentials(kTestEmail, "refresh_token"); |
| 321 | 321 |
| 322 AccountReconcilor* reconcilor = | 322 AccountReconcilor* reconcilor = |
| 323 AccountReconcilorFactory::GetForProfile(profile()); | 323 AccountReconcilorFactory::GetForProfile(profile()); |
| 324 ASSERT_TRUE(reconcilor); | 324 ASSERT_TRUE(reconcilor); |
| 325 | 325 |
| 326 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), | 326 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), |
| 327 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", | 327 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", |
| 328 net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 328 net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 329 SetFakeResponse("https://www.googleapis.com/oauth2/v1/userinfo", | 329 SetFakeResponse(GaiaUrls::GetInstance()->people_get_url().spec(), |
| 330 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 330 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 331 | 331 |
| 332 reconcilor->StartReconcile(); | 332 reconcilor->StartReconcile(); |
| 333 ASSERT_FALSE(reconcilor->AreGaiaAccountsSet()); | 333 ASSERT_FALSE(reconcilor->AreGaiaAccountsSet()); |
| 334 ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked()); | 334 ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked()); |
| 335 | 335 |
| 336 base::RunLoop().RunUntilIdle(); | 336 base::RunLoop().RunUntilIdle(); |
| 337 ASSERT_TRUE(reconcilor->AreGaiaAccountsSet()); | 337 ASSERT_TRUE(reconcilor->AreGaiaAccountsSet()); |
| 338 ASSERT_EQ(1u, reconcilor->GetGaiaAccountsForTesting().size()); | 338 ASSERT_EQ(1u, reconcilor->GetGaiaAccountsForTesting().size()); |
| 339 ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked()); | 339 ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 358 signin_manager()->SetAuthenticatedUsername("Dot.S@gmail.com"); | 358 signin_manager()->SetAuthenticatedUsername("Dot.S@gmail.com"); |
| 359 token_service()->UpdateCredentials("Dot.S@gmail.com", "refresh_token"); | 359 token_service()->UpdateCredentials("Dot.S@gmail.com", "refresh_token"); |
| 360 | 360 |
| 361 AccountReconcilor* reconcilor = | 361 AccountReconcilor* reconcilor = |
| 362 AccountReconcilorFactory::GetForProfile(profile()); | 362 AccountReconcilorFactory::GetForProfile(profile()); |
| 363 ASSERT_TRUE(reconcilor); | 363 ASSERT_TRUE(reconcilor); |
| 364 | 364 |
| 365 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), | 365 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), |
| 366 "[\"f\", [[\"b\", 0, \"n\", \"dot.s@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", | 366 "[\"f\", [[\"b\", 0, \"n\", \"dot.s@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", |
| 367 net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 367 net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 368 SetFakeResponse("https://www.googleapis.com/oauth2/v1/userinfo", | 368 SetFakeResponse(GaiaUrls::GetInstance()->people_get_url().spec(), |
| 369 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 369 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 370 | 370 |
| 371 reconcilor->StartReconcile(); | 371 reconcilor->StartReconcile(); |
| 372 ASSERT_FALSE(reconcilor->AreGaiaAccountsSet()); | 372 ASSERT_FALSE(reconcilor->AreGaiaAccountsSet()); |
| 373 ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked()); | 373 ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked()); |
| 374 | 374 |
| 375 base::RunLoop().RunUntilIdle(); | 375 base::RunLoop().RunUntilIdle(); |
| 376 ASSERT_TRUE(reconcilor->AreGaiaAccountsSet()); | 376 ASSERT_TRUE(reconcilor->AreGaiaAccountsSet()); |
| 377 ASSERT_EQ(1u, reconcilor->GetGaiaAccountsForTesting().size()); | 377 ASSERT_EQ(1u, reconcilor->GetGaiaAccountsForTesting().size()); |
| 378 ASSERT_STREQ("dots@gmail.com", | 378 ASSERT_STREQ("dots@gmail.com", |
| (...skipping 14 matching lines...) Expand all Loading... |
| 393 token_service()->UpdateCredentials("other@gmail.com", "refresh_token"); | 393 token_service()->UpdateCredentials("other@gmail.com", "refresh_token"); |
| 394 | 394 |
| 395 AccountReconcilor* reconcilor = | 395 AccountReconcilor* reconcilor = |
| 396 AccountReconcilorFactory::GetForProfile(profile()); | 396 AccountReconcilorFactory::GetForProfile(profile()); |
| 397 ASSERT_TRUE(reconcilor); | 397 ASSERT_TRUE(reconcilor); |
| 398 | 398 |
| 399 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), | 399 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), |
| 400 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1], " | 400 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1], " |
| 401 "[\"b\", 0, \"n\", \"other@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", | 401 "[\"b\", 0, \"n\", \"other@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", |
| 402 net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 402 net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 403 SetFakeResponse("https://www.googleapis.com/oauth2/v1/userinfo", | 403 SetFakeResponse(GaiaUrls::GetInstance()->people_get_url().spec(), |
| 404 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 404 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 405 | 405 |
| 406 reconcilor->StartReconcile(); | 406 reconcilor->StartReconcile(); |
| 407 ASSERT_FALSE(reconcilor->AreGaiaAccountsSet()); | 407 ASSERT_FALSE(reconcilor->AreGaiaAccountsSet()); |
| 408 ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked()); | 408 ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked()); |
| 409 | 409 |
| 410 base::RunLoop().RunUntilIdle(); | 410 base::RunLoop().RunUntilIdle(); |
| 411 ASSERT_TRUE(reconcilor->AreGaiaAccountsSet()); | 411 ASSERT_TRUE(reconcilor->AreGaiaAccountsSet()); |
| 412 ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked()); | 412 ASSERT_FALSE(reconcilor->AreAllRefreshTokensChecked()); |
| 413 ASSERT_EQ(2u, reconcilor->GetGaiaAccountsForTesting().size()); | 413 ASSERT_EQ(2u, reconcilor->GetGaiaAccountsForTesting().size()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 429 TEST_F(AccountReconcilorTest, StartReconcileAddToCookie) { | 429 TEST_F(AccountReconcilorTest, StartReconcileAddToCookie) { |
| 430 signin_manager()->SetAuthenticatedUsername("user@gmail.com"); | 430 signin_manager()->SetAuthenticatedUsername("user@gmail.com"); |
| 431 token_service()->UpdateCredentials("user@gmail.com", "refresh_token"); | 431 token_service()->UpdateCredentials("user@gmail.com", "refresh_token"); |
| 432 token_service()->UpdateCredentials("other@gmail.com", "refresh_token"); | 432 token_service()->UpdateCredentials("other@gmail.com", "refresh_token"); |
| 433 | 433 |
| 434 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("other@gmail.com")); | 434 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("other@gmail.com")); |
| 435 | 435 |
| 436 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), | 436 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), |
| 437 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", | 437 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", |
| 438 net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 438 net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 439 SetFakeResponse("https://www.googleapis.com/oauth2/v1/userinfo", | 439 SetFakeResponse(GaiaUrls::GetInstance()->people_get_url().spec(), |
| 440 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 440 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 441 | 441 |
| 442 AccountReconcilor* reconcilor = GetMockReconcilor(); | 442 AccountReconcilor* reconcilor = GetMockReconcilor(); |
| 443 reconcilor->StartReconcile(); | 443 reconcilor->StartReconcile(); |
| 444 token_service()->IssueAllTokensForAccount("other@gmail.com", "access_token", | 444 token_service()->IssueAllTokensForAccount("other@gmail.com", "access_token", |
| 445 base::Time::Now() + base::TimeDelta::FromHours(1)); | 445 base::Time::Now() + base::TimeDelta::FromHours(1)); |
| 446 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", | 446 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", |
| 447 base::Time::Now() + base::TimeDelta::FromHours(1)); | 447 base::Time::Now() + base::TimeDelta::FromHours(1)); |
| 448 | 448 |
| 449 base::RunLoop().RunUntilIdle(); | 449 base::RunLoop().RunUntilIdle(); |
| 450 ASSERT_TRUE(reconcilor->is_reconcile_started_); | 450 ASSERT_TRUE(reconcilor->is_reconcile_started_); |
| 451 SimulateMergeSessionCompleted(reconcilor, "other@gmail.com", | 451 SimulateMergeSessionCompleted(reconcilor, "other@gmail.com", |
| 452 GoogleServiceAuthError::AuthErrorNone()); | 452 GoogleServiceAuthError::AuthErrorNone()); |
| 453 ASSERT_FALSE(reconcilor->is_reconcile_started_); | 453 ASSERT_FALSE(reconcilor->is_reconcile_started_); |
| 454 } | 454 } |
| 455 | 455 |
| 456 TEST_F(AccountReconcilorTest, StartReconcileAddToChrome) { | 456 TEST_F(AccountReconcilorTest, StartReconcileAddToChrome) { |
| 457 signin_manager()->SetAuthenticatedUsername("user@gmail.com"); | 457 signin_manager()->SetAuthenticatedUsername("user@gmail.com"); |
| 458 token_service()->UpdateCredentials("user@gmail.com", "refresh_token"); | 458 token_service()->UpdateCredentials("user@gmail.com", "refresh_token"); |
| 459 | 459 |
| 460 EXPECT_CALL(*GetMockReconcilor(), | 460 EXPECT_CALL(*GetMockReconcilor(), |
| 461 PerformAddToChromeAction("other@gmail.com", 1)); | 461 PerformAddToChromeAction("other@gmail.com", 1)); |
| 462 | 462 |
| 463 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), | 463 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), |
| 464 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1], " | 464 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1], " |
| 465 "[\"b\", 0, \"n\", \"other@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", | 465 "[\"b\", 0, \"n\", \"other@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", |
| 466 net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 466 net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 467 SetFakeResponse("https://www.googleapis.com/oauth2/v1/userinfo", | 467 SetFakeResponse(GaiaUrls::GetInstance()->people_get_url().spec(), |
| 468 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 468 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 469 | 469 |
| 470 AccountReconcilor* reconcilor = GetMockReconcilor(); | 470 AccountReconcilor* reconcilor = GetMockReconcilor(); |
| 471 reconcilor->StartReconcile(); | 471 reconcilor->StartReconcile(); |
| 472 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", | 472 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", |
| 473 base::Time::Now() + base::TimeDelta::FromHours(1)); | 473 base::Time::Now() + base::TimeDelta::FromHours(1)); |
| 474 | 474 |
| 475 base::RunLoop().RunUntilIdle(); | 475 base::RunLoop().RunUntilIdle(); |
| 476 ASSERT_TRUE(reconcilor->is_reconcile_started_); | 476 ASSERT_TRUE(reconcilor->is_reconcile_started_); |
| 477 SimulateRefreshTokenFetched(reconcilor, "other@gmail.com", ""); | 477 SimulateRefreshTokenFetched(reconcilor, "other@gmail.com", ""); |
| 478 ASSERT_FALSE(reconcilor->is_reconcile_started_); | 478 ASSERT_FALSE(reconcilor->is_reconcile_started_); |
| 479 } | 479 } |
| 480 | 480 |
| 481 TEST_F(AccountReconcilorTest, StartReconcileBadPrimary) { | 481 TEST_F(AccountReconcilorTest, StartReconcileBadPrimary) { |
| 482 signin_manager()->SetAuthenticatedUsername("user@gmail.com"); | 482 signin_manager()->SetAuthenticatedUsername("user@gmail.com"); |
| 483 token_service()->UpdateCredentials("user@gmail.com", "refresh_token"); | 483 token_service()->UpdateCredentials("user@gmail.com", "refresh_token"); |
| 484 token_service()->UpdateCredentials("other@gmail.com", "refresh_token"); | 484 token_service()->UpdateCredentials("other@gmail.com", "refresh_token"); |
| 485 | 485 |
| 486 EXPECT_CALL(*GetMockReconcilor(), PerformLogoutAllAccountsAction()); | 486 EXPECT_CALL(*GetMockReconcilor(), PerformLogoutAllAccountsAction()); |
| 487 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("user@gmail.com")); | 487 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("user@gmail.com")); |
| 488 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("other@gmail.com")); | 488 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("other@gmail.com")); |
| 489 | 489 |
| 490 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), | 490 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), |
| 491 "[\"f\", [[\"b\", 0, \"n\", \"other@gmail.com\", \"p\", 0, 0, 0, 0, 1], " | 491 "[\"f\", [[\"b\", 0, \"n\", \"other@gmail.com\", \"p\", 0, 0, 0, 0, 1], " |
| 492 "[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", | 492 "[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", |
| 493 net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 493 net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 494 SetFakeResponse("https://www.googleapis.com/oauth2/v1/userinfo", | 494 SetFakeResponse(GaiaUrls::GetInstance()->people_get_url().spec(), |
| 495 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 495 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 496 | 496 |
| 497 AccountReconcilor* reconcilor = GetMockReconcilor(); | 497 AccountReconcilor* reconcilor = GetMockReconcilor(); |
| 498 reconcilor->StartReconcile(); | 498 reconcilor->StartReconcile(); |
| 499 token_service()->IssueAllTokensForAccount("other@gmail.com", "access_token", | 499 token_service()->IssueAllTokensForAccount("other@gmail.com", "access_token", |
| 500 base::Time::Now() + base::TimeDelta::FromHours(1)); | 500 base::Time::Now() + base::TimeDelta::FromHours(1)); |
| 501 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", | 501 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", |
| 502 base::Time::Now() + base::TimeDelta::FromHours(1)); | 502 base::Time::Now() + base::TimeDelta::FromHours(1)); |
| 503 | 503 |
| 504 base::RunLoop().RunUntilIdle(); | 504 base::RunLoop().RunUntilIdle(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 515 signin_manager()->SetAuthenticatedUsername(kTestEmail); | 515 signin_manager()->SetAuthenticatedUsername(kTestEmail); |
| 516 token_service()->UpdateCredentials(kTestEmail, "refresh_token"); | 516 token_service()->UpdateCredentials(kTestEmail, "refresh_token"); |
| 517 | 517 |
| 518 AccountReconcilor* reconcilor = | 518 AccountReconcilor* reconcilor = |
| 519 AccountReconcilorFactory::GetForProfile(profile()); | 519 AccountReconcilorFactory::GetForProfile(profile()); |
| 520 ASSERT_TRUE(reconcilor); | 520 ASSERT_TRUE(reconcilor); |
| 521 | 521 |
| 522 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), | 522 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), |
| 523 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", | 523 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", |
| 524 net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 524 net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 525 SetFakeResponse("https://www.googleapis.com/oauth2/v1/userinfo", | 525 SetFakeResponse(GaiaUrls::GetInstance()->people_get_url().spec(), |
| 526 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 526 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 527 | 527 |
| 528 ASSERT_FALSE(reconcilor->is_reconcile_started_); | 528 ASSERT_FALSE(reconcilor->is_reconcile_started_); |
| 529 reconcilor->StartReconcile(); | 529 reconcilor->StartReconcile(); |
| 530 ASSERT_TRUE(reconcilor->is_reconcile_started_); | 530 ASSERT_TRUE(reconcilor->is_reconcile_started_); |
| 531 | 531 |
| 532 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", | 532 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", |
| 533 base::Time::Now() + base::TimeDelta::FromHours(1)); | 533 base::Time::Now() + base::TimeDelta::FromHours(1)); |
| 534 | 534 |
| 535 base::RunLoop().RunUntilIdle(); | 535 base::RunLoop().RunUntilIdle(); |
| 536 ASSERT_FALSE(reconcilor->is_reconcile_started_); | 536 ASSERT_FALSE(reconcilor->is_reconcile_started_); |
| 537 } | 537 } |
| 538 | 538 |
| 539 TEST_F(AccountReconcilorTest, StartReconcileWithSessionInfoExpiredDefault) { | 539 TEST_F(AccountReconcilorTest, StartReconcileWithSessionInfoExpiredDefault) { |
| 540 signin_manager()->SetAuthenticatedUsername("user@gmail.com"); | 540 signin_manager()->SetAuthenticatedUsername("user@gmail.com"); |
| 541 token_service()->UpdateCredentials("user@gmail.com", "refresh_token"); | 541 token_service()->UpdateCredentials("user@gmail.com", "refresh_token"); |
| 542 token_service()->UpdateCredentials("other@gmail.com", "refresh_token"); | 542 token_service()->UpdateCredentials("other@gmail.com", "refresh_token"); |
| 543 | 543 |
| 544 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("user@gmail.com")); | 544 EXPECT_CALL(*GetMockReconcilor(), PerformMergeAction("user@gmail.com")); |
| 545 | 545 |
| 546 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), | 546 SetFakeResponse(GaiaUrls::GetInstance()->list_accounts_url().spec(), |
| 547 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 0]," | 547 "[\"f\", [[\"b\", 0, \"n\", \"user@gmail.com\", \"p\", 0, 0, 0, 0, 0]," |
| 548 "[\"b\", 0, \"n\", \"other@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", | 548 "[\"b\", 0, \"n\", \"other@gmail.com\", \"p\", 0, 0, 0, 0, 1]]]", |
| 549 net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 549 net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 550 SetFakeResponse("https://www.googleapis.com/oauth2/v1/userinfo", | 550 SetFakeResponse(GaiaUrls::GetInstance()->people_get_url().spec(), |
| 551 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); | 551 "{\"id\":\"foo\"}", net::HTTP_OK, net::URLRequestStatus::SUCCESS); |
| 552 | 552 |
| 553 AccountReconcilor* reconcilor = | 553 AccountReconcilor* reconcilor = |
| 554 AccountReconcilorFactory::GetForProfile(profile()); | 554 AccountReconcilorFactory::GetForProfile(profile()); |
| 555 ASSERT_TRUE(reconcilor); | 555 ASSERT_TRUE(reconcilor); |
| 556 | 556 |
| 557 ASSERT_FALSE(reconcilor->is_reconcile_started_); | 557 ASSERT_FALSE(reconcilor->is_reconcile_started_); |
| 558 reconcilor->StartReconcile(); | 558 reconcilor->StartReconcile(); |
| 559 ASSERT_TRUE(reconcilor->is_reconcile_started_); | 559 ASSERT_TRUE(reconcilor->is_reconcile_started_); |
| 560 | 560 |
| 561 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", | 561 token_service()->IssueAllTokensForAccount("user@gmail.com", "access_token", |
| 562 base::Time::Now() + base::TimeDelta::FromHours(1)); | 562 base::Time::Now() + base::TimeDelta::FromHours(1)); |
| 563 token_service()->IssueAllTokensForAccount("other@gmail.com", "access_token", | 563 token_service()->IssueAllTokensForAccount("other@gmail.com", "access_token", |
| 564 base::Time::Now() + base::TimeDelta::FromHours(1)); | 564 base::Time::Now() + base::TimeDelta::FromHours(1)); |
| 565 | 565 |
| 566 base::RunLoop().RunUntilIdle(); | 566 base::RunLoop().RunUntilIdle(); |
| 567 SimulateMergeSessionCompleted(reconcilor, "user@gmail.com", | 567 SimulateMergeSessionCompleted(reconcilor, "user@gmail.com", |
| 568 GoogleServiceAuthError::AuthErrorNone()); | 568 GoogleServiceAuthError::AuthErrorNone()); |
| 569 ASSERT_FALSE(reconcilor->is_reconcile_started_); | 569 ASSERT_FALSE(reconcilor->is_reconcile_started_); |
| 570 } | 570 } |
| OLD | NEW |