Make FakeUserDataAuthClient create profile directory in browser tests
Some browser tests save user in local state in a PRE test before running
the actual test, with the assumption that the user will be recognized as
a returning user during the actual test. This assumption breaks with
AuthSession enabled + FakeUserDataAuthClient as
AuthSessionAuthenticator::OnAuthSessionCreatedGeneric gets notified
that the user doesn't exist and is new.
This CL makes FakeUserDataAuthClient create a profile directory under
the user data directory in the PRE test so that we'll be able to
recognize the user during the actual test.
It also parametrizes the tests that were fixed as a function of auth
session feature state.
Bug: 1274116
Change-Id: I2d1723c0367b3dbe71ae78cbcda4a6b782504a90
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3537129
Reviewed-by: Pavol Marko <pmarko@chromium.org>
Reviewed-by: Denis Kuznetsov <antrim@chromium.org>
Reviewed-by: Polina Bondarenko <pbond@chromium.org>
Reviewed-by: Yves Arrouye <drcrash@chromium.org>
Reviewed-by: Ben Wells <benwells@chromium.org>
Commit-Queue: Elie Maamari <emaamari@google.com>
Cr-Commit-Position: refs/heads/main@{#989379}
diff --git a/chrome/browser/ash/arc/enterprise/cert_store/cert_store_service_browsertest.cc b/chrome/browser/ash/arc/enterprise/cert_store/cert_store_service_browsertest.cc
index f48c75bf..08c1054 100644
--- a/chrome/browser/ash/arc/enterprise/cert_store/cert_store_service_browsertest.cc
+++ b/chrome/browser/ash/arc/enterprise/cert_store/cert_store_service_browsertest.cc
@@ -10,6 +10,7 @@
#include "ash/components/arc/arc_prefs.h"
#include "ash/components/arc/session/arc_bridge_service.h"
#include "ash/components/arc/test/arc_util_test_support.h"
+#include "ash/constants/ash_features.h"
#include "ash/constants/ash_switches.h"
#include "base/base64.h"
#include "base/bind.h"
@@ -19,6 +20,7 @@
#include "chrome/browser/ash/arc/enterprise/cert_store/cert_store_service.h"
#include "chrome/browser/ash/arc/keymaster/arc_keymaster_bridge.h"
#include "chrome/browser/ash/arc/session/arc_service_launcher.h"
+#include "chrome/browser/ash/login/test/cryptohome_mixin.h"
#include "chrome/browser/ash/platform_keys/key_permissions/key_permissions_service_factory.h"
#include "chrome/browser/ash/platform_keys/platform_keys_service_factory.h"
#include "chrome/browser/ash/policy/affiliation/affiliation_mixin.h"
@@ -295,11 +297,11 @@
} // namespace
-class CertStoreServiceTest
- : public MixinBasedInProcessBrowserTest,
- public ::testing::WithParamInterface<std::vector<TestCertData>> {
+class CertStoreServiceTest : public MixinBasedInProcessBrowserTest,
+ public ::testing::WithParamInterface<
+ std::tuple<std::vector<TestCertData>, bool>> {
public:
- CertStoreServiceTest() = default;
+ CertStoreServiceTest();
CertStoreServiceTest(const CertStoreServiceTest& other) = delete;
CertStoreServiceTest& operator=(const CertStoreServiceTest&) = delete;
@@ -343,6 +345,7 @@
policy::DevicePolicyCrosTestHelper device_policy_helper_;
policy::AffiliationMixin affiliation_mixin_{&mixin_host_,
&device_policy_helper_};
+ std::vector<TestCertData> test_cert_data_vector_;
private:
// Creates ScopedCERTCertificates for each |certs_to_setup| and appends them
@@ -373,8 +376,29 @@
// Owned by the CertStoreService instance.
FakeArcKeymasterBridge* keymaster_bridge_;
+
+ base::test::ScopedFeatureList feature_list_;
+
+ ash::CryptohomeMixin cryptohome_mixin_{&mixin_host_};
};
+CertStoreServiceTest::CertStoreServiceTest()
+ : test_cert_data_vector_(std::get<0>(GetParam())) {
+ cryptohome_mixin_.MarkUserAsExisting(affiliation_mixin_.account_id());
+
+ // TODO(crbug.com/1311355): This test is run with the feature
+ // kUseAuthsessionAuthentication enabled and disabled because of a
+ // transitive dependency of AffiliationTestHelper on that feature. Remove
+ // the parameter when kUseAuthsessionAuthentication is removed.
+ if (std::get<1>(GetParam())) {
+ feature_list_.InitAndEnableFeature(
+ ash::features::kUseAuthsessionAuthentication);
+ } else {
+ feature_list_.InitAndDisableFeature(
+ ash::features::kUseAuthsessionAuthentication);
+ }
+}
+
void CertStoreServiceTest::SetUpCommandLine(base::CommandLine* command_line) {
MixinBasedInProcessBrowserTest::SetUpCommandLine(command_line);
arc::SetArcAvailableCommandLineForTesting(command_line);
@@ -614,10 +638,10 @@
ASSERT_TRUE(service);
// Install all certs from parameter at once.
- ASSERT_NO_FATAL_FAILURE(SetUpCerts(GetParam()));
+ ASSERT_NO_FATAL_FAILURE(SetUpCerts(test_cert_data_vector_));
// Verify all certs are installed correctly.
- ASSERT_NO_FATAL_FAILURE(CheckInstalledCerts(GetParam(), service));
+ ASSERT_NO_FATAL_FAILURE(CheckInstalledCerts(test_cert_data_vector_, service));
}
IN_PROC_BROWSER_TEST_P(CertStoreServiceTest,
@@ -631,23 +655,24 @@
ASSERT_TRUE(service);
// Install certs from parameter one by one.
- for (size_t i = 0; i < GetParam().size(); ++i) {
- ASSERT_NO_FATAL_FAILURE(SetUpCerts({GetParam()[i]}));
+ for (size_t i = 0; i < test_cert_data_vector_.size(); ++i) {
+ ASSERT_NO_FATAL_FAILURE(SetUpCerts({test_cert_data_vector_[i]}));
// Verify only the first (i+1) certs are installed so far.
- ASSERT_NO_FATAL_FAILURE(
- CheckInstalledCerts(std::vector<TestCertData>(
- GetParam().begin(), GetParam().begin() + i + 1),
- service));
+ ASSERT_NO_FATAL_FAILURE(CheckInstalledCerts(
+ std::vector<TestCertData>(test_cert_data_vector_.begin(),
+ test_cert_data_vector_.begin() + i + 1),
+ service));
}
// Uninstall certs from parameter one by one, from last to first.
- for (size_t i = GetParam().size(); i--;) {
+ for (size_t i = test_cert_data_vector_.size(); i--;) {
DeleteCert(installed_certs_.back().nss_cert.get());
// Verify only the first i certs are left after the uninstall.
ASSERT_NO_FATAL_FAILURE(CheckInstalledCerts(
- std::vector<TestCertData>(GetParam().begin(), GetParam().begin() + i),
+ std::vector<TestCertData>(test_cert_data_vector_.begin(),
+ test_cert_data_vector_.begin() + i),
service));
}
}
@@ -655,44 +680,46 @@
INSTANTIATE_TEST_SUITE_P(
CertStoreTests,
CertStoreServiceTest,
- ::testing::Values(
- // No corporate usage keys.
- std::vector<TestCertData>{
- TestCertData(kFileName1,
- false /* is_corporate_usage */,
- keymaster::mojom::ChapsSlot::kUser),
- TestCertData(kFileName2,
- false /* is_corporate_usage */,
- keymaster::mojom::ChapsSlot::kUser)},
- // Corporate usage keys in user slot.
- std::vector<TestCertData>{
- TestCertData(kFileName1,
- true /* is_corporate_usage */,
- keymaster::mojom::ChapsSlot::kUser),
- TestCertData(kFileName2,
- true /* is_corporate_usage */,
- keymaster::mojom::ChapsSlot::kUser)},
- // Corporate usage keys in system slot.
- std::vector<TestCertData>{
- TestCertData(kFileName1,
- true /* is_corporate_usage */,
- keymaster::mojom::ChapsSlot::kSystem),
- TestCertData(kFileName2,
- true /* is_corporate_usage */,
- keymaster::mojom::ChapsSlot::kSystem)},
- // Corporate usage keys in both slots.
- std::vector<TestCertData>{
- TestCertData(kFileName1,
- true /* is_corporate_usage */,
- keymaster::mojom::ChapsSlot::kUser),
- TestCertData(kFileName2,
- true /* is_corporate_usage */,
- keymaster::mojom::ChapsSlot::kSystem),
- TestCertData(kFileName3,
- false /* is_corporate_usage */,
- keymaster::mojom::ChapsSlot::kUser),
- TestCertData(kFileName4,
- true /* is_corporate_usage */,
- keymaster::mojom::ChapsSlot::kSystem)}));
+ ::testing::Combine(
+ ::testing::Values(
+ // No corporate usage keys.
+ std::vector<TestCertData>{
+ TestCertData(kFileName1,
+ false /* is_corporate_usage */,
+ keymaster::mojom::ChapsSlot::kUser),
+ TestCertData(kFileName2,
+ false /* is_corporate_usage */,
+ keymaster::mojom::ChapsSlot::kUser)},
+ // Corporate usage keys in user slot.
+ std::vector<TestCertData>{
+ TestCertData(kFileName1,
+ true /* is_corporate_usage */,
+ keymaster::mojom::ChapsSlot::kUser),
+ TestCertData(kFileName2,
+ true /* is_corporate_usage */,
+ keymaster::mojom::ChapsSlot::kUser)},
+ // Corporate usage keys in system slot.
+ std::vector<TestCertData>{
+ TestCertData(kFileName1,
+ true /* is_corporate_usage */,
+ keymaster::mojom::ChapsSlot::kSystem),
+ TestCertData(kFileName2,
+ true /* is_corporate_usage */,
+ keymaster::mojom::ChapsSlot::kSystem)},
+ // Corporate usage keys in both slots.
+ std::vector<TestCertData>{
+ TestCertData(kFileName1,
+ true /* is_corporate_usage */,
+ keymaster::mojom::ChapsSlot::kUser),
+ TestCertData(kFileName2,
+ true /* is_corporate_usage */,
+ keymaster::mojom::ChapsSlot::kSystem),
+ TestCertData(kFileName3,
+ false /* is_corporate_usage */,
+ keymaster::mojom::ChapsSlot::kUser),
+ TestCertData(kFileName4,
+ true /* is_corporate_usage */,
+ keymaster::mojom::ChapsSlot::kSystem)}),
+ ::testing::Bool()));
} // namespace arc
diff --git a/chrome/browser/ash/login/existing_user_controller_browsertest.cc b/chrome/browser/ash/login/existing_user_controller_browsertest.cc
index 62a69d6..fe30c15 100644
--- a/chrome/browser/ash/login/existing_user_controller_browsertest.cc
+++ b/chrome/browser/ash/login/existing_user_controller_browsertest.cc
@@ -7,6 +7,7 @@
#include "ash/components/arc/enterprise/arc_data_snapshotd_manager.h"
#include "ash/components/arc/test/arc_util_test_support.h"
+#include "ash/components/cryptohome/cryptohome_parameters.h"
#include "ash/components/login/auth/key.h"
#include "ash/components/login/auth/stub_authenticator_builder.h"
#include "ash/components/login/auth/user_context.h"
@@ -1010,6 +1011,36 @@
testing::NiceMock<policy::MockConfigurationPolicyProvider> policy_provider_;
};
+class ExistingUserControllerActiveDirectoryTestCreateProfileDir
+ : public ExistingUserControllerActiveDirectoryTest,
+ public ::testing::WithParamInterface<bool> {
+ public:
+ ExistingUserControllerActiveDirectoryTestCreateProfileDir() {
+ cryptohome_mixin_.MarkUserAsExisting(ad_account_id_);
+
+ // TODO(crbug.com/1311355): This test is run with the feature
+ // kUseAuthsessionAuthentication enabled and disabled because of a
+ // transitive dependency of AffiliationTestHelper on that feature. Remove
+ // the parameter when kUseAuthsessionAuthentication is removed.
+ if (GetParam()) {
+ scoped_feature_list_.InitAndEnableFeature(
+ features::kUseAuthsessionAuthentication);
+ } else {
+ scoped_feature_list_.InitAndDisableFeature(
+ features::kUseAuthsessionAuthentication);
+ }
+ }
+
+ private:
+ base::test::ScopedFeatureList scoped_feature_list_;
+ CryptohomeMixin cryptohome_mixin_{&mixin_host_};
+};
+
+INSTANTIATE_TEST_SUITE_P(
+ ActiveDirectory,
+ ExistingUserControllerActiveDirectoryTestCreateProfileDir,
+ ::testing::Bool());
+
class ExistingUserControllerActiveDirectoryUserAllowlistTest
: public ExistingUserControllerActiveDirectoryTest {
public:
@@ -1074,8 +1105,9 @@
// Tests that Active Directory offline login succeeds on the Active Directory
// managed device.
-IN_PROC_BROWSER_TEST_F(ExistingUserControllerActiveDirectoryTest,
- ActiveDirectoryOfflineLogin_Success) {
+IN_PROC_BROWSER_TEST_P(
+ ExistingUserControllerActiveDirectoryTestCreateProfileDir,
+ ActiveDirectoryOfflineLogin_Success) {
ExpectLoginSuccess();
UserContext user_context(user_manager::UserType::USER_TYPE_ACTIVE_DIRECTORY,
ad_account_id_);
diff --git a/chrome/browser/ash/login/saml/security_token_saml_test.cc b/chrome/browser/ash/login/saml/security_token_saml_test.cc
index fd2fdff..6bd14ad 100644
--- a/chrome/browser/ash/login/saml/security_token_saml_test.cc
+++ b/chrome/browser/ash/login/saml/security_token_saml_test.cc
@@ -8,6 +8,7 @@
#include <iterator>
#include <string>
+#include "ash/constants/ash_features.h"
#include "ash/constants/ash_switches.h"
#include "base/bind.h"
#include "base/command_line.h"
@@ -76,6 +77,10 @@
: saml_idp_mixin_(&mixin_host_,
&gaia_mixin_,
/*client_cert_authorities=*/{GetClientCertCaName()}) {
+ // TODO(crbug.com/1274116): Remove eventually after support for auth session
+ // empty passwords
+ scoped_feature_list_.InitAndDisableFeature(
+ ash::features::kUseAuthsessionAuthentication);
// Allow the forced installation of extensions in the background.
needs_background_networking_ = true;
diff --git a/chrome/browser/ash/login/saml/security_token_saml_test.h b/chrome/browser/ash/login/saml/security_token_saml_test.h
index 4fa59ff..18fb63f 100644
--- a/chrome/browser/ash/login/saml/security_token_saml_test.h
+++ b/chrome/browser/ash/login/saml/security_token_saml_test.h
@@ -10,6 +10,7 @@
#include "base/command_line.h"
#include "base/memory/weak_ptr.h"
#include "base/run_loop.h"
+#include "base/test/scoped_feature_list.h"
#include "base/values.h"
#include "chrome/browser/ash/certificate_provider/test_certificate_provider_extension.h"
#include "chrome/browser/ash/certificate_provider/test_certificate_provider_extension_mixin.h"
@@ -121,6 +122,7 @@
&mixin_host_, &extension_force_install_mixin_};
int pin_dialog_shown_count_ = 0;
base::RunLoop* pin_dialog_shown_run_loop_ = nullptr;
+ base::test::ScopedFeatureList scoped_feature_list_;
base::WeakPtrFactory<SecurityTokenSamlTest> weak_factory_{this};
};
diff --git a/chrome/browser/ash/login/test/cryptohome_mixin.cc b/chrome/browser/ash/login/test/cryptohome_mixin.cc
index 34deeca0..92a2b47 100644
--- a/chrome/browser/ash/login/test/cryptohome_mixin.cc
+++ b/chrome/browser/ash/login/test/cryptohome_mixin.cc
@@ -29,8 +29,9 @@
void CryptohomeMixin::SetUpOnMainThread() {
while (!pending_users_.empty()) {
- chromeos::FakeUserDataAuthClient::Get()->AddExistingUser(
- pending_users_.front());
+ auto user = pending_users_.front();
+ chromeos::FakeUserDataAuthClient::Get()->AddExistingUser(user);
+ chromeos::FakeUserDataAuthClient::Get()->CreateUserProfileDir(user);
pending_users_.pop();
}
}
diff --git a/chrome/browser/ash/policy/arc/unaffiliated_arc_allowed_browsertest.cc b/chrome/browser/ash/policy/arc/unaffiliated_arc_allowed_browsertest.cc
index 832fcdb..342e0a7 100644
--- a/chrome/browser/ash/policy/arc/unaffiliated_arc_allowed_browsertest.cc
+++ b/chrome/browser/ash/policy/arc/unaffiliated_arc_allowed_browsertest.cc
@@ -6,12 +6,14 @@
#include "ash/components/arc/test/arc_util_test_support.h"
#include "ash/components/settings/cros_settings_names.h"
+#include "ash/constants/ash_features.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/run_loop.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/ash/arc/arc_util.h"
#include "chrome/browser/ash/arc/session/arc_session_manager.h"
+#include "chrome/browser/ash/login/test/cryptohome_mixin.h"
#include "chrome/browser/ash/login/ui/login_display_host.h"
#include "chrome/browser/ash/policy/affiliation/affiliation_mixin.h"
#include "chrome/browser/ash/policy/affiliation/affiliation_test_helper.h"
@@ -39,11 +41,24 @@
class UnaffiliatedArcAllowedTest
: public DevicePolicyCrosBrowserTest,
- public ::testing::WithParamInterface<Params> {
+ public ::testing::WithParamInterface<std::tuple<Params, bool>> {
public:
UnaffiliatedArcAllowedTest() {
set_exit_when_last_browser_closes(false);
- affiliation_mixin_.set_affiliated(GetParam().affiliated);
+ affiliation_mixin_.set_affiliated(std::get<0>(GetParam()).affiliated);
+ cryptohome_mixin_.MarkUserAsExisting(affiliation_mixin_.account_id());
+
+ // TODO(crbug.com/1311355): This test is run with the feature
+ // kUseAuthsessionAuthentication enabled and disabled because of a
+ // transitive dependency of AffiliationTestHelper on that feature. Remove
+ // the parameter when kUseAuthsessionAuthentication is removed.
+ if (std::get<1>(GetParam())) {
+ feature_list_.InitAndEnableFeature(
+ ash::features::kUseAuthsessionAuthentication);
+ } else {
+ feature_list_.InitAndDisableFeature(
+ ash::features::kUseAuthsessionAuthentication);
+ }
}
UnaffiliatedArcAllowedTest(const UnaffiliatedArcAllowedTest&) = delete;
@@ -86,6 +101,10 @@
}
AffiliationMixin affiliation_mixin_{&mixin_host_, policy_helper()};
+
+ private:
+ base::test::ScopedFeatureList feature_list_;
+ ash::CryptohomeMixin cryptohome_mixin_{&mixin_host_};
};
IN_PROC_BROWSER_TEST_P(UnaffiliatedArcAllowedTest, PRE_ProfileTest) {
@@ -97,7 +116,7 @@
const user_manager::User* user = user_manager::UserManager::Get()->FindUser(
affiliation_mixin_.account_id());
const Profile* profile = ash::ProfileHelper::Get()->GetProfileByUser(user);
- const bool affiliated = GetParam().affiliated;
+ const bool affiliated = std::get<0>(GetParam()).affiliated;
EXPECT_EQ(affiliated, user->IsAffiliated());
EXPECT_TRUE(arc::IsArcAllowedForProfile(profile))
@@ -120,5 +139,7 @@
INSTANTIATE_TEST_SUITE_P(Blub,
UnaffiliatedArcAllowedTest,
- ::testing::Values(Params(true), Params(false)));
+ ::testing::Combine(::testing::Values(Params(true),
+ Params(false)),
+ ::testing::Bool()));
} // namespace policy
diff --git a/chrome/browser/extensions/api/enterprise_device_attributes/enterprise_device_attributes_apitest.cc b/chrome/browser/extensions/api/enterprise_device_attributes/enterprise_device_attributes_apitest.cc
index d0bcdf01..e74209d89 100644
--- a/chrome/browser/extensions/api/enterprise_device_attributes/enterprise_device_attributes_apitest.cc
+++ b/chrome/browser/extensions/api/enterprise_device_attributes/enterprise_device_attributes_apitest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ash/constants/ash_features.h"
#include "base/files/file_path.h"
#include "base/values.h"
#include "chrome/browser/ash/policy/affiliation/affiliation_mixin.h"
@@ -56,10 +57,11 @@
class EnterpriseDeviceAttributesTest
: public ForceInstalledAffiliatedExtensionApiTest,
- public ::testing::WithParamInterface<bool> {
+ public ::testing::WithParamInterface<std::tuple<bool, bool>> {
public:
EnterpriseDeviceAttributesTest()
- : ForceInstalledAffiliatedExtensionApiTest(GetParam()) {
+ : ForceInstalledAffiliatedExtensionApiTest(std::get<0>(GetParam()),
+ std::get<1>(GetParam())) {
fake_statistics_provider_.SetMachineStatistic(
chromeos::system::kSerialNumberKeyForTest, kSerialNumber);
}
@@ -95,7 +97,7 @@
}
IN_PROC_BROWSER_TEST_P(EnterpriseDeviceAttributesTest, Success) {
- const bool is_affiliated = GetParam();
+ const bool is_affiliated = std::get<0>(GetParam());
EXPECT_EQ(is_affiliated, user_manager::UserManager::Get()
->FindUser(affiliation_mixin_.account_id())
->IsAffiliated());
@@ -120,7 +122,8 @@
// Both cases of affiliated and non-affiliated users are tested.
INSTANTIATE_TEST_SUITE_P(AffiliationCheck,
EnterpriseDeviceAttributesTest,
- ::testing::Bool());
+ ::testing::Combine(::testing::Bool(),
+ ::testing::Bool()));
// Ensure that extensions that are not pre-installed by policy throw an install
// warning if they request the enterprise.deviceAttributes permission in the
diff --git a/chrome/browser/extensions/api/enterprise_networking_attributes/enterprise_networking_attributes_ash_apitest.cc b/chrome/browser/extensions/api/enterprise_networking_attributes/enterprise_networking_attributes_ash_apitest.cc
index 725b8033..906874c3 100644
--- a/chrome/browser/extensions/api/enterprise_networking_attributes/enterprise_networking_attributes_ash_apitest.cc
+++ b/chrome/browser/extensions/api/enterprise_networking_attributes/enterprise_networking_attributes_ash_apitest.cc
@@ -5,6 +5,7 @@
#include <memory>
#include <string>
+#include "ash/constants/ash_features.h"
#include "base/values.h"
#include "chrome/browser/ash/policy/affiliation/affiliation_test_helper.h"
#include "chrome/browser/extensions/api/force_installed_affiliated_extension_apitest.h"
@@ -69,10 +70,11 @@
class EnterpriseNetworkingAttributesTest
: public ForceInstalledAffiliatedExtensionApiTest,
- public ::testing::WithParamInterface<bool> {
+ public ::testing::WithParamInterface<std::tuple<bool, bool>> {
public:
EnterpriseNetworkingAttributesTest()
- : ForceInstalledAffiliatedExtensionApiTest(GetParam()) {}
+ : ForceInstalledAffiliatedExtensionApiTest(std::get<0>(GetParam()),
+ std::get<1>(GetParam())) {}
void SetupDisconnectedNetwork() {
chromeos::ShillDeviceClient::TestInterface* shill_device_client =
@@ -146,6 +148,9 @@
base::Value(shill::kStateOnline));
base::RunLoop().RunUntilIdle();
}
+
+ private:
+ base::test::ScopedFeatureList feature_list_;
};
IN_PROC_BROWSER_TEST_P(EnterpriseNetworkingAttributesTest,
@@ -154,7 +159,7 @@
}
IN_PROC_BROWSER_TEST_P(EnterpriseNetworkingAttributesTest, GetNetworkDetails) {
- const bool is_affiliated = GetParam();
+ const bool is_affiliated = std::get<0>(GetParam());
EXPECT_EQ(is_affiliated, user_manager::UserManager::Get()
->FindUser(affiliation_mixin_.account_id())
->IsAffiliated());
@@ -184,7 +189,8 @@
// Both cases of affiliated and non-affiliated users are tested.
INSTANTIATE_TEST_SUITE_P(AffiliationCheck,
EnterpriseNetworkingAttributesTest,
- ::testing::Bool());
+ ::testing::Combine(::testing::Bool(),
+ ::testing::Bool()));
// Ensure that extensions that are not pre-installed by policy throw an install
// warning if they request the enterprise.networkingAttributes permission in the
diff --git a/chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_apitest_nss.cc b/chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_apitest_nss.cc
index 80442799..125593e 100644
--- a/chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_apitest_nss.cc
+++ b/chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_apitest_nss.cc
@@ -8,6 +8,7 @@
#include <memory>
#include <string>
+#include "ash/constants/ash_features.h"
#include "ash/constants/ash_switches.h"
#include "base/bind.h"
#include "base/files/file_path.h"
@@ -202,12 +203,24 @@
class EnterprisePlatformKeysTest
: public PlatformKeysTestBase,
- public ::testing::WithParamInterface<Params> {
+ public ::testing::WithParamInterface<std::tuple<Params, bool>> {
public:
EnterprisePlatformKeysTest()
- : PlatformKeysTestBase(GetParam().system_token_status_,
- GetParam().enrollment_status_,
- GetParam().user_status_) {}
+ : PlatformKeysTestBase(std::get<0>(GetParam()).system_token_status_,
+ std::get<0>(GetParam()).enrollment_status_,
+ std::get<0>(GetParam()).user_status_) {
+ // TODO(crbug.com/1311355): This test is run with the feature
+ // kUseAuthsessionAuthentication enabled and disabled because of a
+ // transitive dependency of AffiliationTestHelper on that feature. Remove
+ // the parameter when kUseAuthsessionAuthentication is removed.
+ if (std::get<1>(GetParam())) {
+ feature_list_.InitAndEnableFeature(
+ ash::features::kUseAuthsessionAuthentication);
+ } else {
+ feature_list_.InitAndDisableFeature(
+ ash::features::kUseAuthsessionAuthentication);
+ }
+ }
EnterprisePlatformKeysTest(const EnterprisePlatformKeysTest&) = delete;
EnterprisePlatformKeysTest& operator=(const EnterprisePlatformKeysTest&) =
@@ -262,6 +275,7 @@
// destructor).
ash::platform_keys::test_util::ScopedChapsUtilOverride
scoped_chaps_util_override_;
+ base::test::ScopedFeatureList feature_list_;
};
} // namespace
@@ -298,19 +312,22 @@
INSTANTIATE_TEST_SUITE_P(
CheckSystemTokenAvailability,
EnterprisePlatformKeysTest,
- ::testing::Values(
- Params(PlatformKeysTestBase::SystemTokenStatus::EXISTS,
- PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
- PlatformKeysTestBase::UserStatus::MANAGED_AFFILIATED_DOMAIN),
- Params(PlatformKeysTestBase::SystemTokenStatus::EXISTS,
- PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
- PlatformKeysTestBase::UserStatus::MANAGED_OTHER_DOMAIN),
- Params(PlatformKeysTestBase::SystemTokenStatus::EXISTS,
- PlatformKeysTestBase::EnrollmentStatus::NOT_ENROLLED,
- PlatformKeysTestBase::UserStatus::MANAGED_OTHER_DOMAIN),
- Params(PlatformKeysTestBase::SystemTokenStatus::DOES_NOT_EXIST,
- PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
- PlatformKeysTestBase::UserStatus::MANAGED_AFFILIATED_DOMAIN)));
+ ::testing::Combine(
+ ::testing::Values(
+ Params(PlatformKeysTestBase::SystemTokenStatus::EXISTS,
+ PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
+ PlatformKeysTestBase::UserStatus::MANAGED_AFFILIATED_DOMAIN),
+ Params(PlatformKeysTestBase::SystemTokenStatus::EXISTS,
+ PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
+ PlatformKeysTestBase::UserStatus::MANAGED_OTHER_DOMAIN),
+ Params(PlatformKeysTestBase::SystemTokenStatus::EXISTS,
+ PlatformKeysTestBase::EnrollmentStatus::NOT_ENROLLED,
+ PlatformKeysTestBase::UserStatus::MANAGED_OTHER_DOMAIN),
+ Params(
+ PlatformKeysTestBase::SystemTokenStatus::DOES_NOT_EXIST,
+ PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
+ PlatformKeysTestBase::UserStatus::MANAGED_AFFILIATED_DOMAIN)),
+ ::testing::Bool()));
// Ensure that extensions that are not pre-installed by policy throw an install
// warning if they request the enterprise.platformKeys permission in the
diff --git a/chrome/browser/extensions/api/force_installed_affiliated_extension_apitest.cc b/chrome/browser/extensions/api/force_installed_affiliated_extension_apitest.cc
index bd2c11f..ab71284b 100644
--- a/chrome/browser/extensions/api/force_installed_affiliated_extension_apitest.cc
+++ b/chrome/browser/extensions/api/force_installed_affiliated_extension_apitest.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/extensions/api/force_installed_affiliated_extension_apitest.h"
+#include "ash/constants/ash_features.h"
#include "base/files/file_path.h"
#include "base/json/json_writer.h"
#include "base/path_service.h"
@@ -31,13 +32,27 @@
namespace extensions {
ForceInstalledAffiliatedExtensionApiTest::
- ForceInstalledAffiliatedExtensionApiTest(bool is_affiliated)
+ ForceInstalledAffiliatedExtensionApiTest(bool is_affiliated,
+ bool is_auth_session_enabled)
: test_install_attributes_(
ash::StubInstallAttributes::CreateCloudManaged("fake-domain",
"fake-id")) {
+ // TODO(crbug.com/1311355): This test is run with the feature
+ // kUseAuthsessionAuthentication enabled and disabled because of a
+ // transitive dependency of AffiliationTestHelper on that feature. Remove
+ // the parameter when kUseAuthsessionAuthentication is removed.
+ if (is_auth_session_enabled) {
+ feature_list_.InitAndEnableFeature(
+ ash::features::kUseAuthsessionAuthentication);
+ } else {
+ feature_list_.InitAndDisableFeature(
+ ash::features::kUseAuthsessionAuthentication);
+ }
+
set_exit_when_last_browser_closes(false);
set_chromeos_user_ = false;
affiliation_mixin_.set_affiliated(is_affiliated);
+ cryptohome_mixin_.MarkUserAsExisting(affiliation_mixin_.account_id());
}
ForceInstalledAffiliatedExtensionApiTest::
diff --git a/chrome/browser/extensions/api/force_installed_affiliated_extension_apitest.h b/chrome/browser/extensions/api/force_installed_affiliated_extension_apitest.h
index cec0c83..95e2dd47 100644
--- a/chrome/browser/extensions/api/force_installed_affiliated_extension_apitest.h
+++ b/chrome/browser/extensions/api/force_installed_affiliated_extension_apitest.h
@@ -9,6 +9,7 @@
#include "ash/components/tpm/stub_install_attributes.h"
#include "base/values.h"
+#include "chrome/browser/ash/login/test/cryptohome_mixin.h"
#include "chrome/browser/ash/policy/affiliation/affiliation_mixin.h"
#include "chrome/browser/ash/policy/core/device_policy_cros_browser_test.h"
#include "chrome/browser/extensions/mixin_based_extension_apitest.h"
@@ -33,7 +34,9 @@
class ForceInstalledAffiliatedExtensionApiTest
: public MixinBasedExtensionApiTest {
public:
- explicit ForceInstalledAffiliatedExtensionApiTest(bool is_affiliated);
+ explicit ForceInstalledAffiliatedExtensionApiTest(
+ bool is_affiliated,
+ bool is_auth_session_enabled);
~ForceInstalledAffiliatedExtensionApiTest() override;
protected:
@@ -57,6 +60,10 @@
policy::DevicePolicyCrosTestHelper test_helper_;
policy::AffiliationMixin affiliation_mixin_{&mixin_host_, &test_helper_};
ExtensionForceInstallMixin force_install_mixin_{&mixin_host_};
+ ash::CryptohomeMixin cryptohome_mixin_{&mixin_host_};
+
+ private:
+ base::test::ScopedFeatureList feature_list_;
};
} // namespace extensions
diff --git a/chrome/browser/extensions/api/platform_keys/platform_keys_apitest_nss.cc b/chrome/browser/extensions/api/platform_keys/platform_keys_apitest_nss.cc
index 54dad84..14ddaf8 100644
--- a/chrome/browser/extensions/api/platform_keys/platform_keys_apitest_nss.cc
+++ b/chrome/browser/extensions/api/platform_keys/platform_keys_apitest_nss.cc
@@ -8,6 +8,7 @@
#include <memory>
#include <utility>
+#include "ash/constants/ash_features.h"
#include "base/bind.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
@@ -292,13 +293,29 @@
class UnmanagedPlatformKeysTest
: public PlatformKeysTest,
- public ::testing::WithParamInterface<UnmanagedPlatformKeysTestParams> {
+ public ::testing::WithParamInterface<
+ std::tuple<UnmanagedPlatformKeysTestParams, bool>> {
public:
UnmanagedPlatformKeysTest()
- : PlatformKeysTest(GetParam().enrollment_status_,
+ : PlatformKeysTest(std::get<0>(GetParam()).enrollment_status_,
UserStatus::UNMANAGED,
false /* unused */,
- GetParam().user_client_cert_slot_) {}
+ std::get<0>(GetParam()).user_client_cert_slot_) {
+ // TODO(crbug.com/1311355): This test is run with the feature
+ // kUseAuthsessionAuthentication enabled and disabled because of a
+ // transitive dependency of AffiliationTestHelper on that feature. Remove
+ // the parameter when kUseAuthsessionAuthentication is removed.
+ if (std::get<1>(GetParam())) {
+ feature_list_.InitAndEnableFeature(
+ ash::features::kUseAuthsessionAuthentication);
+ } else {
+ feature_list_.InitAndDisableFeature(
+ ash::features::kUseAuthsessionAuthentication);
+ }
+ }
+
+ private:
+ base::test::ScopedFeatureList feature_list_;
};
struct ManagedPlatformKeysTestParams {
@@ -313,24 +330,56 @@
class ManagedWithPermissionPlatformKeysTest
: public PlatformKeysTest,
- public ::testing::WithParamInterface<ManagedPlatformKeysTestParams> {
+ public ::testing::WithParamInterface<
+ std::tuple<ManagedPlatformKeysTestParams, bool>> {
public:
ManagedWithPermissionPlatformKeysTest()
- : PlatformKeysTest(GetParam().enrollment_status_,
- GetParam().user_status_,
+ : PlatformKeysTest(std::get<0>(GetParam()).enrollment_status_,
+ std::get<0>(GetParam()).user_status_,
true /* grant the extension key permission */,
- UserClientCertSlot::kPrivateSlot) {}
+ UserClientCertSlot::kPrivateSlot) {
+ // TODO(crbug.com/1311355): This test is run with the feature
+ // kUseAuthsessionAuthentication enabled and disabled because of a
+ // transitive dependency of AffiliationTestHelper on that feature. Remove
+ // the parameter when kUseAuthsessionAuthentication is removed.
+ if (std::get<1>(GetParam())) {
+ feature_list_.InitAndEnableFeature(
+ ash::features::kUseAuthsessionAuthentication);
+ } else {
+ feature_list_.InitAndDisableFeature(
+ ash::features::kUseAuthsessionAuthentication);
+ }
+ }
+
+ private:
+ base::test::ScopedFeatureList feature_list_;
};
class ManagedWithoutPermissionPlatformKeysTest
: public PlatformKeysTest,
- public ::testing::WithParamInterface<ManagedPlatformKeysTestParams> {
+ public ::testing::WithParamInterface<
+ std::tuple<ManagedPlatformKeysTestParams, bool>> {
public:
ManagedWithoutPermissionPlatformKeysTest()
- : PlatformKeysTest(GetParam().enrollment_status_,
- GetParam().user_status_,
+ : PlatformKeysTest(std::get<0>(GetParam()).enrollment_status_,
+ std::get<0>(GetParam()).user_status_,
false /* do not grant key permission */,
- UserClientCertSlot::kPrivateSlot) {}
+ UserClientCertSlot::kPrivateSlot) {
+ // TODO(crbug.com/1311355): This test is run with the feature
+ // kUseAuthsessionAuthentication enabled and disabled because of a
+ // transitive dependency of AffiliationTestHelper on that feature. Remove
+ // the parameter when kUseAuthsessionAuthentication is removed.
+ if (std::get<1>(GetParam())) {
+ feature_list_.InitAndEnableFeature(
+ ash::features::kUseAuthsessionAuthentication);
+ } else {
+ feature_list_.InitAndDisableFeature(
+ ash::features::kUseAuthsessionAuthentication);
+ }
+ }
+
+ private:
+ base::test::ScopedFeatureList feature_list_;
};
} // namespace
@@ -375,18 +424,21 @@
INSTANTIATE_TEST_SUITE_P(
Unmanaged,
UnmanagedPlatformKeysTest,
- ::testing::Values(UnmanagedPlatformKeysTestParams(
- PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
- PlatformKeysTest::UserClientCertSlot::kPrivateSlot),
- UnmanagedPlatformKeysTestParams(
- PlatformKeysTestBase::EnrollmentStatus::NOT_ENROLLED,
- PlatformKeysTest::UserClientCertSlot::kPrivateSlot),
- UnmanagedPlatformKeysTestParams(
- PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
- PlatformKeysTest::UserClientCertSlot::kPublicSlot),
- UnmanagedPlatformKeysTestParams(
- PlatformKeysTestBase::EnrollmentStatus::NOT_ENROLLED,
- PlatformKeysTest::UserClientCertSlot::kPublicSlot)));
+ ::testing::Combine(
+ ::testing::Values(
+ UnmanagedPlatformKeysTestParams(
+ PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
+ PlatformKeysTest::UserClientCertSlot::kPrivateSlot),
+ UnmanagedPlatformKeysTestParams(
+ PlatformKeysTestBase::EnrollmentStatus::NOT_ENROLLED,
+ PlatformKeysTest::UserClientCertSlot::kPrivateSlot),
+ UnmanagedPlatformKeysTestParams(
+ PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
+ PlatformKeysTest::UserClientCertSlot::kPublicSlot),
+ UnmanagedPlatformKeysTestParams(
+ PlatformKeysTestBase::EnrollmentStatus::NOT_ENROLLED,
+ PlatformKeysTest::UserClientCertSlot::kPublicSlot)),
+ ::testing::Bool()));
IN_PROC_BROWSER_TEST_P(ManagedWithoutPermissionPlatformKeysTest,
PRE_UserPermissionsBlocked) {
@@ -425,16 +477,18 @@
INSTANTIATE_TEST_SUITE_P(
ManagedWithoutPermission,
ManagedWithoutPermissionPlatformKeysTest,
- ::testing::Values(
- ManagedPlatformKeysTestParams(
- PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
- PlatformKeysTestBase::UserStatus::MANAGED_AFFILIATED_DOMAIN),
- ManagedPlatformKeysTestParams(
- PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
- PlatformKeysTestBase::UserStatus::MANAGED_OTHER_DOMAIN),
- ManagedPlatformKeysTestParams(
- PlatformKeysTestBase::EnrollmentStatus::NOT_ENROLLED,
- PlatformKeysTestBase::UserStatus::MANAGED_OTHER_DOMAIN)));
+ ::testing::Combine(
+ ::testing::Values(
+ ManagedPlatformKeysTestParams(
+ PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
+ PlatformKeysTestBase::UserStatus::MANAGED_AFFILIATED_DOMAIN),
+ ManagedPlatformKeysTestParams(
+ PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
+ PlatformKeysTestBase::UserStatus::MANAGED_OTHER_DOMAIN),
+ ManagedPlatformKeysTestParams(
+ PlatformKeysTestBase::EnrollmentStatus::NOT_ENROLLED,
+ PlatformKeysTestBase::UserStatus::MANAGED_OTHER_DOMAIN)),
+ ::testing::Bool()));
IN_PROC_BROWSER_TEST_P(ManagedWithPermissionPlatformKeysTest,
PRE_PolicyGrantsAccessToCorporateKey) {
@@ -484,13 +538,15 @@
INSTANTIATE_TEST_SUITE_P(
ManagedWithPermission,
ManagedWithPermissionPlatformKeysTest,
- ::testing::Values(
- ManagedPlatformKeysTestParams(
- PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
- PlatformKeysTestBase::UserStatus::MANAGED_AFFILIATED_DOMAIN),
- ManagedPlatformKeysTestParams(
- PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
- PlatformKeysTestBase::UserStatus::MANAGED_OTHER_DOMAIN),
- ManagedPlatformKeysTestParams(
- PlatformKeysTestBase::EnrollmentStatus::NOT_ENROLLED,
- PlatformKeysTestBase::UserStatus::MANAGED_OTHER_DOMAIN)));
+ ::testing::Combine(
+ ::testing::Values(
+ ManagedPlatformKeysTestParams(
+ PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
+ PlatformKeysTestBase::UserStatus::MANAGED_AFFILIATED_DOMAIN),
+ ManagedPlatformKeysTestParams(
+ PlatformKeysTestBase::EnrollmentStatus::ENROLLED,
+ PlatformKeysTestBase::UserStatus::MANAGED_OTHER_DOMAIN),
+ ManagedPlatformKeysTestParams(
+ PlatformKeysTestBase::EnrollmentStatus::NOT_ENROLLED,
+ PlatformKeysTestBase::UserStatus::MANAGED_OTHER_DOMAIN)),
+ ::testing::Bool()));
diff --git a/chrome/browser/extensions/api/platform_keys/platform_keys_test_base.cc b/chrome/browser/extensions/api/platform_keys/platform_keys_test_base.cc
index fa1f980..ef2c1885 100644
--- a/chrome/browser/extensions/api/platform_keys/platform_keys_test_base.cc
+++ b/chrome/browser/extensions/api/platform_keys/platform_keys_test_base.cc
@@ -50,6 +50,7 @@
set_chromeos_user_ = false;
// We log in without running browser.
set_exit_when_last_browser_closes(false);
+ cryptohome_mixin_.MarkUserAsExisting(account_id_);
}
PlatformKeysTestBase::~PlatformKeysTestBase() {}
diff --git a/chrome/browser/extensions/api/platform_keys/platform_keys_test_base.h b/chrome/browser/extensions/api/platform_keys/platform_keys_test_base.h
index 46da2fa0..eeac4c4 100644
--- a/chrome/browser/extensions/api/platform_keys/platform_keys_test_base.h
+++ b/chrome/browser/extensions/api/platform_keys/platform_keys_test_base.h
@@ -8,6 +8,7 @@
#include <memory>
#include "ash/components/tpm/stub_install_attributes.h"
+#include "chrome/browser/ash/login/test/cryptohome_mixin.h"
#include "chrome/browser/ash/policy/core/device_policy_cros_browser_test.h"
#include "chrome/browser/extensions/mixin_based_extension_apitest.h"
#include "components/account_id/account_id.h"
@@ -108,6 +109,7 @@
FakeGaia fake_gaia_;
net::EmbeddedTestServer gaia_server_{net::EmbeddedTestServer::TYPE_HTTPS};
ash::ScopedStubInstallAttributes install_attributes_;
+ ash::CryptohomeMixin cryptohome_mixin_{&mixin_host_};
};
#endif // CHROME_BROWSER_EXTENSIONS_API_PLATFORM_KEYS_PLATFORM_KEYS_TEST_BASE_H_
diff --git a/chromeos/dbus/userdataauth/fake_userdataauth_client.cc b/chromeos/dbus/userdataauth/fake_userdataauth_client.cc
index 70c8e5c..163bd1f7 100644
--- a/chromeos/dbus/userdataauth/fake_userdataauth_client.cc
+++ b/chromeos/dbus/userdataauth/fake_userdataauth_client.cc
@@ -7,6 +7,7 @@
#include <utility>
#include "base/containers/contains.h"
+#include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/location.h"
@@ -634,6 +635,11 @@
return keys.find(label);
}
+void FakeUserDataAuthClient::CreateUserProfileDir(
+ const cryptohome::AccountIdentifier& account_id) {
+ base::CreateDirectory(GetUserProfileDir(account_id));
+}
+
base::FilePath FakeUserDataAuthClient::GetUserProfileDir(
const cryptohome::AccountIdentifier& account_id) const {
DCHECK(!user_data_dir_.empty());
diff --git a/chromeos/dbus/userdataauth/fake_userdataauth_client.h b/chromeos/dbus/userdataauth/fake_userdataauth_client.h
index 52a102de..bb702fdf 100644
--- a/chromeos/dbus/userdataauth/fake_userdataauth_client.h
+++ b/chromeos/dbus/userdataauth/fake_userdataauth_client.h
@@ -279,6 +279,8 @@
void set_user_data_dir(base::FilePath path) { user_data_dir_ = path; }
+ void CreateUserProfileDir(const cryptohome::AccountIdentifier& account_id);
+
private:
// Helper that returns the protobuf reply.
template <typename ReplyType>