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

Side by Side Diff: components/policy/core/common/cloud/component_cloud_policy_service_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_service.h" 5 #include "components/policy/core/common/cloud/component_cloud_policy_service.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 builder_.policy_data().set_policy_type( 123 builder_.policy_data().set_policy_type(
124 dm_protocol::kChromeExtensionPolicyType); 124 dm_protocol::kChromeExtensionPolicyType);
125 builder_.policy_data().set_settings_entity_id(kTestExtension); 125 builder_.policy_data().set_settings_entity_id(kTestExtension);
126 builder_.payload().set_download_url(kTestDownload); 126 builder_.payload().set_download_url(kTestDownload);
127 builder_.payload().set_secure_hash(crypto::SHA256HashString(kTestPolicy)); 127 builder_.payload().set_secure_hash(crypto::SHA256HashString(kTestPolicy));
128 128
129 expected_policy_.Set("Name", 129 expected_policy_.Set("Name",
130 POLICY_LEVEL_MANDATORY, 130 POLICY_LEVEL_MANDATORY,
131 POLICY_SCOPE_USER, 131 POLICY_SCOPE_USER,
132 POLICY_SOURCE_CLOUD,
132 new base::StringValue("disabled"), 133 new base::StringValue("disabled"),
133 nullptr); 134 nullptr);
134 expected_policy_.Set("Second", 135 expected_policy_.Set("Second",
135 POLICY_LEVEL_RECOMMENDED, 136 POLICY_LEVEL_RECOMMENDED,
136 POLICY_SCOPE_USER, 137 POLICY_SCOPE_USER,
138 POLICY_SOURCE_CLOUD,
137 new base::StringValue("maybe"), 139 new base::StringValue("maybe"),
138 nullptr); 140 nullptr);
139 } 141 }
140 142
141 void TearDown() override { 143 void TearDown() override {
142 // The service cleans up its backend on the background thread. 144 // The service cleans up its backend on the background thread.
143 service_.reset(); 145 service_.reset();
144 RunUntilIdle(); 146 RunUntilIdle();
145 } 147 }
146 148
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 // The initial, cached policy will be served once the backend is initialized. 509 // The initial, cached policy will be served once the backend is initialized.
508 EXPECT_CALL(delegate_, OnComponentCloudPolicyUpdated()); 510 EXPECT_CALL(delegate_, OnComponentCloudPolicyUpdated());
509 Connect(); 511 Connect();
510 Mock::VerifyAndClearExpectations(&delegate_); 512 Mock::VerifyAndClearExpectations(&delegate_);
511 513
512 PolicyBundle expected_bundle; 514 PolicyBundle expected_bundle;
513 const PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, kTestExtension); 515 const PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, kTestExtension);
514 expected_bundle.Get(ns).Set("Name", 516 expected_bundle.Get(ns).Set("Name",
515 POLICY_LEVEL_MANDATORY, 517 POLICY_LEVEL_MANDATORY,
516 POLICY_SCOPE_USER, 518 POLICY_SCOPE_USER,
519 POLICY_SOURCE_CLOUD,
517 new base::StringValue("published"), 520 new base::StringValue("published"),
518 nullptr); 521 nullptr);
519 EXPECT_TRUE(service_->policy().Equals(expected_bundle)); 522 EXPECT_TRUE(service_->policy().Equals(expected_bundle));
520 } 523 }
521 524
522 TEST_F(ComponentCloudPolicyServiceTest, PurgeWhenServerRemovesPolicy) { 525 TEST_F(ComponentCloudPolicyServiceTest, PurgeWhenServerRemovesPolicy) {
523 // Initialize with cached policy. 526 // Initialize with cached policy.
524 PopulateCache(); 527 PopulateCache();
525 Connect(); 528 Connect();
526 529
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 EXPECT_TRUE(ContainsKey(contents, kTestExtension)); 575 EXPECT_TRUE(ContainsKey(contents, kTestExtension));
573 EXPECT_FALSE(ContainsKey(contents, kTestExtension2)); 576 EXPECT_FALSE(ContainsKey(contents, kTestExtension2));
574 577
575 // And the service isn't publishing policy for the second extension anymore. 578 // And the service isn't publishing policy for the second extension anymore.
576 expected_bundle.Clear(); 579 expected_bundle.Clear();
577 expected_bundle.Get(ns).CopyFrom(expected_policy_); 580 expected_bundle.Get(ns).CopyFrom(expected_policy_);
578 EXPECT_TRUE(service_->policy().Equals(expected_bundle)); 581 EXPECT_TRUE(service_->policy().Equals(expected_bundle));
579 } 582 }
580 583
581 } // namespace policy 584 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698