#include "chrome/browser/safe_browsing/cloud_content_scanning/cloud_binary_upload_service.h"
#include <memory>
#include <utility>
#include <vector>
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/test/bind.h"
#include "base/test/scoped_command_line.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "build/branding_buildflags.h"
#include "chrome/browser/enterprise/connectors/analysis/content_analysis_features.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "chrome/browser/safe_browsing/advanced_protection_status_manager.h"
#include "chrome/browser/safe_browsing/advanced_protection_status_manager_factory.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/binary_fcm_service.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/file_analysis_request.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/multipart_uploader.h"
#include "chrome/test/base/testing_profile.h"
#include "components/enterprise/common/proto/connectors.pb.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_utils.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
_;
namespace safe_browsing {
namespace {
enterprise_connectors::CloudAnalysisSettings CloudAnalysisSettingsWithUrl(
const std::string& url) { … }
}
_;
Invoke;
NiceMock;
Return;
SaveArg;
class MockRequest : public BinaryUploadService::Request { … };
class FakeConnectorUploadRequest : public ConnectorUploadRequest { … };
class FakeConnectorUploadRequestFactory : public ConnectorUploadRequestFactory { … };
class MockBinaryFCMService : public BinaryFCMService { … };
class CloudBinaryUploadServiceTest : public ::testing::TestWithParam<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(CloudBinaryUploadServiceTest, FailsForLargeFile) { … }
TEST_P(CloudBinaryUploadServiceTest, SucceedsWhenMissingInstanceID) { … }
TEST_P(CloudBinaryUploadServiceTest,
SucceedsWhenMissingInstanceID_Authentication) { … }
TEST_P(CloudBinaryUploadServiceTest, PasteSucceedsWhenMissingInstanceID) { … }
TEST_P(CloudBinaryUploadServiceTest, FailsWhenUploadFails) { … }
TEST_P(CloudBinaryUploadServiceTest, FailsWhenUploadFails_Authentication) { … }
TEST_P(CloudBinaryUploadServiceTest, HoldsScanResponsesUntilAllReady) { … }
TEST_P(CloudBinaryUploadServiceTest, TimesOut) { … }
TEST_P(CloudBinaryUploadServiceTest, OnInstanceIDAfterTimeout) { … }
TEST_P(CloudBinaryUploadServiceTest, OnUploadCompleteAfterTimeout) { … }
TEST_P(CloudBinaryUploadServiceTest, OnGetResponseAfterTimeout) { … }
TEST_P(CloudBinaryUploadServiceTest, OnGetResponseBeforeTimeout) { … }
TEST_P(CloudBinaryUploadServiceTest,
OnUnauthorized_RetrySucceeds_ShouldReturnSuccess) { … }
TEST_P(CloudBinaryUploadServiceTest,
OnUnauthorized_RetryFails_ShouldReturnUnAuthorized) { … }
TEST_P(CloudBinaryUploadServiceTest,
TwoUploads_AuthCheckFailsThenSucceeds_ShouldReturnSuccess) { … }
TEST_P(CloudBinaryUploadServiceTest, OnGetSynchronousResponse) { … }
TEST_P(CloudBinaryUploadServiceTest, ReturnsAsynchronouslyWithNoFCM) { … }
TEST_P(CloudBinaryUploadServiceTest, ReturnsAsynchronouslyWithDisconnectedFCM) { … }
TEST_P(CloudBinaryUploadServiceTest,
ReturnsAsynchronouslyWithNoFCMAndIncompleteResponse) { … }
TEST_P(CloudBinaryUploadServiceTest, IsAuthorizedValidTimer) { … }
TEST_P(CloudBinaryUploadServiceTest, IsAuthorizedMultipleDMTokens) { … }
TEST_P(CloudBinaryUploadServiceTest,
AdvancedProtectionMalwareRequestAuthorized) { … }
TEST_P(CloudBinaryUploadServiceTest, AdvancedProtectionDlpRequestUnauthorized) { … }
TEST_P(CloudBinaryUploadServiceTest,
DeepScanESBEnabledEnhancedProtectionMalwareRequestAuthorized) { … }
TEST_P(CloudBinaryUploadServiceTest, ConnectorUrlParams){ … }
TEST_P(CloudBinaryUploadServiceTest, UrlOverride) { … }
TEST_P(CloudBinaryUploadServiceTest, GetUploadUrl) { … }
TEST_P(CloudBinaryUploadServiceTest, RequestQueue) { … }
TEST_P(CloudBinaryUploadServiceTest, TestMaxParallelRequestsFlag) { … }
TEST_P(CloudBinaryUploadServiceTest, EmptyFileRequest) { … }
TEST_P(CloudBinaryUploadServiceTest, RunsStartCallback) { … }
TEST_P(CloudBinaryUploadServiceTest, VerifyBlockingSet) { … }
}