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

Unified Diff: chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc

Issue 964563002: Replace SetAuthenticatedUsername with SetAuthenticatedAccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@priv
Patch Set: Address review comments Created 5 years, 8 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
Index: chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc
diff --git a/chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc b/chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc
index 9bd390857d68ad98a1925e764dbeb9a7bf0c045f..381788832cf00eb8dffa18ceb0993bbec30776d9 100644
--- a/chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc
+++ b/chrome/browser/policy/cloud/user_policy_signin_service_unittest.cc
@@ -65,6 +65,7 @@ namespace policy {
namespace {
+const char kTestGaiaId[] = "gaia-id-testuser@test.com";
const char kTestUser[] = "testuser@test.com";
#if !defined(OS_ANDROID)
@@ -134,8 +135,10 @@ class UserPolicySigninServiceTest : public testing::Test {
// a valid login token, while on other platforms, the login refresh token
// is specified directly.
#if defined(OS_ANDROID)
- GetTokenService()->IssueRefreshTokenForUser(kTestUser,
- "oauth2_login_refresh_token");
+ GetTokenService()->IssueRefreshTokenForUser(
+ SigninManagerFactory::GetForProfile(profile_.get())
+ ->GetAuthenticatedAccountId(),
+ "oauth2_login_refresh_token");
#endif
service->RegisterForPolicy(
kTestUser,
@@ -390,7 +393,7 @@ class UserPolicySigninServiceSignedInTest : public UserPolicySigninServiceTest {
// Set the user as signed in.
SigninManagerFactory::GetForProfile(profile_.get())->
- SetAuthenticatedUsername(kTestUser);
+ SetAuthenticatedAccountInfo(kTestGaiaId, kTestUser);
// Let the SigninService know that the profile has been created.
content::NotificationService::current()->Notify(
@@ -425,8 +428,10 @@ TEST_F(UserPolicySigninServiceSignedInTest, InitWhileSignedIn) {
ASSERT_FALSE(IsRequestActive());
// Make oauth token available.
- GetTokenService()->IssueRefreshTokenForUser(kTestUser,
- "oauth_login_refresh_token");
+ GetTokenService()->IssueRefreshTokenForUser(
+ SigninManagerFactory::GetForProfile(profile_.get())
+ ->GetAuthenticatedAccountId(),
+ "oauth_login_refresh_token");
// Client registration should be in progress since we now have an oauth token.
EXPECT_EQ(mock_store_->signin_username_, kTestUser);
@@ -444,8 +449,10 @@ TEST_F(UserPolicySigninServiceSignedInTest, InitWhileSignedInOAuthError) {
ASSERT_FALSE(IsRequestActive());
// Make oauth token available.
- GetTokenService()->IssueRefreshTokenForUser(kTestUser,
- "oauth_login_refresh_token");
+ GetTokenService()->IssueRefreshTokenForUser(
+ SigninManagerFactory::GetForProfile(profile_.get())
+ ->GetAuthenticatedAccountId(),
+ "oauth_login_refresh_token");
// Client registration should be in progress since we now have an oauth token.
ASSERT_TRUE(IsRequestActive());
@@ -463,15 +470,17 @@ TEST_F(UserPolicySigninServiceTest, SignInAfterInit) {
ASSERT_FALSE(manager_->core()->service());
// Now sign in the user.
- SigninManagerFactory::GetForProfile(profile_.get())->SetAuthenticatedUsername(
- kTestUser);
+ SigninManagerFactory::GetForProfile(profile_.get())
+ ->SetAuthenticatedAccountInfo(kTestGaiaId, kTestUser);
// Complete initialization of the store.
mock_store_->NotifyStoreLoaded();
// Make oauth token available.
- GetTokenService()->IssueRefreshTokenForUser(kTestUser,
- "oauth_login_refresh_token");
+ GetTokenService()->IssueRefreshTokenForUser(
+ SigninManagerFactory::GetForProfile(profile_.get())
+ ->GetAuthenticatedAccountId(),
+ "oauth_login_refresh_token");
// UserCloudPolicyManager should be initialized.
EXPECT_EQ(mock_store_->signin_username_, kTestUser);
@@ -487,15 +496,18 @@ TEST_F(UserPolicySigninServiceTest, SignInWithNonEnterpriseUser) {
ASSERT_FALSE(manager_->core()->service());
// Now sign in a non-enterprise user (blacklisted gmail.com domain).
- SigninManagerFactory::GetForProfile(profile_.get())->SetAuthenticatedUsername(
- "non_enterprise_user@gmail.com");
+ SigninManagerFactory::GetForProfile(profile_.get())
+ ->SetAuthenticatedAccountInfo("gaia-id-non_enterprise_user@gmail.com",
+ "non_enterprise_user@gmail.com");
// Complete initialization of the store.
mock_store_->NotifyStoreLoaded();
// Make oauth token available.
- GetTokenService()->IssueRefreshTokenForUser(kTestUser,
- "oauth_login_refresh_token");
+ GetTokenService()->IssueRefreshTokenForUser(
+ SigninManagerFactory::GetForProfile(profile_.get())
+ ->GetAuthenticatedAccountId(),
+ "oauth_login_refresh_token");
// UserCloudPolicyManager should not be initialized and there should be no
// DMToken request active.
@@ -509,12 +521,14 @@ TEST_F(UserPolicySigninServiceTest, UnregisteredClient) {
ASSERT_FALSE(manager_->core()->service());
// Now sign in the user.
- SigninManagerFactory::GetForProfile(profile_.get())->SetAuthenticatedUsername(
- kTestUser);
+ SigninManagerFactory::GetForProfile(profile_.get())
+ ->SetAuthenticatedAccountInfo(kTestGaiaId, kTestUser);
// Make oauth token available.
- GetTokenService()->IssueRefreshTokenForUser(kTestUser,
- "oauth_login_refresh_token");
+ GetTokenService()->IssueRefreshTokenForUser(
+ SigninManagerFactory::GetForProfile(profile_.get())
+ ->GetAuthenticatedAccountId(),
+ "oauth_login_refresh_token");
// UserCloudPolicyManager should be initialized.
EXPECT_EQ(mock_store_->signin_username_, kTestUser);
@@ -537,12 +551,14 @@ TEST_F(UserPolicySigninServiceTest, RegisteredClient) {
ASSERT_FALSE(manager_->core()->service());
// Now sign in the user.
- SigninManagerFactory::GetForProfile(profile_.get())->SetAuthenticatedUsername(
- kTestUser);
+ SigninManagerFactory::GetForProfile(profile_.get())
+ ->SetAuthenticatedAccountInfo(kTestGaiaId, kTestUser);
// Make oauth token available.
- GetTokenService()->IssueRefreshTokenForUser(kTestUser,
- "oauth_login_refresh_token");
+ GetTokenService()->IssueRefreshTokenForUser(
+ SigninManagerFactory::GetForProfile(profile_.get())
+ ->GetAuthenticatedAccountId(),
+ "oauth_login_refresh_token");
// UserCloudPolicyManager should be initialized.
EXPECT_EQ(mock_store_->signin_username_, kTestUser);

Powered by Google App Engine
This is Rietveld 408576698