OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "components/policy/core/common/cloud/component_cloud_policy_store.h" | 5 #include "components/policy/core/common/cloud/component_cloud_policy_store.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 ComponentPolicyBuilder::kFakeToken); | 79 ComponentPolicyBuilder::kFakeToken); |
80 | 80 |
81 builder_.policy_data().set_policy_type( | 81 builder_.policy_data().set_policy_type( |
82 dm_protocol::kChromeExtensionPolicyType); | 82 dm_protocol::kChromeExtensionPolicyType); |
83 builder_.policy_data().set_settings_entity_id(kTestExtension); | 83 builder_.policy_data().set_settings_entity_id(kTestExtension); |
84 builder_.payload().set_download_url(kTestDownload); | 84 builder_.payload().set_download_url(kTestDownload); |
85 builder_.payload().set_secure_hash(TestPolicyHash()); | 85 builder_.payload().set_secure_hash(TestPolicyHash()); |
86 | 86 |
87 PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, kTestExtension); | 87 PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, kTestExtension); |
88 PolicyMap& policy = expected_bundle_.Get(ns); | 88 PolicyMap& policy = expected_bundle_.Get(ns); |
89 policy.Set("Name", | 89 policy.Set("Name", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
90 POLICY_LEVEL_MANDATORY, | |
91 POLICY_SCOPE_USER, | |
92 POLICY_SOURCE_CLOUD, | 90 POLICY_SOURCE_CLOUD, |
93 new base::StringValue("disabled"), | 91 base::WrapUnique(new base::StringValue("disabled")), nullptr); |
94 NULL); | 92 policy.Set("Second", POLICY_LEVEL_RECOMMENDED, POLICY_SCOPE_USER, |
95 policy.Set("Second", | |
96 POLICY_LEVEL_RECOMMENDED, | |
97 POLICY_SCOPE_USER, | |
98 POLICY_SOURCE_CLOUD, | 93 POLICY_SOURCE_CLOUD, |
99 new base::StringValue("maybe"), | 94 base::WrapUnique(new base::StringValue("maybe")), nullptr); |
100 NULL); | |
101 } | 95 } |
102 | 96 |
103 // Returns true if the policy exposed by the |store_| is empty. | 97 // Returns true if the policy exposed by the |store_| is empty. |
104 bool IsEmpty() { | 98 bool IsEmpty() { |
105 return store_->policy().begin() == store_->policy().end(); | 99 return store_->policy().begin() == store_->policy().end(); |
106 } | 100 } |
107 | 101 |
108 std::unique_ptr<em::PolicyFetchResponse> CreateResponse() { | 102 std::unique_ptr<em::PolicyFetchResponse> CreateResponse() { |
109 builder_.Build(); | 103 builder_.Build(); |
110 return base::WrapUnique(new em::PolicyFetchResponse(builder_.policy())); | 104 return base::WrapUnique(new em::PolicyFetchResponse(builder_.policy())); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 | 319 |
326 // And they aren't loaded anymore either. | 320 // And they aren't loaded anymore either. |
327 ComponentCloudPolicyStore yet_another_store(&store_delegate_, cache_.get()); | 321 ComponentCloudPolicyStore yet_another_store(&store_delegate_, cache_.get()); |
328 yet_another_store.SetCredentials(ComponentPolicyBuilder::kFakeUsername, | 322 yet_another_store.SetCredentials(ComponentPolicyBuilder::kFakeUsername, |
329 ComponentPolicyBuilder::kFakeToken); | 323 ComponentPolicyBuilder::kFakeToken); |
330 yet_another_store.Load(); | 324 yet_another_store.Load(); |
331 EXPECT_TRUE(yet_another_store.policy().Equals(empty_bundle)); | 325 EXPECT_TRUE(yet_another_store.policy().Equals(empty_bundle)); |
332 } | 326 } |
333 | 327 |
334 } // namespace policy | 328 } // namespace policy |
OLD | NEW |