chromium/chrome/browser/safe_browsing/download_protection/deep_scanning_request_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 "chrome/browser/safe_browsing/download_protection/deep_scanning_request.h"

#include <unordered_map>

#include "base/containers/contains.h"
#include "base/containers/flat_map.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/strcat.h"
#include "base/strings/stringprintf.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/download/chrome_download_manager_delegate.h"
#include "chrome/browser/download/download_core_service.h"
#include "chrome/browser/download/download_core_service_factory.h"
#include "chrome/browser/download/download_item_warning_data.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/enterprise/connectors/common.h"
#include "chrome/browser/enterprise/connectors/connectors_service.h"
#include "chrome/browser/enterprise/connectors/reporting/realtime_reporting_client_factory.h"
#include "chrome/browser/enterprise/connectors/test/deep_scanning_test_utils.h"
#include "chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router.h"
#include "chrome/browser/extensions/api/safe_browsing_private/safe_browsing_private_event_router_factory.h"
#include "chrome/browser/policy/dm_token_utils.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/binary_fcm_service.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/cloud_binary_upload_service.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/deep_scanning_utils.h"
#include "chrome/browser/safe_browsing/download_protection/download_protection_service.h"
#include "chrome/browser/safe_browsing/download_protection/download_protection_util.h"
#include "chrome/browser/safe_browsing/test_extension_event_observer.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/download/public/common/mock_download_item.h"
#include "components/enterprise/common/proto/connectors.pb.h"
#include "components/enterprise/connectors/core/connectors_prefs.h"
#include "components/policy/core/common/cloud/dm_token.h"
#include "components/policy/core/common/cloud/mock_cloud_policy_client.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/signin/public/identity_manager/identity_test_environment.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_item_utils.h"
#include "content/public/test/browser_task_environment.h"
#include "crypto/sha2.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/ash/components/system/fake_statistics_provider.h"
#endif

namespace safe_browsing {

Return;
ReturnRef;
ReturnRefOfCopy;

namespace {

constexpr char kUserName[] =;

constexpr char kScanForDlpAndMalware[] =;

constexpr char kScanForMalware[] =;

constexpr char kScanForDlp[] =;

constexpr char kNoScan[] =;

const std::set<std::string>* ExeMimeTypes() {}

const std::set<std::string>* TxtMimeTypes() {}

constexpr char kScanId[] =;

}  // namespace

class FakeBinaryUploadService : public BinaryUploadService {};

class FakeDownloadProtectionService : public DownloadProtectionService {};

class DeepScanningRequestTest : public testing::Test {};

class DeepScanningRequestFeaturesEnabledTest : public DeepScanningRequestTest {};

TEST_F(DeepScanningRequestFeaturesEnabledTest, ChecksFeatureFlags) {}

TEST_F(DeepScanningRequestFeaturesEnabledTest, VerifyBlockingSet) {}

class DeepScanningRequestAllFeaturesEnabledTest
    : public DeepScanningRequestTest {};

TEST_F(DeepScanningRequestAllFeaturesEnabledTest,
       GeneratesCorrectRequestFromPolicy) {}

class DeepScanningAPPRequestTest : public DeepScanningRequestTest {};

TEST_F(DeepScanningAPPRequestTest, GeneratesCorrectRequestForConsumer) {}

class DeepScanningReportingTest : public DeepScanningRequestTest {};

TEST_F(DeepScanningReportingTest, ProcessesResponseCorrectly) {}

TEST_F(DeepScanningReportingTest, ConsumerEncryptedArchiveSuccess) {}

TEST_F(DeepScanningReportingTest, ConsumerEncryptedArchiveFailed) {}

TEST_F(DeepScanningReportingTest, ConsumerUnencryptedArchive) {}

TEST_F(DeepScanningReportingTest, MultipleFiles) {}

TEST_F(DeepScanningReportingTest, Timeout) {}

class DeepScanningDownloadFailClosedTest
    : public DeepScanningRequestTest,
      public testing::WithParamInterface<
          std::tuple<safe_browsing::BinaryUploadService::Result, bool>> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(DeepScanningDownloadFailClosedTest, HandlesDefaultActionCorrectly) {}

class DeepScanningDownloadRestrictionsTest
    : public DeepScanningReportingTest,
      public testing::WithParamInterface<DownloadPrefs::DownloadRestriction> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(DeepScanningDownloadRestrictionsTest, GeneratesCorrectReport) {}

class DeepScanningRequestConnectorsFeatureTest
    : public DeepScanningRequestTest {};

TEST_F(DeepScanningRequestConnectorsFeatureTest,
       ShouldUploadBinary_MalwareListPolicy) {}

TEST_F(DeepScanningRequestConnectorsFeatureTest, ShouldUploadBinary_FileURLs) {}

TEST_F(DeepScanningRequestAllFeaturesEnabledTest, PopulatesRequest) {}

}  // namespace safe_browsing