#include "components/safe_browsing/core/browser/db/v4_local_database_manager.h"
#include <utility>
#include "base/command_line.h"
#include "base/containers/fixed_flat_map.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/run_loop.h"
#include "base/strings/string_tokenizer.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_command_line.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "base/test/test_simple_task_runner.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "components/safe_browsing/core/browser/db/v4_database.h"
#include "components/safe_browsing/core/browser/db/v4_protocol_manager_util.h"
#include "components/safe_browsing/core/browser/db/v4_test_util.h"
#include "components/safe_browsing/core/common/features.h"
#include "crypto/sha2.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/platform_test.h"
namespace safe_browsing {
using enum ExtendedReportingLevel;
namespace {
FullHashInfos;
FullHashStr HashForUrl(const GURL& url) { … }
const int kDefaultStoreFileSizeInBytes = …;
class FakeGetHashProtocolManager : public V4GetHashProtocolManager { … };
class FakeGetHashProtocolManagerFactory
: public V4GetHashProtocolManagerFactory { … };
class ScopedFakeGetHashProtocolManagerFactory { … };
}
class GetHashProtocolManagerFactoryWithTestUrlLoader
: public V4GetHashProtocolManagerFactory { … };
class ScopedGetHashProtocolManagerFactoryWithTestUrlLoader { … };
class FakeV4Database : public V4Database { … };
class TestClient : public SafeBrowsingDatabaseManager::Client { … };
class TestAllowlistClient : public SafeBrowsingDatabaseManager::Client { … };
class TestExtensionClient : public SafeBrowsingDatabaseManager::Client { … };
class FakeV4LocalDatabaseManager : public V4LocalDatabaseManager { … };
class V4LocalDatabaseManagerTest : public PlatformTest { … };
TEST_F(V4LocalDatabaseManagerTest, TestGetThreatSource) { … }
TEST_F(V4LocalDatabaseManagerTest, TestCanCheckUrl) { … }
TEST_F(V4LocalDatabaseManagerTest,
TestCheckBrowseUrlWithEmptyStoresReturnsNoMatch) { … }
TEST_F(V4LocalDatabaseManagerTest, TestCheckBrowseUrlWithFakeDbReturnsMatch) { … }
TEST_F(V4LocalDatabaseManagerTest, TestCheckCsdAllowlistWithPrefixMatch) { … }
TEST_F(V4LocalDatabaseManagerTest,
TestCheckCsdAllowlistWithPrefixTheFullMatch) { … }
TEST_F(V4LocalDatabaseManagerTest, TestCheckCsdAllowlistWithFullMatch) { … }
TEST_F(V4LocalDatabaseManagerTest, TestCheckCsdAllowlistWithNoMatch) { … }
TEST_F(V4LocalDatabaseManagerTest, TestCheckCsdAllowlistUnavailable) { … }
TEST_F(V4LocalDatabaseManagerTest,
TestCheckBrowseUrlReturnsNoMatchWhenDisabled) { … }
TEST_F(V4LocalDatabaseManagerTest,
TestCheckUrlForHCAllowlistWithPrefixMatchButNoLocalFullHashMatch) { … }
TEST_F(V4LocalDatabaseManagerTest,
TestCheckUrlForHCAllowlistWithLocalFullHashMatch) { … }
TEST_F(V4LocalDatabaseManagerTest, TestCheckUrlForHCAllowlistWithNoMatch) { … }
TEST_F(V4LocalDatabaseManagerTest, TestCheckUrlForHCAllowlistUnavailable) { … }
TEST_F(V4LocalDatabaseManagerTest, TestCheckUrlForHCAllowlistAfterStopping) { … }
TEST_F(V4LocalDatabaseManagerTest, TestCheckUrlForHCAllowlistSmallSize) { … }
TEST_F(V4LocalDatabaseManagerTest,
TestCheckUrlForHCAllowlistSkippedViaCommandLineSwitch) { … }
TEST_F(V4LocalDatabaseManagerTest, TestGetSeverestThreatTypeAndMetadata) { … }
TEST_F(V4LocalDatabaseManagerTest, TestChecksAreQueued) { … }
TEST_F(V4LocalDatabaseManagerTest, CancelWhileQueued) { … }
TEST_F(V4LocalDatabaseManagerTest, CancelPending) { … }
TEST_F(V4LocalDatabaseManagerTest, CancelQueued) { … }
TEST_F(V4LocalDatabaseManagerTest, QueuedCheckWithFullHash) { … }
TEST_F(V4LocalDatabaseManagerTest, PerformFullHashCheckCalledAsync) { … }
TEST_F(V4LocalDatabaseManagerTest, UsingWeakPtrDropsCallback) { … }
TEST_F(V4LocalDatabaseManagerTest, TestMatchDownloadAllowlistUrl) { … }
TEST_F(V4LocalDatabaseManagerTest, TestCheckBrowseUrlWithSameClientAndCancel) { … }
TEST_F(V4LocalDatabaseManagerTest, TestSubresourceFilterCallback) { … }
TEST_F(V4LocalDatabaseManagerTest, TestCheckExtensionIDsNothingBlocklisted) { … }
TEST_F(V4LocalDatabaseManagerTest, TestCheckExtensionIDsOneIsBlocklisted) { … }
TEST_F(V4LocalDatabaseManagerTest,
TestCheckExtensionIDsOneIsBlocklisted_RealProtocolManager) { … }
TEST_F(V4LocalDatabaseManagerTest, TestCheckDownloadUrlNothingBlocklisted) { … }
TEST_F(V4LocalDatabaseManagerTest, TestCheckDownloadUrlWithOneBlocklisted) { … }
TEST_F(V4LocalDatabaseManagerTest, NotificationOnUpdate) { … }
TEST_F(V4LocalDatabaseManagerTest, FlagOneUrlAsPhishing) { … }
TEST_F(V4LocalDatabaseManagerTest, FlagOneUrlAsMalware) { … }
TEST_F(V4LocalDatabaseManagerTest, FlagOneUrlAsUWS) { … }
TEST_F(V4LocalDatabaseManagerTest, FlagMultipleUrls) { … }
TEST_F(V4LocalDatabaseManagerTest, SyncedLists) { … }
TEST_F(V4LocalDatabaseManagerTest, TestQueuedChecksMatchArtificialPrefixes) { … }
}