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

Unified Diff: components/policy/core/common/cloud/user_cloud_policy_store_unittest.cc

Issue 491513002: No longer accept unsigned cloud policy blobs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review feedback. Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/policy/core/common/cloud/user_cloud_policy_store.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/policy/core/common/cloud/user_cloud_policy_store_unittest.cc
diff --git a/components/policy/core/common/cloud/user_cloud_policy_store_unittest.cc b/components/policy/core/common/cloud/user_cloud_policy_store_unittest.cc
index 08a3f70a7bdf785b2175a085be18b5f57bff7731..3d667caa0cdaefa495ca7527cfcdf659e41d02e2 100644
--- a/components/policy/core/common/cloud/user_cloud_policy_store_unittest.cc
+++ b/components/policy/core/common/cloud/user_cloud_policy_store_unittest.cc
@@ -207,8 +207,8 @@ TEST_F(UserCloudPolicyStoreTest, LoadImmediatelyWithInvalidFile) {
EXPECT_TRUE(store_->policy_map().empty());
}
-// Load file from cache with no key data, then migrate to have a key.
-TEST_F(UserCloudPolicyStoreTest, Migration) {
+// Load file from cache with no key data - should give us a validation error.
+TEST_F(UserCloudPolicyStoreTest, ShouldFailToLoadUnsignedPolicy) {
UserPolicyBuilder unsigned_builder;
unsigned_builder.UnsetSigningKey();
InitPolicyPayload(&unsigned_builder.payload());
@@ -223,22 +223,11 @@ TEST_F(UserCloudPolicyStoreTest, Migration) {
int size = data.size();
ASSERT_EQ(size, base::WriteFile(policy_file(), data.c_str(), size));
- // Now make sure the data can get loaded.
- Sequence s;
- EXPECT_CALL(*external_data_manager_, OnPolicyStoreLoaded()).InSequence(s);
- EXPECT_CALL(observer_, OnStoreLoaded(store_.get())).InSequence(s);
+ // Now make sure the data generates a validation error.
+ ExpectError(store_.get(), CloudPolicyStore::STATUS_VALIDATION_ERROR);
store_->LoadImmediately(); // Should load without running the message loop.
- Mock::VerifyAndClearExpectations(external_data_manager_.get());
Mock::VerifyAndClearExpectations(&observer_);
- ASSERT_TRUE(store_->policy());
- EXPECT_EQ(unsigned_builder.policy_data().SerializeAsString(),
- store_->policy()->SerializeAsString());
- VerifyPolicyMap(store_.get());
- EXPECT_EQ(CloudPolicyStore::STATUS_OK, store_->status());
- EXPECT_TRUE(store_->policy_key().empty());
- EXPECT_FALSE(base::PathExists(key_file()));
-
// Now mimic a new policy coming down - this should result in a new key
// being installed.
StorePolicyAndEnsureLoaded(policy_.policy());
« no previous file with comments | « components/policy/core/common/cloud/user_cloud_policy_store.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698