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