Commit 2bc76571 authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

GOOGLE_CHROME_BUILD -> GOOGLE_CHROME_BRANDING for mdm_utils.h/cc

The MDM service is disabled in Chromium branded builds, but it can be
enabled in tests via the GoogleMdmEscrowServiceEnablerForTesting class.

The class used to be available only in GOOGLE_CHROME_BUILD builds.
To not use GOOGLE_CHROME_BUILD in a .h file, make the class available
always and make it a no-op in GOOGLE_CHROME builds.

That simplifies a few tests, removes a dependency on the GOOGLE_CHROME_BRANDING
buildflag header target, and makes it easy to remove GOOGLE_CHROME_BUILD
from mdm_utils.h/cc

While here, also remove the unused parameter for
GoogleMdmEscrowServiceEnablerForTesting's constructor.

Bug: 961769
Change-Id: I1dfdbdf056634d1e47272f397c11919193bf7fc3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1894295
Commit-Queue: Nico Weber <thakis@chromium.org>
Auto-Submit: Nico Weber <thakis@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#711471}
parent 92364484
......@@ -9,7 +9,6 @@
#include "base/synchronization/waitable_event.h"
#include "base/test/test_reg_util_win.h"
#include "base/time/time_override.h"
#include "build/branding_buildflags.h"
#include "chrome/credential_provider/common/gcp_strings.h"
#include "chrome/credential_provider/gaiacp/associated_user_validator.h"
#include "chrome/credential_provider/gaiacp/gaia_credential_provider.h"
......@@ -378,9 +377,7 @@ TEST_P(AssociatedUserValidatorUserAccessBlockingTest, BlockUserAccessAsNeeded) {
const bool contains_stored_password = std::get<6>(GetParam());
GoogleMdmEnrolledStatusForTesting forced_status(mdm_enrolled);
#if !BUILDFLAG(GOOGLE_CHROME_BRANDING)
GoogleMdmEscrowServiceEnablerForTesting escrow_service_enabler(true);
#endif
GoogleMdmEscrowServiceEnablerForTesting escrow_service_enabler;
FakeAssociatedUserValidator validator;
fake_internet_checker()->SetHasInternetConnection(
......@@ -514,9 +511,7 @@ TEST_F(AssociatedUserValidatorTest, ValidTokenHandle_Refresh) {
}
TEST_F(AssociatedUserValidatorTest, InvalidTokenHandle_MissingPasswordLsaData) {
#if !BUILDFLAG(GOOGLE_CHROME_BRANDING)
GoogleMdmEscrowServiceEnablerForTesting escrow_service_enabler(true);
#endif
GoogleMdmEscrowServiceEnablerForTesting escrow_service_enabler;
FakeAssociatedUserValidator validator;
CComBSTR sid;
......@@ -545,9 +540,7 @@ TEST_F(AssociatedUserValidatorTest, InvalidTokenHandle_MissingPasswordLsaData) {
}
TEST_F(AssociatedUserValidatorTest, ValidTokenHandle_PresentPasswordLsaData) {
#if !BUILDFLAG(GOOGLE_CHROME_BRANDING)
GoogleMdmEscrowServiceEnablerForTesting escrow_service_enabler(true);
#endif
GoogleMdmEscrowServiceEnablerForTesting escrow_service_enabler;
FakeAssociatedUserValidator validator;
CComBSTR sid;
......
......@@ -8,7 +8,6 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "build/branding_buildflags.h"
#include "chrome/credential_provider/common/gcp_strings.h"
#include "chrome/credential_provider/gaiacp/gaia_credential_base.h"
#include "chrome/credential_provider/gaiacp/gaia_resources.h"
......@@ -1356,9 +1355,7 @@ class GcpGaiaCredentialBasePasswordRecoveryTest
TEST_P(GcpGaiaCredentialBasePasswordRecoveryTest, PasswordRecovery) {
// Enable standard escrow service features in non-Chrome builds so that
// the escrow service code can be tested by the build machines.
#if !BUILDFLAG(GOOGLE_CHROME_BRANDING)
GoogleMdmEscrowServiceEnablerForTesting escrow_service_enabler(true);
#endif
GoogleMdmEscrowServiceEnablerForTesting escrow_service_enabler;
USES_CONVERSION;
int generate_public_key_result = std::get<0>(GetParam());
......@@ -1592,9 +1589,7 @@ TEST_P(GcpGaiaCredentialBasePasswordRecoveryDisablingTest,
PasswordRecovery_Disabled) {
// Enable standard escrow service features in non-Chrome builds so that
// the escrow service code can be tested by the build machines.
#if !BUILDFLAG(GOOGLE_CHROME_BRANDING)
GoogleMdmEscrowServiceEnablerForTesting escrow_service_enabler(true);
#endif
GoogleMdmEscrowServiceEnablerForTesting escrow_service_enabler;
USES_CONVERSION;
const wchar_t* escrow_service_url = GetParam();
......
......@@ -22,6 +22,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/win/win_util.h"
#include "base/win/wmi.h"
#include "build/branding_buildflags.h"
#include "chrome/credential_provider/common/gcp_strings.h"
#include "chrome/credential_provider/gaiacp/gcp_utils.h"
#include "chrome/credential_provider/gaiacp/logging.h"
......@@ -36,7 +37,7 @@ constexpr wchar_t kRegMdmEscrowServiceServerUrl[] = L"mdm_ess_url";
constexpr wchar_t kRegMdmSupportsMultiUser[] = L"mdm_mu";
constexpr wchar_t kRegMdmAllowConsumerAccounts[] = L"mdm_aca";
constexpr wchar_t kUserPasswordLsaStoreKeyPrefix[] =
#if defined(GOOGLE_CHROME_BUILD)
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
L"Chrome-GCPW-";
#else
L"Chromium-GCPW-";
......@@ -63,7 +64,7 @@ EnrolledStatus g_enrolled_status = EnrolledStatus::kDontForce;
bool g_use_test_serial_number = false;
base::string16 g_test_serial_number = L"";
#if !defined(GOOGLE_CHROME_BUILD)
#if !BUILDFLAG(GOOGLE_CHROME_BRANDING)
enum class EscrowServiceStatus {
kDisabled,
kEnabled,
......@@ -362,7 +363,7 @@ GURL MdmEscrowServiceUrl() {
}
bool MdmPasswordRecoveryEnabled() {
#if !defined(GOOGLE_CHROME_BUILD)
#if !BUILDFLAG(GOOGLE_CHROME_BRANDING)
if (g_escrow_service_enabled == EscrowServiceStatus::kDisabled)
return false;
#endif
......@@ -445,17 +446,18 @@ GoogleSerialNumberForTesting::~GoogleSerialNumberForTesting() {
// GoogleSerialNumberForTesting //////////////////////////////////////////
#if !defined(GOOGLE_CHROME_BUILD)
GoogleMdmEscrowServiceEnablerForTesting::
GoogleMdmEscrowServiceEnablerForTesting(bool enable) {
g_escrow_service_enabled =
enable ? EscrowServiceStatus::kEnabled : EscrowServiceStatus::kDisabled;
GoogleMdmEscrowServiceEnablerForTesting() {
#if !BUILDFLAG(GOOGLE_CHROME_BRANDING)
g_escrow_service_enabled = EscrowServiceStatus::kEnabled;
#endif
}
GoogleMdmEscrowServiceEnablerForTesting::
~GoogleMdmEscrowServiceEnablerForTesting() {
#if !BUILDFLAG(GOOGLE_CHROME_BRANDING)
g_escrow_service_enabled = EscrowServiceStatus::kDisabled;
}
#endif
}
} // namespace credential_provider
......@@ -58,15 +58,13 @@ class GoogleSerialNumberForTesting {
~GoogleSerialNumberForTesting();
};
#if !defined(GOOGLE_CHROME_BUILD)
// Class used in tests to force password escrow service availability when not
// in a Google Chrome build.
// in a Google Chrome build (where the service is disabled).
class GoogleMdmEscrowServiceEnablerForTesting {
public:
explicit GoogleMdmEscrowServiceEnablerForTesting(bool enable);
GoogleMdmEscrowServiceEnablerForTesting();
~GoogleMdmEscrowServiceEnablerForTesting();
};
#endif
// If MdmEnrollmentEnabled returns true, this function verifies that the machine
// is enrolled to MDM AND that the server to which it is enrolled is the same
......
......@@ -9,7 +9,6 @@
#include "base/json/json_writer.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/test_reg_util_win.h"
#include "build/branding_buildflags.h"
#include "chrome/browser/ui/startup/credential_provider_signin_dialog_win_test_data.h"
#include "chrome/credential_provider/common/gcp_strings.h"
#include "chrome/credential_provider/gaiacp/gaia_credential_provider_i.h"
......@@ -181,9 +180,7 @@ TEST_P(GcpReauthCredentialEnforceAuthReasonGetStringValueTest, FidDescription) {
USES_CONVERSION;
// Enable standard escrow service features in non-Chrome builds so that
// the escrow service code can be tested by the build machines.
#if !BUILDFLAG(GOOGLE_CHROME_BRANDING)
GoogleMdmEscrowServiceEnablerForTesting escrow_service_enabler(true);
#endif
GoogleMdmEscrowServiceEnablerForTesting escrow_service_enabler;
CredentialProviderSigninDialogTestDataStorage test_data_storage;
......
......@@ -32,7 +32,6 @@ test("gcp_unittests") {
"../gaiacp:version",
"../setup:common",
"//base",
"//build:branding_buildflags",
"//chrome/test:credential_provider_test_utils",
"//net:test_support",
"//testing/gmock",
......
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