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 |