chromium/components/safe_browsing/core/browser/realtime/url_lookup_service_unittest.cc

// Copyright 2019 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/realtime/url_lookup_service.h"

#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/task/sequenced_task_runner.h"
#include "base/test/bind.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 "build/build_config.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/safe_browsing/buildflags.h"
#include "components/safe_browsing/core/browser/referrer_chain_provider.h"
#include "components/safe_browsing/core/browser/safe_browsing_token_fetcher.h"
#include "components/safe_browsing/core/browser/test_safe_browsing_token_fetcher.h"
#include "components/safe_browsing/core/browser/verdict_cache_manager.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "components/unified_consent/pref_names.h"
#include "components/unified_consent/unified_consent_service.h"
#include "net/base/net_errors.h"
#include "net/http/http_status_code.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 "services/network/test/test_utils.h"
#include "testing/platform_test.h"

_;
DoAll;
Return;
SetArgPointee;

namespace safe_browsing {

namespace {
constexpr char kRealTimeLookupUrlPrefix[] =;

constexpr char kTestUrl[] =;
constexpr char kTestReferrerUrl[] =;
constexpr char kTestSubframeUrl[] =;
constexpr char kTestSubframeReferrerUrl[] =;

class MockReferrerChainProvider : public ReferrerChainProvider {};

bool GetRequestProto(const network::ResourceRequest& request,
                     RTLookupRequest* request_proto) {}

class MustRunInterceptor {};

}  // namespace

class RealTimeUrlLookupServiceTest : public PlatformTest {};

TEST_F(RealTimeUrlLookupServiceTest, TestFillRequestProto) {}

TEST_F(RealTimeUrlLookupServiceTest, TestSanitizeURL) {}

TEST_F(RealTimeUrlLookupServiceTest, TestFillPageLoadToken_FeatureEnabled) {}

TEST_F(RealTimeUrlLookupServiceTest, TestGetSBThreatTypeForRTThreatType) {}

TEST_F(RealTimeUrlLookupServiceTest, TestCanCheckUrl) {}

TEST_F(RealTimeUrlLookupServiceTest, TestCacheNotInCacheManager) {}

TEST_F(RealTimeUrlLookupServiceTest, TestCacheInCacheManager) {}

TEST_F(RealTimeUrlLookupServiceTest, TestStartLookup_PendingRequestForSameUrl) {}

TEST_F(RealTimeUrlLookupServiceTest, TestStartLookup_ResponseIsAlreadyCached) {}

TEST_F(RealTimeUrlLookupServiceTest,
       TestStartLookup_PingWithTokenUpdatesEsbProtegoPingWithTokenLastLogTime) {}

TEST_F(
    RealTimeUrlLookupServiceTest,
    TestStartLookup_PingWithoutTokenSetsEsbProtegoPingWithoutTokenLastLogTime) {}

TEST_F(
    RealTimeUrlLookupServiceTest,
    TestStartLookup_DoesNotSetEsbProtegoPingWithTokenLastLogTimeWhenCacheIsHit) {}

TEST_F(
    RealTimeUrlLookupServiceTest,
    TestStartLookup_DoesNotSetEsbProtegoPingWithoutTokenLastLogTimeWhenCacheIsHit) {}

TEST_F(
    RealTimeUrlLookupServiceTest,
    TestStartLookup_DoesNotSetEsbProtegoPingWithTokenLastLogTimeWhenEsbIsDisabled) {}

TEST_F(
    RealTimeUrlLookupServiceTest,
    TestStartLookup_DoesNotSetEsbProtegoPingWithoutTokenLastLogTimeWhenEsbIsDisabled) {}

TEST_F(RealTimeUrlLookupServiceTest,
       TestStartLookup_AttachTokenWhenWithTokenIsEnabled) {}

TEST_F(RealTimeUrlLookupServiceTest,
       TestStartLookup_NoTokenWhenTokenIsUnavailable) {}

TEST_F(RealTimeUrlLookupServiceTest,
       TestStartLookup_NoTokenWhenNotConfiguredInClient) {}

TEST_F(RealTimeUrlLookupServiceTest,
       TestStartLookup_OnInvalidAccessTokenCalledResponseCodeUnauthorized) {}

TEST_F(RealTimeUrlLookupServiceTest,
       TestStartLookup_OnInvalidAccessTokenNotCalledResponseCodeForbidden) {}

TEST_F(RealTimeUrlLookupServiceTest, TestReferrerChain_ReferrerChainAttached) {}

TEST_F(RealTimeUrlLookupServiceTest,
       TestReferrerChain_SanitizedIfSubresourceNotAllowed) {}

TEST_F(RealTimeUrlLookupServiceTest,
       TestReferrerChain_NotSanitizedIfSubresourceAllowed) {}

TEST_F(RealTimeUrlLookupServiceTest,
       TestReferrerChain_SanitizedIfMinAllowedTimestampIsNotMet) {}

// Tests that when a call to IdentifyReferrerChainByPendingEventURL does not
// identify the referrer chain, the service falls back to
// IdentifyReferrerChainByEventURL.
TEST_F(RealTimeUrlLookupServiceTest,
       TestReferrerChain_FallbackToEventUrlReferrerChain) {}

TEST_F(
    RealTimeUrlLookupServiceTest,
    TestReferrerChain_NoFallbackToEventUrlReferrerChain_AsyncChecksDisabled) {}

TEST_F(RealTimeUrlLookupServiceTest, TestShutdown_CallbackNotPostedOnShutdown) {}

TEST_F(RealTimeUrlLookupServiceTest, TestShutdown_CacheManagerReset) {}

TEST_F(RealTimeUrlLookupServiceTest,
       TestShutdown_SendRequestNotCalledOnShutdown) {}

TEST_F(RealTimeUrlLookupServiceTest, TestSendSampledRequest) {}

TEST_F(RealTimeUrlLookupServiceTest, TestConcurrentSendSampledRequests) {}

TEST_F(RealTimeUrlLookupServiceTest,
       TestCanSendRTSampleRequest_FeatureEnabled) {}

TEST_F(RealTimeUrlLookupServiceTest, TestBackoffModeSet) {}

TEST_F(RealTimeUrlLookupServiceTest, TestBackoffModeSet_UnparseableResponse) {}

TEST_F(RealTimeUrlLookupServiceTest, TestBackoffModeRespected_Cached) {}

TEST_F(RealTimeUrlLookupServiceTest, TestBackoffModeRespected_NotCached) {}

TEST_F(RealTimeUrlLookupServiceTest, TestRetriableErrors) {}

}  // namespace safe_browsing