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

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

Issue 5162006: Always send the device ID when making device management requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years, 1 month 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
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 "chrome/browser/policy/mock_device_management_backend.h" 5 #include "chrome/browser/policy/mock_device_management_backend.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/stl_util-inl.h" 9 #include "base/stl_util-inl.h"
10 10
(...skipping 24 matching lines...) Expand all
35 } 35 }
36 36
37 MockDeviceManagementBackend::~MockDeviceManagementBackend() { 37 MockDeviceManagementBackend::~MockDeviceManagementBackend() {
38 } 38 }
39 39
40 void MockDeviceManagementBackend::AllShouldSucceed() { 40 void MockDeviceManagementBackend::AllShouldSucceed() {
41 ON_CALL(*this, ProcessRegisterRequest(_, _, _, _)). 41 ON_CALL(*this, ProcessRegisterRequest(_, _, _, _)).
42 WillByDefault(Invoke( 42 WillByDefault(Invoke(
43 this, 43 this,
44 &MockDeviceManagementBackend::SimulateSuccessfulRegisterRequest)); 44 &MockDeviceManagementBackend::SimulateSuccessfulRegisterRequest));
45 ON_CALL(*this, ProcessPolicyRequest(_, _, _)). 45 ON_CALL(*this, ProcessPolicyRequest(_, _, _, _)).
46 WillByDefault(Invoke( 46 WillByDefault(Invoke(
47 this, 47 this,
48 &MockDeviceManagementBackend::SimulateSuccessfulPolicyRequest)); 48 &MockDeviceManagementBackend::SimulateSuccessfulPolicyRequest));
49 } 49 }
50 50
51 void MockDeviceManagementBackend::AllShouldFail() { 51 void MockDeviceManagementBackend::AllShouldFail() {
52 ON_CALL(*this, ProcessRegisterRequest(_, _, _, _)). 52 ON_CALL(*this, ProcessRegisterRequest(_, _, _, _)).
53 WillByDefault(Invoke( 53 WillByDefault(Invoke(
54 this, 54 this,
55 &MockDeviceManagementBackend::SimulateFailedRegisterRequest)); 55 &MockDeviceManagementBackend::SimulateFailedRegisterRequest));
56 ON_CALL(*this, ProcessPolicyRequest(_, _, _)). 56 ON_CALL(*this, ProcessPolicyRequest(_, _, _, _)).
57 WillByDefault(Invoke( 57 WillByDefault(Invoke(
58 this, 58 this,
59 &MockDeviceManagementBackend::SimulateFailedPolicyRequest)); 59 &MockDeviceManagementBackend::SimulateFailedPolicyRequest));
60 } 60 }
61 61
62 void MockDeviceManagementBackend::UnmanagedDevice() { 62 void MockDeviceManagementBackend::UnmanagedDevice() {
63 ON_CALL(*this, ProcessRegisterRequest(_, _, _, _)). 63 ON_CALL(*this, ProcessRegisterRequest(_, _, _, _)).
64 WillByDefault(Invoke( 64 WillByDefault(Invoke(
65 this, 65 this,
66 &MockDeviceManagementBackend::SimulateUnmanagedRegisterRequest)); 66 &MockDeviceManagementBackend::SimulateUnmanagedRegisterRequest));
(...skipping 16 matching lines...) Expand all
83 DeviceRegisterResponseDelegate* delegate) { 83 DeviceRegisterResponseDelegate* delegate) {
84 DeviceRegisterResponse response; 84 DeviceRegisterResponse response;
85 std::string token(kFakeDeviceManagementToken); 85 std::string token(kFakeDeviceManagementToken);
86 token += next_token_suffix_++; 86 token += next_token_suffix_++;
87 response.set_device_management_token(token); 87 response.set_device_management_token(token);
88 delegate->HandleRegisterResponse(response); 88 delegate->HandleRegisterResponse(response);
89 } 89 }
90 90
91 void MockDeviceManagementBackend::SimulateSuccessfulPolicyRequest( 91 void MockDeviceManagementBackend::SimulateSuccessfulPolicyRequest(
92 const std::string& device_management_token, 92 const std::string& device_management_token,
93 const std::string& device_id,
93 const em::DevicePolicyRequest& request, 94 const em::DevicePolicyRequest& request,
94 DevicePolicyResponseDelegate* delegate) { 95 DevicePolicyResponseDelegate* delegate) {
95 delegate->HandlePolicyResponse(policy_response_); 96 delegate->HandlePolicyResponse(policy_response_);
96 } 97 }
97 98
98 void MockDeviceManagementBackend::SimulateFailedRegisterRequest( 99 void MockDeviceManagementBackend::SimulateFailedRegisterRequest(
99 const std::string& auth_token, 100 const std::string& auth_token,
100 const std::string& device_id, 101 const std::string& device_id,
101 const em::DeviceRegisterRequest& request, 102 const em::DeviceRegisterRequest& request,
102 DeviceRegisterResponseDelegate* delegate) { 103 DeviceRegisterResponseDelegate* delegate) {
103 delegate->OnError(kErrorRequestFailed); 104 delegate->OnError(kErrorRequestFailed);
104 } 105 }
105 106
106 void MockDeviceManagementBackend::SimulateFailedPolicyRequest( 107 void MockDeviceManagementBackend::SimulateFailedPolicyRequest(
107 const std::string& device_management_token, 108 const std::string& device_management_token,
109 const std::string& device_id,
108 const em::DevicePolicyRequest& request, 110 const em::DevicePolicyRequest& request,
109 DevicePolicyResponseDelegate* delegate) { 111 DevicePolicyResponseDelegate* delegate) {
110 delegate->OnError(kErrorRequestFailed); 112 delegate->OnError(kErrorRequestFailed);
111 } 113 }
112 114
113 void MockDeviceManagementBackend::SimulateUnmanagedRegisterRequest( 115 void MockDeviceManagementBackend::SimulateUnmanagedRegisterRequest(
114 const std::string& auth_token, 116 const std::string& auth_token,
115 const std::string& device_id, 117 const std::string& device_id,
116 const em::DeviceRegisterRequest& request, 118 const em::DeviceRegisterRequest& request,
117 DeviceRegisterResponseDelegate* delegate) { 119 DeviceRegisterResponseDelegate* delegate) {
118 delegate->OnError(kErrorServiceManagementNotSupported); 120 delegate->OnError(kErrorServiceManagementNotSupported);
119 } 121 }
120 122
121 } // namespace 123 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/policy/mock_device_management_backend.h ('k') | net/tools/testserver/device_management.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698