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

Side by Side Diff: chrome/browser/policy/device_management_policy_provider_unittest.cc

Issue 5341004: Chrome should re-register device when DMServer doesn't recognize token (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review feedback Created 10 years 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/policy/device_management_policy_provider.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/scoped_temp_dir.h" 6 #include "base/scoped_temp_dir.h"
7 #include "chrome/browser/browser_thread.h" 7 #include "chrome/browser/browser_thread.h"
8 #include "chrome/browser/net/gaia/token_service.h" 8 #include "chrome/browser/net/gaia/token_service.h"
9 #include "chrome/browser/policy/configuration_policy_pref_store.h" 9 #include "chrome/browser/policy/configuration_policy_pref_store.h"
10 #include "chrome/browser/policy/device_management_policy_provider.h" 10 #include "chrome/browser/policy/device_management_policy_provider.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce( 203 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
204 MockDeviceManagementBackendSucceedBooleanPolicy(key::kDisableSpdy, true)); 204 MockDeviceManagementBackendSucceedBooleanPolicy(key::kDisableSpdy, true));
205 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce( 205 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
206 MockDeviceManagementBackendSucceedBooleanPolicy(key::kDisableSpdy, true)); 206 MockDeviceManagementBackendSucceedBooleanPolicy(key::kDisableSpdy, true));
207 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce( 207 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
208 MockDeviceManagementBackendFailPolicy( 208 MockDeviceManagementBackendFailPolicy(
209 DeviceManagementBackend::kErrorRequestFailed)); 209 DeviceManagementBackend::kErrorRequestFailed));
210 SimulateSuccessfulLoginAndRunPending(); 210 SimulateSuccessfulLoginAndRunPending();
211 } 211 }
212 212
213 // The client should try to re-register the device if the device server reports
214 // back that it doesn't recognize the device token on a policy request.
215 TEST_F(DeviceManagementPolicyProviderTest, DeviceNotFound) {
216 InSequence s;
217 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce(
218 MockDeviceManagementBackendSucceedRegister());
219 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
220 MockDeviceManagementBackendFailPolicy(
221 DeviceManagementBackend::kErrorServiceDeviceNotFound));
222 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce(
223 MockDeviceManagementBackendSucceedRegister());
224 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
225 MockDeviceManagementBackendSucceedBooleanPolicy(key::kDisableSpdy, true));
226 SimulateSuccessfulLoginAndRunPending();
227 }
228
229 // The client should try to re-register the device if the device server reports
230 // back that the device token is invalid on a policy request.
231 TEST_F(DeviceManagementPolicyProviderTest, InvalidTokenOnPolicyRequest) {
232 InSequence s;
233 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce(
234 MockDeviceManagementBackendSucceedRegister());
235 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
236 MockDeviceManagementBackendFailPolicy(
237 DeviceManagementBackend::kErrorServiceManagementTokenInvalid));
238 EXPECT_CALL(*backend_, ProcessRegisterRequest(_, _, _, _)).WillOnce(
239 MockDeviceManagementBackendSucceedRegister());
240 EXPECT_CALL(*backend_, ProcessPolicyRequest(_, _, _, _)).WillOnce(
241 MockDeviceManagementBackendSucceedBooleanPolicy(key::kDisableSpdy, true));
242 SimulateSuccessfulLoginAndRunPending();
243 }
244
213 } // namespace policy 245 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/device_management_policy_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698