chromium/net/reporting/reporting_header_parser_unittest.cc

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

#include "net/reporting/reporting_header_parser.h"

#include <optional>
#include <sstream>
#include <string>
#include <vector>

#include "base/functional/bind.h"
#include "base/json/json_reader.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/time/time.h"
#include "base/values.h"
#include "net/base/features.h"
#include "net/base/isolation_info.h"
#include "net/base/network_anonymization_key.h"
#include "net/base/schemeful_site.h"
#include "net/reporting/mock_persistent_reporting_store.h"
#include "net/reporting/reporting_cache.h"
#include "net/reporting/reporting_endpoint.h"
#include "net/reporting/reporting_target_type.h"
#include "net/reporting/reporting_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace net {
namespace {

CommandType;
Dictionary;

constexpr char kReportingHeaderTypeHistogram[] =;

class ReportingHeaderParserTestBase
    : public ReportingTestBase,
      public ::testing::WithParamInterface<bool> {};

// This test is parametrized on a boolean that represents whether to use a
// MockPersistentReportingStore.
class ReportingHeaderParserTest : public ReportingHeaderParserTestBase {};

// TODO(juliatuttle): Ideally these tests should be expecting that JSON parsing
// (and therefore header parsing) may happen asynchronously, but the entire
// pipeline is also tested by NetworkErrorLoggingEndToEndTest.

TEST_P(ReportingHeaderParserTest, Invalid) {}

TEST_P(ReportingHeaderParserTest, Basic) {}

TEST_P(ReportingHeaderParserTest, PathAbsoluteURLEndpoint) {}

TEST_P(ReportingHeaderParserTest, OmittedGroupName) {}

TEST_P(ReportingHeaderParserTest, IncludeSubdomainsTrue) {}

TEST_P(ReportingHeaderParserTest, IncludeSubdomainsFalse) {}

TEST_P(ReportingHeaderParserTest, IncludeSubdomainsEtldRejected) {}

TEST_P(ReportingHeaderParserTest, NonIncludeSubdomainsEtldAccepted) {}

TEST_P(ReportingHeaderParserTest, IncludeSubdomainsNotBoolean) {}

TEST_P(ReportingHeaderParserTest, NonDefaultPriority) {}

TEST_P(ReportingHeaderParserTest, NonDefaultWeight) {}

TEST_P(ReportingHeaderParserTest, MaxAge) {}

TEST_P(ReportingHeaderParserTest, MultipleEndpointsSameGroup) {}

TEST_P(ReportingHeaderParserTest, MultipleEndpointsDifferentGroups) {}

TEST_P(ReportingHeaderParserTest, MultipleHeadersFromDifferentOrigins) {}

// Test that each combination of NAK, origin, and group name is considered
// distinct.
// See also: ReportingCacheTest.ClientsKeyedByEndpointGroupKey
TEST_P(ReportingHeaderParserTest, EndpointGroupKey) {}

TEST_P(ReportingHeaderParserTest,
       HeaderErroneouslyContainsMultipleGroupsOfSameName) {}

TEST_P(ReportingHeaderParserTest,
       HeaderErroneouslyContainsGroupsWithRedundantEndpoints) {}

TEST_P(ReportingHeaderParserTest,
       HeaderErroneouslyContainsMultipleGroupsOfSameNameAndEndpoints) {}

TEST_P(ReportingHeaderParserTest,
       HeaderErroneouslyContainsGroupsOfSameNameAndOverlappingEndpoints) {}

TEST_P(ReportingHeaderParserTest, OverwriteOldHeader) {}

TEST_P(ReportingHeaderParserTest, OverwriteOldHeaderWithCompletelyNew) {}

TEST_P(ReportingHeaderParserTest, ZeroMaxAgeRemovesEndpointGroup) {}

// Invalid advertisements that parse as JSON should remove an endpoint group,
// while those that don't are ignored.
TEST_P(ReportingHeaderParserTest, InvalidAdvertisementRemovesEndpointGroup) {}

TEST_P(ReportingHeaderParserTest, EvictEndpointsOverPerOriginLimit1) {}

TEST_P(ReportingHeaderParserTest, EvictEndpointsOverPerOriginLimit2) {}

TEST_P(ReportingHeaderParserTest, EvictEndpointsOverGlobalLimit) {}

INSTANTIATE_TEST_SUITE_P();

// This test is parametrized on a boolean that represents whether to use a
// MockPersistentReportingStore.
class ReportingHeaderParserStructuredHeaderTest
    : public ReportingHeaderParserTestBase {};

TEST_P(ReportingHeaderParserStructuredHeaderTest, ParseInvalid) {}

TEST_P(ReportingHeaderParserStructuredHeaderTest, ProcessInvalid) {}

TEST_P(ReportingHeaderParserStructuredHeaderTest, ParseBasic) {}

TEST_P(ReportingHeaderParserStructuredHeaderTest, Basic) {}

TEST_P(ReportingHeaderParserStructuredHeaderTest, PathAbsoluteURLEndpoint) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace
}  // namespace net