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 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
795 GenerateDeviceLocalAccountUserId(kAccount1, | 797 GenerateDeviceLocalAccountUserId(kAccount1, |
796 DeviceLocalAccount::TYPE_PUBLIC_SESSION), | 798 DeviceLocalAccount::TYPE_PUBLIC_SESSION), |
797 service_.get()); | 799 service_.get()); |
798 } | 800 } |
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 |
807 expected_policy_map_.Set(key::kDisableSpdy, | |
bartfab (slow)
2015/09/16 15:58:41
How come you expect a policy to be set that was no
fhorschig
2015/09/17 11:20:41
Removed. It's exactly what was set in line 144. I
| |
808 POLICY_LEVEL_MANDATORY, | |
809 POLICY_SCOPE_USER, | |
810 POLICY_SOURCE_CLOUD, | |
811 new base::FundamentalValue(true), | |
812 nullptr); | |
813 | |
805 // Values implicitly enforced for public accounts. | 814 // Values implicitly enforced for public accounts. |
806 expected_policy_map_.Set(key::kLidCloseAction, | 815 expected_policy_map_.Set(key::kLidCloseAction, |
807 POLICY_LEVEL_MANDATORY, | 816 POLICY_LEVEL_MANDATORY, |
808 POLICY_SCOPE_MACHINE, | 817 POLICY_SCOPE_MACHINE, |
818 POLICY_SOURCE_BUILT_IN, | |
809 new base::FundamentalValue( | 819 new base::FundamentalValue( |
810 chromeos::PowerPolicyController:: | 820 chromeos::PowerPolicyController:: |
811 ACTION_STOP_SESSION), | 821 ACTION_STOP_SESSION), |
812 NULL); | 822 NULL); |
813 expected_policy_map_.Set(key::kShelfAutoHideBehavior, | 823 expected_policy_map_.Set(key::kShelfAutoHideBehavior, |
814 POLICY_LEVEL_MANDATORY, | 824 POLICY_LEVEL_MANDATORY, |
815 POLICY_SCOPE_MACHINE, | 825 POLICY_SCOPE_MACHINE, |
826 POLICY_SOURCE_BUILT_IN, | |
816 new base::StringValue("Never"), | 827 new base::StringValue("Never"), |
817 NULL); | 828 NULL); |
818 expected_policy_map_.Set(key::kShowLogoutButtonInTray, | 829 expected_policy_map_.Set(key::kShowLogoutButtonInTray, |
819 POLICY_LEVEL_MANDATORY, | 830 POLICY_LEVEL_MANDATORY, |
820 POLICY_SCOPE_MACHINE, | 831 POLICY_SCOPE_MACHINE, |
832 POLICY_SOURCE_BUILT_IN, | |
821 new base::FundamentalValue(true), | 833 new base::FundamentalValue(true), |
822 NULL); | 834 NULL); |
823 expected_policy_map_.Set(key::kFullscreenAllowed, | 835 expected_policy_map_.Set(key::kFullscreenAllowed, |
824 POLICY_LEVEL_MANDATORY, | 836 POLICY_LEVEL_MANDATORY, |
825 POLICY_SCOPE_MACHINE, | 837 POLICY_SCOPE_MACHINE, |
838 POLICY_SOURCE_BUILT_IN, | |
826 new base::FundamentalValue(false), | 839 new base::FundamentalValue(false), |
827 NULL); | 840 NULL); |
828 } | 841 } |
829 | 842 |
830 void DeviceLocalAccountPolicyProviderTest::TearDown() { | 843 void DeviceLocalAccountPolicyProviderTest::TearDown() { |
831 provider_->RemoveObserver(&provider_observer_); | 844 provider_->RemoveObserver(&provider_observer_); |
832 provider_->Shutdown(); | 845 provider_->Shutdown(); |
833 provider_.reset(); | 846 provider_.reset(); |
834 DeviceLocalAccountPolicyServiceTestBase::TearDown(); | 847 DeviceLocalAccountPolicyServiceTestBase::TearDown(); |
835 } | 848 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
882 ASSERT_TRUE(broker); | 895 ASSERT_TRUE(broker); |
883 broker->core()->store()->Load(); | 896 broker->core()->store()->Load(); |
884 FlushDeviceSettings(); | 897 FlushDeviceSettings(); |
885 Mock::VerifyAndClearExpectations(&provider_observer_); | 898 Mock::VerifyAndClearExpectations(&provider_observer_); |
886 | 899 |
887 expected_policy_bundle.Get( | 900 expected_policy_bundle.Get( |
888 PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) | 901 PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) |
889 .Set(key::kDisableSpdy, | 902 .Set(key::kDisableSpdy, |
890 POLICY_LEVEL_MANDATORY, | 903 POLICY_LEVEL_MANDATORY, |
891 POLICY_SCOPE_USER, | 904 POLICY_SCOPE_USER, |
905 POLICY_SOURCE_CLOUD, | |
892 new base::FundamentalValue(false), | 906 new base::FundamentalValue(false), |
893 NULL); | 907 NULL); |
894 EXPECT_TRUE(expected_policy_bundle.Equals(provider_->policies())); | 908 EXPECT_TRUE(expected_policy_bundle.Equals(provider_->policies())); |
895 | 909 |
896 // Any values set for the |ShelfAutoHideBehavior|, |ShowLogoutButtonInTray| | 910 // Any values set for the |ShelfAutoHideBehavior|, |ShowLogoutButtonInTray| |
897 // and |ExtensionAllowedTypes| policies should be overridden. | 911 // and |ExtensionAllowedTypes| policies should be overridden. |
898 EXPECT_CALL(provider_observer_, OnUpdatePolicy(provider_.get())) | 912 EXPECT_CALL(provider_observer_, OnUpdatePolicy(provider_.get())) |
899 .Times(AtLeast(1)); | 913 .Times(AtLeast(1)); |
900 device_local_account_policy_.payload().mutable_shelfautohidebehavior()-> | 914 device_local_account_policy_.payload().mutable_shelfautohidebehavior()-> |
901 set_value("Always"); | 915 set_value("Always"); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
972 em::DeviceManagementResponse response; | 986 em::DeviceManagementResponse response; |
973 device_local_account_policy_.Build(); | 987 device_local_account_policy_.Build(); |
974 response.mutable_policy_response()->add_response()->CopyFrom( | 988 response.mutable_policy_response()->add_response()->CopyFrom( |
975 device_local_account_policy_.policy()); | 989 device_local_account_policy_.policy()); |
976 request_job->SendResponse(DM_STATUS_SUCCESS, response); | 990 request_job->SendResponse(DM_STATUS_SUCCESS, response); |
977 FlushDeviceSettings(); | 991 FlushDeviceSettings(); |
978 Mock::VerifyAndClearExpectations(&provider_observer_); | 992 Mock::VerifyAndClearExpectations(&provider_observer_); |
979 } | 993 } |
980 | 994 |
981 } // namespace policy | 995 } // namespace policy |
OLD | NEW |