Commit 82cf2844 authored by Dominique Fauteux-Chapleau's avatar Dominique Fauteux-Chapleau Committed by Chromium LUCI CQ

Add testing config for per-profile Connectors

A small change in ConnectorsService is required to make this test config
work. When checking analysis/reporting settings, 2 things are required
to obtain settings: a policy set to a valid value and a DM token (from
the browser or the profile). The previous implementation checked the DM
token first, meaning the blocking BrowserDMTokenStorage::RetrieveDMToken
call would trigger on multiple tests and crash them (see patchset 1
failures for examples of this).

The solution is to simply switch the
order of checks and read the policy first. This is also a valid
optimization of Connectors logic, as reading prefs is faster than
potentially reading the DM token from local storage.

Change-Id: Ie1026b57cf7a4fd66663530ec2a77a72f21d6d81
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2623812
Commit-Queue: Dominique Fauteux-Chapleau <domfc@chromium.org>
Reviewed-by: default avatarMarc-André Decoste <mad@chromium.org>
Reviewed-by: default avatarRobert Kaplow <rkaplow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843115}
parent bfdb84b7
......@@ -128,17 +128,18 @@ base::Optional<ReportingSettings> ConnectorsService::GetReportingSettings(
if (!ConnectorsEnabled())
return base::nullopt;
base::Optional<ReportingSettings> settings =
connectors_manager_->GetReportingSettings(connector);
if (!settings.has_value())
return base::nullopt;
base::Optional<DmToken> dm_token = GetDmToken(ConnectorScopePref(connector));
if (!dm_token.has_value())
return base::nullopt;
base::Optional<ReportingSettings> settings =
connectors_manager_->GetReportingSettings(connector);
if (settings.has_value()) {
settings.value().dm_token = dm_token.value().value;
settings.value().per_profile =
dm_token.value().scope == policy::POLICY_SCOPE_USER;
}
settings.value().dm_token = dm_token.value().value;
settings.value().per_profile =
dm_token.value().scope == policy::POLICY_SCOPE_USER;
return settings;
}
......@@ -149,15 +150,16 @@ base::Optional<AnalysisSettings> ConnectorsService::GetAnalysisSettings(
if (!ConnectorsEnabled())
return base::nullopt;
base::Optional<AnalysisSettings> settings =
connectors_manager_->GetAnalysisSettings(url, connector);
if (!settings.has_value())
return base::nullopt;
base::Optional<DmToken> dm_token = GetDmToken(ConnectorScopePref(connector));
if (!dm_token.has_value())
return base::nullopt;
base::Optional<AnalysisSettings> settings =
connectors_manager_->GetAnalysisSettings(url, connector);
if (settings.has_value()) {
settings.value().dm_token = dm_token.value().value;
}
settings.value().dm_token = dm_token.value().value;
return settings;
}
......
......@@ -8292,7 +8292,7 @@
]
}
],
"WebProtectConnectors": [
"WebProtectPerProfile": [
{
"platforms": [
"chromeos",
......@@ -8304,7 +8304,7 @@
{
"name": "Enabled",
"enable_features": [
"EnterpriseConnectorsEnabled"
"PerProfileConnectorsEnabled"
]
}
]
......
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