Commit 2cc707e7 authored by Dominique Fauteux-Chapleau's avatar Dominique Fauteux-Chapleau Committed by Commit Bot

Fix NotBlockedExternalUserProviders

Add Windows specific code to test registry provider blocked by the policy.

Bug: 1019160
Change-Id: I5ae7c383028b2a6a51075d76b60ae01dc507034c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1893572Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Commit-Queue: Dominique Fauteux-Chapleau <domfc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713555}
parent e365ccdb
......@@ -48,6 +48,11 @@
#include "components/user_manager/scoped_user_manager.h"
#endif
#if defined(OS_WIN)
#include "base/test/test_reg_util_win.h"
#include "base/win/registry.h"
#endif
namespace extensions {
namespace {
......@@ -59,6 +64,13 @@ const char kAppPath[] = "/app.crx";
const char kExternalAppId[] = "kekdneafjmhmndejhmbcadfiiofngffo";
#endif
#if defined(OS_WIN)
const char kExternalAppCrxPath[] =
"external\\kekdneafjmhmndejhmbcadfiiofngffo.crx";
const wchar_t kExternalAppRegistryKey[] =
L"Software\\Google\\Chrome\\Extensions\\kekdneafjmhmndejhmbcadfiiofngffo";
#endif
class ExternalProviderImplTest : public ExtensionServiceTestBase {
public:
ExternalProviderImplTest() {}
......@@ -92,8 +104,25 @@ class ExternalProviderImplTest : public ExtensionServiceTestBase {
}
void OverrideExternalExtensionsPath() {
// Windows doesn't use the provider that installs the |kExternalAppId|
// extension implicitly, so to test that the blocking policy works on
// Windows it is installed through a Windows-specific registry provider.
#if defined(OS_WIN)
EXPECT_NO_FATAL_FAILURE(
registry_override_manager_.OverrideRegistry(HKEY_CURRENT_USER));
EXPECT_EQ(ERROR_SUCCESS,
external_extension_key_.Create(
HKEY_CURRENT_USER, kExternalAppRegistryKey, KEY_ALL_ACCESS));
EXPECT_EQ(ERROR_SUCCESS,
external_extension_key_.WriteValue(
L"path",
data_dir().AppendASCII(kExternalAppCrxPath).value().c_str()));
EXPECT_EQ(ERROR_SUCCESS,
external_extension_key_.WriteValue(L"version", L"1"));
#else
external_externsions_overrides_.reset(new base::ScopedPathOverride(
chrome::DIR_EXTERNAL_EXTENSIONS, data_dir().AppendASCII("external")));
#endif
}
void SetExternalExtensionsBlockedByPolicy(const bool block_external) {
......@@ -174,6 +203,12 @@ class ExternalProviderImplTest : public ExtensionServiceTestBase {
chromeos::system::ScopedFakeStatisticsProvider fake_statistics_provider_;
#endif
#if defined(OS_WIN)
// Registry key pointing to the external extension for Windows.
base::win::RegKey external_extension_key_;
registry_util::RegistryOverrideManager registry_override_manager_;
#endif
DISALLOW_COPY_AND_ASSIGN(ExternalProviderImplTest);
};
......
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