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/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/test/test_simple_task_runner.h" | 15 #include "base/test/test_simple_task_runner.h" |
16 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 16 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
17 #include "components/policy/core/common/cloud/policy_builder.h" | 17 #include "components/policy/core/common/cloud/policy_builder.h" |
18 #include "components/policy/core/common/cloud/resource_cache.h" | 18 #include "components/policy/core/common/cloud/resource_cache.h" |
19 #include "components/policy/core/common/external_data_fetcher.h" | 19 #include "components/policy/core/common/external_data_fetcher.h" |
20 #include "components/policy/core/common/policy_types.h" | |
21 #include "crypto/sha2.h" | 20 #include "crypto/sha2.h" |
22 #include "policy/proto/chrome_extension_policy.pb.h" | 21 #include "policy/proto/chrome_extension_policy.pb.h" |
23 #include "policy/proto/device_management_backend.pb.h" | 22 #include "policy/proto/device_management_backend.pb.h" |
24 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
26 | 25 |
27 namespace em = enterprise_management; | 26 namespace em = enterprise_management; |
28 | 27 |
29 using testing::Mock; | 28 using testing::Mock; |
30 | 29 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 dm_protocol::kChromeExtensionPolicyType); | 81 dm_protocol::kChromeExtensionPolicyType); |
83 builder_.policy_data().set_settings_entity_id(kTestExtension); | 82 builder_.policy_data().set_settings_entity_id(kTestExtension); |
84 builder_.payload().set_download_url(kTestDownload); | 83 builder_.payload().set_download_url(kTestDownload); |
85 builder_.payload().set_secure_hash(TestPolicyHash()); | 84 builder_.payload().set_secure_hash(TestPolicyHash()); |
86 | 85 |
87 PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, kTestExtension); | 86 PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, kTestExtension); |
88 PolicyMap& policy = expected_bundle_.Get(ns); | 87 PolicyMap& policy = expected_bundle_.Get(ns); |
89 policy.Set("Name", | 88 policy.Set("Name", |
90 POLICY_LEVEL_MANDATORY, | 89 POLICY_LEVEL_MANDATORY, |
91 POLICY_SCOPE_USER, | 90 POLICY_SCOPE_USER, |
92 POLICY_SOURCE_CLOUD, | |
93 new base::StringValue("disabled"), | 91 new base::StringValue("disabled"), |
94 NULL); | 92 NULL); |
95 policy.Set("Second", | 93 policy.Set("Second", |
96 POLICY_LEVEL_RECOMMENDED, | 94 POLICY_LEVEL_RECOMMENDED, |
97 POLICY_SCOPE_USER, | 95 POLICY_SCOPE_USER, |
98 POLICY_SOURCE_CLOUD, | |
99 new base::StringValue("maybe"), | 96 new base::StringValue("maybe"), |
100 NULL); | 97 NULL); |
101 } | 98 } |
102 | 99 |
103 // Returns true if the policy exposed by the |store_| is empty. | 100 // Returns true if the policy exposed by the |store_| is empty. |
104 bool IsEmpty() { | 101 bool IsEmpty() { |
105 return store_->policy().begin() == store_->policy().end(); | 102 return store_->policy().begin() == store_->policy().end(); |
106 } | 103 } |
107 | 104 |
108 scoped_ptr<em::PolicyFetchResponse> CreateResponse() { | 105 scoped_ptr<em::PolicyFetchResponse> CreateResponse() { |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 | 322 |
326 // And they aren't loaded anymore either. | 323 // And they aren't loaded anymore either. |
327 ComponentCloudPolicyStore yet_another_store(&store_delegate_, cache_.get()); | 324 ComponentCloudPolicyStore yet_another_store(&store_delegate_, cache_.get()); |
328 yet_another_store.SetCredentials(ComponentPolicyBuilder::kFakeUsername, | 325 yet_another_store.SetCredentials(ComponentPolicyBuilder::kFakeUsername, |
329 ComponentPolicyBuilder::kFakeToken); | 326 ComponentPolicyBuilder::kFakeToken); |
330 yet_another_store.Load(); | 327 yet_another_store.Load(); |
331 EXPECT_TRUE(yet_another_store.policy().Equals(empty_bundle)); | 328 EXPECT_TRUE(yet_another_store.policy().Equals(empty_bundle)); |
332 } | 329 } |
333 | 330 |
334 } // namespace policy | 331 } // namespace policy |
OLD | NEW |