Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: components/policy/core/common/cloud/component_cloud_policy_store_unittest.cc

Issue 1304843004: Add source column to chrome://policy showing the origins of policies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed another test. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
20 #include "crypto/sha2.h" 21 #include "crypto/sha2.h"
21 #include "policy/proto/chrome_extension_policy.pb.h" 22 #include "policy/proto/chrome_extension_policy.pb.h"
22 #include "policy/proto/device_management_backend.pb.h" 23 #include "policy/proto/device_management_backend.pb.h"
23 #include "testing/gmock/include/gmock/gmock.h" 24 #include "testing/gmock/include/gmock/gmock.h"
24 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
25 26
26 namespace em = enterprise_management; 27 namespace em = enterprise_management;
27 28
28 using testing::Mock; 29 using testing::Mock;
29 30
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 dm_protocol::kChromeExtensionPolicyType); 82 dm_protocol::kChromeExtensionPolicyType);
82 builder_.policy_data().set_settings_entity_id(kTestExtension); 83 builder_.policy_data().set_settings_entity_id(kTestExtension);
83 builder_.payload().set_download_url(kTestDownload); 84 builder_.payload().set_download_url(kTestDownload);
84 builder_.payload().set_secure_hash(TestPolicyHash()); 85 builder_.payload().set_secure_hash(TestPolicyHash());
85 86
86 PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, kTestExtension); 87 PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, kTestExtension);
87 PolicyMap& policy = expected_bundle_.Get(ns); 88 PolicyMap& policy = expected_bundle_.Get(ns);
88 policy.Set("Name", 89 policy.Set("Name",
89 POLICY_LEVEL_MANDATORY, 90 POLICY_LEVEL_MANDATORY,
90 POLICY_SCOPE_USER, 91 POLICY_SCOPE_USER,
92 POLICY_SOURCE_CLOUD,
91 new base::StringValue("disabled"), 93 new base::StringValue("disabled"),
92 NULL); 94 NULL);
93 policy.Set("Second", 95 policy.Set("Second",
94 POLICY_LEVEL_RECOMMENDED, 96 POLICY_LEVEL_RECOMMENDED,
95 POLICY_SCOPE_USER, 97 POLICY_SCOPE_USER,
98 POLICY_SOURCE_CLOUD,
96 new base::StringValue("maybe"), 99 new base::StringValue("maybe"),
97 NULL); 100 NULL);
98 } 101 }
99 102
100 // Returns true if the policy exposed by the |store_| is empty. 103 // Returns true if the policy exposed by the |store_| is empty.
101 bool IsEmpty() { 104 bool IsEmpty() {
102 return store_->policy().begin() == store_->policy().end(); 105 return store_->policy().begin() == store_->policy().end();
103 } 106 }
104 107
105 scoped_ptr<em::PolicyFetchResponse> CreateResponse() { 108 scoped_ptr<em::PolicyFetchResponse> CreateResponse() {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 325
323 // And they aren't loaded anymore either. 326 // And they aren't loaded anymore either.
324 ComponentCloudPolicyStore yet_another_store(&store_delegate_, cache_.get()); 327 ComponentCloudPolicyStore yet_another_store(&store_delegate_, cache_.get());
325 yet_another_store.SetCredentials(ComponentPolicyBuilder::kFakeUsername, 328 yet_another_store.SetCredentials(ComponentPolicyBuilder::kFakeUsername,
326 ComponentPolicyBuilder::kFakeToken); 329 ComponentPolicyBuilder::kFakeToken);
327 yet_another_store.Load(); 330 yet_another_store.Load();
328 EXPECT_TRUE(yet_another_store.policy().Equals(empty_bundle)); 331 EXPECT_TRUE(yet_another_store.policy().Equals(empty_bundle));
329 } 332 }
330 333
331 } // namespace policy 334 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698