chromium/chrome/common/extensions/permissions/permission_set_unittest.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include <stddef.h>

#include <memory>
#include <utility>

#include "base/command_line.h"
#include "base/json/json_file_value_serializer.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_test_util.h"
#include "chrome/common/extensions/permissions/chrome_permission_message_provider.h"
#include "chrome/grit/generated_resources.h"
#include "components/version_info/version_info.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/features/feature_channel.h"
#include "extensions/common/permissions/permission_message_provider.h"
#include "extensions/common/permissions/permission_message_test_util.h"
#include "extensions/common/permissions/permission_message_util.h"
#include "extensions/common/permissions/permission_set.h"
#include "extensions/common/permissions/permissions_data.h"
#include "extensions/common/permissions/permissions_info.h"
#include "extensions/common/permissions/socket_permission.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"

LoadManifest;
APIPermissionID;

namespace extensions {

namespace {

static void AddPattern(URLPatternSet* extent, const std::string& pattern) {}

size_t IndexOf(const PermissionMessages& warnings, const std::string& warning) {}

PermissionIDSet MakePermissionIDSet(APIPermissionID id1, APIPermissionID id2) {}

PermissionIDSet MakePermissionIDSet(const APIPermissionSet& permissions) {}

std::string PermissionIDsToString(const PermissionIDSet& ids) {}

std::string CoalescedPermissionIDsToString(const PermissionMessages& msgs) {}

// Check that the given |permissions| produce a single warning message,
// identified by the set of |expected_ids|.
testing::AssertionResult PermissionSetProducesMessage(
    const PermissionSet& permissions,
    Manifest::Type extension_type,
    const PermissionIDSet& expected_ids) {}

}  // namespace

// Tests GetByID.
TEST(PermissionsTest, GetByID) {}

// Tests that GetByName works with normal permission names and aliases.
TEST(PermissionsTest, GetByName) {}

TEST(PermissionsTest, GetAll) {}

TEST(PermissionsTest, GetAllByName) {}

// Tests that the aliases are properly mapped.
TEST(PermissionsTest, Aliases) {}

TEST(PermissionsTest, EffectiveHostPermissions) {}

TEST(PermissionsTest, ExplicitAccessToOrigin) {}

TEST(PermissionsTest, CreateUnion) {}

TEST(PermissionsTest, CreateIntersection) {}

TEST(PermissionsTest, CreateDifference) {}

TEST(PermissionsTest, IsPrivilegeIncrease) {}

// Tests that swapping out a permission for a less powerful one is not
// considered a privilege increase.
// Regression test for https://crbug.com/841938.
TEST(PermissionsTest,
     IsNotPrivilegeIncreaseWhenSwitchingForLowerPrivilegePermission) {}

TEST(PermissionsTest, PermissionMessages) {}

TEST(PermissionsTest, FileSystemPermissionMessages) {}

TEST(PermissionsTest, HiddenFileSystemPermissionMessages) {}

TEST(PermissionsTest, SuppressedPermissionMessages) {}

TEST(PermissionsTest, AccessToDevicesMessages) {}

TEST(PermissionsTest, MergedFileSystemPermissionComparison) {}

TEST(PermissionsTest, GetWarningMessages_ManyHosts) {}

TEST(PermissionsTest, GetWarningMessages_AudioVideo) {}

TEST(PermissionsTest, GetWarningMessages_CombinedSessions) {}

TEST(PermissionsTest, GetWarningMessages_DeclarativeWebRequest) {}

TEST(PermissionsTest, GetWarningMessages_Serial) {}

TEST(PermissionsTest, GetWarningMessages_Socket_AnyHost) {}

TEST(PermissionsTest, GetWarningMessages_Socket_OneDomainTwoHostnames) {}

TEST(PermissionsTest, GetWarningMessages_Socket_TwoDomainsOneHostname) {}

// Since platform apps always use isolated storage, they can't (silently)
// access user data on other domains, so there's no need to prompt about host
// permissions. See crbug.com/255229.
TEST(PermissionsTest, GetWarningMessages_PlatformAppHosts) {}

testing::AssertionResult ShowsAllHostsWarning(const std::string& pattern) {}

TEST(PermissionsTest, GetWarningMessages_TLDWildcardTreatedAsAllHosts) {}

TEST(PermissionsTest, GetDistinctHosts) {}

TEST(PermissionsTest, GetDistinctHosts_ComIsBestRcd) {}

TEST(PermissionsTest, GetDistinctHosts_NetIs2ndBestRcd) {}

TEST(PermissionsTest, GetDistinctHosts_OrgIs3rdBestRcd) {}

TEST(PermissionsTest, GetDistinctHosts_FirstInListIs4thBestRcd) {}

TEST(PermissionsTest, IsHostPrivilegeIncrease) {}

TEST(PermissionsTest, GetAPIsAsStrings) {}

TEST(PermissionsTest, IsEmpty) {}

TEST(PermissionsTest, SyncFileSystemPermission) {}

// Make sure that we don't crash when we're trying to show the permissions
// even though everything with a chrome:// scheme except chrome://favicon is
// not a valid permission.
// More details here: crbug/246314.
TEST(PermissionsTest, ChromeURLs) {}

TEST(PermissionsTest, IsPrivilegeIncrease_DeclarativeWebRequest) {}

// Exercises setting different members in the PermissionSet. Due to varying
// amounts of initialization, these can be non-trivial and have side-effects.
TEST(PermissionsTest, SettingMembers) {}

}  // namespace extensions