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

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

Issue 8741014: Added auto-enrollment request support to the device_management_backend. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/policy/device_management_backend_mock.h" 6 #include "chrome/browser/policy/device_management_backend_mock.h"
7 #include "chrome/browser/policy/device_management_service.h" 7 #include "chrome/browser/policy/device_management_service.h"
8 #include "chrome/browser/policy/proto/device_management_constants.h" 8 #include "chrome/browser/policy/proto/device_management_constants.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/test/base/in_process_browser_test.h" 9 #include "chrome/test/base/in_process_browser_test.h"
12 #include "content/public/common/url_fetcher.h" 10 #include "content/public/common/url_fetcher.h"
13 #include "net/test/test_server.h" 11 #include "net/test/test_server.h"
14 #include "net/url_request/url_request.h" 12 #include "net/url_request/url_request.h"
15 #include "net/url_request/url_request_test_job.h" 13 #include "net/url_request/url_request_test_job.h"
16 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
18 16
19 using testing::DoAll; 17 using testing::DoAll;
20 using testing::Invoke; 18 using testing::Invoke;
(...skipping 11 matching lines...) Expand all
32 "\x63\x63\x34\x61\x33\x32\x38\x31\x66\x33\x38\x62\x36\x35\x31\x31" 30 "\x63\x63\x34\x61\x33\x32\x38\x31\x66\x33\x38\x62\x36\x35\x31\x31"
33 "\x36\x64\x61\x62\x66\x63"; 31 "\x36\x64\x61\x62\x66\x63";
34 // Contains a single policy setting, namely HomepageIsNewTabPage: false. 32 // Contains a single policy setting, namely HomepageIsNewTabPage: false.
35 const char kServiceResponsePolicy[] = 33 const char kServiceResponsePolicy[] =
36 "\x08\x00\x2a\x2a\x0a\x28\x0a\x06\x70\x6f\x6c\x69\x63\x79\x12\x1e" 34 "\x08\x00\x2a\x2a\x0a\x28\x0a\x06\x70\x6f\x6c\x69\x63\x79\x12\x1e"
37 "\x0a\x1c\x0a\x14\x48\x6f\x6d\x65\x70\x61\x67\x65\x49\x73\x4e\x65" 35 "\x0a\x1c\x0a\x14\x48\x6f\x6d\x65\x70\x61\x67\x65\x49\x73\x4e\x65"
38 "\x77\x54\x61\x62\x50\x61\x67\x65\x12\x04\x08\x01\x10\x00"; 36 "\x77\x54\x61\x62\x50\x61\x67\x65\x12\x04\x08\x01\x10\x00";
39 // Successful unregister response. 37 // Successful unregister response.
40 const char kServiceResponseUnregister[] = 38 const char kServiceResponseUnregister[] =
41 "\x08\x00\x22\x00"; 39 "\x08\x00\x22\x00";
40 // Auto-enrollment response with no modulus and no hashes.
41 const char kServiceResponseAutoEnrollment[] = "\x42\x00";
42
42 43
43 #define PROTO_STRING(name) (std::string(name, arraysize(name) - 1)) 44 #define PROTO_STRING(name) (std::string(name, arraysize(name) - 1))
44 45
45 // Interceptor implementation that returns test data back to the service. 46 // Interceptor implementation that returns test data back to the service.
46 class CannedResponseInterceptor : public net::URLRequest::Interceptor { 47 class CannedResponseInterceptor : public net::URLRequest::Interceptor {
47 public: 48 public:
48 CannedResponseInterceptor(const GURL& service_url, 49 CannedResponseInterceptor(const GURL& service_url,
49 const std::string& response_data) 50 const std::string& response_data)
50 : service_url_(service_url), 51 : service_url_(service_url),
51 response_data_(response_data) { 52 response_data_(response_data) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 CannedResponseInterceptor interceptor( 132 CannedResponseInterceptor interceptor(
132 GURL(kServiceUrl), PROTO_STRING(kServiceResponseUnregister)); 133 GURL(kServiceUrl), PROTO_STRING(kServiceResponseUnregister));
133 DeviceUnregisterResponseDelegateMock delegate; 134 DeviceUnregisterResponseDelegateMock delegate;
134 EXPECT_CALL(delegate, HandleUnregisterResponse(_)) 135 EXPECT_CALL(delegate, HandleUnregisterResponse(_))
135 .WillOnce(InvokeWithoutArgs(QuitMessageLoop)); 136 .WillOnce(InvokeWithoutArgs(QuitMessageLoop));
136 em::DeviceUnregisterRequest request; 137 em::DeviceUnregisterRequest request;
137 backend->ProcessUnregisterRequest(token_, "testid", request, &delegate); 138 backend->ProcessUnregisterRequest(token_, "testid", request, &delegate);
138 139
139 MessageLoop::current()->Run(); 140 MessageLoop::current()->Run();
140 } 141 }
142
143 {
144 CannedResponseInterceptor interceptor(
145 GURL(kServiceUrl), PROTO_STRING(kServiceResponseAutoEnrollment));
146 DeviceAutoEnrollmentResponseDelegateMock delegate;
147 EXPECT_CALL(delegate, HandleAutoEnrollmentResponse(_))
148 .WillOnce(InvokeWithoutArgs(QuitMessageLoop));
149 em::DeviceAutoEnrollmentRequest request;
150 request.set_remainder(0);
151 request.set_modulus(1);
152 backend->ProcessAutoEnrollmentRequest("testid", request, &delegate);
153
154 MessageLoop::current()->Run();
155 }
141 } 156 }
142 157
143 IN_PROC_BROWSER_TEST_F(DeviceManagementServiceIntegrationTest, 158 IN_PROC_BROWSER_TEST_F(DeviceManagementServiceIntegrationTest,
144 WithTestServer) { 159 WithTestServer) {
145 net::TestServer test_server_( 160 net::TestServer test_server_(
146 net::TestServer::TYPE_HTTP, 161 net::TestServer::TYPE_HTTP,
147 FilePath(FILE_PATH_LITERAL("chrome/test/data/policy"))); 162 FilePath(FILE_PATH_LITERAL("chrome/test/data/policy")));
148 ASSERT_TRUE(test_server_.Start()); 163 ASSERT_TRUE(test_server_.Start());
149 DeviceManagementService service( 164 DeviceManagementService service(
150 test_server_.GetURL("device_management").spec()); 165 test_server_.GetURL("device_management").spec());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 197
183 { 198 {
184 DeviceUnregisterResponseDelegateMock delegate; 199 DeviceUnregisterResponseDelegateMock delegate;
185 EXPECT_CALL(delegate, HandleUnregisterResponse(_)) 200 EXPECT_CALL(delegate, HandleUnregisterResponse(_))
186 .WillOnce(InvokeWithoutArgs(QuitMessageLoop)); 201 .WillOnce(InvokeWithoutArgs(QuitMessageLoop));
187 em::DeviceUnregisterRequest request; 202 em::DeviceUnregisterRequest request;
188 backend->ProcessUnregisterRequest(token_, "testid", request, &delegate); 203 backend->ProcessUnregisterRequest(token_, "testid", request, &delegate);
189 204
190 MessageLoop::current()->Run(); 205 MessageLoop::current()->Run();
191 } 206 }
207
208 {
209 DeviceAutoEnrollmentResponseDelegateMock delegate;
210 EXPECT_CALL(delegate, HandleAutoEnrollmentResponse(_))
211 .WillOnce(InvokeWithoutArgs(QuitMessageLoop));
212 em::DeviceAutoEnrollmentRequest request;
213 request.set_modulus(1);
214 request.set_remainder(0);
215 backend->ProcessAutoEnrollmentRequest("testid", request, &delegate);
216
217 MessageLoop::current()->Run();
218 }
192 } 219 }
193 220
194 } // namespace policy 221 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/device_management_backend_mock.cc ('k') | chrome/browser/policy/device_management_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698