chromium/net/network_error_logging/network_error_logging_service_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 <memory>
#include <string>
#include <vector>

#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/strings/stringprintf.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_clock.h"
#include "base/test/values_test_util.h"
#include "base/time/time.h"
#include "base/values.h"
#include "net/base/features.h"
#include "net/base/ip_address.h"
#include "net/base/net_errors.h"
#include "net/base/network_anonymization_key.h"
#include "net/base/schemeful_site.h"
#include "net/network_error_logging/mock_persistent_nel_store.h"
#include "net/network_error_logging/network_error_logging_service.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 {

// The tests are parametrized on a boolean value which represents whether or not
// to use a MockPersistentNelStore.
// If a MockPersistentNelStore is used, then calls to
// NetworkErrorLoggingService::OnHeader(), OnRequest(),
// QueueSignedExchangeReport(), RemoveBrowsingData(), and
// RemoveAllBrowsingData() will block until the store finishes loading.
// Therefore, for tests that should run synchronously (i.e. tests that don't
// specifically test the asynchronous/deferred task behavior), FinishLoading()
// must be called after the first call to one of the above methods.
class NetworkErrorLoggingServiceTest : public ::testing::TestWithParam<bool> {};

void ExpectDictDoubleValue(double expected_value,
                           const base::Value::Dict& value,
                           const std::string& key) {}

TEST_P(NetworkErrorLoggingServiceTest, CreateService) {}

TEST_P(NetworkErrorLoggingServiceTest, NoReportingService) {}

TEST_P(NetworkErrorLoggingServiceTest, NoPolicy) {}

TEST_P(NetworkErrorLoggingServiceTest, PolicyKeyMatchesNakAndOrigin) {}

TEST_P(NetworkErrorLoggingServiceTest,
       PolicyKeyMatchesNakAndOriginIncludeSubdomains) {}

TEST_P(NetworkErrorLoggingServiceTest,
       PolicyKeyMatchesNakAndOriginIncludeSubdomainsAndSuccess) {}

TEST_P(NetworkErrorLoggingServiceTest, NetworkAnonymizationKeyDisabled) {}

TEST_P(NetworkErrorLoggingServiceTest, JsonTooLong) {}

TEST_P(NetworkErrorLoggingServiceTest, JsonTooDeep) {}

TEST_P(NetworkErrorLoggingServiceTest, IncludeSubdomainsEtldRejected) {}

TEST_P(NetworkErrorLoggingServiceTest, NonIncludeSubdomainsEtldAccepted) {}

TEST_P(NetworkErrorLoggingServiceTest, SuccessReportQueued) {}

TEST_P(NetworkErrorLoggingServiceTest, FailureReportQueued) {}

TEST_P(NetworkErrorLoggingServiceTest, UnknownFailureReportQueued) {}

TEST_P(NetworkErrorLoggingServiceTest, UnknownCertFailureReportQueued) {}

TEST_P(NetworkErrorLoggingServiceTest, HttpErrorReportQueued) {}

TEST_P(NetworkErrorLoggingServiceTest, SuccessReportDowngraded) {}

TEST_P(NetworkErrorLoggingServiceTest, FailureReportDowngraded) {}

TEST_P(NetworkErrorLoggingServiceTest, HttpErrorReportDowngraded) {}

TEST_P(NetworkErrorLoggingServiceTest, DNSFailureReportNotDowngraded) {}

TEST_P(NetworkErrorLoggingServiceTest, SuccessPOSTReportQueued) {}

TEST_P(NetworkErrorLoggingServiceTest, MaxAge0) {}

TEST_P(NetworkErrorLoggingServiceTest, SuccessFraction0) {}

TEST_P(NetworkErrorLoggingServiceTest, SuccessFractionHalf) {}

TEST_P(NetworkErrorLoggingServiceTest, FailureFraction0) {}

TEST_P(NetworkErrorLoggingServiceTest, FailureFractionHalf) {}

TEST_P(NetworkErrorLoggingServiceTest,
       ExcludeSubdomainsDoesntMatchDifferentPort) {}

TEST_P(NetworkErrorLoggingServiceTest, ExcludeSubdomainsDoesntMatchSubdomain) {}

TEST_P(NetworkErrorLoggingServiceTest, IncludeSubdomainsMatchesDifferentPort) {}

TEST_P(NetworkErrorLoggingServiceTest, IncludeSubdomainsMatchesSubdomain) {}

TEST_P(NetworkErrorLoggingServiceTest,
       IncludeSubdomainsDoesntMatchSuperdomain) {}

TEST_P(NetworkErrorLoggingServiceTest,
       IncludeSubdomainsDoesntReportConnectionError) {}

TEST_P(NetworkErrorLoggingServiceTest,
       IncludeSubdomainsDoesntReportApplicationError) {}

TEST_P(NetworkErrorLoggingServiceTest, IncludeSubdomainsDoesntReportSuccess) {}

TEST_P(NetworkErrorLoggingServiceTest,
       IncludeSubdomainsReportsSameOriginSuccess) {}

TEST_P(NetworkErrorLoggingServiceTest, RemoveAllBrowsingData) {}

TEST_P(NetworkErrorLoggingServiceTest, RemoveSomeBrowsingData) {}

TEST_P(NetworkErrorLoggingServiceTest, Nested) {}

TEST_P(NetworkErrorLoggingServiceTest, NestedTooDeep) {}

TEST_P(NetworkErrorLoggingServiceTest, StatusAsValue) {}

TEST_P(NetworkErrorLoggingServiceTest, InvalidHeaderData) {}

TEST_P(NetworkErrorLoggingServiceTest, NoReportingService_SignedExchange) {}

TEST_P(NetworkErrorLoggingServiceTest, NoPolicyForOrigin_SignedExchange) {}

TEST_P(NetworkErrorLoggingServiceTest, SuccessFraction0_SignedExchange) {}

TEST_P(NetworkErrorLoggingServiceTest, SuccessReportQueued_SignedExchange) {}

TEST_P(NetworkErrorLoggingServiceTest, FailureReportQueued_SignedExchange) {}

TEST_P(NetworkErrorLoggingServiceTest, MismatchingSubdomain_SignedExchange) {}

TEST_P(NetworkErrorLoggingServiceTest, MismatchingIPAddress_SignedExchange) {}

TEST_P(NetworkErrorLoggingServiceTest,
       SignedExchangeNetworkAnonymizationKeyDisabled) {}

// When the max number of policies is exceeded, first try to remove expired
// policies before evicting the least recently used unexpired policy.
TEST_P(NetworkErrorLoggingServiceTest, EvictAllExpiredPoliciesFirst) {}

TEST_P(NetworkErrorLoggingServiceTest, EvictLeastRecentlyUsedPolicy) {}

TEST_P(NetworkErrorLoggingServiceTest, SendsCommandsToStoreSynchronous) {}

TEST_P(NetworkErrorLoggingServiceTest, DuplicateEntriesInStore) {}

// Same as the above test, except that all the tasks are queued until loading
// is complete.
TEST_P(NetworkErrorLoggingServiceTest, SendsCommandsToStoreDeferred) {}

// These two tests check that if loading fails, the commands should still
// be sent to the store; the actual store impl will just ignore them.
TEST_P(NetworkErrorLoggingServiceTest,
       SendsCommandsToStoreSynchronousLoadFailed) {}

TEST_P(NetworkErrorLoggingServiceTest, SendsCommandsToStoreDeferredLoadFailed) {}

TEST_P(NetworkErrorLoggingServiceTest, FlushesStoreOnDestruction) {}

TEST_P(NetworkErrorLoggingServiceTest,
       DoesntFlushStoreOnDestructionBeforeLoad) {}

TEST_P(NetworkErrorLoggingServiceTest, DoNothingIfShutDown) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace
}  // namespace net