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

Unified Diff: chrome/browser/policy/cloud/component_cloud_policy_service_unittest.cc

Issue 78953002: Fixes and improvements to cloud policy for extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/cloud/component_cloud_policy_service_unittest.cc
diff --git a/chrome/browser/policy/cloud/component_cloud_policy_service_unittest.cc b/chrome/browser/policy/cloud/component_cloud_policy_service_unittest.cc
index e0342288809f21dd83de872485c25bf5ccd748b5..e40855ac4ab56f76948d586b04019b5b0516fc09 100644
--- a/chrome/browser/policy/cloud/component_cloud_policy_service_unittest.cc
+++ b/chrome/browser/policy/cloud/component_cloud_policy_service_unittest.cc
@@ -57,6 +57,16 @@ const char kTestPolicy[] =
" }"
"}";
+const char kInvalidTestPolicy[] =
+ "{"
+ " \"Name\": {"
+ " \"Value\": \"published\""
+ " },"
+ " \"Undeclared Name\": {"
+ " \"Value\": \"not published\""
+ " }"
+ "}";
+
const char kTestSchema[] =
"{"
" \"type\": \"object\","
@@ -516,4 +526,29 @@ TEST_F(ComponentCloudPolicyServiceTest, SignOut) {
ASSERT_EQ(0u, contents.size());
}
+TEST_F(ComponentCloudPolicyServiceTest, LoadInvalidPolicyFromCache) {
+ // Put the invalid test policy in the cache. One of its policies will be
+ // loaded, the other should be filtered out by the schema.
+ builder_.payload().set_secure_hash(base::SHA1HashString(kInvalidTestPolicy));
+ EXPECT_TRUE(cache_->Store(
+ "extension-policy", kTestExtension, CreateSerializedResponse()));
+ EXPECT_TRUE(cache_->Store(
+ "extension-policy-data", kTestExtension, kInvalidTestPolicy));
+
+ LoadStore();
+ InitializeRegistry();
+
+ // The initial, cached policy will be served once the backend is initialized.
+ EXPECT_CALL(delegate_, OnComponentCloudPolicyUpdated());
+ RunUntilIdle();
+ Mock::VerifyAndClearExpectations(&delegate_);
+
+ PolicyBundle expected_bundle;
+ const PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, kTestExtension);
+ expected_bundle.Get(ns).Set("Name", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
+ base::Value::CreateStringValue("published"),
+ NULL);
+ EXPECT_TRUE(service_->policy().Equals(expected_bundle));
+}
+
} // namespace policy
« no previous file with comments | « chrome/browser/policy/cloud/component_cloud_policy_service.cc ('k') | chrome/browser/policy/forwarding_policy_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698