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

Side by Side Diff: chrome/browser/chromeos/login/signin/oauth2_browsertest.cc

Issue 2903123002: cros: Terminate if merge session fails for online sign-in (Closed)
Patch Set: add test Created 3 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <string> 5 #include <string>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 login_manager->ContinueSessionRestore(); 580 login_manager->ContinueSessionRestore();
581 581
582 // Let go DB thread to finish TokenService::LoadCredentials. 582 // Let go DB thread to finish TokenService::LoadCredentials.
583 db_blocker.reset(); 583 db_blocker.reset();
584 584
585 // Session restore can finish normally and token is loaded. 585 // Session restore can finish normally and token is loaded.
586 WaitForMergeSessionCompletion(OAuth2LoginManager::SESSION_RESTORE_DONE); 586 WaitForMergeSessionCompletion(OAuth2LoginManager::SESSION_RESTORE_DONE);
587 EXPECT_TRUE(token_service->RefreshTokenIsAvailable(account_id)); 587 EXPECT_TRUE(token_service->RefreshTokenIsAvailable(account_id));
588 } 588 }
589 589
590 IN_PROC_BROWSER_TEST_F(OAuth2Test, TerminateOnBadMergeSessionAfterOnlineAuth) {
achuithb 2017/05/25 19:44:17 Let's add a comment and a link to the bug
xiyuan 2017/05/25 20:24:10 Done.
591 SimulateNetworkOnline();
592 WaitForGaiaPageLoad();
593
594 content::WindowedNotificationObserver termination_waiter(
595 chrome::NOTIFICATION_APP_TERMINATING,
596 content::NotificationService::AllSources());
597
598 // Configure FakeGaia so that online auth succeeds but merge session fails.
599 FakeGaia::MergeSessionParams params;
600 params.auth_sid_cookie = kTestAuthSIDCookie;
601 params.auth_lsid_cookie = kTestAuthLSIDCookie;
602 params.auth_code = kTestAuthCode;
603 params.refresh_token = kTestRefreshToken;
604 params.access_token = kTestAuthLoginAccessToken;
605 fake_gaia_->SetMergeSessionParams(params);
606
607 // Simulate an online sign-in.
608 GetLoginDisplay()->ShowSigninScreenForCreds(kTestEmail, kTestAccountPassword);
609
610 // User session should be terminated.
611 termination_waiter.Wait();
612
613 // Merge session should fail. Check after |termination_waiter| to ensure
614 // user profile is initialized and there is an OAuth2LoginManage.
615 WaitForMergeSessionCompletion(OAuth2LoginManager::SESSION_RESTORE_FAILED);
616 }
617
590 const char kGooglePageContent[] = 618 const char kGooglePageContent[] =
591 "<html><title>Hello!</title><script>alert('hello');</script>" 619 "<html><title>Hello!</title><script>alert('hello');</script>"
592 "<body>Hello Google!</body></html>"; 620 "<body>Hello Google!</body></html>";
593 const char kRandomPageContent[] = 621 const char kRandomPageContent[] =
594 "<html><title>SomthingElse</title><body>I am SomethingElse</body></html>"; 622 "<html><title>SomthingElse</title><body>I am SomethingElse</body></html>";
595 const char kHelloPagePath[] = "/hello_google"; 623 const char kHelloPagePath[] = "/hello_google";
596 const char kRandomPagePath[] = "/non_google_page"; 624 const char kRandomPagePath[] = "/non_google_page";
597 625
598 626
599 // FakeGoogle serves content of http://www.google.com/hello_google page for 627 // FakeGoogle serves content of http://www.google.com/hello_google page for
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 919
892 if (!catcher.GetNextResult()) { 920 if (!catcher.GetNextResult()) {
893 std::string message = catcher.message(); 921 std::string message = catcher.message();
894 ADD_FAILURE() << "Tests failed: " << message; 922 ADD_FAILURE() << "Tests failed: " << message;
895 } 923 }
896 924
897 EXPECT_TRUE(fake_google_.IsPageRequested()); 925 EXPECT_TRUE(fake_google_.IsPageRequested());
898 } 926 }
899 927
900 } // namespace chromeos 928 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698