Commit 6f15fae3 authored by Dominique Fauteux-Chapleau's avatar Dominique Fauteux-Chapleau Committed by Commit Bot

Reuse DeepScanningDialogDelegate unit tests for Enterprise Connectors

Bug: 1076083
Change-Id: Id2c599da0d3699312d667833238a86d7ef259ed1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2212392Reviewed-by: default avatarRoger Tawa <rogerta@chromium.org>
Commit-Queue: Dominique Fauteux-Chapleau <domfc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771888}
parent e51d55a3
...@@ -443,6 +443,10 @@ void ConnectorsManager::SetUpForTesting() { ...@@ -443,6 +443,10 @@ void ConnectorsManager::SetUpForTesting() {
void ConnectorsManager::TearDownForTesting() { void ConnectorsManager::TearDownForTesting() {
pref_change_registrar_.RemoveAll(); pref_change_registrar_.RemoveAll();
ClearCacheForTesting();
}
void ConnectorsManager::ClearCacheForTesting() {
analysis_connector_settings_.clear(); analysis_connector_settings_.clear();
reporting_connector_settings_.clear(); reporting_connector_settings_.clear();
} }
......
...@@ -76,6 +76,7 @@ class ConnectorsManager { ...@@ -76,6 +76,7 @@ class ConnectorsManager {
// singleton that would otherwise persist its state. // singleton that would otherwise persist its state.
void SetUpForTesting(); void SetUpForTesting();
void TearDownForTesting(); void TearDownForTesting();
void ClearCacheForTesting();
private: private:
friend struct base::DefaultSingletonTraits<ConnectorsManager>; friend struct base::DefaultSingletonTraits<ConnectorsManager>;
......
...@@ -20,7 +20,9 @@ ...@@ -20,7 +20,9 @@
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "chrome/browser/enterprise/connectors/common.h" #include "chrome/browser/enterprise/connectors/common.h"
#include "chrome/browser/enterprise/connectors/connectors_manager.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/binary_upload_service.h" #include "chrome/browser/safe_browsing/cloud_content_scanning/binary_upload_service.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/deep_scanning_test_utils.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/deep_scanning_utils.h" #include "chrome/browser/safe_browsing/cloud_content_scanning/deep_scanning_utils.h"
#include "chrome/browser/safe_browsing/cloud_content_scanning/fake_deep_scanning_dialog_delegate.h" #include "chrome/browser/safe_browsing/cloud_content_scanning/fake_deep_scanning_dialog_delegate.h"
#include "chrome/browser/safe_browsing/dm_token_utils.h" #include "chrome/browser/safe_browsing/dm_token_utils.h"
...@@ -64,55 +66,100 @@ class ScopedSetDMToken { ...@@ -64,55 +66,100 @@ class ScopedSetDMToken {
class BaseTest : public testing::Test { class BaseTest : public testing::Test {
public: public:
BaseTest() : profile_manager_(TestingBrowserProcess::GetGlobal()) { explicit BaseTest(bool use_legacy_policies)
: profile_manager_(TestingBrowserProcess::GetGlobal()),
use_legacy_policies_(use_legacy_policies) {
EXPECT_TRUE(profile_manager_.SetUp()); EXPECT_TRUE(profile_manager_.SetUp());
profile_ = profile_manager_.CreateTestingProfile("test-user"); profile_ = profile_manager_.CreateTestingProfile("test-user");
DeepScanningDialogDelegate::DisableUIForTesting(); DeepScanningDialogDelegate::DisableUIForTesting();
} }
void EnableFeatures(const std::vector<base::Feature>& features) { void EnableFeatures() {
scoped_feature_list_.Reset(); scoped_feature_list_.Reset();
scoped_feature_list_.InitWithFeatures(features, {}); if (use_legacy_policies_) {
scoped_feature_list_.InitWithFeatures(
{kContentComplianceEnabled, kMalwareScanEnabled}, {});
} else {
scoped_feature_list_.InitWithFeatures(
{kContentComplianceEnabled, kMalwareScanEnabled,
enterprise_connectors::kEnterpriseConnectorsEnabled},
{});
}
} }
void DisableFeatures(const std::vector<base::Feature>& features) { void DisableFeatures() {
scoped_feature_list_.Reset(); scoped_feature_list_.Reset();
scoped_feature_list_.InitWithFeatures({}, features); scoped_feature_list_.InitWithFeatures(
{}, {kContentComplianceEnabled, kMalwareScanEnabled,
enterprise_connectors::kEnterpriseConnectorsEnabled});
} }
void SetDlpPolicy(CheckContentComplianceValues state) { void SetDlpPolicy(CheckContentComplianceValues state) {
if (use_legacy_policies_) {
TestingBrowserProcess::GetGlobal()->local_state()->SetInteger( TestingBrowserProcess::GetGlobal()->local_state()->SetInteger(
prefs::kCheckContentCompliance, state); prefs::kCheckContentCompliance, state);
} else {
SetDlpPolicyForConnectors(state);
}
} }
void SetWaitPolicy(DelayDeliveryUntilVerdictValues state) { void SetWaitPolicy(DelayDeliveryUntilVerdictValues state) {
if (use_legacy_policies_) {
TestingBrowserProcess::GetGlobal()->local_state()->SetInteger( TestingBrowserProcess::GetGlobal()->local_state()->SetInteger(
prefs::kDelayDeliveryUntilVerdict, state); prefs::kDelayDeliveryUntilVerdict, state);
} else {
SetDelayDeliveryUntilVerdictPolicyForConnectors(state);
}
} }
void SetAllowPasswordPolicy(AllowPasswordProtectedFilesValues state) { void SetAllowPasswordPolicy(AllowPasswordProtectedFilesValues state) {
if (use_legacy_policies_) {
TestingBrowserProcess::GetGlobal()->local_state()->SetInteger( TestingBrowserProcess::GetGlobal()->local_state()->SetInteger(
prefs::kAllowPasswordProtectedFiles, state); prefs::kAllowPasswordProtectedFiles, state);
} else {
SetAllowPasswordProtectedFilesPolicyForConnectors(state);
}
} }
void SetMalwarePolicy(SendFilesForMalwareCheckValues state) { void SetMalwarePolicy(SendFilesForMalwareCheckValues state) {
if (use_legacy_policies_) {
profile_->GetPrefs()->SetInteger( profile_->GetPrefs()->SetInteger(
prefs::kSafeBrowsingSendFilesForMalwareCheck, state); prefs::kSafeBrowsingSendFilesForMalwareCheck, state);
} else {
SetMalwarePolicyForConnectors(state);
}
} }
void SetBlockLargeFilePolicy(BlockLargeFileTransferValues state) { void SetBlockLargeFilePolicy(BlockLargeFileTransferValues state) {
if (use_legacy_policies_) {
TestingBrowserProcess::GetGlobal()->local_state()->SetInteger( TestingBrowserProcess::GetGlobal()->local_state()->SetInteger(
prefs::kBlockLargeFileTransfer, state); prefs::kBlockLargeFileTransfer, state);
} else {
SetBlockLargeFileTransferPolicyForConnectors(state);
}
} }
void AddUrlToList(const char* pref_name, const GURL& url) { void SetUnsupportedFileTypePolicy(BlockUnsupportedFiletypesValues state) {
ListPrefUpdate(TestingBrowserProcess::GetGlobal()->local_state(), pref_name) if (use_legacy_policies_) {
->Append(url.host()); TestingBrowserProcess::GetGlobal()->local_state()->SetInteger(
prefs::kBlockUnsupportedFiletypes, state);
} else {
SetBlockUnsupportedFileTypesPolicyForConnectors(state);
}
} }
void AddUrlToList(const char* pref_name, const char* url) { void AddUrlToList(const char* pref_name, const std::string& url) {
ListPrefUpdate(TestingBrowserProcess::GetGlobal()->local_state(), pref_name) if (use_legacy_policies_) {
ListPrefUpdate(TestingBrowserProcess::GetGlobal()->local_state(),
pref_name)
->Append(url); ->Append(url);
} else {
AddUrlToListForConnectors(pref_name, url);
}
}
void AddUrlToList(const char* pref_name, const GURL& url) {
AddUrlToList(pref_name, url.host());
} }
void ScanUpload(content::WebContents* web_contents, void ScanUpload(content::WebContents* web_contents,
...@@ -139,28 +186,57 @@ class BaseTest : public testing::Test { ...@@ -139,28 +186,57 @@ class BaseTest : public testing::Test {
} }
void SetUp() override { void SetUp() override {
enterprise_connectors::ConnectorsManager::GetInstance()->SetUpForTesting();
// Always set this so DeepScanningDialogDelegate::ShowForWebContents waits // Always set this so DeepScanningDialogDelegate::ShowForWebContents waits
// for the verdict before running its callback. // for the verdict before running its callback.
SetWaitPolicy(DELAY_UPLOADS); SetWaitPolicy(DELAY_UPLOADS);
} }
void TearDown() override {
enterprise_connectors::ConnectorsManager::GetInstance()
->TearDownForTesting();
}
Profile* profile() { return profile_; } Profile* profile() { return profile_; }
private: content::WebContents* contents() {
if (!web_contents_) {
content::WebContents::CreateParams params(profile());
web_contents_ = content::WebContents::Create(params);
}
return web_contents_.get();
}
void RunUntilDone() { run_loop_.Run(); }
protected:
content::BrowserTaskEnvironment task_environment_; content::BrowserTaskEnvironment task_environment_;
base::test::ScopedFeatureList scoped_feature_list_; base::test::ScopedFeatureList scoped_feature_list_;
TestingPrefServiceSimple pref_service_; TestingPrefServiceSimple pref_service_;
TestingProfileManager profile_manager_; TestingProfileManager profile_manager_;
TestingProfile* profile_; TestingProfile* profile_;
base::ScopedTempDir temp_dir_; base::ScopedTempDir temp_dir_;
bool use_legacy_policies_;
std::unique_ptr<content::WebContents> web_contents_;
base::RunLoop run_loop_;
}; };
} // namespace } // namespace
using DeepScanningDialogDelegateIsEnabledTest = BaseTest; class DeepScanningDialogDelegateIsEnabledTest
: public BaseTest,
public testing::WithParamInterface<bool> {
public:
DeepScanningDialogDelegateIsEnabledTest() : BaseTest(GetParam()) {}
};
INSTANTIATE_TEST_SUITE_P(,
DeepScanningDialogDelegateIsEnabledTest,
testing::Bool());
TEST_F(DeepScanningDialogDelegateIsEnabledTest, NoFeatureNoDMTokenNoPref) { TEST_P(DeepScanningDialogDelegateIsEnabledTest, NoFeatureNoDMTokenNoPref) {
DisableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); DisableFeatures();
ScopedSetDMToken scoped_dm_token( ScopedSetDMToken scoped_dm_token(
policy::DMToken::CreateInvalidTokenForTesting()); policy::DMToken::CreateInvalidTokenForTesting());
...@@ -172,8 +248,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, NoFeatureNoDMTokenNoPref) { ...@@ -172,8 +248,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, NoFeatureNoDMTokenNoPref) {
EXPECT_FALSE(data.do_malware_scan); EXPECT_FALSE(data.do_malware_scan);
} }
TEST_F(DeepScanningDialogDelegateIsEnabledTest, NoDMTokenNoPref) { TEST_P(DeepScanningDialogDelegateIsEnabledTest, NoDMTokenNoPref) {
EnableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); EnableFeatures();
ScopedSetDMToken scoped_dm_token( ScopedSetDMToken scoped_dm_token(
policy::DMToken::CreateInvalidTokenForTesting()); policy::DMToken::CreateInvalidTokenForTesting());
...@@ -185,8 +261,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, NoDMTokenNoPref) { ...@@ -185,8 +261,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, NoDMTokenNoPref) {
EXPECT_FALSE(data.do_malware_scan); EXPECT_FALSE(data.do_malware_scan);
} }
TEST_F(DeepScanningDialogDelegateIsEnabledTest, NoDMToken) { TEST_P(DeepScanningDialogDelegateIsEnabledTest, NoDMToken) {
EnableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); EnableFeatures();
SetDlpPolicy(CHECK_UPLOADS_AND_DOWNLOADS); SetDlpPolicy(CHECK_UPLOADS_AND_DOWNLOADS);
SetMalwarePolicy(SEND_UPLOADS_AND_DOWNLOADS); SetMalwarePolicy(SEND_UPLOADS_AND_DOWNLOADS);
ScopedSetDMToken scoped_dm_token( ScopedSetDMToken scoped_dm_token(
...@@ -200,8 +276,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, NoDMToken) { ...@@ -200,8 +276,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, NoDMToken) {
EXPECT_FALSE(data.do_malware_scan); EXPECT_FALSE(data.do_malware_scan);
} }
TEST_F(DeepScanningDialogDelegateIsEnabledTest, NoFeatureNoPref) { TEST_P(DeepScanningDialogDelegateIsEnabledTest, NoFeatureNoPref) {
DisableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); DisableFeatures();
ScopedSetDMToken scoped_dm_token( ScopedSetDMToken scoped_dm_token(
policy::DMToken::CreateValidTokenForTesting(kDmToken)); policy::DMToken::CreateValidTokenForTesting(kDmToken));
...@@ -213,8 +289,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, NoFeatureNoPref) { ...@@ -213,8 +289,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, NoFeatureNoPref) {
EXPECT_FALSE(data.do_malware_scan); EXPECT_FALSE(data.do_malware_scan);
} }
TEST_F(DeepScanningDialogDelegateIsEnabledTest, NoFeatureNoDMToken) { TEST_P(DeepScanningDialogDelegateIsEnabledTest, NoFeatureNoDMToken) {
DisableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); DisableFeatures();
SetDlpPolicy(CHECK_UPLOADS_AND_DOWNLOADS); SetDlpPolicy(CHECK_UPLOADS_AND_DOWNLOADS);
SetMalwarePolicy(SEND_UPLOADS_AND_DOWNLOADS); SetMalwarePolicy(SEND_UPLOADS_AND_DOWNLOADS);
ScopedSetDMToken scoped_dm_token( ScopedSetDMToken scoped_dm_token(
...@@ -228,8 +304,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, NoFeatureNoDMToken) { ...@@ -228,8 +304,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, NoFeatureNoDMToken) {
EXPECT_FALSE(data.do_malware_scan); EXPECT_FALSE(data.do_malware_scan);
} }
TEST_F(DeepScanningDialogDelegateIsEnabledTest, NoFeature) { TEST_P(DeepScanningDialogDelegateIsEnabledTest, NoFeature) {
DisableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); DisableFeatures();
ScopedSetDMToken scoped_dm_token( ScopedSetDMToken scoped_dm_token(
policy::DMToken::CreateValidTokenForTesting(kDmToken)); policy::DMToken::CreateValidTokenForTesting(kDmToken));
SetDlpPolicy(CHECK_UPLOADS_AND_DOWNLOADS); SetDlpPolicy(CHECK_UPLOADS_AND_DOWNLOADS);
...@@ -243,8 +319,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, NoFeature) { ...@@ -243,8 +319,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, NoFeature) {
EXPECT_FALSE(data.do_malware_scan); EXPECT_FALSE(data.do_malware_scan);
} }
TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpNoPref) { TEST_P(DeepScanningDialogDelegateIsEnabledTest, DlpNoPref) {
EnableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); EnableFeatures();
ScopedSetDMToken scoped_dm_token( ScopedSetDMToken scoped_dm_token(
policy::DMToken::CreateValidTokenForTesting(kDmToken)); policy::DMToken::CreateValidTokenForTesting(kDmToken));
...@@ -256,8 +332,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpNoPref) { ...@@ -256,8 +332,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpNoPref) {
EXPECT_FALSE(data.do_malware_scan); EXPECT_FALSE(data.do_malware_scan);
} }
TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpNoPref2) { TEST_P(DeepScanningDialogDelegateIsEnabledTest, DlpNoPref2) {
EnableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); EnableFeatures();
ScopedSetDMToken scoped_dm_token( ScopedSetDMToken scoped_dm_token(
policy::DMToken::CreateValidTokenForTesting(kDmToken)); policy::DMToken::CreateValidTokenForTesting(kDmToken));
SetDlpPolicy(CHECK_NONE); SetDlpPolicy(CHECK_NONE);
...@@ -270,8 +346,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpNoPref2) { ...@@ -270,8 +346,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpNoPref2) {
EXPECT_FALSE(data.do_malware_scan); EXPECT_FALSE(data.do_malware_scan);
} }
TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpNoPref3) { TEST_P(DeepScanningDialogDelegateIsEnabledTest, DlpNoPref3) {
EnableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); EnableFeatures();
ScopedSetDMToken scoped_dm_token( ScopedSetDMToken scoped_dm_token(
policy::DMToken::CreateValidTokenForTesting(kDmToken)); policy::DMToken::CreateValidTokenForTesting(kDmToken));
SetDlpPolicy(CHECK_DOWNLOADS); SetDlpPolicy(CHECK_DOWNLOADS);
...@@ -284,8 +360,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpNoPref3) { ...@@ -284,8 +360,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpNoPref3) {
EXPECT_FALSE(data.do_malware_scan); EXPECT_FALSE(data.do_malware_scan);
} }
TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpEnabled) { TEST_P(DeepScanningDialogDelegateIsEnabledTest, DlpEnabled) {
EnableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); EnableFeatures();
ScopedSetDMToken scoped_dm_token( ScopedSetDMToken scoped_dm_token(
policy::DMToken::CreateValidTokenForTesting(kDmToken)); policy::DMToken::CreateValidTokenForTesting(kDmToken));
SetDlpPolicy(CHECK_UPLOADS); SetDlpPolicy(CHECK_UPLOADS);
...@@ -298,8 +374,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpEnabled) { ...@@ -298,8 +374,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpEnabled) {
EXPECT_FALSE(data.do_malware_scan); EXPECT_FALSE(data.do_malware_scan);
} }
TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpEnabled2) { TEST_P(DeepScanningDialogDelegateIsEnabledTest, DlpEnabled2) {
EnableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); EnableFeatures();
ScopedSetDMToken scoped_dm_token( ScopedSetDMToken scoped_dm_token(
policy::DMToken::CreateValidTokenForTesting(kDmToken)); policy::DMToken::CreateValidTokenForTesting(kDmToken));
SetDlpPolicy(CHECK_UPLOADS_AND_DOWNLOADS); SetDlpPolicy(CHECK_UPLOADS_AND_DOWNLOADS);
...@@ -312,8 +388,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpEnabled2) { ...@@ -312,8 +388,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpEnabled2) {
EXPECT_FALSE(data.do_malware_scan); EXPECT_FALSE(data.do_malware_scan);
} }
TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpEnabledWithUrl) { TEST_P(DeepScanningDialogDelegateIsEnabledTest, DlpEnabledWithUrl) {
EnableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); EnableFeatures();
ScopedSetDMToken scoped_dm_token( ScopedSetDMToken scoped_dm_token(
policy::DMToken::CreateValidTokenForTesting(kDmToken)); policy::DMToken::CreateValidTokenForTesting(kDmToken));
SetDlpPolicy(CHECK_UPLOADS_AND_DOWNLOADS); SetDlpPolicy(CHECK_UPLOADS_AND_DOWNLOADS);
...@@ -328,9 +404,9 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpEnabledWithUrl) { ...@@ -328,9 +404,9 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpEnabledWithUrl) {
EXPECT_EQ(kTestUrl, data.url); EXPECT_EQ(kTestUrl, data.url);
} }
TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpDisabledByList) { TEST_P(DeepScanningDialogDelegateIsEnabledTest, DlpDisabledByList) {
GURL url(kTestUrl); GURL url(kTestUrl);
EnableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); EnableFeatures();
ScopedSetDMToken scoped_dm_token( ScopedSetDMToken scoped_dm_token(
policy::DMToken::CreateValidTokenForTesting(kDmToken)); policy::DMToken::CreateValidTokenForTesting(kDmToken));
SetDlpPolicy(CHECK_UPLOADS); SetDlpPolicy(CHECK_UPLOADS);
...@@ -344,8 +420,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpDisabledByList) { ...@@ -344,8 +420,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpDisabledByList) {
EXPECT_FALSE(data.do_malware_scan); EXPECT_FALSE(data.do_malware_scan);
} }
TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpDisabledByListWithPatterns) { TEST_P(DeepScanningDialogDelegateIsEnabledTest, DlpDisabledByListWithPatterns) {
EnableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); EnableFeatures();
ScopedSetDMToken scoped_dm_token( ScopedSetDMToken scoped_dm_token(
policy::DMToken::CreateValidTokenForTesting(kDmToken)); policy::DMToken::CreateValidTokenForTesting(kDmToken));
SetDlpPolicy(CHECK_UPLOADS); SetDlpPolicy(CHECK_UPLOADS);
...@@ -445,8 +521,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpDisabledByListWithPatterns) { ...@@ -445,8 +521,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, DlpDisabledByListWithPatterns) {
EXPECT_FALSE(data.do_malware_scan); EXPECT_FALSE(data.do_malware_scan);
} }
TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareNoPref) { TEST_P(DeepScanningDialogDelegateIsEnabledTest, MalwareNoPref) {
EnableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); EnableFeatures();
ScopedSetDMToken scoped_dm_token( ScopedSetDMToken scoped_dm_token(
policy::DMToken::CreateValidTokenForTesting(kDmToken)); policy::DMToken::CreateValidTokenForTesting(kDmToken));
...@@ -458,8 +534,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareNoPref) { ...@@ -458,8 +534,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareNoPref) {
EXPECT_FALSE(data.do_malware_scan); EXPECT_FALSE(data.do_malware_scan);
} }
TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareNoPref2) { TEST_P(DeepScanningDialogDelegateIsEnabledTest, MalwareNoPref2) {
EnableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); EnableFeatures();
ScopedSetDMToken scoped_dm_token( ScopedSetDMToken scoped_dm_token(
policy::DMToken::CreateValidTokenForTesting(kDmToken)); policy::DMToken::CreateValidTokenForTesting(kDmToken));
SetMalwarePolicy(DO_NOT_SCAN); SetMalwarePolicy(DO_NOT_SCAN);
...@@ -472,8 +548,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareNoPref2) { ...@@ -472,8 +548,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareNoPref2) {
EXPECT_FALSE(data.do_malware_scan); EXPECT_FALSE(data.do_malware_scan);
} }
TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareNoPref4) { TEST_P(DeepScanningDialogDelegateIsEnabledTest, MalwareNoPref4) {
EnableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); EnableFeatures();
ScopedSetDMToken scoped_dm_token( ScopedSetDMToken scoped_dm_token(
policy::DMToken::CreateValidTokenForTesting(kDmToken)); policy::DMToken::CreateValidTokenForTesting(kDmToken));
SetMalwarePolicy(SEND_DOWNLOADS); SetMalwarePolicy(SEND_DOWNLOADS);
...@@ -486,8 +562,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareNoPref4) { ...@@ -486,8 +562,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareNoPref4) {
EXPECT_FALSE(data.do_malware_scan); EXPECT_FALSE(data.do_malware_scan);
} }
TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareNoList) { TEST_P(DeepScanningDialogDelegateIsEnabledTest, MalwareNoList) {
EnableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); EnableFeatures();
ScopedSetDMToken scoped_dm_token( ScopedSetDMToken scoped_dm_token(
policy::DMToken::CreateValidTokenForTesting(kDmToken)); policy::DMToken::CreateValidTokenForTesting(kDmToken));
SetMalwarePolicy(SEND_UPLOADS); SetMalwarePolicy(SEND_UPLOADS);
...@@ -500,8 +576,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareNoList) { ...@@ -500,8 +576,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareNoList) {
EXPECT_FALSE(data.do_malware_scan); EXPECT_FALSE(data.do_malware_scan);
} }
TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareNoList2) { TEST_P(DeepScanningDialogDelegateIsEnabledTest, MalwareNoList2) {
EnableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); EnableFeatures();
ScopedSetDMToken scoped_dm_token( ScopedSetDMToken scoped_dm_token(
policy::DMToken::CreateValidTokenForTesting(kDmToken)); policy::DMToken::CreateValidTokenForTesting(kDmToken));
SetMalwarePolicy(SEND_UPLOADS_AND_DOWNLOADS); SetMalwarePolicy(SEND_UPLOADS_AND_DOWNLOADS);
...@@ -514,9 +590,9 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareNoList2) { ...@@ -514,9 +590,9 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareNoList2) {
EXPECT_FALSE(data.do_malware_scan); EXPECT_FALSE(data.do_malware_scan);
} }
TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareEnabled) { TEST_P(DeepScanningDialogDelegateIsEnabledTest, MalwareEnabled) {
GURL url(kTestUrl); GURL url(kTestUrl);
EnableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); EnableFeatures();
ScopedSetDMToken scoped_dm_token( ScopedSetDMToken scoped_dm_token(
policy::DMToken::CreateValidTokenForTesting(kDmToken)); policy::DMToken::CreateValidTokenForTesting(kDmToken));
SetMalwarePolicy(SEND_UPLOADS_AND_DOWNLOADS); SetMalwarePolicy(SEND_UPLOADS_AND_DOWNLOADS);
...@@ -530,9 +606,9 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareEnabled) { ...@@ -530,9 +606,9 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareEnabled) {
EXPECT_TRUE(data.do_malware_scan); EXPECT_TRUE(data.do_malware_scan);
} }
TEST_F(DeepScanningDialogDelegateIsEnabledTest, NoScanInIncognito) { TEST_P(DeepScanningDialogDelegateIsEnabledTest, NoScanInIncognito) {
GURL url(kTestUrl); GURL url(kTestUrl);
EnableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); EnableFeatures();
ScopedSetDMToken scoped_dm_token( ScopedSetDMToken scoped_dm_token(
policy::DMToken::CreateValidTokenForTesting(kDmToken)); policy::DMToken::CreateValidTokenForTesting(kDmToken));
SetDlpPolicy(CHECK_UPLOADS_AND_DOWNLOADS); SetDlpPolicy(CHECK_UPLOADS_AND_DOWNLOADS);
...@@ -556,8 +632,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, NoScanInIncognito) { ...@@ -556,8 +632,8 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, NoScanInIncognito) {
url, &data, enterprise_connectors::AnalysisConnector::FILE_ATTACHED)); url, &data, enterprise_connectors::AnalysisConnector::FILE_ATTACHED));
} }
TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareEnabledWithPatterns) { TEST_P(DeepScanningDialogDelegateIsEnabledTest, MalwareEnabledWithPatterns) {
EnableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); EnableFeatures();
ScopedSetDMToken scoped_dm_token( ScopedSetDMToken scoped_dm_token(
policy::DMToken::CreateValidTokenForTesting(kDmToken)); policy::DMToken::CreateValidTokenForTesting(kDmToken));
SetMalwarePolicy(SEND_UPLOADS_AND_DOWNLOADS); SetMalwarePolicy(SEND_UPLOADS_AND_DOWNLOADS);
...@@ -655,18 +731,13 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareEnabledWithPatterns) { ...@@ -655,18 +731,13 @@ TEST_F(DeepScanningDialogDelegateIsEnabledTest, MalwareEnabledWithPatterns) {
EXPECT_FALSE(data.do_malware_scan); EXPECT_FALSE(data.do_malware_scan);
} }
class DeepScanningDialogDelegateAuditOnlyTest : public BaseTest { class DeepScanningDialogDelegateAuditOnlyTest
protected: : public BaseTest,
void RunUntilDone() { run_loop_.Run(); } public testing::WithParamInterface<bool> {
public:
content::WebContents* contents() { DeepScanningDialogDelegateAuditOnlyTest() : BaseTest(GetParam()) {}
if (!web_contents_) {
content::WebContents::CreateParams params(profile());
web_contents_ = content::WebContents::Create(params);
}
return web_contents_.get();
}
protected:
void SetDLPResponse(DlpDeepScanningVerdict verdict) { void SetDLPResponse(DlpDeepScanningVerdict verdict) {
dlp_verdict_ = verdict; dlp_verdict_ = verdict;
} }
...@@ -695,11 +766,10 @@ class DeepScanningDialogDelegateAuditOnlyTest : public BaseTest { ...@@ -695,11 +766,10 @@ class DeepScanningDialogDelegateAuditOnlyTest : public BaseTest {
SetMalwarePolicy(DO_NOT_SCAN); SetMalwarePolicy(DO_NOT_SCAN);
} }
private:
void SetUp() override { void SetUp() override {
BaseTest::SetUp(); BaseTest::SetUp();
EnableFeatures({kContentComplianceEnabled, kMalwareScanEnabled}); EnableFeatures();
SetDlpPolicy(CHECK_UPLOADS); SetDlpPolicy(CHECK_UPLOADS);
SetMalwarePolicy(SEND_UPLOADS); SetMalwarePolicy(SEND_UPLOADS);
...@@ -733,8 +803,7 @@ class DeepScanningDialogDelegateAuditOnlyTest : public BaseTest { ...@@ -733,8 +803,7 @@ class DeepScanningDialogDelegateAuditOnlyTest : public BaseTest {
return encrypted_.count(path) > 0; return encrypted_.count(path) > 0;
} }
base::RunLoop run_loop_; private:
std::unique_ptr<content::WebContents> web_contents_;
ScopedSetDMToken scoped_dm_token_{ ScopedSetDMToken scoped_dm_token_{
policy::DMToken::CreateValidTokenForTesting(kDmToken)}; policy::DMToken::CreateValidTokenForTesting(kDmToken)};
bool include_dlp_ = true; bool include_dlp_ = true;
...@@ -752,7 +821,11 @@ class DeepScanningDialogDelegateAuditOnlyTest : public BaseTest { ...@@ -752,7 +821,11 @@ class DeepScanningDialogDelegateAuditOnlyTest : public BaseTest {
base::Optional<DlpDeepScanningVerdict> dlp_verdict_ = base::nullopt; base::Optional<DlpDeepScanningVerdict> dlp_verdict_ = base::nullopt;
}; };
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, Empty) { INSTANTIATE_TEST_SUITE_P(,
DeepScanningDialogDelegateAuditOnlyTest,
testing::Bool());
TEST_P(DeepScanningDialogDelegateAuditOnlyTest, Empty) {
GURL url(kTestUrl); GURL url(kTestUrl);
DeepScanningDialogDelegate::Data data; DeepScanningDialogDelegate::Data data;
ASSERT_TRUE(DeepScanningDialogDelegate::IsEnabled( ASSERT_TRUE(DeepScanningDialogDelegate::IsEnabled(
...@@ -777,7 +850,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, Empty) { ...@@ -777,7 +850,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, Empty) {
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, StringData) { TEST_P(DeepScanningDialogDelegateAuditOnlyTest, StringData) {
GURL url(kTestUrl); GURL url(kTestUrl);
DeepScanningDialogDelegate::Data data; DeepScanningDialogDelegate::Data data;
ASSERT_TRUE(DeepScanningDialogDelegate::IsEnabled( ASSERT_TRUE(DeepScanningDialogDelegate::IsEnabled(
...@@ -803,7 +876,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, StringData) { ...@@ -803,7 +876,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, StringData) {
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, StringData2) { TEST_P(DeepScanningDialogDelegateAuditOnlyTest, StringData2) {
GURL url(kTestUrl); GURL url(kTestUrl);
DeepScanningDialogDelegate::Data data; DeepScanningDialogDelegate::Data data;
ASSERT_TRUE(DeepScanningDialogDelegate::IsEnabled( ASSERT_TRUE(DeepScanningDialogDelegate::IsEnabled(
...@@ -831,7 +904,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, StringData2) { ...@@ -831,7 +904,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, StringData2) {
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, TEST_P(DeepScanningDialogDelegateAuditOnlyTest,
FileDataPositiveMalwareAndDlpVerdicts) { FileDataPositiveMalwareAndDlpVerdicts) {
GURL url(kTestUrl); GURL url(kTestUrl);
DeepScanningDialogDelegate::Data data; DeepScanningDialogDelegate::Data data;
...@@ -858,7 +931,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, ...@@ -858,7 +931,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest,
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, TEST_P(DeepScanningDialogDelegateAuditOnlyTest,
FileDataPositiveMalwareAndDlpVerdicts2) { FileDataPositiveMalwareAndDlpVerdicts2) {
GURL url(kTestUrl); GURL url(kTestUrl);
DeepScanningDialogDelegate::Data data; DeepScanningDialogDelegate::Data data;
...@@ -887,7 +960,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, ...@@ -887,7 +960,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest,
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, TEST_P(DeepScanningDialogDelegateAuditOnlyTest,
FileDataPositiveMalwareVerdict) { FileDataPositiveMalwareVerdict) {
SetScanPolicies(/*dlp=*/false, /*malware=*/true); SetScanPolicies(/*dlp=*/false, /*malware=*/true);
AddUrlToList(prefs::kURLsToCheckForMalwareOfUploadedContent, "*"); AddUrlToList(prefs::kURLsToCheckForMalwareOfUploadedContent, "*");
...@@ -918,7 +991,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, ...@@ -918,7 +991,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest,
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, FileIsEncrypted) { TEST_P(DeepScanningDialogDelegateAuditOnlyTest, FileIsEncrypted) {
content::InProcessUtilityThreadHelper in_process_utility_thread_helper; content::InProcessUtilityThreadHelper in_process_utility_thread_helper;
SetScanPolicies(/*dlp=*/true, /*malware=*/true); SetScanPolicies(/*dlp=*/true, /*malware=*/true);
...@@ -954,7 +1027,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, FileIsEncrypted) { ...@@ -954,7 +1027,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, FileIsEncrypted) {
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, FileIsEncrypted_PolicyAllows) { TEST_P(DeepScanningDialogDelegateAuditOnlyTest, FileIsEncrypted_PolicyAllows) {
content::InProcessUtilityThreadHelper in_process_utility_thread_helper; content::InProcessUtilityThreadHelper in_process_utility_thread_helper;
SetScanPolicies(/*dlp=*/true, /*malware=*/true); SetScanPolicies(/*dlp=*/true, /*malware=*/true);
...@@ -990,7 +1063,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, FileIsEncrypted_PolicyAllows) { ...@@ -990,7 +1063,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, FileIsEncrypted_PolicyAllows) {
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, TEST_P(DeepScanningDialogDelegateAuditOnlyTest,
FileDataNegativeMalwareVerdict) { FileDataNegativeMalwareVerdict) {
SetScanPolicies(/*dlp=*/false, /*malware=*/true); SetScanPolicies(/*dlp=*/false, /*malware=*/true);
AddUrlToList(prefs::kURLsToCheckForMalwareOfUploadedContent, "*"); AddUrlToList(prefs::kURLsToCheckForMalwareOfUploadedContent, "*");
...@@ -1024,7 +1097,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, ...@@ -1024,7 +1097,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest,
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, FileDataPositiveDlpVerdict) { TEST_P(DeepScanningDialogDelegateAuditOnlyTest, FileDataPositiveDlpVerdict) {
SetScanPolicies(/*dlp=*/true, /*malware=*/false); SetScanPolicies(/*dlp=*/true, /*malware=*/false);
GURL url(kTestUrl); GURL url(kTestUrl);
DeepScanningDialogDelegate::Data data; DeepScanningDialogDelegate::Data data;
...@@ -1053,7 +1126,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, FileDataPositiveDlpVerdict) { ...@@ -1053,7 +1126,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, FileDataPositiveDlpVerdict) {
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, FileDataNegativeDlpVerdict) { TEST_P(DeepScanningDialogDelegateAuditOnlyTest, FileDataNegativeDlpVerdict) {
SetScanPolicies(/*dlp=*/true, /*malware=*/false); SetScanPolicies(/*dlp=*/true, /*malware=*/false);
AddUrlToList(prefs::kURLsToCheckForMalwareOfUploadedContent, "*"); AddUrlToList(prefs::kURLsToCheckForMalwareOfUploadedContent, "*");
GURL url(kTestUrl); GURL url(kTestUrl);
...@@ -1088,7 +1161,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, FileDataNegativeDlpVerdict) { ...@@ -1088,7 +1161,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, FileDataNegativeDlpVerdict) {
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, TEST_P(DeepScanningDialogDelegateAuditOnlyTest,
FileDataNegativeMalwareAndDlpVerdicts) { FileDataNegativeMalwareAndDlpVerdicts) {
SetScanPolicies(/*dlp=*/true, /*malware=*/true); SetScanPolicies(/*dlp=*/true, /*malware=*/true);
AddUrlToList(prefs::kURLsToCheckForMalwareOfUploadedContent, "*"); AddUrlToList(prefs::kURLsToCheckForMalwareOfUploadedContent, "*");
...@@ -1125,7 +1198,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, ...@@ -1125,7 +1198,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest,
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, StringFileData) { TEST_P(DeepScanningDialogDelegateAuditOnlyTest, StringFileData) {
GURL url(kTestUrl); GURL url(kTestUrl);
DeepScanningDialogDelegate::Data data; DeepScanningDialogDelegate::Data data;
ASSERT_TRUE(DeepScanningDialogDelegate::IsEnabled( ASSERT_TRUE(DeepScanningDialogDelegate::IsEnabled(
...@@ -1155,7 +1228,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, StringFileData) { ...@@ -1155,7 +1228,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, StringFileData) {
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, StringFileDataNoDLP) { TEST_P(DeepScanningDialogDelegateAuditOnlyTest, StringFileDataNoDLP) {
// Enable malware scan so deep scanning still occurs. // Enable malware scan so deep scanning still occurs.
SetScanPolicies(/*dlp=*/false, /*malware=*/true); SetScanPolicies(/*dlp=*/false, /*malware=*/true);
AddUrlToList(prefs::kURLsToCheckForMalwareOfUploadedContent, "*"); AddUrlToList(prefs::kURLsToCheckForMalwareOfUploadedContent, "*");
...@@ -1190,7 +1263,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, StringFileDataNoDLP) { ...@@ -1190,7 +1263,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, StringFileDataNoDLP) {
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, StringFileDataFailedDLP) { TEST_P(DeepScanningDialogDelegateAuditOnlyTest, StringFileDataFailedDLP) {
SetScanPolicies(/*dlp=*/true, /*malware=*/false); SetScanPolicies(/*dlp=*/true, /*malware=*/false);
GURL url(kTestUrl); GURL url(kTestUrl);
DeepScanningDialogDelegate::Data data; DeepScanningDialogDelegate::Data data;
...@@ -1224,7 +1297,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, StringFileDataFailedDLP) { ...@@ -1224,7 +1297,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, StringFileDataFailedDLP) {
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, StringFileDataPartialSuccess) { TEST_P(DeepScanningDialogDelegateAuditOnlyTest, StringFileDataPartialSuccess) {
GURL url(kTestUrl); GURL url(kTestUrl);
DeepScanningDialogDelegate::Data data; DeepScanningDialogDelegate::Data data;
ASSERT_TRUE(DeepScanningDialogDelegate::IsEnabled( ASSERT_TRUE(DeepScanningDialogDelegate::IsEnabled(
...@@ -1277,7 +1350,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, StringFileDataPartialSuccess) { ...@@ -1277,7 +1350,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, StringFileDataPartialSuccess) {
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, NoDelay) { TEST_P(DeepScanningDialogDelegateAuditOnlyTest, NoDelay) {
SetWaitPolicy(DELAY_NONE); SetWaitPolicy(DELAY_NONE);
AddUrlToList(prefs::kURLsToCheckForMalwareOfUploadedContent, "*"); AddUrlToList(prefs::kURLsToCheckForMalwareOfUploadedContent, "*");
GURL url(kTestUrl); GURL url(kTestUrl);
...@@ -1342,7 +1415,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, NoDelay) { ...@@ -1342,7 +1415,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, NoDelay) {
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, EmptyWait) { TEST_P(DeepScanningDialogDelegateAuditOnlyTest, EmptyWait) {
GURL url(kTestUrl); GURL url(kTestUrl);
DeepScanningDialogDelegate::Data data; DeepScanningDialogDelegate::Data data;
ASSERT_TRUE(DeepScanningDialogDelegate::IsEnabled( ASSERT_TRUE(DeepScanningDialogDelegate::IsEnabled(
...@@ -1365,7 +1438,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, EmptyWait) { ...@@ -1365,7 +1438,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, EmptyWait) {
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, SupportedTypes) { TEST_P(DeepScanningDialogDelegateAuditOnlyTest, SupportedTypes) {
content::InProcessUtilityThreadHelper in_process_utility_thread_helper; content::InProcessUtilityThreadHelper in_process_utility_thread_helper;
GURL url(kTestUrl); GURL url(kTestUrl);
...@@ -1406,7 +1479,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, SupportedTypes) { ...@@ -1406,7 +1479,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, SupportedTypes) {
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, UnsupportedTypesDefaultPolicy) { TEST_P(DeepScanningDialogDelegateAuditOnlyTest, UnsupportedTypesDefaultPolicy) {
GURL url(kTestUrl); GURL url(kTestUrl);
DeepScanningDialogDelegate::Data data; DeepScanningDialogDelegate::Data data;
ASSERT_TRUE(DeepScanningDialogDelegate::IsEnabled( ASSERT_TRUE(DeepScanningDialogDelegate::IsEnabled(
...@@ -1444,9 +1517,9 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, UnsupportedTypesDefaultPolicy) { ...@@ -1444,9 +1517,9 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, UnsupportedTypesDefaultPolicy) {
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, UnsupportedTypesBlockPolicy) { TEST_P(DeepScanningDialogDelegateAuditOnlyTest, UnsupportedTypesBlockPolicy) {
TestingBrowserProcess::GetGlobal()->local_state()->SetInteger( SetUnsupportedFileTypePolicy(
prefs::kBlockUnsupportedFiletypes, BLOCK_UNSUPPORTED_FILETYPES_UPLOADS); BLOCK_UNSUPPORTED_FILETYPES_UPLOADS_AND_DOWNLOADS);
GURL url(kTestUrl); GURL url(kTestUrl);
DeepScanningDialogDelegate::Data data; DeepScanningDialogDelegate::Data data;
EXPECT_TRUE(DeepScanningDialogDelegate::IsEnabled( EXPECT_TRUE(DeepScanningDialogDelegate::IsEnabled(
...@@ -1484,7 +1557,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, UnsupportedTypesBlockPolicy) { ...@@ -1484,7 +1557,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, UnsupportedTypesBlockPolicy) {
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, SupportedAndUnsupportedTypes) { TEST_P(DeepScanningDialogDelegateAuditOnlyTest, SupportedAndUnsupportedTypes) {
GURL url(kTestUrl); GURL url(kTestUrl);
DeepScanningDialogDelegate::Data data; DeepScanningDialogDelegate::Data data;
ASSERT_TRUE(DeepScanningDialogDelegate::IsEnabled( ASSERT_TRUE(DeepScanningDialogDelegate::IsEnabled(
...@@ -1531,7 +1604,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, SupportedAndUnsupportedTypes) { ...@@ -1531,7 +1604,7 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, SupportedAndUnsupportedTypes) {
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
TEST_F(DeepScanningDialogDelegateAuditOnlyTest, UnsupportedTypeAndDLPFailure) { TEST_P(DeepScanningDialogDelegateAuditOnlyTest, UnsupportedTypeAndDLPFailure) {
GURL url(kTestUrl); GURL url(kTestUrl);
DeepScanningDialogDelegate::Data data; DeepScanningDialogDelegate::Data data;
ASSERT_TRUE(DeepScanningDialogDelegate::IsEnabled( ASSERT_TRUE(DeepScanningDialogDelegate::IsEnabled(
...@@ -1569,17 +1642,48 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, UnsupportedTypeAndDLPFailure) { ...@@ -1569,17 +1642,48 @@ TEST_F(DeepScanningDialogDelegateAuditOnlyTest, UnsupportedTypeAndDLPFailure) {
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
// TODO(crbug/1041890): This test should not depend on
// DeepScanningDialogDelegateAuditOnlyTest. Refactor this by moving common
// functionalities to BaseTest or util classes/functions.
class DeepScanningDialogDelegateResultHandlingTest class DeepScanningDialogDelegateResultHandlingTest
: public DeepScanningDialogDelegateAuditOnlyTest, : public BaseTest,
public testing::WithParamInterface<BinaryUploadService::Result> {}; public testing::WithParamInterface<
std::tuple<BinaryUploadService::Result, bool>> {
public:
DeepScanningDialogDelegateResultHandlingTest()
: BaseTest(std::get<1>(GetParam())) {}
void SetUp() override {
BaseTest::SetUp();
EnableFeatures();
SetDlpPolicy(CHECK_UPLOADS);
SetMalwarePolicy(SEND_UPLOADS);
DeepScanningDialogDelegate::SetFactoryForTesting(base::BindRepeating(
&FakeDeepScanningDialogDelegate::Create, run_loop_.QuitClosure(),
base::BindRepeating(
&DeepScanningDialogDelegateResultHandlingTest::StatusCallback,
base::Unretained(this)),
/*encryption_callback=*/
base::BindRepeating([](const base::FilePath& path) { return false; }),
kDmToken));
}
BinaryUploadService::Result result() const { return std::get<0>(GetParam()); }
DeepScanningClientResponse StatusCallback(const base::FilePath& path) {
DeepScanningClientResponse response =
FakeDeepScanningDialogDelegate::SuccessfulResponse(
/*dlp*/ true, /*malware=*/true);
return response;
}
protected:
ScopedSetDMToken scoped_dm_token_{
policy::DMToken::CreateValidTokenForTesting(kDmToken)};
};
TEST_P(DeepScanningDialogDelegateResultHandlingTest, Test) { TEST_P(DeepScanningDialogDelegateResultHandlingTest, Test) {
GURL url(kTestUrl); GURL url(kTestUrl);
DeepScanningDialogDelegate::Data data; DeepScanningDialogDelegate::Data data;
FakeDeepScanningDialogDelegate::SetResponseResult(GetParam()); FakeDeepScanningDialogDelegate::SetResponseResult(result());
ASSERT_TRUE(DeepScanningDialogDelegate::IsEnabled( ASSERT_TRUE(DeepScanningDialogDelegate::IsEnabled(
profile(), url, &data, profile(), url, &data,
enterprise_connectors::AnalysisConnector::FILE_ATTACHED)); enterprise_connectors::AnalysisConnector::FILE_ATTACHED));
...@@ -1589,8 +1693,8 @@ TEST_P(DeepScanningDialogDelegateResultHandlingTest, Test) { ...@@ -1589,8 +1693,8 @@ TEST_P(DeepScanningDialogDelegateResultHandlingTest, Test) {
bool called = false; bool called = false;
ScanUpload( ScanUpload(
contents(), std::move(data), contents(), std::move(data),
base::BindOnce( base::BindLambdaForTesting(
[](bool* called, const DeepScanningDialogDelegate::Data& data, [this, &called](const DeepScanningDialogDelegate::Data& data,
const DeepScanningDialogDelegate::Result& result) { const DeepScanningDialogDelegate::Result& result) {
EXPECT_EQ(0u, data.text.size()); EXPECT_EQ(0u, data.text.size());
EXPECT_EQ(1u, data.paths.size()); EXPECT_EQ(1u, data.paths.size());
...@@ -1599,18 +1703,18 @@ TEST_P(DeepScanningDialogDelegateResultHandlingTest, Test) { ...@@ -1599,18 +1703,18 @@ TEST_P(DeepScanningDialogDelegateResultHandlingTest, Test) {
bool expected = bool expected =
DeepScanningDialogDelegate::ResultShouldAllowDataUse( DeepScanningDialogDelegate::ResultShouldAllowDataUse(
GetParam(), data.settings); this->result(), data.settings);
EXPECT_EQ(expected, result.paths_results[0]); EXPECT_EQ(expected, result.paths_results[0]);
*called = true; called = true;
}, }));
&called));
RunUntilDone(); RunUntilDone();
EXPECT_TRUE(called); EXPECT_TRUE(called);
} }
INSTANTIATE_TEST_SUITE_P( INSTANTIATE_TEST_SUITE_P(
Tests, ,
DeepScanningDialogDelegateResultHandlingTest, DeepScanningDialogDelegateResultHandlingTest,
testing::Combine(
testing::Values(BinaryUploadService::Result::UNKNOWN, testing::Values(BinaryUploadService::Result::UNKNOWN,
BinaryUploadService::Result::SUCCESS, BinaryUploadService::Result::SUCCESS,
BinaryUploadService::Result::UPLOAD_FAILURE, BinaryUploadService::Result::UPLOAD_FAILURE,
...@@ -1618,11 +1722,32 @@ INSTANTIATE_TEST_SUITE_P( ...@@ -1618,11 +1722,32 @@ INSTANTIATE_TEST_SUITE_P(
BinaryUploadService::Result::FILE_TOO_LARGE, BinaryUploadService::Result::FILE_TOO_LARGE,
BinaryUploadService::Result::FAILED_TO_GET_TOKEN, BinaryUploadService::Result::FAILED_TO_GET_TOKEN,
BinaryUploadService::Result::UNAUTHORIZED, BinaryUploadService::Result::UNAUTHORIZED,
BinaryUploadService::Result::FILE_ENCRYPTED)); BinaryUploadService::Result::FILE_ENCRYPTED),
testing::Bool()));
class DeepScanningDialogDelegatePolicyResultsTest : public BaseTest { class DeepScanningDialogDelegatePolicyResultsTest
: public BaseTest,
public testing::WithParamInterface<bool> {
public: public:
DeepScanningDialogDelegatePolicyResultsTest() : BaseTest(GetParam()) {}
void SetUp() override {
BaseTest::SetUp();
EnableFeatures();
if (!use_legacy_policies_) {
// This is required since Connector policies can't return settings if
// there are no URL patterns. Legacy policies don't need to account for
// this since DLP is implicitly "*" on uploads.
AddUrlsToCheckForMalwareOfUploadsForConnectors({"*"});
}
}
enterprise_connectors::AnalysisSettings settings() { enterprise_connectors::AnalysisSettings settings() {
// Clear the cache before getting settings so there's no race with the pref
// change and the cached values being updated.
enterprise_connectors::ConnectorsManager::GetInstance()
->ClearCacheForTesting();
base::Optional<enterprise_connectors::AnalysisSettings> settings = base::Optional<enterprise_connectors::AnalysisSettings> settings =
enterprise_connectors::ConnectorsManager::GetInstance() enterprise_connectors::ConnectorsManager::GetInstance()
->GetAnalysisSettings( ->GetAnalysisSettings(
...@@ -1633,7 +1758,11 @@ class DeepScanningDialogDelegatePolicyResultsTest : public BaseTest { ...@@ -1633,7 +1758,11 @@ class DeepScanningDialogDelegatePolicyResultsTest : public BaseTest {
} }
}; };
TEST_F(DeepScanningDialogDelegatePolicyResultsTest, BlockLargeFile) { INSTANTIATE_TEST_SUITE_P(,
DeepScanningDialogDelegatePolicyResultsTest,
testing::Bool());
TEST_P(DeepScanningDialogDelegatePolicyResultsTest, BlockLargeFile) {
// The value returned by ResultShouldAllowDataUse for FILE_TOO_LARGE should // The value returned by ResultShouldAllowDataUse for FILE_TOO_LARGE should
// match the BlockLargeFilePolicy. // match the BlockLargeFilePolicy.
SetBlockLargeFilePolicy( SetBlockLargeFilePolicy(
...@@ -1654,7 +1783,7 @@ TEST_F(DeepScanningDialogDelegatePolicyResultsTest, BlockLargeFile) { ...@@ -1654,7 +1783,7 @@ TEST_F(DeepScanningDialogDelegatePolicyResultsTest, BlockLargeFile) {
BinaryUploadService::Result::FILE_TOO_LARGE, settings())); BinaryUploadService::Result::FILE_TOO_LARGE, settings()));
} }
TEST_F(DeepScanningDialogDelegatePolicyResultsTest, TEST_P(DeepScanningDialogDelegatePolicyResultsTest,
AllowPasswordProtectedFiles) { AllowPasswordProtectedFiles) {
// The value returned by ResultShouldAllowDataUse for FILE_ENCRYPTED should // The value returned by ResultShouldAllowDataUse for FILE_ENCRYPTED should
// match the AllowPasswordProtectedFiles policy. // match the AllowPasswordProtectedFiles policy.
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "components/policy/core/common/cloud/mock_cloud_policy_client.h" #include "components/policy/core/common/cloud/mock_cloud_policy_client.h"
#include "components/policy/core/common/cloud/realtime_reporting_job_configuration.h" #include "components/policy/core/common/cloud/realtime_reporting_job_configuration.h"
#include "components/prefs/scoped_user_pref_update.h" #include "components/prefs/scoped_user_pref_update.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -93,19 +94,19 @@ void ClearConnectorUrlPattern( ...@@ -93,19 +94,19 @@ void ClearConnectorUrlPattern(
return; return;
DCHECK(list->is_list()); DCHECK(list->is_list());
for (const base::Value& pattern : list->GetList()) { if (list->GetList().empty())
DCHECK(pattern.is_dict()); return;
list->EraseListValueIf([&tags](const base::Value& pattern) {
DCHECK(pattern.is_dict());
const base::Value* pattern_tags = const base::Value* pattern_tags =
pattern.FindKey(enterprise_connectors::kKeyTags); pattern.FindKey(enterprise_connectors::kKeyTags);
if (!pattern_tags) if (!pattern_tags)
continue; return false;
DCHECK(pattern_tags->is_list()); DCHECK(pattern_tags->is_list());
if (*pattern_tags == tags) { return (*pattern_tags == tags);
list->EraseListValue(pattern); });
}
}
} }
template <typename T> template <typename T>
...@@ -383,25 +384,22 @@ void SetDlpPolicyForConnectors(CheckContentComplianceValues state) { ...@@ -383,25 +384,22 @@ void SetDlpPolicyForConnectors(CheckContentComplianceValues state) {
// nothing for DLP. // nothing for DLP.
// This is replicated in the connector policies by adding the wildcard pattern // This is replicated in the connector policies by adding the wildcard pattern
// on upload connectors with the "dlp" tag in "enable" or "disable". The // on upload connectors with the "dlp" tag in "enable", and by removing any
// wildcard pattern should also be included in the disable list if the policy // "enable" patterns with the "dlp" tag when the policy is disabled.
// is disabled for downloads since no scan can occur with the legacy policy
// when it is disabled.
bool enable_uploads =
state == CHECK_UPLOADS || state == CHECK_UPLOADS_AND_DOWNLOADS;
if (state == CHECK_UPLOADS || state == CHECK_UPLOADS_AND_DOWNLOADS) {
AddConnectorUrlPattern( AddConnectorUrlPattern(
enterprise_connectors::AnalysisConnector::FILE_ATTACHED, enable_uploads, enterprise_connectors::AnalysisConnector::FILE_ATTACHED, true,
MakeListValue({"*"}), MakeListValue({"dlp"})); MakeListValue({"*"}), MakeListValue({"dlp"}));
AddConnectorUrlPattern( AddConnectorUrlPattern(
enterprise_connectors::AnalysisConnector::BULK_DATA_ENTRY, enable_uploads, enterprise_connectors::AnalysisConnector::BULK_DATA_ENTRY, true,
MakeListValue({"*"}), MakeListValue({"dlp"}));
if (state != CHECK_DOWNLOADS && state != CHECK_UPLOADS_AND_DOWNLOADS) {
AddConnectorUrlPattern(
enterprise_connectors::AnalysisConnector::FILE_DOWNLOADED, false,
MakeListValue({"*"}), MakeListValue({"dlp"})); MakeListValue({"*"}), MakeListValue({"dlp"}));
} else {
ClearUrlsToCheckComplianceOfUploadsForConnectors();
} }
if (state != CHECK_DOWNLOADS && state != CHECK_UPLOADS_AND_DOWNLOADS)
ClearUrlsToCheckComplianceOfDownloadsForConnectors();
} }
void SetMalwarePolicyForConnectors(SendFilesForMalwareCheckValues state) { void SetMalwarePolicyForConnectors(SendFilesForMalwareCheckValues state) {
...@@ -414,26 +412,20 @@ void SetMalwarePolicyForConnectors(SendFilesForMalwareCheckValues state) { ...@@ -414,26 +412,20 @@ void SetMalwarePolicyForConnectors(SendFilesForMalwareCheckValues state) {
// it's disabled. // it's disabled.
// This is replicated in the connector policies by adding the wildcard pattern // This is replicated in the connector policies by adding the wildcard pattern
// on the download connector with the "malware" tag in "enable" or "disable". // on the download connector with the "malware" tag in "enable", and by
// The wildcard pattern should also be included in the disable list if the // removing any "enable" patterns with the "malware" tag when the policy is
// policy is disabled for uploads since no scan can occur with the legacy // disabled.
// policy when it is disabled.
bool enable_downloads = if (state == SEND_DOWNLOADS || state == SEND_UPLOADS_AND_DOWNLOADS) {
state == SEND_DOWNLOADS || state == SEND_UPLOADS_AND_DOWNLOADS;
AddConnectorUrlPattern(
enterprise_connectors::AnalysisConnector::FILE_DOWNLOADED,
enable_downloads, MakeListValue({"*"}), MakeListValue({"malware"}));
if (state != SEND_UPLOADS && state != SEND_UPLOADS_AND_DOWNLOADS) {
AddConnectorUrlPattern( AddConnectorUrlPattern(
enterprise_connectors::AnalysisConnector::FILE_ATTACHED, false, enterprise_connectors::AnalysisConnector::FILE_DOWNLOADED, true,
MakeListValue({"*"}), MakeListValue({"malware"}));
AddConnectorUrlPattern(
enterprise_connectors::AnalysisConnector::BULK_DATA_ENTRY, false,
MakeListValue({"*"}), MakeListValue({"malware"})); MakeListValue({"*"}), MakeListValue({"malware"}));
} else {
ClearUrlsToCheckForMalwareOfDownloadsForConnectors();
} }
if (state != SEND_UPLOADS && state != SEND_UPLOADS_AND_DOWNLOADS)
ClearUrlsToCheckForMalwareOfUploadsForConnectors();
} }
void SetDelayDeliveryUntilVerdictPolicyForConnectors( void SetDelayDeliveryUntilVerdictPolicyForConnectors(
...@@ -456,16 +448,16 @@ void SetDelayDeliveryUntilVerdictPolicyForConnectors( ...@@ -456,16 +448,16 @@ void SetDelayDeliveryUntilVerdictPolicyForConnectors(
void SetAllowPasswordProtectedFilesPolicyForConnectors( void SetAllowPasswordProtectedFilesPolicyForConnectors(
AllowPasswordProtectedFilesValues state) { AllowPasswordProtectedFilesValues state) {
bool allow_uploads = bool block_uploads =
state == ALLOW_UPLOADS || state == ALLOW_UPLOADS_AND_DOWNLOADS; state != ALLOW_UPLOADS && state != ALLOW_UPLOADS_AND_DOWNLOADS;
bool allow_downloads = bool block_downloads =
state == ALLOW_DOWNLOADS || state == ALLOW_UPLOADS_AND_DOWNLOADS; state != ALLOW_DOWNLOADS && state != ALLOW_UPLOADS_AND_DOWNLOADS;
SetConnectorField(enterprise_connectors::AnalysisConnector::FILE_ATTACHED, SetConnectorField(enterprise_connectors::AnalysisConnector::FILE_ATTACHED,
enterprise_connectors::kKeyBlockPasswordProtected, enterprise_connectors::kKeyBlockPasswordProtected,
!allow_uploads); block_uploads);
SetConnectorField(enterprise_connectors::AnalysisConnector::FILE_DOWNLOADED, SetConnectorField(enterprise_connectors::AnalysisConnector::FILE_DOWNLOADED,
enterprise_connectors::kKeyBlockPasswordProtected, enterprise_connectors::kKeyBlockPasswordProtected,
!allow_downloads); block_downloads);
} }
void SetBlockUnsupportedFileTypesPolicyForConnectors( void SetBlockUnsupportedFileTypesPolicyForConnectors(
...@@ -531,10 +523,25 @@ void AddUrlsToNotCheckForMalwareOfDownloadsForConnectors( ...@@ -531,10 +523,25 @@ void AddUrlsToNotCheckForMalwareOfDownloadsForConnectors(
MakeListValue(urls), MakeListValue({"malware"})); MakeListValue(urls), MakeListValue({"malware"}));
} }
void ClearUrlsToCheckComplianceOfDownloadsForConnectors() { void AddUrlToListForConnectors(const char* pref_name, const std::string& url) {
ClearConnectorUrlPattern( if (pref_name == prefs::kURLsToCheckComplianceOfDownloadedContent)
enterprise_connectors::AnalysisConnector::FILE_DOWNLOADED, true, AddUrlsToCheckComplianceOfDownloadsForConnectors({url});
MakeListValue({"dlp"})); else if (pref_name == prefs::kURLsToNotCheckComplianceOfUploadedContent)
AddUrlsToNotCheckComplianceOfUploadsForConnectors({url});
else if (pref_name == prefs::kURLsToCheckForMalwareOfUploadedContent)
AddUrlsToCheckForMalwareOfUploadsForConnectors({url});
else if (pref_name == prefs::kURLsToNotCheckForMalwareOfDownloadedContent)
AddUrlsToNotCheckForMalwareOfDownloadsForConnectors({url});
else
NOTREACHED();
}
void ClearUrlsToCheckComplianceOfUploadsForConnectors() {
for (auto connector :
{enterprise_connectors::AnalysisConnector::FILE_ATTACHED,
enterprise_connectors::AnalysisConnector::BULK_DATA_ENTRY}) {
ClearConnectorUrlPattern(connector, true, MakeListValue({"dlp"}));
}
} }
void ClearUrlsToCheckForMalwareOfUploadsForConnectors() { void ClearUrlsToCheckForMalwareOfUploadsForConnectors() {
...@@ -545,4 +552,16 @@ void ClearUrlsToCheckForMalwareOfUploadsForConnectors() { ...@@ -545,4 +552,16 @@ void ClearUrlsToCheckForMalwareOfUploadsForConnectors() {
} }
} }
void ClearUrlsToCheckComplianceOfDownloadsForConnectors() {
ClearConnectorUrlPattern(
enterprise_connectors::AnalysisConnector::FILE_DOWNLOADED, true,
MakeListValue({"dlp"}));
}
void ClearUrlsToCheckForMalwareOfDownloadsForConnectors() {
ClearConnectorUrlPattern(
enterprise_connectors::AnalysisConnector::FILE_DOWNLOADED, true,
MakeListValue({"malware"}));
}
} // namespace safe_browsing } // namespace safe_browsing
...@@ -126,8 +126,11 @@ void AddUrlsToCheckForMalwareOfUploadsForConnectors( ...@@ -126,8 +126,11 @@ void AddUrlsToCheckForMalwareOfUploadsForConnectors(
const std::vector<std::string>& urls); const std::vector<std::string>& urls);
void AddUrlsToNotCheckForMalwareOfDownloadsForConnectors( void AddUrlsToNotCheckForMalwareOfDownloadsForConnectors(
const std::vector<std::string>& urls); const std::vector<std::string>& urls);
void ClearUrlsToCheckComplianceOfDownloadsForConnectors(); void AddUrlToListForConnectors(const char* pref_name, const std::string& url);
void ClearUrlsToCheckComplianceOfUploadsForConnectors();
void ClearUrlsToCheckForMalwareOfUploadsForConnectors(); void ClearUrlsToCheckForMalwareOfUploadsForConnectors();
void ClearUrlsToCheckComplianceOfDownloadsForConnectors();
void ClearUrlsToCheckForMalwareOfDownloadsForConnectors();
} // namespace safe_browsing } // namespace safe_browsing
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment