#ifdef UNSAFE_BUFFERS_BUILD
#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) { … }
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) { … }
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_F(IndexedResponseHeaderRuleTest, MatchingResponseHeaders) { … }
TEST_F(IndexedResponseHeaderRuleTest, MatchingResponseHeaders_ModifyHeaders) { … }
class IndexedHeaderSubstitutionRuleTest : public IndexedRuleTest { … };
TEST_F(IndexedHeaderSubstitutionRuleTest,
ModifyHeaderInfoRegexFilterAndSubstitutionParsing) { … }
}
}