| 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 5885d1c3478609a059eeafc53dd14873a52629d9..4c90264a7a441111c8963e6781fb50fda35e7028 100644
|
| --- a/chrome/browser/policy/cloud/component_cloud_policy_service_unittest.cc
|
| +++ b/chrome/browser/policy/cloud/component_cloud_policy_service_unittest.cc
|
| @@ -26,6 +26,7 @@
|
| #include "chrome/browser/policy/proto/cloud/chrome_extension_policy.pb.h"
|
| #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h"
|
| #include "chrome/browser/policy/schema_map.h"
|
| +#include "chrome/browser/policy/test/policy_test_utils.h"
|
| #include "components/policy/core/common/schema.h"
|
| #include "net/url_request/test_url_fetcher_factory.h"
|
| #include "net/url_request/url_fetcher_delegate.h"
|
| @@ -57,6 +58,16 @@ const char kTestPolicy[] =
|
| " }"
|
| "}";
|
|
|
| +const char kInvalidTestPolicy[] =
|
| + "{"
|
| + " \"Name\": {"
|
| + " \"Value\": \"published\""
|
| + " },"
|
| + " \"Undeclared Name\": {"
|
| + " \"Value\": \"not published\""
|
| + " }"
|
| + "}";
|
| +
|
| const char kTestSchema[] =
|
| "{"
|
| " \"type\": \"object\","
|
| @@ -516,4 +527,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)) << service_->policy();
|
| +}
|
| +
|
| } // namespace policy
|
|
|