| Index: components/arc/arc_util_unittest.cc
|
| diff --git a/components/arc/arc_util_unittest.cc b/components/arc/arc_util_unittest.cc
|
| index 0a52662a6140706d77d386ef2ffd7991c662fc74..ede067969dc132da3ed7467a8f1423a31ead9e5c 100644
|
| --- a/components/arc/arc_util_unittest.cc
|
| +++ b/components/arc/arc_util_unittest.cc
|
| @@ -12,6 +12,11 @@
|
| #include "base/macros.h"
|
| #include "base/memory/ptr_util.h"
|
| #include "base/test/scoped_feature_list.h"
|
| +#include "chrome/common/pref_names.h"
|
| +#include "components/prefs/pref_registry_simple.h"
|
| +#include "components/prefs/pref_service.h"
|
| +#include "components/prefs/pref_service_factory.h"
|
| +#include "components/prefs/testing_pref_store.h"
|
| #include "components/signin/core/account_id/account_id.h"
|
| #include "components/user_manager/fake_user_manager.h"
|
| #include "components/user_manager/user.h"
|
| @@ -23,6 +28,12 @@
|
| namespace arc {
|
| namespace {
|
|
|
| +// The constants matching the values from DeviceEcryptfsMigrationStrategy
|
| +// policy.
|
| +constexpr int kMigrationAllowedPolicyUnset = 0;
|
| +constexpr int kMigrationAllowedPolicyDisabled = 1;
|
| +constexpr int kMigrationAllowedPolicyEnabled = 2;
|
| +
|
| // If an instance is created, based on the value passed to the consturctor,
|
| // EnableARC feature is enabled/disabled in the scope.
|
| class ScopedArcFeature {
|
| @@ -239,5 +250,90 @@ TEST_F(ArcUtilTest, IsArcAllowedForUser) {
|
| EXPECT_FALSE(IsArcAllowedForUser(ephemeral_user));
|
| }
|
|
|
| +TEST_F(ArcUtilTest, IsMigrationAllowedDeviceOwned) {
|
| + ResetGlobalDataForTesting();
|
| + auto* command_line = base::CommandLine::ForCurrentProcess();
|
| + command_line->InitFromArgv({"", "--initial-encryption-ecryptfs"});
|
| + SetHasDeviceOwner();
|
| + EXPECT_TRUE(IsArcAvailable());
|
| +}
|
| +
|
| +TEST_F(ArcUtilTest, IsMigrationAllowedUserNotInitialized) {
|
| + ResetGlobalDataForTesting();
|
| + auto* command_line = base::CommandLine::ForCurrentProcess();
|
| + command_line->InitFromArgv({"", "--initial-encryption-ecryptfs"});
|
| + EXPECT_FALSE(IsArcAvailable());
|
| +}
|
| +
|
| +TEST_F(ArcUtilTest, IsMigrationAllowedNoPolicy) {
|
| + ResetGlobalDataForTesting();
|
| + auto* command_line = base::CommandLine::ForCurrentProcess();
|
| + command_line->InitFromArgv({"", "--initial-encryption-ecryptfs"});
|
| + user_manager::FakeUserManager fake_user_manager;
|
| +
|
| + PrefServiceFactory pref_service_factory;
|
| + scoped_refptr<TestingPrefStore> pref_store(new TestingPrefStore);
|
| + pref_service_factory.set_user_prefs(pref_store.get());
|
| + scoped_refptr<PrefRegistrySimple> registry(new PrefRegistrySimple);
|
| + std::unique_ptr<PrefService> pref_service(
|
| + pref_service_factory.Create(registry.get()));
|
| +
|
| + fake_user_manager.SetLocalState(pref_service.get());
|
| + ScopedUserManager scoped_user_manager(&fake_user_manager);
|
| + EXPECT_FALSE(IsArcAvailable());
|
| +}
|
| +
|
| +TEST_F(ArcUtilTest, IsMigrationAllowedPolicyAllowed) {
|
| + ResetGlobalDataForTesting();
|
| + auto* command_line = base::CommandLine::ForCurrentProcess();
|
| + command_line->InitFromArgv({"", "--initial-encryption-ecryptfs"});
|
| + user_manager::FakeUserManager fake_user_manager;
|
| +
|
| + PrefServiceFactory pref_service_factory;
|
| + scoped_refptr<TestingPrefStore> managed_pref_store(new TestingPrefStore);
|
| + scoped_refptr<TestingPrefStore> user_pref_store(new TestingPrefStore);
|
| + managed_pref_store->SetInteger(prefs::kDeviceEcryptfsMigrationStrategy,
|
| + kMigrationAllowedPolicyEnabled);
|
| + pref_service_factory.set_managed_prefs(managed_pref_store.get());
|
| + pref_service_factory.set_user_prefs(user_pref_store.get());
|
| + scoped_refptr<PrefRegistrySimple> registry(new PrefRegistrySimple);
|
| + registry->RegisterIntegerPref(prefs::kDeviceEcryptfsMigrationStrategy,
|
| + kMigrationAllowedPolicyUnset);
|
| + std::unique_ptr<PrefService> pref_service(
|
| + pref_service_factory.Create(registry.get()));
|
| + pref_service->SetInteger(prefs::kDeviceEcryptfsMigrationStrategy,
|
| + kMigrationAllowedPolicyEnabled);
|
| +
|
| + fake_user_manager.SetLocalState(pref_service.get());
|
| + ScopedUserManager scoped_user_manager(&fake_user_manager);
|
| + EXPECT_TRUE(IsArcAvailable());
|
| +}
|
| +
|
| +TEST_F(ArcUtilTest, IsMigrationAllowedPolicyDisabled) {
|
| + ResetGlobalDataForTesting();
|
| + auto* command_line = base::CommandLine::ForCurrentProcess();
|
| + command_line->InitFromArgv({"", "--initial-encryption-ecryptfs"});
|
| + user_manager::FakeUserManager fake_user_manager;
|
| +
|
| + PrefServiceFactory pref_service_factory;
|
| + scoped_refptr<TestingPrefStore> managed_pref_store(new TestingPrefStore);
|
| + scoped_refptr<TestingPrefStore> user_pref_store(new TestingPrefStore);
|
| + managed_pref_store->SetInteger(prefs::kDeviceEcryptfsMigrationStrategy,
|
| + kMigrationAllowedPolicyDisabled);
|
| + pref_service_factory.set_managed_prefs(managed_pref_store.get());
|
| + pref_service_factory.set_user_prefs(user_pref_store.get());
|
| + scoped_refptr<PrefRegistrySimple> registry(new PrefRegistrySimple);
|
| + registry->RegisterIntegerPref(prefs::kDeviceEcryptfsMigrationStrategy,
|
| + kMigrationAllowedPolicyUnset);
|
| + std::unique_ptr<PrefService> pref_service(
|
| + pref_service_factory.Create(registry.get()));
|
| + pref_service->SetInteger(prefs::kDeviceEcryptfsMigrationStrategy,
|
| + kMigrationAllowedPolicyDisabled);
|
| +
|
| + fake_user_manager.SetLocalState(pref_service.get());
|
| + ScopedUserManager scoped_user_manager(&fake_user_manager);
|
| + EXPECT_FALSE(IsArcAvailable());
|
| +}
|
| +
|
| } // namespace
|
| } // namespace arc
|
|
|