Commit 1cb50193 authored by David Bienvenu's avatar David Bienvenu Committed by Commit Bot

Revert "[Signin] Add ConsentLevel to SetPrimaryAccount in test utils"

This reverts commit 90fcdb0a.

Reason for revert: <test failures, e.g.,components_unittests failing on builder "Cast Audio Linux>

Original change's description:
> [Signin] Add ConsentLevel to SetPrimaryAccount in test utils
> 
> First part of adding ConsentLevel support to identity_test_utils.
> This CL merges two separate methods SetPrimaryAccount and
> SetUnconsentedPrimaryAccount into a single one that takes ConsentLevel
> as a parameter.
> 
> Bug: 1046746
> Change-Id: I93f7811414b7c1ee583237681c567a881560ce23
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2401140
> Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
> Reviewed-by: David Roger <droger@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#807046}

TBR=droger@chromium.org,bsazonov@chromium.org

Change-Id: If33b0579b09c4bccb5bb144f6299a4821d377269
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1046746
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2412615Reviewed-by: default avatarDavid Bienvenu <davidbienvenu@google.com>
Commit-Queue: David Bienvenu <davidbienvenu@google.com>
Cr-Commit-Position: refs/heads/master@{#807101}
parent 16089216
...@@ -161,9 +161,8 @@ class SigninReauthViewControllerBrowserTest : public InProcessBrowserTest { ...@@ -161,9 +161,8 @@ class SigninReauthViewControllerBrowserTest : public InProcessBrowserTest {
https_server(), kChallengePath); https_server(), kChallengePath);
https_server()->StartAcceptingConnections(); https_server()->StartAcceptingConnections();
account_id_ = account_id_ = signin::SetUnconsentedPrimaryAccount(identity_manager(),
signin::SetPrimaryAccount(identity_manager(), "alice@gmail.com", "alice@gmail.com")
signin::ConsentLevel::kNotRequired)
.account_id; .account_id;
reauth_result_loop_ = std::make_unique<base::RunLoop>(); reauth_result_loop_ = std::make_unique<base::RunLoop>();
......
...@@ -491,8 +491,7 @@ class IdentityManager : public KeyedService, ...@@ -491,8 +491,7 @@ class IdentityManager : public KeyedService,
private: private:
// These test helpers need to use some of the private methods below. // These test helpers need to use some of the private methods below.
friend CoreAccountInfo SetPrimaryAccount(IdentityManager* identity_manager, friend CoreAccountInfo SetPrimaryAccount(IdentityManager* identity_manager,
const std::string& email, const std::string& email);
ConsentLevel consent_level);
friend CoreAccountInfo SetUnconsentedPrimaryAccount( friend CoreAccountInfo SetUnconsentedPrimaryAccount(
IdentityManager* identity_manager, IdentityManager* identity_manager,
const std::string& email); const std::string& email);
......
...@@ -361,14 +361,12 @@ IdentityTestEnvironment::identity_manager_observer() { ...@@ -361,14 +361,12 @@ IdentityTestEnvironment::identity_manager_observer() {
CoreAccountInfo IdentityTestEnvironment::SetPrimaryAccount( CoreAccountInfo IdentityTestEnvironment::SetPrimaryAccount(
const std::string& email) { const std::string& email) {
return signin::SetPrimaryAccount(identity_manager(), email, return signin::SetPrimaryAccount(identity_manager(), email);
ConsentLevel::kSync);
} }
CoreAccountInfo IdentityTestEnvironment::SetUnconsentedPrimaryAccount( CoreAccountInfo IdentityTestEnvironment::SetUnconsentedPrimaryAccount(
const std::string& email) { const std::string& email) {
return signin::SetPrimaryAccount(identity_manager(), email, return signin::SetUnconsentedPrimaryAccount(identity_manager(), email);
ConsentLevel::kNotRequired);
} }
void IdentityTestEnvironment::SetRefreshTokenForPrimaryAccount() { void IdentityTestEnvironment::SetRefreshTokenForPrimaryAccount() {
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "components/signin/public/base/list_accounts_test_utils.h" #include "components/signin/public/base/list_accounts_test_utils.h"
#include "components/signin/public/identity_manager/consent_level.h" #include "components/signin/public/identity_manager/consent_level.h"
#include "components/signin/public/identity_manager/identity_manager.h" #include "components/signin/public/identity_manager/identity_manager.h"
#include "components/signin/public/identity_manager/primary_account_mutator.h"
#include "components/signin/public/identity_manager/test_identity_manager_observer.h" #include "components/signin/public/identity_manager/test_identity_manager_observer.h"
#include "google_apis/gaia/gaia_auth_util.h" #include "google_apis/gaia/gaia_auth_util.h"
#include "google_apis/gaia/gaia_constants.h" #include "google_apis/gaia/gaia_constants.h"
...@@ -114,35 +113,42 @@ AccountInfo EnsureAccountExists(AccountTrackerService* account_tracker_service, ...@@ -114,35 +113,42 @@ AccountInfo EnsureAccountExists(AccountTrackerService* account_tracker_service,
} // namespace } // namespace
CoreAccountInfo SetPrimaryAccount(IdentityManager* identity_manager, CoreAccountInfo SetPrimaryAccount(IdentityManager* identity_manager,
const std::string& email, const std::string& email) {
ConsentLevel consent_level) { DCHECK(!identity_manager->HasPrimaryAccount());
// TODO(https://crbug.com/1046746): Change this to ConsentLevel::kNotRequired PrimaryAccountManager* primary_account_manager =
// after fixing all callers. identity_manager->GetPrimaryAccountManager();
DCHECK(!identity_manager->HasPrimaryAccount(consent_level)); DCHECK(!primary_account_manager->IsAuthenticated());
AccountInfo account_info = AccountInfo account_info =
EnsureAccountExists(identity_manager->GetAccountTrackerService(), email); EnsureAccountExists(identity_manager->GetAccountTrackerService(), email);
DCHECK(!account_info.gaia.empty()); DCHECK(!account_info.gaia.empty());
PrimaryAccountMutator* primary_account_mutator = primary_account_manager->SignIn(email);
identity_manager->GetPrimaryAccountMutator();
// TODO(https://crbug.com/1046746): Refactor PrimaryAccountMutator API and DCHECK(primary_account_manager->IsAuthenticated());
// pass ConsentLevel directly there. DCHECK(identity_manager->HasPrimaryAccount());
switch (consent_level) { return identity_manager->GetPrimaryAccountInfo();
case ConsentLevel::kSync: }
DCHECK(
primary_account_mutator->SetPrimaryAccount(account_info.account_id));
break;
case ConsentLevel::kNotRequired:
primary_account_mutator->SetUnconsentedPrimaryAccount(
account_info.account_id);
break;
}
DCHECK(identity_manager->HasPrimaryAccount(consent_level)); CoreAccountInfo SetUnconsentedPrimaryAccount(IdentityManager* identity_manager,
const std::string& email) {
DCHECK(!identity_manager->HasPrimaryAccount(ConsentLevel::kNotRequired));
AccountInfo account_info =
EnsureAccountExists(identity_manager->GetAccountTrackerService(), email);
DCHECK(!account_info.gaia.empty());
PrimaryAccountManager* primary_account_manager =
identity_manager->GetPrimaryAccountManager();
primary_account_manager->SetUnconsentedPrimaryAccountInfo(account_info);
DCHECK(identity_manager->HasPrimaryAccount(ConsentLevel::kNotRequired));
DCHECK_EQ(account_info.gaia, DCHECK_EQ(account_info.gaia,
identity_manager->GetPrimaryAccountInfo(consent_level).gaia); identity_manager
return identity_manager->GetPrimaryAccountInfo(consent_level); ->GetPrimaryAccountInfo(signin::ConsentLevel::kNotRequired)
.gaia);
return identity_manager->GetPrimaryAccountInfo(
signin::ConsentLevel::kNotRequired);
} }
void SetRefreshTokenForPrimaryAccount(IdentityManager* identity_manager, void SetRefreshTokenForPrimaryAccount(IdentityManager* identity_manager,
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "components/signin/public/identity_manager/account_info.h" #include "components/signin/public/identity_manager/account_info.h"
#include "components/signin/public/identity_manager/consent_level.h"
namespace network { namespace network {
class TestURLLoaderFactory; class TestURLLoaderFactory;
...@@ -51,10 +50,13 @@ class IdentityManager; ...@@ -51,10 +50,13 @@ class IdentityManager;
// PrimaryAccountManager callbacks for signin success. Blocks until the primary // PrimaryAccountManager callbacks for signin success. Blocks until the primary
// account is set. Returns the CoreAccountInfo of the newly-set account. // account is set. Returns the CoreAccountInfo of the newly-set account.
// NOTE: See disclaimer at top of file re: direct usage. // NOTE: See disclaimer at top of file re: direct usage.
CoreAccountInfo SetPrimaryAccount( CoreAccountInfo SetPrimaryAccount(IdentityManager* identity_manager,
IdentityManager* identity_manager, const std::string& email);
const std::string& email,
ConsentLevel consent_level = ConsentLevel::kSync); // As above, but adds an "unconsented" primary account. See ./README.md for
// the distinction between primary and unconsented primary accounts.
CoreAccountInfo SetUnconsentedPrimaryAccount(IdentityManager* identity_manager,
const std::string& email);
// Sets a refresh token for the primary account (which must already be set). // Sets a refresh token for the primary account (which must already be set).
// Blocks until the refresh token is set. If |token_value| is empty a default // Blocks until the refresh token is set. If |token_value| is empty a default
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment