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