#include "net/extras/sqlite/sqlite_persistent_reporting_and_nel_store.h"
#include <memory>
#include <vector>
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_clock.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "net/base/features.h"
#include "net/base/network_anonymization_key.h"
#include "net/network_error_logging/network_error_logging_service.h"
#include "net/reporting/reporting_target_type.h"
#include "net/reporting/reporting_test_util.h"
#include "net/test/test_with_task_environment.h"
#include "sql/database.h"
#include "sql/meta_table.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace net {
namespace {
const base::FilePath::CharType kReportingAndNELStoreFilename[] = …);
const IPAddress kServerIP = …;
const std::string kHeader = …;
const std::string kHeaderMaxAge0 = …;
const std::string kGroupName1 = …;
const std::string kGroupName2 = …;
const base::Time kExpires = …;
enum class Op { … };
struct TestCase { … };
const std::vector<TestCase> kCoalescingTestcases = …;
const std::vector<TestCase> kCoalescingTestcasesForUpdateDetails = …;
}
class SQLitePersistentReportingAndNelStoreTest
: public TestWithTaskEnvironment { … };
TEST_F(SQLitePersistentReportingAndNelStoreTest, CreateDBAndTables) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest, TestInvalidMetaTableRecovery) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest, PersistNelPolicy) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest, LoadFailed) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest, UpdateNelPolicyAccessTime) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest, DeleteNelPolicy) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest,
NelPolicyUniquenessConstraint) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest, CoalesceNelPolicyOperations) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest,
DontCoalesceUnrelatedNelPolicies) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest,
DontPersistNelPoliciesWithTransientNetworkAnonymizationKeys) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest,
NelPoliciesRestoredWithNetworkAnonymizationKeysDisabled) { … }
class SQLitePersistNelTest : public SQLitePersistentReportingAndNelStoreTest { … };
TEST_F(SQLitePersistNelTest, AddAndRetrieveNelPolicy) { … }
TEST_F(SQLitePersistNelTest, AddAndDeleteNelPolicy) { … }
TEST_F(SQLitePersistNelTest, ExpirationTimeIsPersisted) { … }
TEST_F(SQLitePersistNelTest, OnRequestUpdatesAccessTime) { … }
TEST_F(SQLitePersistNelTest, RemoveSomeBrowsingData) { … }
TEST_F(SQLitePersistNelTest, RemoveAllBrowsingData) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest, PersistReportingClients) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest,
UpdateReportingEndpointGroupAccessTime) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest,
UpdateReportingEndpointDetails) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest,
UpdateReportingEndpointGroupDetails) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest, DeleteReportingEndpoint) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest, DeleteReportingEndpointGroup) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest,
ReportingEndpointUniquenessConstraint) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest,
ReportingEndpointGroupUniquenessConstraint) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest,
CoalesceReportingEndpointOperations) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest,
DontCoalesceUnrelatedReportingEndpoints) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest,
CoalesceReportingEndpointGroupOperations) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest,
DontCoalesceUnrelatedReportingEndpointGroups) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest,
DontPersistReportingEndpointsWithTransientNetworkAnonymizationKeys) { … }
TEST_F(
SQLitePersistentReportingAndNelStoreTest,
DontPersistReportingEndpointGroupsWithTransientNetworkAnonymizationKeys) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest,
ReportingEndpointsRestoredWithNetworkAnonymizationKeysDisabled) { … }
TEST_F(SQLitePersistentReportingAndNelStoreTest,
ReportingEndpointGroupsRestoredWithNetworkAnonymizationKeysDisabled) { … }
}