chromium/net/proxy_resolution/proxy_bypass_rules_unittest.cc

// Copyright 2010 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/40284755): Remove this and spanify to fix the errors.
#pragma allow_unsafe_buffers
#endif

#include "net/proxy_resolution/proxy_bypass_rules.h"

#include "base/strings/string_util.h"
#include "build/build_config.h"
#include "net/proxy_resolution/proxy_config_service_common_unittest.h"
#include "testing/gtest/include/gtest/gtest.h"

#if BUILDFLAG(IS_WIN)
// On Windows, "loopback" resolves to localhost and is implicitly bypassed to
// match WinInet.
#define BYPASS_LOOPBACK
#endif

namespace net {

namespace {

// Calls |rules.Matches()| for each name in |hosts| (for various URL schemes),
// and checks that the result is |bypasses|. If the host is in |inverted_hosts|
// then the expectation is reversed.
void ExpectRulesMatch(const ProxyBypassRules& rules,
                      const char* hosts[],
                      size_t num_hosts,
                      bool bypasses,
                      const std::set<std::string>& inverted_hosts) {}

// Tests calling |rules.Matches()| for localhost URLs returns |bypasses|.
void ExpectBypassLocalhost(
    const ProxyBypassRules& rules,
    bool bypasses,
    const std::set<std::string>& inverted_hosts = std::set<std::string>()) {}

// Tests calling |rules.Matches()| for link-local URLs returns |bypasses|.
void ExpectBypassLinkLocal(const ProxyBypassRules& rules, bool bypasses) {}

// Tests calling |rules.Matches()| with miscelaneous URLs that are neither
// localhost or link local IPs, returns |bypasses|.
void ExpectBypassMisc(
    const ProxyBypassRules& rules,
    bool bypasses,
    const std::set<std::string>& inverted_hosts = std::set<std::string>()) {}

TEST(ProxyBypassRulesTest, ParseAndMatchBasicHost) {}

TEST(ProxyBypassRulesTest, ParseAndMatchBasicDomain) {}

TEST(ProxyBypassRulesTest, ParseAndMatchBasicDomainWithPort) {}

TEST(ProxyBypassRulesTest, MatchAll) {}

TEST(ProxyBypassRulesTest, WildcardAtStart) {}

// Tests a codepath that parses hostnamepattern:port, where "port" is invalid
// by containing a leading plus.
TEST(ProxyBypassRulesTest, ParseInvalidPort) {}

TEST(ProxyBypassRulesTest, IPV4Address) {}

TEST(ProxyBypassRulesTest, IPV4AddressWithPort) {}

TEST(ProxyBypassRulesTest, IPV6Address) {}

TEST(ProxyBypassRulesTest, IPV6AddressWithPort) {}

TEST(ProxyBypassRulesTest, HTTPOnly) {}

TEST(ProxyBypassRulesTest, HTTPOnlyWithWildcard) {}

TEST(ProxyBypassRulesTest, DoesNotUseSuffixMatching) {}

TEST(ProxyBypassRulesTest, MultipleRules) {}

TEST(ProxyBypassRulesTest, BadInputs) {}

TEST(ProxyBypassRulesTest, Equals) {}

TEST(ProxyBypassRulesTest, BypassSimpleHostnames) {}

TEST(ProxyBypassRulesTest, ParseAndMatchCIDR_IPv4) {}

TEST(ProxyBypassRulesTest, ParseAndMatchCIDR_IPv6) {}

// Test that parsing an IPv6 range given a bracketed literal is not supported.
// Whether IPv6 literals need to be bracketed or not is pretty much a coin toss
// depending on the context, and here it is expected to be unbracketed to match
// macOS. It would be fine to support bracketed too, however none of the
// grammars we parse need that.
TEST(ProxyBypassRulesTest, ParseBracketedIPv6Range) {}

// Check which URLs an empty ProxyBypassRules matches.
TEST(ProxyBypassRulesTest, DefaultImplicitRules) {}

// Test use of the <-loopback> bypass rule.
TEST(ProxyBypassRulesTest, NegativeWinLoopback) {}

// Verifies the evaluation order of mixing negative and positive rules. This
// expectation comes from WinInet (which is where <-loopback> comes from).
TEST(ProxyBypassRulesTest, RemoveImplicitAndAddLocalhost) {}

// Verifies the evaluation order of mixing negative and positive rules. This
// expectation comes from WinInet (which is where <-loopback> comes from).
TEST(ProxyBypassRulesTest, AddLocalhostThenRemoveImplicit) {}

TEST(ProxyBypassRulesTest, AddRulesToSubtractImplicit) {}

TEST(ProxyBypassRulesTest, GetRulesToSubtractImplicit) {}

// Verifies that the <local> and <-loopback> rules can be specified in any
// case. This matches how WinInet's parses them.
TEST(ProxyBypassRulesTest, LoopbackAndLocalCaseInsensitive) {}

}  // namespace

}  // namespace net