Commit 0d0a4d9a authored by Roman Sorokin's avatar Roman Sorokin Committed by Commit Bot

Check for if old policy has higher priority than new renamed policy

In case new renamed policy has lower priority (for example it's the
enterprise default value) and the old policy is set -- the old value
should be used.
Also modified a policy->pref mapping test.
The issue was introduced in crrev.com/c/2507771

Bug: 1151109, 1138572
Change-Id: I3fae90729a8aad1fbc946017b1f7a5134b727826
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2555058
Commit-Queue: Roman Sorokin [CET] <rsorokin@chromium.org>
Reviewed-by: default avatarJulian Pastarmov <pastarmovj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830589}
parent 5976d186
......@@ -4876,7 +4876,7 @@
"policy_pref_mapping_tests": [
{
"policies": { "QuickUnlockModeAllowlist": ["PIN"] },
"prefs": { "quick_unlock_mode_whitelist": {} }
"prefs": { "quick_unlock_mode_whitelist": { "value": ["PIN"]} }
}
]
},
......@@ -4886,7 +4886,7 @@
"policy_pref_mapping_tests": [
{
"policies": { "QuickUnlockModeWhitelist": ["PIN"] },
"prefs": { "quick_unlock_mode_whitelist": {} }
"prefs": { "quick_unlock_mode_whitelist": { "value": ["PIN"]} }
}
]
},
......
......@@ -362,6 +362,9 @@ void SetProviderPolicy(MockConfigurationPolicyProvider* provider,
const base::Value& policies,
PolicyLevel level) {
PolicyMap policy_map;
#if defined(OS_CHROMEOS)
SetEnterpriseUsersDefaults(&policy_map);
#endif // defined(OS_CHROMEOS)
for (const auto& it : policies.DictItems()) {
const PolicyDetails* policy_details = GetChromePolicyDetails(it.first);
ASSERT_TRUE(policy_details);
......
......@@ -137,7 +137,8 @@ void RemapRenamedPolicies(PolicyMap* policies) {
for (const auto& policy_pair : renamed_policies) {
PolicyMap::Entry* old_policy = policies->GetMutable(policy_pair.first);
const PolicyMap::Entry* new_policy = policies->Get(policy_pair.second);
if (old_policy && !new_policy) {
if (old_policy &&
(!new_policy || old_policy->has_higher_priority_than(*new_policy))) {
PolicyMap::Entry policy_entry = old_policy->DeepCopy();
// TODO(pastarmovj): Re-add the policy errors in a way that does not
// depend on resources being loaded that early.
......
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