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,10 +161,9 @@ class SigninReauthViewControllerBrowserTest : public InProcessBrowserTest {
https_server(), kChallengePath);
https_server()->StartAcceptingConnections();
account_id_ =
signin::SetPrimaryAccount(identity_manager(), "alice@gmail.com",
signin::ConsentLevel::kNotRequired)
.account_id;
account_id_ = signin::SetUnconsentedPrimaryAccount(identity_manager(),
"alice@gmail.com")
.account_id;
reauth_result_loop_ = std::make_unique<base::RunLoop>();
InProcessBrowserTest::SetUpOnMainThread();
......
......@@ -491,8 +491,7 @@ class IdentityManager : public KeyedService,
private:
// These test helpers need to use some of the private methods below.
friend CoreAccountInfo SetPrimaryAccount(IdentityManager* identity_manager,
const std::string& email,
ConsentLevel consent_level);
const std::string& email);
friend CoreAccountInfo SetUnconsentedPrimaryAccount(
IdentityManager* identity_manager,
const std::string& email);
......
......@@ -361,14 +361,12 @@ IdentityTestEnvironment::identity_manager_observer() {
CoreAccountInfo IdentityTestEnvironment::SetPrimaryAccount(
const std::string& email) {
return signin::SetPrimaryAccount(identity_manager(), email,
ConsentLevel::kSync);
return signin::SetPrimaryAccount(identity_manager(), email);
}
CoreAccountInfo IdentityTestEnvironment::SetUnconsentedPrimaryAccount(
const std::string& email) {
return signin::SetPrimaryAccount(identity_manager(), email,
ConsentLevel::kNotRequired);
return signin::SetUnconsentedPrimaryAccount(identity_manager(), email);
}
void IdentityTestEnvironment::SetRefreshTokenForPrimaryAccount() {
......
......@@ -17,7 +17,6 @@
#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/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 "google_apis/gaia/gaia_auth_util.h"
#include "google_apis/gaia/gaia_constants.h"
......@@ -114,35 +113,42 @@ AccountInfo EnsureAccountExists(AccountTrackerService* account_tracker_service,
} // namespace
CoreAccountInfo SetPrimaryAccount(IdentityManager* identity_manager,
const std::string& email,
ConsentLevel consent_level) {
// TODO(https://crbug.com/1046746): Change this to ConsentLevel::kNotRequired
// after fixing all callers.
DCHECK(!identity_manager->HasPrimaryAccount(consent_level));
const std::string& email) {
DCHECK(!identity_manager->HasPrimaryAccount());
PrimaryAccountManager* primary_account_manager =
identity_manager->GetPrimaryAccountManager();
DCHECK(!primary_account_manager->IsAuthenticated());
AccountInfo account_info =
EnsureAccountExists(identity_manager->GetAccountTrackerService(), email);
DCHECK(!account_info.gaia.empty());
PrimaryAccountMutator* primary_account_mutator =
identity_manager->GetPrimaryAccountMutator();
// TODO(https://crbug.com/1046746): Refactor PrimaryAccountMutator API and
// pass ConsentLevel directly there.
switch (consent_level) {
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;
}
primary_account_manager->SignIn(email);
DCHECK(primary_account_manager->IsAuthenticated());
DCHECK(identity_manager->HasPrimaryAccount());
return identity_manager->GetPrimaryAccountInfo();
}
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(consent_level));
DCHECK(identity_manager->HasPrimaryAccount(ConsentLevel::kNotRequired));
DCHECK_EQ(account_info.gaia,
identity_manager->GetPrimaryAccountInfo(consent_level).gaia);
return identity_manager->GetPrimaryAccountInfo(consent_level);
identity_manager
->GetPrimaryAccountInfo(signin::ConsentLevel::kNotRequired)
.gaia);
return identity_manager->GetPrimaryAccountInfo(
signin::ConsentLevel::kNotRequired);
}
void SetRefreshTokenForPrimaryAccount(IdentityManager* identity_manager,
......
......@@ -9,7 +9,6 @@
#include "build/build_config.h"
#include "components/signin/public/identity_manager/account_info.h"
#include "components/signin/public/identity_manager/consent_level.h"
namespace network {
class TestURLLoaderFactory;
......@@ -51,10 +50,13 @@ class IdentityManager;
// PrimaryAccountManager callbacks for signin success. Blocks until the primary
// account is set. Returns the CoreAccountInfo of the newly-set account.
// NOTE: See disclaimer at top of file re: direct usage.
CoreAccountInfo SetPrimaryAccount(
IdentityManager* identity_manager,
const std::string& email,
ConsentLevel consent_level = ConsentLevel::kSync);
CoreAccountInfo SetPrimaryAccount(IdentityManager* identity_manager,
const std::string& email);
// 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).
// 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