chromium/components/domain_reliability/monitor_unittest.cc

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

#include "components/domain_reliability/monitor.h"

#include <stddef.h>

#include <map>
#include <memory>
#include <string>
#include <string_view>
#include <utility>
#include <vector>

#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "components/domain_reliability/baked_in_configs.h"
#include "components/domain_reliability/beacon.h"
#include "components/domain_reliability/config.h"
#include "components/domain_reliability/features.h"
#include "components/domain_reliability/google_configs.h"
#include "components/domain_reliability/test_util.h"
#include "net/base/isolation_info.h"
#include "net/base/load_timing_info.h"
#include "net/base/net_errors.h"
#include "net/base/network_anonymization_key.h"
#include "net/base/proxy_chain.h"
#include "net/base/request_priority.h"
#include "net/http/http_connection_info.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_response_info.h"
#include "net/http/http_util.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/gtest_util.h"
#include "net/third_party/quiche/src/quiche/quic/core/quic_error_codes.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
#include "net/url_request/url_request_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace domain_reliability {

namespace {

BeaconVector;

const char kBeaconOutcomeHistogram[] =;

scoped_refptr<net::HttpResponseHeaders> MakeHttpResponseHeaders(
    std::string_view headers) {}

size_t CountQueuedBeacons(const DomainReliabilityContext* context) {}

}  // namespace

class DomainReliabilityMonitorTest : public testing::Test {};

namespace {

TEST_F(DomainReliabilityMonitorTest, Create) {}

TEST_F(DomainReliabilityMonitorTest, NoContext) {}

TEST_F(DomainReliabilityMonitorTest, NetworkFailure) {}

TEST_F(DomainReliabilityMonitorTest, GoAwayWithPortMigrationDetected) {}

TEST_F(DomainReliabilityMonitorTest, ServerFailure) {}

// Make sure the monitor does not log requests that did not access the network.
TEST_F(DomainReliabilityMonitorTest, DidNotAccessNetwork) {}

// Make sure the monitor does not log requests that don't send credentials.
TEST_F(DomainReliabilityMonitorTest, DoNotSendCookies) {}

// Make sure the monitor does not log a network-local error.
TEST_F(DomainReliabilityMonitorTest, LocalError) {}

// Make sure the monitor does not log the proxy's IP if one was used.
TEST_F(DomainReliabilityMonitorTest, WasFetchedViaProxy) {}

// Make sure the monitor does not log the cached IP returned after a successful
// cache revalidation request.
TEST_F(DomainReliabilityMonitorTest,
       NoCachedIPFromSuccessfulRevalidationRequest) {}

// Make sure the monitor does not log the cached IP returned with a failed
// cache revalidation request.
TEST_F(DomainReliabilityMonitorTest, NoCachedIPFromFailedRevalidationRequest) {}

// Make sure the monitor does log uploads, even when credentials are not
// allowed.
TEST_F(DomainReliabilityMonitorTest, Upload) {}

// Make sure NetworkAnonymizationKey is populated in the beacon, or not,
// depending on features::kPartitionDomainReliabilityByNetworkIsolationKey.
TEST_F(DomainReliabilityMonitorTest, NetworkAnonymizationKey) {}

// Will fail when baked-in configs expire, as a reminder to update them.
// (File a bug in Internals>Network>ReportingAndNEL if this starts failing.)
TEST_F(DomainReliabilityMonitorTest, BakedInAndGoogleConfigs) {}

// Test that Google configs are created only when needed.
TEST_F(DomainReliabilityMonitorTest, GoogleConfigOnDemand) {}

TEST_F(DomainReliabilityMonitorTest, ClearBeacons) {}

TEST_F(DomainReliabilityMonitorTest, ClearBeaconsWithFilter) {}

TEST_F(DomainReliabilityMonitorTest, ClearContexts) {}

TEST_F(DomainReliabilityMonitorTest, ClearContextsWithFilter) {}

TEST_F(DomainReliabilityMonitorTest, WildcardMatchesSelf) {}

TEST_F(DomainReliabilityMonitorTest, WildcardMatchesSubdomain) {}

TEST_F(DomainReliabilityMonitorTest, WildcardDoesntMatchSubsubdomain) {}

TEST_F(DomainReliabilityMonitorTest, WildcardPrefersSelfToParentWildcard) {}

TEST_F(DomainReliabilityMonitorTest,
    WildcardPrefersSelfWildcardToParentWildcard) {}

// Uses a real request, to make sure CreateBeaconFromAttempt() works as
// expected.
TEST_F(DomainReliabilityMonitorTest, RealRequest) {}

}  // namespace

}  // namespace domain_reliability