chromium/services/network/public/cpp/ip_address_space_util_unittest.cc

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

#include "services/network/public/cpp/ip_address_space_util.h"

#include "base/command_line.h"
#include "base/test/scoped_feature_list.h"
#include "net/base/ip_address.h"
#include "net/base/ip_endpoint.h"
#include "net/base/transport_info.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/network_switches.h"
#include "services/network/public/mojom/ip_address_space.mojom.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"

namespace network {
namespace {

ContentSecurityPolicy;
IPAddressSpace;
ParsedHeaders;
URLResponseHead;
IPAddress;
IPAddressBytes;
IPEndPoint;
TransportInfo;
TransportType;

IPAddress PublicIPv4Address() {}

IPAddress PrivateIPv4Address() {}

TransportInfo DirectTransport(const IPEndPoint& endpoint) {}

TransportInfo ProxiedTransport(const IPEndPoint& endpoint) {}

TransportInfo MakeTransport(TransportType type, const IPEndPoint& endpoint) {}

IPAddressSpace IPEndPointToIPAddressSpace(const IPEndPoint& endpoint) {}

// Helper for tests that do not care about command-line overrides.
IPAddressSpace IPAddressToIPAddressSpace(const IPAddress& address) {}

// Verifies that the address space of an invalid IP address is `unknown`.
TEST(IPAddressSpaceTest, IPEndPointToIPAddressSpaceInvalid) {}

// Verifies that the address space of a regular IP address is `public`.
TEST(IPAddressSpaceTest, IPEndPointToIPAddressSpaceV4Public) {}

// Verifies that the address space of IP addresses belonging to any of the
// three "Private Use" address blocks defined in RFC 1918 is `private`.
TEST(IPAddressSpaceTest, IPEndPointToIPAddressSpaceV4PrivateUse) {}

// Verifies that the address space of IP addresses belonging to the "Link-local"
// 169.254.0.0/16 block are `private`.
TEST(IPAddressSpaceTest, IPEndPointToIPAddressSpaceV4LinkLocal) {}

// Verifies that the address space of IPv4 localhost and the rest of the
// 127.0.0.0/8 block is `local`.
TEST(IPAddressSpaceTest, IPEndPointToIPAddressSpaceV4Localhost) {}

IPAddress ParseIPAddress(std::string_view str) {}

// Verifies that the address space of a regular IPv6 address is `public`.
TEST(IPAddressSpaceTest, IPEndPointToIPAddressSpaceV6Public) {}

// Verifies that the address space of IPv6 addresses in the "Unique-local"
// (fc00::/7) address block is `private`.
TEST(IPAddressSpaceTest, IPEndPointToIPAddressSpaceV6UniqueLocal) {}

// Verifies that the address space of IPv6 addresses in the "Link-local unicast"
// (fe80::/10) address block is `private`.
TEST(IPAddressSpaceTest, IPEndPointToIPAddressSpaceV6LinkLocalUnicast) {}

// Verifies that the address space of IPv6 localhost (::1/128) is `local`.
TEST(IPAddressSpaceTest, IPEndPointToIPAddressSpaceV6Localhost) {}

// Verifies that IPv4-mapped IPv6 addresses belong to the address space of the
// mapped IPv4 address.
TEST(IPAddressSpaceTest, IPEndPointToAddressSpaceIPv4MappedIPv6) {}

// Verifies that 0.0.0.0/8 is mapped to non-public address spaces.
TEST(IPAddressSpaceTest, IPEndPointToAddressSpaceNullIP) {}

// Verifies that 0.0.0.0/8 is mapped to the public address space if configured
// via feature flag.
TEST(IPAddressSpaceTest, IPEndPointToAddressSpaceNullIPKillSwitch) {}

// Verifies that the `ip-address-space-overrides` switch can be present and
// empty, in which case it is ignored.
TEST(IPAddressSpaceTest, IPEndPointToAddressSpaceOverrideEmpty) {}

// Verifies that a single IPv4 endpoints can be overridden.
TEST(IPAddressSpaceTest, IPEndPointToAddressSpaceOverrideSingle) {}

// Verifies that multiple IPv4 endpoints can be overridden.
TEST(IPAddressSpaceTest, IPEndPointToAddressSpaceOverrideMultiple) {}

// Verifies that invalid entries in the command-line switch comma-separated list
// are simply ignored, and that subsequent entries are still applied.
TEST(IPAddressSpaceTest, IPEndPointToAddressSpaceOverrideInvalid) {}

// Verifies that command-line overrides that overlap with previously-given
// overrides are ignored. In other words, the first matching override is
// applied.
TEST(IPAddressSpaceTest, IPEndPointToAddressSpaceOverrideOverlap) {}

// Verifies that invalid IP addresses are not subject to overrides.
TEST(IPAddressSpaceTest, IPEndPointToAddressSpaceOverrideInvalidAddress) {}

// Verifies that command-line overrides can specify IPv6 addresses.
TEST(IPAddressSpaceTest, IPEndPointToAddressSpaceOverrideV6) {}

TEST(IPAddressSpaceTest, TransportInfoToIPAddressSpaceProxiedIsUnknown) {}

TEST(IPAddressSpaceTest, TransportInfoToIPAddressSpaceProxiedIgnoresOverrides) {}

TEST(IPAddressSpaceTest,
     TransportInfoToIPAddressSpaceCachedFromProxyIsUnknown) {}

TEST(IPAddressSpaceTest,
     TransportInfoToIPAddressSpaceCachedFromProxyIgnoresOverrides) {}

// Verifies that IPv4-mapped IPv6 addresses are not overridden as though they
// were the mapped IPv4 address instead.
TEST(IPAddressSpaceTest, IPEndPointToAddressSpaceOverrideIPv4MappedIPv6) {}

TEST(IPAddressSpaceTest, IsLessPublicAddressSpaceThanLocal) {}

TEST(IPAddressSpaceTest, IsLessPublicAddressSpaceThanPrivate) {}

TEST(IPAddressSpaceTest, IsLessPublicAddressSpaceThanPublic) {}

TEST(IPAddressSpaceTest, IsLessPublicAddressSpaceThanUnknown) {}

TEST(IPAddressSpaceUtilTest, CalculateClientAddressSpaceFileURL) {}

TEST(IPAddressSpaceUtilTest,
     CalculateClientAddressSpaceInheritedFromServiceWorker) {}

TEST(IPAddressSpaceUtilTest, CalculateClientAddressSpaceNullParams) {}

TEST(IPAddressSpaceUtilTest, CalculateClientAddressSpaceEmptyParams) {}

TEST(IPAddressSpaceUtilTest, CalculateClientAddressSpaceIPAddress) {}

TEST(IPAddressSpaceUtilTest, CalculateClientAddressSpaceTreatAsPublicAddress) {}

TEST(IPAddressSpaceTest, CalculateClientAddressSpaceOverride) {}

TEST(IPAddressSpaceTest, CalculateResourceAddressSpaceFileURL) {}

TEST(IPAddressSpaceTest, CalculateResourceAddressSpaceIPAddress) {}

TEST(IPAddressSpaceTest, CalculateResourceAddressSpaceOverride) {}

}  // namespace
}  // namespace network