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

Side by Side Diff: chrome/browser/chromeos/settings/session_manager_operation_unittest.cc

Issue 2714493002: Load DeviceLocalAccount policy and DeviceSettings immediately on restore after Chrome crash. (Closed)
Patch Set: add flag to correctly process LoadImmediately() call Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/settings/session_manager_operation.h" 5 #include "chrome/browser/chromeos/settings/session_manager_operation.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 bool validated_; 102 bool validated_;
103 103
104 private: 104 private:
105 DISALLOW_COPY_AND_ASSIGN(SessionManagerOperationTest); 105 DISALLOW_COPY_AND_ASSIGN(SessionManagerOperationTest);
106 }; 106 };
107 107
108 TEST_F(SessionManagerOperationTest, LoadNoPolicyNoKey) { 108 TEST_F(SessionManagerOperationTest, LoadNoPolicyNoKey) {
109 LoadSettingsOperation op( 109 LoadSettingsOperation op(
110 false /* force_key_load */, true /* cloud_validations */, 110 false /* force_key_load */, true /* cloud_validations */,
111 false /* force_immediate_load */,
111 base::Bind(&SessionManagerOperationTest::OnOperationCompleted, 112 base::Bind(&SessionManagerOperationTest::OnOperationCompleted,
112 base::Unretained(this))); 113 base::Unretained(this)));
113 114
114 EXPECT_CALL(*this, 115 EXPECT_CALL(*this,
115 OnOperationCompleted( 116 OnOperationCompleted(
116 &op, DeviceSettingsService::STORE_KEY_UNAVAILABLE)); 117 &op, DeviceSettingsService::STORE_KEY_UNAVAILABLE));
117 op.Start(&device_settings_test_helper_, owner_key_util_, NULL); 118 op.Start(&device_settings_test_helper_, owner_key_util_, NULL);
118 device_settings_test_helper_.Flush(); 119 device_settings_test_helper_.Flush();
119 Mock::VerifyAndClearExpectations(this); 120 Mock::VerifyAndClearExpectations(this);
120 121
121 EXPECT_FALSE(op.policy_data().get()); 122 EXPECT_FALSE(op.policy_data().get());
122 EXPECT_FALSE(op.device_settings().get()); 123 EXPECT_FALSE(op.device_settings().get());
123 ASSERT_TRUE(op.public_key().get()); 124 ASSERT_TRUE(op.public_key().get());
124 EXPECT_FALSE(op.public_key()->is_loaded()); 125 EXPECT_FALSE(op.public_key()->is_loaded());
125 } 126 }
126 127
127 TEST_F(SessionManagerOperationTest, LoadOwnerKey) { 128 TEST_F(SessionManagerOperationTest, LoadOwnerKey) {
128 owner_key_util_->SetPublicKeyFromPrivateKey(*policy_.GetSigningKey()); 129 owner_key_util_->SetPublicKeyFromPrivateKey(*policy_.GetSigningKey());
129 LoadSettingsOperation op( 130 LoadSettingsOperation op(
130 false /* force_key_load */, true /* cloud_validations */, 131 false /* force_key_load */, true /* cloud_validations */,
132 false /* force_immediate_load */,
131 base::Bind(&SessionManagerOperationTest::OnOperationCompleted, 133 base::Bind(&SessionManagerOperationTest::OnOperationCompleted,
132 base::Unretained(this))); 134 base::Unretained(this)));
133 135
134 EXPECT_CALL(*this, 136 EXPECT_CALL(*this,
135 OnOperationCompleted( 137 OnOperationCompleted(
136 &op, DeviceSettingsService::STORE_NO_POLICY)); 138 &op, DeviceSettingsService::STORE_NO_POLICY));
137 op.Start(&device_settings_test_helper_, owner_key_util_, NULL); 139 op.Start(&device_settings_test_helper_, owner_key_util_, NULL);
138 device_settings_test_helper_.Flush(); 140 device_settings_test_helper_.Flush();
139 Mock::VerifyAndClearExpectations(this); 141 Mock::VerifyAndClearExpectations(this);
140 142
141 CheckPublicKeyLoaded(&op); 143 CheckPublicKeyLoaded(&op);
142 } 144 }
143 145
144 TEST_F(SessionManagerOperationTest, LoadPolicy) { 146 TEST_F(SessionManagerOperationTest, LoadPolicy) {
145 owner_key_util_->SetPublicKeyFromPrivateKey(*policy_.GetSigningKey()); 147 owner_key_util_->SetPublicKeyFromPrivateKey(*policy_.GetSigningKey());
146 device_settings_test_helper_.set_policy_blob(policy_.GetBlob()); 148 device_settings_test_helper_.set_policy_blob(policy_.GetBlob());
147 LoadSettingsOperation op( 149 LoadSettingsOperation op(
148 false /* force_key_load */, true /* cloud_validations */, 150 false /* force_key_load */, true /* cloud_validations */,
151 false /* force_immediate_load */,
149 base::Bind(&SessionManagerOperationTest::OnOperationCompleted, 152 base::Bind(&SessionManagerOperationTest::OnOperationCompleted,
150 base::Unretained(this))); 153 base::Unretained(this)));
151 154
152 EXPECT_CALL(*this, 155 EXPECT_CALL(*this,
153 OnOperationCompleted( 156 OnOperationCompleted(
154 &op, DeviceSettingsService::STORE_SUCCESS)); 157 &op, DeviceSettingsService::STORE_SUCCESS));
155 op.Start(&device_settings_test_helper_, owner_key_util_, NULL); 158 op.Start(&device_settings_test_helper_, owner_key_util_, NULL);
156 device_settings_test_helper_.Flush(); 159 device_settings_test_helper_.Flush();
157 Mock::VerifyAndClearExpectations(this); 160 Mock::VerifyAndClearExpectations(this);
158 161
159 ASSERT_TRUE(op.policy_data().get()); 162 ASSERT_TRUE(op.policy_data().get());
160 EXPECT_EQ(policy_.policy_data().SerializeAsString(), 163 EXPECT_EQ(policy_.policy_data().SerializeAsString(),
161 op.policy_data()->SerializeAsString()); 164 op.policy_data()->SerializeAsString());
162 ASSERT_TRUE(op.device_settings().get()); 165 ASSERT_TRUE(op.device_settings().get());
163 EXPECT_EQ(policy_.payload().SerializeAsString(), 166 EXPECT_EQ(policy_.payload().SerializeAsString(),
164 op.device_settings()->SerializeAsString()); 167 op.device_settings()->SerializeAsString());
165 } 168 }
166 169
167 TEST_F(SessionManagerOperationTest, RestartLoad) { 170 TEST_F(SessionManagerOperationTest, RestartLoad) {
168 owner_key_util_->SetPrivateKey(policy_.GetSigningKey()); 171 owner_key_util_->SetPrivateKey(policy_.GetSigningKey());
169 device_settings_test_helper_.set_policy_blob(policy_.GetBlob()); 172 device_settings_test_helper_.set_policy_blob(policy_.GetBlob());
170 LoadSettingsOperation op( 173 LoadSettingsOperation op(
171 false /* force_key_load */, true /* cloud_validations */, 174 false /* force_key_load */, true /* cloud_validations */,
175 false /* force_immediate_load */,
172 base::Bind(&SessionManagerOperationTest::OnOperationCompleted, 176 base::Bind(&SessionManagerOperationTest::OnOperationCompleted,
173 base::Unretained(this))); 177 base::Unretained(this)));
174 178
175 EXPECT_CALL(*this, OnOperationCompleted(&op, _)).Times(0); 179 EXPECT_CALL(*this, OnOperationCompleted(&op, _)).Times(0);
176 op.Start(&device_settings_test_helper_, owner_key_util_, NULL); 180 op.Start(&device_settings_test_helper_, owner_key_util_, NULL);
177 content::RunAllBlockingPoolTasksUntilIdle(); 181 content::RunAllBlockingPoolTasksUntilIdle();
178 device_settings_test_helper_.FlushRetrieve(); 182 device_settings_test_helper_.FlushRetrieve();
179 EXPECT_TRUE(op.public_key().get()); 183 EXPECT_TRUE(op.public_key().get());
180 EXPECT_TRUE(op.public_key()->is_loaded()); 184 EXPECT_TRUE(op.public_key()->is_loaded());
181 Mock::VerifyAndClearExpectations(this); 185 Mock::VerifyAndClearExpectations(this);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 policy_.GetBlob()); 228 policy_.GetBlob());
225 ASSERT_TRUE(op.policy_data().get()); 229 ASSERT_TRUE(op.policy_data().get());
226 EXPECT_EQ(policy_.policy_data().SerializeAsString(), 230 EXPECT_EQ(policy_.policy_data().SerializeAsString(),
227 op.policy_data()->SerializeAsString()); 231 op.policy_data()->SerializeAsString());
228 ASSERT_TRUE(op.device_settings().get()); 232 ASSERT_TRUE(op.device_settings().get());
229 EXPECT_EQ(policy_.payload().SerializeAsString(), 233 EXPECT_EQ(policy_.payload().SerializeAsString(),
230 op.device_settings()->SerializeAsString()); 234 op.device_settings()->SerializeAsString());
231 } 235 }
232 236
233 } // namespace chromeos 237 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698