chromium/chrome/browser/extensions/api/webstore_private/extension_install_status_unittest.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/extensions/api/webstore_private/extension_install_status.h"

#include <vector>

#include "base/json/json_reader.h"
#include "base/json/values_util.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "base/values.h"
#include "chrome/browser/extensions/extension_management_internal.h"
#include "chrome/browser/supervised_user/supervised_user_test_util.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/browser_with_test_window_test.h"
#include "components/supervised_user/core/common/features.h"
#include "components/supervised_user/core/common/pref_names.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "extensions/browser/disable_reason.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/pref_names.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/extension_features.h"
#include "extensions/common/manifest.h"
#include "extensions/common/permissions/permission_set.h"

APIPermissionID;

namespace extensions {
namespace {
constexpr char kExtensionId[] =;
constexpr char kExtensionSettingsWithUpdateUrlBlocking[] =;

constexpr char kExtensionSettingsWithWildcardBlocking[] =;

constexpr char kExtensionSettingsWithIdBlocked[] =;

}  // namespace

class ExtensionInstallStatusTest : public BrowserWithTestWindowTest {};

TEST_F(ExtensionInstallStatusTest, ExtensionEnabled) {}

TEST_F(ExtensionInstallStatusTest, ExtensionDisabled) {}

TEST_F(ExtensionInstallStatusTest, ExtensionInstalledButDisabledByPolicy) {}

TEST_F(ExtensionInstallStatusTest, ExtensionTerminated) {}

TEST_F(ExtensionInstallStatusTest, ExtensionBlocklisted) {}

TEST_F(ExtensionInstallStatusTest, ExtensionAllowed) {}

TEST_F(ExtensionInstallStatusTest, ExtensionForceInstalledByPolicy) {}

TEST_F(ExtensionInstallStatusTest, ExtensionBlockedByUpdateUrl) {}

TEST_F(ExtensionInstallStatusTest, ExtensionBlockedByWildcard) {}

TEST_F(ExtensionInstallStatusTest, ExtensionBlockedById) {}

TEST_F(ExtensionInstallStatusTest,
       ExtensionBlockByUpdateUrlWithRequestEnabled) {}

TEST_F(ExtensionInstallStatusTest, ExtensionBlockByWildcardWithRequestEnabled) {}

TEST_F(ExtensionInstallStatusTest, ExtensionBlockByIdWithRequestEnabled) {}

TEST_F(ExtensionInstallStatusTest, PendingExtenisonIsWaitingToBeReviewed) {}

TEST_F(ExtensionInstallStatusTest, PendingExtenisonIsApproved) {}

TEST_F(ExtensionInstallStatusTest, PendingExtenisonIsRejected) {}

// If an existing, installed extension is disabled due to reason
// DISABLE_CUSTODIAN_APPROVAL_REQUIRED, then GetWebstoreExtensionInstallStatus()
// should return kCustodianApprovalRequired.
TEST_F(ExtensionInstallStatusTest,
       ExistingExtensionWithCustodianApprovalRequired) {}

TEST_F(ExtensionInstallStatusTest, ExtensionBlockedByManifestType) {}

TEST_F(ExtensionInstallStatusTest, ExtensionWithoutPermissionInfo) {}

TEST_F(ExtensionInstallStatusTest, ExtensionWithoutManifestInfo) {}

TEST_F(ExtensionInstallStatusTest, ExtensionBlockedByPermissions) {}

TEST_F(ExtensionInstallStatusTest, ExtensionBlockedByPermissionsWithUpdateUrl) {}

TEST_F(ExtensionInstallStatusTest,
       ExtensionBlockedByPermissionButAllowlistById) {}

// Extension policies apply to non web store update url doesn't affect the
// status here.
TEST_F(ExtensionInstallStatusTest, NonWebstoreUpdateUrlPolicy) {}

TEST_F(ExtensionInstallStatusTest, ManifestVersionIsBlocked) {}

TEST_F(ExtensionInstallStatusTest,
       ManifestVersionIsBlockedWithExtensionRequest) {}

// If an existing, installed extension is disabled due to corruption, then
// GetWebstoreExtensionInstallStatus() should return kCorrupted.
TEST_F(ExtensionInstallStatusTest, ExtensionCorrupted) {}

class SupervisedUserExtensionInstallStatusTest
    : public ExtensionInstallStatusTest {};

// If a supervised user requires parent approval to install a new extension that
// has not received parental approval before, then
// GetWebstoreExtensionInstallStatus() should return
// kCustodianApprovalRequiredForInstallation.
TEST_F(SupervisedUserExtensionInstallStatusTest,
       NewExtensionWithCustodianApprovalRequiredForInstallation) {}

// If a supervised user can skip parent permission to install extensions,
// then for a new (uninstalled) extension GetWebstoreExtensionInstallStatus()
// should return kInstallable.
TEST_F(
    SupervisedUserExtensionInstallStatusTest,
    NewExtensionOnSkipApprovalModeDoesNotRequireCustodianApprovalForInstallation) {}

// If a supervised user wants to install an extension that has been already
// granted parent approval (e.g. via synced settings from another client),
// then GetWebstoreExtensionInstallStatus() should return kInstallable.
TEST_F(
    SupervisedUserExtensionInstallStatusTest,
    NewExtensionWithParentApprovalDoesNotRequireCustodianApprovalForInstallation) {}

// A test suite to toggle the behavior of the MV2 deprecation experiment.
class ExtensionInstallStatusTestWithMV2Deprecation
    : public ExtensionInstallStatusTest,
      public testing::WithParamInterface<bool> {};

ExtensionInstallStatusTestWithMV2DeprecationEnabled;

INSTANTIATE_TEST_SUITE_P();
INSTANTIATE_TEST_SUITE_P();

// Tests the webstore properly checks whether an extension can be installed
// inline with the MV2 Deprecation experiments.
TEST_P(ExtensionInstallStatusTestWithMV2Deprecation,
       MV2ExtensionsAreBlockedWithExperiment) {}

// An extension explicitly blocked by the admin should be considered blocked
// by policy, rather than a deprecated manifest version.
TEST_P(ExtensionInstallStatusTestWithMV2DeprecationEnabled,
       IdBlockedByPolicyTakesPriorityOverDeprecatedManifestVersion) {}

// If an admin blocks all MV2 extensions, they should be considered blocked by
// policy, rather than a deprecated manifest version.
TEST_P(ExtensionInstallStatusTestWithMV2DeprecationEnabled,
       ManifestV2PolicyTakesPriorityOverDeprecatedManifestVersion) {}

// Extensions that are installed and enabled should indicate such, even if they
// are using a deprecated manifest version (since they are either re-enabled by
// the user or are allowed by the admin).
TEST_P(ExtensionInstallStatusTestWithMV2DeprecationEnabled,
       EnabledTakesPriorityOverDeprecatedManifestVersion) {}

// Extensions that are installed and disabled and have a deprecated manifest
// version should indicate they are unsupported due to the manifest version.
// Note, this applies even if they are disabled due to other reasons.
TEST_P(ExtensionInstallStatusTestWithMV2DeprecationEnabled,
       DeprecatedManifestVersionTakesPriorityOverDisabled) {}

}  // namespace extensions