chromium/services/network/private_network_access_checker_unittest.cc

// Copyright 2021 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/private_network_access_checker.h"

#include <string_view>

#include "base/strings/strcat.h"
#include "base/test/metrics/histogram_tester.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/resource_request.h"
#include "services/network/public/mojom/client_security_state.mojom-shared.h"
#include "services/network/public/mojom/client_security_state.mojom.h"
#include "services/network/public/mojom/cors.mojom.h"
#include "services/network/public/mojom/ip_address_space.mojom.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"

Optional;

namespace network {
namespace {

Result;

constexpr std::string_view kCheckResultHistogramName =;

constexpr char kNoAcceptChFrame[] =;

// For better readability than literal `nullptr`.
constexpr mojom::ClientSecurityState* kNullClientSecurityState =;

net::IPEndPoint LocalEndpoint() {}

net::IPEndPoint PrivateEndpoint() {}

GURL PrivateEndpointUrl() {}

net::IPEndPoint PublicEndpoint() {}

net::TransportInfo DirectTransport(const net::IPEndPoint& endpoint) {}

net::TransportInfo ProxiedTransport(const net::IPEndPoint& endpoint) {}

net::TransportInfo CachedTransport(const net::IPEndPoint& endpoint) {}

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

TEST(PrivateNetworkAccessCheckerTest, ClientSecurityStateNull) {}

TEST(PrivateNetworkAccessCheckerTest, ClientSecurityStateFromFactory) {}

TEST(PrivateNetworkAccessCheckerTest, ClientSecurityStateFromRequest) {}

TEST(PrivateNetworkAccessCheckerTest, CheckLoadOptionUnknown) {}

TEST(PrivateNetworkAccessCheckerTest, CheckLoadOptionPublic) {}

TEST(PrivateNetworkAccessCheckerTest, CheckLoadOptionPrivate) {}

TEST(PrivateNetworkAccessCheckerTest, CheckLoadOptionLocal) {}

TEST(PrivateNetworkAccessCheckerTest,
     CheckAllowedPotentiallyTrustworthySameOrigin) {}

TEST(PrivateNetworkAccessCheckerTest,
     CheckDisallowedPotentiallyTrustworthyCrossOrigin) {}

TEST(PrivateNetworkAccessCheckerTest, CheckDisallowedUntrustworthySameOrigin) {}

TEST(PrivateNetworkAccessCheckerTest,
     CheckDisallowedPotentiallyTrustworthyCrossOriginAfterResetForRedirect) {}

TEST(PrivateNetworkAccessCheckerTest,
     CheckAllowedPotentiallyTrustworthySameOriginAfterResetForRedirect) {}

TEST(PrivateNetworkAccessCheckerTest, CheckAllowedMissingClientSecurityState) {}

TEST(PrivateNetworkAccessCheckerTest,
     CheckAllowedMissingClientSecurityStateInconsistentIpAddressSpace) {}

TEST(PrivateNetworkAccessCheckerTest, CheckAllowedNoLessPublic) {}

TEST(PrivateNetworkAccessCheckerTest, CheckAllowedByPolicyAllow) {}

TEST(PrivateNetworkAccessCheckerTest,
     CheckAllowedByPolicyWarnInconsistentIpAddressSpace) {}

TEST(PrivateNetworkAccessCheckerTest,
     CheckAllowedByPolicyAllowInconsistentIpAddressSpace) {}

TEST(PrivateNetworkAccessCheckerTest, CheckAllowedByPolicyWarn) {}

TEST(PrivateNetworkAccessCheckerTest, CheckBlockedByPolicyBlock) {}

TEST(PrivateNetworkAccessCheckerTest, CheckBlockedByPolicyPreflightWarn) {}

TEST(PrivateNetworkAccessCheckerTest, CheckBlockedByPolicyPreflightBlock) {}

TEST(PrivateNetworkAccessCheckerTest, CheckBlockedByTargetIpAddressSpace) {}

TEST(PrivateNetworkAccessCheckerTest, CheckAllowedByPolicyPreflightWarn) {}

TEST(PrivateNetworkAccessCheckerTest, CheckAllowedByTargetIpAddressSpace) {}

TEST(PrivateNetworkAccessCheckerTest,
     CheckAllowedByPolicyPreflightWarnInconsistent) {}

TEST(PrivateNetworkAccessCheckerTest,
     CheckBlockedByInconsistentIpAddressSpace) {}

TEST(PrivateNetworkAccessCheckerTest,
     CheckBlockedByUnmatchedRequiredAddressSpaceAndResourceAddressSpace) {}

TEST(PrivateNetworkAccessCheckerTest, ResponseAddressSpace) {}

TEST(PrivateNetworkAccessCheckerTest, ProxiedTransportAddressSpaceIsUnknown) {}

TEST(PrivateNetworkAccessCheckerTest,
     CachedFromProxyTransportAddressSpaceIsUnknown) {}

TEST(PrivateNetworkAccessCheckerTest, CachedTransportAddressSpace) {}

TEST(PrivateNetworkAccessCheckerTest, ResetTargetAddressSpace) {}

TEST(PrivateNetworkAccessCheckerTest, ResetResponseAddressSpace) {}

TEST(PrivateNetworkAccessCheckerTest,
     DoesNotRecordPrivateIpInferrableHistogramForPublicEndpoint) {}

TEST(PrivateNetworkAccessCheckerTest,
     DoesNotRecordPrivateIpInferrableHistogramForHttpsScheme) {}

TEST(PrivateNetworkAccessCheckerTest,
     DoesNotRecordPrivateIpInferrableHistogramWithTargetIpAddressSpace) {}

TEST(PrivateNetworkAccessCheckerTest,
     RecordsPrivateIpInferrableHistogramPolicyAllow) {}

TEST(PrivateNetworkAccessCheckerTest,
     RecordsPrivateIpInferrableHistogramNoLessPublic) {}

TEST(PrivateNetworkAccessCheckerTest, RecordsPrivateIpInferrableHistogramTrue) {}

TEST(PrivateNetworkAccessCheckerTest,
     RecordsPrivateIpInferrableHistogramTrueIpv6) {}

TEST(PrivateNetworkAccessCheckerTest,
     RecordsPrivateIpInferrableHistogramFalse) {}

TEST(PrivateNetworkAccessCheckerTest,
     RecordsPrivateIpInferrableHistogramAfterResetForRetry) {}

TEST(PrivateNetworkAccessCheckerTest,
     RecordsPrivateIpInferrableHistogramAfterResetForRedirect) {}

TEST(PrivateNetworkAccessCheckerTest,
     DoesNotRecordPrivateIpResolveMatchHistogramLocalhost) {}

TEST(PrivateNetworkAccessCheckerTest,
     DoesNotRecordPrivateIpResolveMatchHistogramDomain) {}

TEST(PrivateNetworkAccessCheckerTest,
     DoesNotRecordPrivateIpResolveMatchHistogramProxy) {}

TEST(PrivateNetworkAccessCheckerTest,
     RecordsPrivateIpResolveMatchHistogramFalse) {}

TEST(PrivateNetworkAccessCheckerTest,
     RecordsPrivateIpResolveMatchHistogramTrue) {}

TEST(PrivateNetworkAccessCheckerTest,
     RecordsPrivateIpResolveMatchHistogramTrueIpv6) {}

TEST(PrivateNetworkAccessCheckerTest,
     RecordsPrivateIpResolveMatchHistogramAfterResetForRetry) {}

TEST(PrivateNetworkAccessCheckerTest,
     RecordsPrivateIpResolveMatchHistogramAfterResetForRedirect) {}

}  // namespace
}  // namespace network