OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" | 5 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "chromeos/dbus/power_policy_controller.h" | 31 #include "chromeos/dbus/power_policy_controller.h" |
32 #include "components/policy/core/common/cloud/cloud_policy_client.h" | 32 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
33 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 33 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
34 #include "components/policy/core/common/cloud/cloud_policy_service.h" | 34 #include "components/policy/core/common/cloud/cloud_policy_service.h" |
35 #include "components/policy/core/common/cloud/mock_device_management_service.h" | 35 #include "components/policy/core/common/cloud/mock_device_management_service.h" |
36 #include "components/policy/core/common/cloud/policy_builder.h" | 36 #include "components/policy/core/common/cloud/policy_builder.h" |
37 #include "components/policy/core/common/external_data_fetcher.h" | 37 #include "components/policy/core/common/external_data_fetcher.h" |
38 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 38 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
39 #include "components/policy/core/common/policy_bundle.h" | 39 #include "components/policy/core/common/policy_bundle.h" |
40 #include "components/policy/core/common/policy_map.h" | 40 #include "components/policy/core/common/policy_map.h" |
| 41 #include "components/policy/core/common/policy_types.h" |
41 #include "components/policy/core/common/schema_registry.h" | 42 #include "components/policy/core/common/schema_registry.h" |
42 #include "net/url_request/url_request_context_getter.h" | 43 #include "net/url_request/url_request_context_getter.h" |
43 #include "net/url_request/url_request_test_util.h" | 44 #include "net/url_request/url_request_test_util.h" |
44 #include "policy/policy_constants.h" | 45 #include "policy/policy_constants.h" |
45 #include "policy/proto/cloud_policy.pb.h" | 46 #include "policy/proto/cloud_policy.pb.h" |
46 #include "policy/proto/device_management_backend.pb.h" | 47 #include "policy/proto/device_management_backend.pb.h" |
47 #include "testing/gtest/include/gtest/gtest.h" | 48 #include "testing/gtest/include/gtest/gtest.h" |
48 | 49 |
49 using testing::AnyNumber; | 50 using testing::AnyNumber; |
50 using testing::AtLeast; | 51 using testing::AtLeast; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 cros_settings_(&device_settings_service_), | 137 cros_settings_(&device_settings_service_), |
137 extension_cache_task_runner_(new base::TestSimpleTaskRunner) { | 138 extension_cache_task_runner_(new base::TestSimpleTaskRunner) { |
138 } | 139 } |
139 | 140 |
140 void DeviceLocalAccountPolicyServiceTestBase::SetUp() { | 141 void DeviceLocalAccountPolicyServiceTestBase::SetUp() { |
141 chromeos::DeviceSettingsTestBase::SetUp(); | 142 chromeos::DeviceSettingsTestBase::SetUp(); |
142 | 143 |
143 expected_policy_map_.Set(key::kDisableSpdy, | 144 expected_policy_map_.Set(key::kDisableSpdy, |
144 POLICY_LEVEL_MANDATORY, | 145 POLICY_LEVEL_MANDATORY, |
145 POLICY_SCOPE_USER, | 146 POLICY_SCOPE_USER, |
| 147 POLICY_SOURCE_CLOUD, |
146 new base::FundamentalValue(true), | 148 new base::FundamentalValue(true), |
147 NULL); | 149 NULL); |
148 | 150 |
149 device_local_account_policy_.payload().mutable_disablespdy()->set_value( | 151 device_local_account_policy_.payload().mutable_disablespdy()->set_value( |
150 true); | 152 true); |
151 device_local_account_policy_.policy_data().set_policy_type( | 153 device_local_account_policy_.policy_data().set_policy_type( |
152 dm_protocol::kChromePublicAccountPolicyType); | 154 dm_protocol::kChromePublicAccountPolicyType); |
153 } | 155 } |
154 | 156 |
155 void DeviceLocalAccountPolicyServiceTestBase::TearDown() { | 157 void DeviceLocalAccountPolicyServiceTestBase::TearDown() { |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 | 801 |
800 void DeviceLocalAccountPolicyProviderTest::SetUp() { | 802 void DeviceLocalAccountPolicyProviderTest::SetUp() { |
801 DeviceLocalAccountPolicyServiceTestBase::SetUp(); | 803 DeviceLocalAccountPolicyServiceTestBase::SetUp(); |
802 provider_->Init(&schema_registry_); | 804 provider_->Init(&schema_registry_); |
803 provider_->AddObserver(&provider_observer_); | 805 provider_->AddObserver(&provider_observer_); |
804 | 806 |
805 // Values implicitly enforced for public accounts. | 807 // Values implicitly enforced for public accounts. |
806 expected_policy_map_.Set(key::kLidCloseAction, | 808 expected_policy_map_.Set(key::kLidCloseAction, |
807 POLICY_LEVEL_MANDATORY, | 809 POLICY_LEVEL_MANDATORY, |
808 POLICY_SCOPE_MACHINE, | 810 POLICY_SCOPE_MACHINE, |
| 811 POLICY_SOURCE_ENTERPRISE_OVERRIDE, |
809 new base::FundamentalValue( | 812 new base::FundamentalValue( |
810 chromeos::PowerPolicyController:: | 813 chromeos::PowerPolicyController:: |
811 ACTION_STOP_SESSION), | 814 ACTION_STOP_SESSION), |
812 NULL); | 815 NULL); |
813 expected_policy_map_.Set(key::kShelfAutoHideBehavior, | 816 expected_policy_map_.Set(key::kShelfAutoHideBehavior, |
814 POLICY_LEVEL_MANDATORY, | 817 POLICY_LEVEL_MANDATORY, |
815 POLICY_SCOPE_MACHINE, | 818 POLICY_SCOPE_MACHINE, |
| 819 POLICY_SOURCE_ENTERPRISE_OVERRIDE, |
816 new base::StringValue("Never"), | 820 new base::StringValue("Never"), |
817 NULL); | 821 NULL); |
818 expected_policy_map_.Set(key::kShowLogoutButtonInTray, | 822 expected_policy_map_.Set(key::kShowLogoutButtonInTray, |
819 POLICY_LEVEL_MANDATORY, | 823 POLICY_LEVEL_MANDATORY, |
820 POLICY_SCOPE_MACHINE, | 824 POLICY_SCOPE_MACHINE, |
| 825 POLICY_SOURCE_ENTERPRISE_OVERRIDE, |
821 new base::FundamentalValue(true), | 826 new base::FundamentalValue(true), |
822 NULL); | 827 NULL); |
823 expected_policy_map_.Set(key::kFullscreenAllowed, | 828 expected_policy_map_.Set(key::kFullscreenAllowed, |
824 POLICY_LEVEL_MANDATORY, | 829 POLICY_LEVEL_MANDATORY, |
825 POLICY_SCOPE_MACHINE, | 830 POLICY_SCOPE_MACHINE, |
| 831 POLICY_SOURCE_ENTERPRISE_OVERRIDE, |
826 new base::FundamentalValue(false), | 832 new base::FundamentalValue(false), |
827 NULL); | 833 NULL); |
828 } | 834 } |
829 | 835 |
830 void DeviceLocalAccountPolicyProviderTest::TearDown() { | 836 void DeviceLocalAccountPolicyProviderTest::TearDown() { |
831 provider_->RemoveObserver(&provider_observer_); | 837 provider_->RemoveObserver(&provider_observer_); |
832 provider_->Shutdown(); | 838 provider_->Shutdown(); |
833 provider_.reset(); | 839 provider_.reset(); |
834 DeviceLocalAccountPolicyServiceTestBase::TearDown(); | 840 DeviceLocalAccountPolicyServiceTestBase::TearDown(); |
835 } | 841 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 ASSERT_TRUE(broker); | 888 ASSERT_TRUE(broker); |
883 broker->core()->store()->Load(); | 889 broker->core()->store()->Load(); |
884 FlushDeviceSettings(); | 890 FlushDeviceSettings(); |
885 Mock::VerifyAndClearExpectations(&provider_observer_); | 891 Mock::VerifyAndClearExpectations(&provider_observer_); |
886 | 892 |
887 expected_policy_bundle.Get( | 893 expected_policy_bundle.Get( |
888 PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) | 894 PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) |
889 .Set(key::kDisableSpdy, | 895 .Set(key::kDisableSpdy, |
890 POLICY_LEVEL_MANDATORY, | 896 POLICY_LEVEL_MANDATORY, |
891 POLICY_SCOPE_USER, | 897 POLICY_SCOPE_USER, |
| 898 POLICY_SOURCE_CLOUD, |
892 new base::FundamentalValue(false), | 899 new base::FundamentalValue(false), |
893 NULL); | 900 NULL); |
894 EXPECT_TRUE(expected_policy_bundle.Equals(provider_->policies())); | 901 EXPECT_TRUE(expected_policy_bundle.Equals(provider_->policies())); |
895 | 902 |
896 // Any values set for the |ShelfAutoHideBehavior|, |ShowLogoutButtonInTray| | 903 // Any values set for the |ShelfAutoHideBehavior|, |ShowLogoutButtonInTray| |
897 // and |ExtensionAllowedTypes| policies should be overridden. | 904 // and |ExtensionAllowedTypes| policies should be overridden. |
898 EXPECT_CALL(provider_observer_, OnUpdatePolicy(provider_.get())) | 905 EXPECT_CALL(provider_observer_, OnUpdatePolicy(provider_.get())) |
899 .Times(AtLeast(1)); | 906 .Times(AtLeast(1)); |
900 device_local_account_policy_.payload().mutable_shelfautohidebehavior()-> | 907 device_local_account_policy_.payload().mutable_shelfautohidebehavior()-> |
901 set_value("Always"); | 908 set_value("Always"); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 em::DeviceManagementResponse response; | 979 em::DeviceManagementResponse response; |
973 device_local_account_policy_.Build(); | 980 device_local_account_policy_.Build(); |
974 response.mutable_policy_response()->add_response()->CopyFrom( | 981 response.mutable_policy_response()->add_response()->CopyFrom( |
975 device_local_account_policy_.policy()); | 982 device_local_account_policy_.policy()); |
976 request_job->SendResponse(DM_STATUS_SUCCESS, response); | 983 request_job->SendResponse(DM_STATUS_SUCCESS, response); |
977 FlushDeviceSettings(); | 984 FlushDeviceSettings(); |
978 Mock::VerifyAndClearExpectations(&provider_observer_); | 985 Mock::VerifyAndClearExpectations(&provider_observer_); |
979 } | 986 } |
980 | 987 |
981 } // namespace policy | 988 } // namespace policy |
OLD | NEW |