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

Side by Side Diff: chrome/browser/policy/device_management_service_browsertest.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 "base/message_loop.h" 5 #include "base/message_loop.h"
6 #include "chrome/browser/browser_thread.h" 6 #include "chrome/browser/browser_thread.h"
7 #include "chrome/browser/policy/device_management_backend_mock.h" 7 #include "chrome/browser/policy/device_management_backend_mock.h"
8 #include "chrome/browser/policy/device_management_service.h" 8 #include "chrome/browser/policy/device_management_service.h"
9 #include "chrome/browser/profile.h" 9 #include "chrome/browser/profile.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 { 97 {
98 CannedResponseInterceptor interceptor( 98 CannedResponseInterceptor interceptor(
99 GURL(kServiceUrl), PROTO_STRING(kServiceResponseRegister)); 99 GURL(kServiceUrl), PROTO_STRING(kServiceResponseRegister));
100 DeviceRegisterResponseDelegateMock delegate; 100 DeviceRegisterResponseDelegateMock delegate;
101 EXPECT_CALL(delegate, HandleRegisterResponse(_)) 101 EXPECT_CALL(delegate, HandleRegisterResponse(_))
102 .WillOnce(DoAll(Invoke(this, &DeviceManagementServiceIntegrationTest 102 .WillOnce(DoAll(Invoke(this, &DeviceManagementServiceIntegrationTest
103 ::CaptureToken), 103 ::CaptureToken),
104 InvokeWithoutArgs(QuitMessageLoop))); 104 InvokeWithoutArgs(QuitMessageLoop)));
105 em::DeviceRegisterRequest request; 105 em::DeviceRegisterRequest request;
106 backend->ProcessRegisterRequest("token", "device id", request, &delegate); 106 backend->ProcessRegisterRequest("token", "testid", request, &delegate);
107 MessageLoop::current()->Run(); 107 MessageLoop::current()->Run();
108 } 108 }
109 109
110 { 110 {
111 CannedResponseInterceptor interceptor( 111 CannedResponseInterceptor interceptor(
112 GURL(kServiceUrl), PROTO_STRING(kServiceResponsePolicy)); 112 GURL(kServiceUrl), PROTO_STRING(kServiceResponsePolicy));
113 DevicePolicyResponseDelegateMock delegate; 113 DevicePolicyResponseDelegateMock delegate;
114 EXPECT_CALL(delegate, HandlePolicyResponse(_)) 114 EXPECT_CALL(delegate, HandlePolicyResponse(_))
115 .WillOnce(InvokeWithoutArgs(QuitMessageLoop)); 115 .WillOnce(InvokeWithoutArgs(QuitMessageLoop));
116 em::DevicePolicyRequest request; 116 em::DevicePolicyRequest request;
117 request.set_policy_scope("chrome"); 117 request.set_policy_scope("chrome");
118 em::DevicePolicySettingRequest* setting_request = 118 em::DevicePolicySettingRequest* setting_request =
119 request.add_setting_request(); 119 request.add_setting_request();
120 setting_request->set_key("policy"); 120 setting_request->set_key("policy");
121 backend->ProcessPolicyRequest(token_, request, &delegate); 121 backend->ProcessPolicyRequest(token_, "testid", request, &delegate);
122 122
123 MessageLoop::current()->Run(); 123 MessageLoop::current()->Run();
124 } 124 }
125 125
126 { 126 {
127 CannedResponseInterceptor interceptor( 127 CannedResponseInterceptor interceptor(
128 GURL(kServiceUrl), PROTO_STRING(kServiceResponseUnregister)); 128 GURL(kServiceUrl), PROTO_STRING(kServiceResponseUnregister));
129 DeviceUnregisterResponseDelegateMock delegate; 129 DeviceUnregisterResponseDelegateMock delegate;
130 EXPECT_CALL(delegate, HandleUnregisterResponse(_)) 130 EXPECT_CALL(delegate, HandleUnregisterResponse(_))
131 .WillOnce(InvokeWithoutArgs(QuitMessageLoop)); 131 .WillOnce(InvokeWithoutArgs(QuitMessageLoop));
132 em::DeviceUnregisterRequest request; 132 em::DeviceUnregisterRequest request;
133 backend->ProcessUnregisterRequest(token_, request, &delegate); 133 backend->ProcessUnregisterRequest(token_, "testid", request, &delegate);
134 134
135 MessageLoop::current()->Run(); 135 MessageLoop::current()->Run();
136 } 136 }
137 } 137 }
138 138
139 IN_PROC_BROWSER_TEST_F(DeviceManagementServiceIntegrationTest, 139 IN_PROC_BROWSER_TEST_F(DeviceManagementServiceIntegrationTest,
140 WithTestServer) { 140 WithTestServer) {
141 net::TestServer test_server_( 141 net::TestServer test_server_(
142 net::TestServer::TYPE_HTTP, 142 net::TestServer::TYPE_HTTP,
143 FilePath(FILE_PATH_LITERAL("chrome/test/data/policy"))); 143 FilePath(FILE_PATH_LITERAL("chrome/test/data/policy")));
144 ASSERT_TRUE(test_server_.Start()); 144 ASSERT_TRUE(test_server_.Start());
145 DeviceManagementService service( 145 DeviceManagementService service(
146 test_server_.GetURL("device_management").spec()); 146 test_server_.GetURL("device_management").spec());
147 service.Initialize(browser()->profile()->GetRequestContext()); 147 service.Initialize(browser()->profile()->GetRequestContext());
148 scoped_ptr<DeviceManagementBackend> backend(service.CreateBackend()); 148 scoped_ptr<DeviceManagementBackend> backend(service.CreateBackend());
149 149
150 { 150 {
151 DeviceRegisterResponseDelegateMock delegate; 151 DeviceRegisterResponseDelegateMock delegate;
152 EXPECT_CALL(delegate, HandleRegisterResponse(_)) 152 EXPECT_CALL(delegate, HandleRegisterResponse(_))
153 .WillOnce(DoAll(Invoke(this, &DeviceManagementServiceIntegrationTest 153 .WillOnce(DoAll(Invoke(this, &DeviceManagementServiceIntegrationTest
154 ::CaptureToken), 154 ::CaptureToken),
155 InvokeWithoutArgs(QuitMessageLoop))); 155 InvokeWithoutArgs(QuitMessageLoop)));
156 em::DeviceRegisterRequest request; 156 em::DeviceRegisterRequest request;
157 backend->ProcessRegisterRequest("token", "device id", request, &delegate); 157 backend->ProcessRegisterRequest("token", "testid", request, &delegate);
158 MessageLoop::current()->Run(); 158 MessageLoop::current()->Run();
159 } 159 }
160 160
161 { 161 {
162 em::DevicePolicyResponse expected_response; 162 em::DevicePolicyResponse expected_response;
163 163
164 DevicePolicyResponseDelegateMock delegate; 164 DevicePolicyResponseDelegateMock delegate;
165 EXPECT_CALL(delegate, HandlePolicyResponse(_)) 165 EXPECT_CALL(delegate, HandlePolicyResponse(_))
166 .WillOnce(InvokeWithoutArgs(QuitMessageLoop)); 166 .WillOnce(InvokeWithoutArgs(QuitMessageLoop));
167 em::DevicePolicyRequest request; 167 em::DevicePolicyRequest request;
168 request.set_policy_scope("chrome"); 168 request.set_policy_scope("chrome");
169 em::DevicePolicySettingRequest* setting_request = 169 em::DevicePolicySettingRequest* setting_request =
170 request.add_setting_request(); 170 request.add_setting_request();
171 setting_request->set_key("policy"); 171 setting_request->set_key("policy");
172 backend->ProcessPolicyRequest(token_, request, &delegate); 172 backend->ProcessPolicyRequest(token_, "testid", request, &delegate);
173 173
174 MessageLoop::current()->Run(); 174 MessageLoop::current()->Run();
175 } 175 }
176 176
177 { 177 {
178 DeviceUnregisterResponseDelegateMock delegate; 178 DeviceUnregisterResponseDelegateMock delegate;
179 EXPECT_CALL(delegate, HandleUnregisterResponse(_)) 179 EXPECT_CALL(delegate, HandleUnregisterResponse(_))
180 .WillOnce(InvokeWithoutArgs(QuitMessageLoop)); 180 .WillOnce(InvokeWithoutArgs(QuitMessageLoop));
181 em::DeviceUnregisterRequest request; 181 em::DeviceUnregisterRequest request;
182 backend->ProcessUnregisterRequest(token_, request, &delegate); 182 backend->ProcessUnregisterRequest(token_, "testid", request, &delegate);
183 183
184 MessageLoop::current()->Run(); 184 MessageLoop::current()->Run();
185 } 185 }
186 } 186 }
187 187
188 } // namespace policy 188 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698