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

Unified Diff: chrome/browser/policy/cloud_policy_controller_unittest.cc

Issue 9599009: Fix infinite refresh of device policy when the TPM gets out of sync with the stateful partition. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Added unit test Created 8 years, 10 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
Index: chrome/browser/policy/cloud_policy_controller_unittest.cc
diff --git a/chrome/browser/policy/cloud_policy_controller_unittest.cc b/chrome/browser/policy/cloud_policy_controller_unittest.cc
index faedef328a52e3879284cd9abe2e0cd704785c18..2026597f4790351beebec174de6fa740653134de 100644
--- a/chrome/browser/policy/cloud_policy_controller_unittest.cc
+++ b/chrome/browser/policy/cloud_policy_controller_unittest.cc
@@ -345,4 +345,39 @@ TEST_F(CloudPolicyControllerTest, SetFetchingDoneAfterPolicyFetchFails) {
EXPECT_TRUE(cache_->last_policy_refresh_time().is_null());
}
+TEST_F(CloudPolicyControllerTest, DelayRefreshesIfPolicyIsInvalid) {
+ // Reply with a protobuf whose timestamp is too far in the future. The policy
+ // cache will reject it, and the controller should detect that and go into
+ // STATE_POLICY_ERROR instead of STATE_POLICY_VALID.
+
+ // Build the |response|.
+ em::DeviceManagementResponse response;
+ em::PolicyData data;
+ em::CloudPolicySettings settings;
+ EXPECT_TRUE(settings.SerializeToString(data.mutable_policy_value()));
+ base::Time far_in_the_future =
+ base::Time::NowFromSystemTime() + base::TimeDelta::FromDays(42);
+ base::TimeDelta timestamp = far_in_the_future - base::Time::UnixEpoch();
+ data.set_timestamp(timestamp.InMilliseconds());
+ std::string serialized_data;
+ EXPECT_TRUE(data.SerializeToString(&serialized_data));
+ em::PolicyFetchResponse* fetch_response =
+ response.mutable_policy_response()->add_response();
+ fetch_response->set_policy_data(serialized_data);
+
+ data_store_->SetupForTesting("device_token", "device_id",
+ "madmax@managedchrome.com",
+ "auth_token", true);
+
+ EXPECT_CALL(service_,
+ CreateJob(DeviceManagementRequestJob::TYPE_POLICY_FETCH))
+ .WillOnce(DoAll(InvokeWithoutArgs(&loop_, &MessageLoop::QuitNow),
+ service_.SucceedJob(response)));
+ CreateNewController();
+ loop_.RunAllPending();
+ EXPECT_EQ(CloudPolicySubsystem::NETWORK_ERROR, notifier_.state());
+ EXPECT_EQ(CloudPolicySubsystem::POLICY_NETWORK_ERROR,
+ notifier_.error_details());
+}
+
} // namespace policy
« no previous file with comments | « chrome/browser/policy/cloud_policy_controller.cc ('k') | chrome/browser/policy/cloud_policy_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698