chromium/extensions/browser/api/declarative_net_request/indexed_rule_unittest.cc

// Copyright 2017 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/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "extensions/browser/api/declarative_net_request/indexed_rule.h"

#include <memory>
#include <optional>
#include <utility>

#include "base/containers/flat_set.h"
#include "base/format_macros.h"
#include "base/numerics/safe_conversions.h"
#include "base/ranges/algorithm.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/values_test_util.h"
#include "components/version_info/channel.h"
#include "extensions/browser/api/declarative_net_request/constants.h"
#include "extensions/browser/api/declarative_net_request/test_utils.h"
#include "extensions/common/api/declarative_net_request.h"
#include "extensions/common/api/declarative_net_request/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_features.h"
#include "extensions/common/features/feature_channel.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace extensions::declarative_net_request {
namespace {

flat_rule;
dnr_api;

constexpr const char* kTestExtensionId =;

GURL GetBaseURL() {}

dnr_api::Redirect MakeRedirectUrl(const char* redirect_url) {}

dnr_api::Rule CreateGenericParsedRule() {}

dnr_api::HeaderInfo CreateHeaderInfo(
    std::string header,
    std::optional<std::vector<std::string>> values,
    std::optional<std::vector<std::string>> excluded_values) {}

IndexedRuleTest;

TEST_F(IndexedRuleTest, IDParsing) {}

TEST_F(IndexedRuleTest, PriorityParsing) {}

TEST_F(IndexedRuleTest, OptionsParsing) {}

TEST_F(IndexedRuleTest, ResourceTypesParsing) {}

TEST_F(IndexedRuleTest, UrlFilterParsing) {}

// Ensure case-insensitive patterns are lower-cased as required by
// url_pattern_index.
TEST_F(IndexedRuleTest, CaseInsensitiveLowerCased) {}

TEST_F(IndexedRuleTest, DomainsParsing) {}

TEST_F(IndexedRuleTest, RedirectUrlParsing) {}

TEST_F(IndexedRuleTest, RedirectParsing) {}

TEST_F(IndexedRuleTest, RegexFilterParsing) {}

TEST_F(IndexedRuleTest, MultipleFiltersSpecified) {}

TEST_F(IndexedRuleTest, RegexSubstitutionParsing) {}

// Tests the parsing behavior when multiple keys in "Redirect" dictionary are
// specified.
TEST_F(IndexedRuleTest, MultipleRedirectKeys) {}

TEST_F(IndexedRuleTest, InvalidAllowAllRequestsResourceType) {}

TEST_F(IndexedRuleTest, ModifyHeadersParsing) {}

TEST_F(IndexedRuleTest, RequestMethodsParsing) {}

TEST_F(IndexedRuleTest, TabID) {}

class IndexedResponseHeaderRuleTest : public IndexedRuleTest {};

// Test the validation of rules that specify response header matching
// conditions.
TEST_F(IndexedResponseHeaderRuleTest, MatchingResponseHeaders) {}

// Test that response header matching rules may only modify response headers.
TEST_F(IndexedResponseHeaderRuleTest, MatchingResponseHeaders_ModifyHeaders) {}

class IndexedHeaderSubstitutionRuleTest : public IndexedRuleTest {};

// Test parsing for regex filters and substitutions inside ModifyHeaderInfo.
TEST_F(IndexedHeaderSubstitutionRuleTest,
       ModifyHeaderInfoRegexFilterAndSubstitutionParsing) {}

}  // namespace
}  // namespace extensions::declarative_net_request