Commit de95b29a authored by Mihai Sardarescu's avatar Mihai Sardarescu Committed by Commit Bot

[dice] Enable Desktop Identity Consistency M2 for tests

This CL enables Dice M2 by default in Chromium that have API keys
configured as those are mandatory for DICE.

It also ensures that unit and browser tests have DICE M2 enabled,
even for builds when the API keys are not configured.

Bug: 829220
Change-Id: I752bf7e9e03da0ddd33841e42ec1c550fcaf91c7
Reviewed-on: https://chromium-review.googlesource.com/1044210
Commit-Queue: Mihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarJesse Doherty <jwd@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556057}
parent 7446a963
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "components/signin/core/browser/signin_pref_names.h" #include "components/signin/core/browser/signin_pref_names.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "google_apis/google_api_keys.h"
namespace { namespace {
...@@ -83,6 +84,8 @@ signin::AccountConsistencyMethod GetMethodForNonRegularProfile() { ...@@ -83,6 +84,8 @@ signin::AccountConsistencyMethod GetMethodForNonRegularProfile() {
} // namespace } // namespace
bool AccountConsistencyModeManager::ignore_missing_key_for_testing_ = false;
// static // static
AccountConsistencyModeManager* AccountConsistencyModeManager::GetForProfile( AccountConsistencyModeManager* AccountConsistencyModeManager::GetForProfile(
Profile* profile) { Profile* profile) {
...@@ -179,6 +182,11 @@ bool AccountConsistencyModeManager::IsMirrorEnabledForProfile( ...@@ -179,6 +182,11 @@ bool AccountConsistencyModeManager::IsMirrorEnabledForProfile(
signin::AccountConsistencyMethod::kMirror; signin::AccountConsistencyMethod::kMirror;
} }
// static
void AccountConsistencyModeManager::SetIgnoreMissingApiKeysForTesting() {
ignore_missing_key_for_testing_ = true;
}
signin::AccountConsistencyMethod signin::AccountConsistencyMethod
AccountConsistencyModeManager::GetAccountConsistencyMethod() { AccountConsistencyModeManager::GetAccountConsistencyMethod() {
if (profile_->GetProfileType() != Profile::ProfileType::REGULAR_PROFILE) { if (profile_->GetProfileType() != Profile::ProfileType::REGULAR_PROFILE) {
...@@ -200,13 +208,26 @@ AccountConsistencyModeManager::GetAccountConsistencyMethod() { ...@@ -200,13 +208,26 @@ AccountConsistencyModeManager::GetAccountConsistencyMethod() {
signin::AccountConsistencyMethod method = signin::AccountConsistencyMethod method =
signin::GetAccountConsistencyMethod(); signin::GetAccountConsistencyMethod();
if (method == signin::AccountConsistencyMethod::kMirror ||
signin::DiceMethodGreaterOrEqual(
signin::AccountConsistencyMethod::kDiceFixAuthErrors, method)) {
return method;
}
DCHECK(signin::DiceMethodGreaterOrEqual(
method, signin::AccountConsistencyMethod::kDicePrepareMigration));
// Legacy supervised users cannot get Dice. // Legacy supervised users cannot get Dice.
// TODO(droger): remove this once legacy supervised users are no longer // TODO(droger): remove this once legacy supervised users are no longer
// supported. // supported.
if (profile_->IsLegacySupervised() && if (profile_->IsLegacySupervised())
(method != signin::AccountConsistencyMethod::kMirror) && return signin::AccountConsistencyMethod::kDiceFixAuthErrors;
signin::DiceMethodGreaterOrEqual(
method, signin::AccountConsistencyMethod::kDiceFixAuthErrors)) { bool can_enable_dice_for_build =
ignore_missing_key_for_testing_ || google_apis::HasKeysConfigured();
if (!can_enable_dice_for_build) {
LOG(WARNING) << "Desktop Identity Consistency cannot be enabled as no "
"API keys have been configured.";
return signin::AccountConsistencyMethod::kDiceFixAuthErrors; return signin::AccountConsistencyMethod::kDiceFixAuthErrors;
} }
......
...@@ -58,6 +58,10 @@ class AccountConsistencyModeManager : public KeyedService { ...@@ -58,6 +58,10 @@ class AccountConsistencyModeManager : public KeyedService {
// behaviour enabled. // behaviour enabled.
static bool IsMirrorEnabledForProfile(Profile* profile); static bool IsMirrorEnabledForProfile(Profile* profile);
// By default, Deskotp Identity Consistency (aka Dice) is not enabled in
// builds lacking an API key. For testing, set to have Dice enabled in tests.
static void SetIgnoreMissingApiKeysForTesting();
private: private:
FRIEND_TEST_ALL_PREFIXES(AccountConsistencyModeManagerTest, FRIEND_TEST_ALL_PREFIXES(AccountConsistencyModeManagerTest,
MigrateAtCreation); MigrateAtCreation);
...@@ -76,6 +80,10 @@ class AccountConsistencyModeManager : public KeyedService { ...@@ -76,6 +80,10 @@ class AccountConsistencyModeManager : public KeyedService {
Profile* profile_; Profile* profile_;
// By default, DICE is not enabled in builds lacking an API key. Set to true
// for tests.
static bool ignore_missing_key_for_testing_;
DISALLOW_COPY_AND_ASSIGN(AccountConsistencyModeManager); DISALLOW_COPY_AND_ASSIGN(AccountConsistencyModeManager);
}; };
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/app/chrome_main_delegate.h" #include "chrome/app/chrome_main_delegate.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/signin/account_consistency_mode_manager.h"
#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
...@@ -86,6 +87,12 @@ void ChromeTestSuite::Initialize() { ...@@ -86,6 +87,12 @@ void ChromeTestSuite::Initialize() {
ChromeMainDelegate::kNonWildcardDomainNonPortSchemes, ChromeMainDelegate::kNonWildcardDomainNonPortSchemes,
ChromeMainDelegate::kNonWildcardDomainNonPortSchemesSize); ChromeMainDelegate::kNonWildcardDomainNonPortSchemesSize);
// Desktop Identity Consistency (a.k.a. DICE) requires API keys to be
// configured as they are needed for regular web sign-in flows to Google.
// Ignore this requiement for unit and browser tests to make sure that the
// DICE feature gets the right test coverage.
AccountConsistencyModeManager::SetIgnoreMissingApiKeysForTesting();
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
// Look in the framework bundle for resources. // Look in the framework bundle for resources.
base::FilePath path; base::FilePath path;
......
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
], ],
"experiments": [ "experiments": [
{ {
"name": "DiceFixAuthErrors", "name": "DicePrepareMigration",
"params": { "params": {
"method": "dice_fix_auth_errors" "method": "dice_prepare_migration_new_endpoint"
}, },
"enable_features": [ "enable_features": [
"AccountConsistency" "AccountConsistency"
......
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