| // Copyright 2021 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #include "base/values.h" |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/policy/chrome_browser_policy_connector.h" |
| #include "chrome/browser/policy/policy_test_utils.h" |
| #include "chrome/browser/policy/profile_policy_connector.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "components/policy/core/common/policy_map.h" |
| #include "components/policy/core/common/policy_namespace.h" |
| #include "components/policy/core/common/policy_service.h" |
| #include "components/policy/core/common/policy_types.h" |
| #include "components/policy/policy_constants.h" |
| #include "content/public/test/browser_test.h" |
| |
| namespace policy { |
| |
| IN_PROC_BROWSER_TEST_F(PolicyTest, SeparateProxyPoliciesMerging) { |
| // Add an individual proxy policy value. |
| PolicyMap policies; |
| policies.Set(key::kProxyServerMode, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| POLICY_SOURCE_CLOUD, base::Value(3), nullptr); |
| UpdateProviderPolicy(policies); |
| |
| // It should be removed and replaced with a dictionary. |
| PolicyMap expected; |
| base::Value expected_value(base::Value::Type::DICTIONARY); |
| expected_value.SetIntKey(key::kProxyServerMode, 3); |
| expected.Set(key::kProxySettings, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
| POLICY_SOURCE_CLOUD, std::move(expected_value), nullptr); |
| #if BUILDFLAG(IS_CHROMEOS_ASH) |
| SetEnterpriseUsersDefaults(&expected); |
| #endif |
| |
| // Check both the browser and the profile. |
| const PolicyMap& actual_from_browser = |
| g_browser_process->browser_policy_connector() |
| ->GetPolicyService() |
| ->GetPolicies(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())); |
| EXPECT_TRUE(expected.Equals(actual_from_browser)); |
| const PolicyMap& actual_from_profile = |
| browser() |
| ->profile() |
| ->GetProfilePolicyConnector() |
| ->policy_service() |
| ->GetPolicies(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())); |
| EXPECT_TRUE(expected.Equals(actual_from_profile)); |
| } |
| |
| } // namespace policy |