chromium/components/safe_browsing/core/browser/safe_browsing_url_checker_impl_unittest.cc

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

#include "components/safe_browsing/core/browser/safe_browsing_url_checker_impl.h"
#include <memory>

#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/mock_callback.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/timer/mock_timer.h"
#include "components/safe_browsing/core/browser/db/test_database_manager.h"
#include "components/safe_browsing/core/browser/db/v4_protocol_manager_util.h"
#include "components/safe_browsing/core/browser/realtime/fake_url_lookup_service.h"
#include "components/safe_browsing/core/browser/realtime/url_lookup_service.h"
#include "components/safe_browsing/core/browser/safe_browsing_token_fetcher.h"
#include "components/safe_browsing/core/browser/url_checker_delegate.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/safe_browsing/core/common/hashprefix_realtime/hash_realtime_utils.h"
#include "components/safe_browsing/core/common/proto/csd.pb.h"
#include "components/security_interstitials/core/unsafe_resource.h"
#include "components/sessions/core/session_id.h"
#include "net/http/http_request_headers.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"

UnsafeResource;
_;

namespace safe_browsing {

namespace {

constexpr char kAllowlistedUrl[] =;

// A matcher for threat source in UnsafeResource.
MATCHER_P(IsSameThreatSource, threatSource, "") {}

class MockSafeBrowsingDatabaseManager : public TestSafeBrowsingDatabaseManager {};

class MockUrlCheckerDelegate : public UrlCheckerDelegate {};

class FakeRealTimeUrlLookupService
    : public testing::FakeRealTimeUrlLookupService {};

class MockHashRealTimeService : public HashRealTimeService {};

struct CreateSafeBrowsingUrlCheckerOptionalArgs {};

}  // namespace

class SafeBrowsingUrlCheckerTest : public PlatformTest {};

TEST_F(SafeBrowsingUrlCheckerTest, CheckUrl_SafeUrl) {}

TEST_F(SafeBrowsingUrlCheckerTest, CheckUrl_DangerousUrl) {}

TEST_F(SafeBrowsingUrlCheckerTest, CheckUrl_RedirectUrlsSafe) {}

TEST_F(SafeBrowsingUrlCheckerTest,
       CheckUrl_RedirectUrlsOriginDangerousRedirectSafe) {}

TEST_F(SafeBrowsingUrlCheckerTest, CheckUrl_UrlRealTimeEnabledAllowlistMatch) {}

TEST_F(SafeBrowsingUrlCheckerTest, CheckUrl_UrlRealTimeEnabledSafeUrl) {}

TEST_F(SafeBrowsingUrlCheckerTest,
       CheckUrl_UrlRealTimeEnabledSafeUrl_EmptyUrlLookupServiceMetricSuffix) {}

TEST_F(SafeBrowsingUrlCheckerTest,
       CheckUrl_UrlRealTimeEnabledSafeUrlFromCache) {}

TEST_F(SafeBrowsingUrlCheckerTest,
       CheckUrl_UrlRealTimeEnabledSafeUrlFromCacheFalsePositive) {}

TEST_F(SafeBrowsingUrlCheckerTest,
       CheckUrl_UrlRealTimeEnabled_SuspiciousSiteDetection) {}

TEST_F(SafeBrowsingUrlCheckerTest,
       CheckUrl_UrlRealTimeEnabledSafeBrowsingDisabled_ManagedWarn) {}

TEST_F(SafeBrowsingUrlCheckerTest,
       CheckUrl_UrlRealTimeEnabledSafeBrowsingDisabled_ManagedBlock) {}

TEST_F(SafeBrowsingUrlCheckerTest,
       CheckUrl_UrlRealTimeEnabledSafeBrowsingDisabled_Dangerous) {}

TEST_F(SafeBrowsingUrlCheckerTest,
       CheckUrl_UrlRealTimeEnabledSafeBrowsingDisabled_Safe) {}

TEST_F(SafeBrowsingUrlCheckerTest,
       CheckUrl_UrlRealTimeEnabledRedirectUrlsSafe) {}

TEST_F(SafeBrowsingUrlCheckerTest, CheckUrl_CancelCheckOnDestruct) {}

TEST_F(SafeBrowsingUrlCheckerTest, CheckUrl_CancelCheckOnTimeout) {}

TEST_F(SafeBrowsingUrlCheckerTest, CheckUrl_HashRealTimeService_InvalidUrl) {}

TEST_F(SafeBrowsingUrlCheckerTest,
       CheckUrl_HashRealTimeService_AllowlistMatchSafe) {}

TEST_F(SafeBrowsingUrlCheckerTest,
       CheckUrl_HashRealTimeService_AllowlistMatchUnsafe) {}

TEST_F(SafeBrowsingUrlCheckerTest, CheckUrl_HashRealTimeService_SafeLookup) {}

TEST_F(SafeBrowsingUrlCheckerTest, CheckUrl_HashRealTimeService_UnsafeLookup) {}

TEST_F(SafeBrowsingUrlCheckerTest,
       CheckUrl_HashRealTimeService_MissingService) {}

TEST_F(SafeBrowsingUrlCheckerTest,
       CheckUrl_HashRealTimeService_UnsuccessfulLookup) {}

TEST_F(SafeBrowsingUrlCheckerTest,
       CheckUrl_HashRealTimeServiceAndUrlRealTimeBothEnabled) {}

TEST_F(SafeBrowsingUrlCheckerTest,
       CheckUrl_BackgroundHashRealTimeLookups_SampleRateIsZero) {}

TEST_F(SafeBrowsingUrlCheckerTest,
       CheckUrl_BackgroundHashRealTimeLookups_NoHashRealTimeSelection) {}

TEST_F(SafeBrowsingUrlCheckerTest,
       CheckUrl_BackgroundHashRealTimeLookups_HashRealTimeService) {}

TEST_F(SafeBrowsingUrlCheckerTest,
       CheckUrl_BackgroundHashRealTimeLookups_Android) {}

TEST_F(SafeBrowsingUrlCheckerTest,
       CheckUrl_HashRealTimeEnabledThroughDatabaseManager) {}

TEST_F(SafeBrowsingUrlCheckerTest, CheckUrl_AllowlistedUrl) {}

TEST_F(SafeBrowsingUrlCheckerTest, CheckUrl_AllowlistCheckLoggingDetails) {}

}  // namespace safe_browsing