#include "chrome/browser/enterprise/connectors/common.h"
#include "base/memory/raw_ptr.h"
#include "chrome/browser/enterprise/connectors/connectors_service.h"
#include "chrome/browser/enterprise/connectors/test/deep_scanning_test_utils.h"
#include "chrome/browser/policy/dm_token_utils.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/deep_scanning_utils.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/download_danger_type.h"
#include "components/download/public/common/mock_download_item.h"
#include "components/enterprise/common/proto/connectors.pb.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/fake_download_item.h"
#include "content/public/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace enterprise_connectors {
namespace {
#if BUILDFLAG(ENTERPRISE_CONTENT_ANALYSIS)
struct CustomMessageTestCase { … };
constexpr char kDmToken[] = …;
constexpr char kTestUrl[] = …;
constexpr char kTestInvalidUrl[] = …;
constexpr char kTestMessage[] = …;
constexpr char16_t kU16TestMessage[] = …;
constexpr char kTestMessage2[] = …;
constexpr char kGoogleServiceProvider[] = …;
constexpr char kTestEscapedHtmlMessage[] = …;
constexpr char16_t kTestUnescapedHtmlMessage[] = …;
constexpr size_t kRuleMessageOffset = …;
constexpr char kTestLinkedMessage[] = …;
constexpr char16_t kU16TestLinkedMessage[] = …;
ContentAnalysisResponse CreateContentAnalysisResponse(
const std::vector<CustomMessageTestCase>& triggered_rules,
const std::string& url) { … }
class BaseTest : public testing::Test { … };
#endif
}
#if BUILDFLAG(ENTERPRISE_CONTENT_ANALYSIS)
class EnterpriseConnectorsResultShouldAllowDataUseTest
: public BaseTest,
public testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(EnterpriseConnectorsResultShouldAllowDataUseTest, BlockLargeFile) { … }
TEST_P(EnterpriseConnectorsResultShouldAllowDataUseTest,
BlockPasswordProtected) { … }
TEST_P(EnterpriseConnectorsResultShouldAllowDataUseTest, BlockUploadFailure) { … }
class ContentAnalysisResponseCustomMessageTest
: public BaseTest,
public testing::WithParamInterface<
std::tuple<std::vector<CustomMessageTestCase>, std::u16string>> { … };
TEST_P(ContentAnalysisResponseCustomMessageTest, ValidUrlCustomMessage) { … }
TEST_P(ContentAnalysisResponseCustomMessageTest, InvalidUrlCustomMessage) { … }
TEST_P(ContentAnalysisResponseCustomMessageTest, DownloadsItemCustomMessage) { … }
INSTANTIATE_TEST_SUITE_P(…);
#endif
}