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

Side by Side Diff: net/socket/ssl_server_socket_unittest.cc

Issue 7054010: Update SSLServerSocket to provide the net::StreamSocket interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add a StartHandshake method, and make Connect NOT_IMPLEMENTED. Created 9 years, 6 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 | 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 // This test suite uses SSLClientSocket to test the implementation of 5 // This test suite uses SSLClientSocket to test the implementation of
6 // SSLServerSocket. In order to establish connections between the sockets 6 // SSLServerSocket. In order to establish connections between the sockets
7 // we need two additional classes: 7 // we need two additional classes:
8 // 1. FakeSocket 8 // 1. FakeSocket
9 // Connects SSL socket to FakeDataChannel. This class is just a stub. 9 // Connects SSL socket to FakeDataChannel. This class is just a stub.
10 // 10 //
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 286
287 // This test executes Connect() of SSLClientSocket and Accept() of 287 // This test executes Connect() of SSLClientSocket and Accept() of
288 // SSLServerSocket to make sure handshaking between the two sockets are 288 // SSLServerSocket to make sure handshaking between the two sockets are
289 // completed successfully. 289 // completed successfully.
290 TEST_F(SSLServerSocketTest, Handshake) { 290 TEST_F(SSLServerSocketTest, Handshake) {
291 Initialize(); 291 Initialize();
292 292
293 TestCompletionCallback connect_callback; 293 TestCompletionCallback connect_callback;
294 TestCompletionCallback accept_callback; 294 TestCompletionCallback accept_callback;
295 295
296 int server_ret = server_socket_->Accept(&accept_callback); 296 int server_ret = server_socket_->Connect(&accept_callback);
wtc 2011/06/10 22:17:35 These Connect calls should be changed to StartHand
Wez 2011/06/11 01:08:33 Yes. SSLServerSocket has a Connect method inherit
297 EXPECT_TRUE(server_ret == net::OK || server_ret == net::ERR_IO_PENDING); 297 EXPECT_TRUE(server_ret == net::OK || server_ret == net::ERR_IO_PENDING);
298 298
299 int client_ret = client_socket_->Connect(&connect_callback); 299 int client_ret = client_socket_->Connect(&connect_callback);
300 EXPECT_TRUE(client_ret == net::OK || client_ret == net::ERR_IO_PENDING); 300 EXPECT_TRUE(client_ret == net::OK || client_ret == net::ERR_IO_PENDING);
301 301
302 if (client_ret == net::ERR_IO_PENDING) { 302 if (client_ret == net::ERR_IO_PENDING) {
303 EXPECT_EQ(net::OK, connect_callback.WaitForResult()); 303 EXPECT_EQ(net::OK, connect_callback.WaitForResult());
304 } 304 }
305 if (server_ret == net::ERR_IO_PENDING) { 305 if (server_ret == net::ERR_IO_PENDING) {
306 EXPECT_EQ(net::OK, accept_callback.WaitForResult()); 306 EXPECT_EQ(net::OK, accept_callback.WaitForResult());
307 } 307 }
308 308
309 // Make sure the cert status is expected. 309 // Make sure the cert status is expected.
310 SSLInfo ssl_info; 310 SSLInfo ssl_info;
311 client_socket_->GetSSLInfo(&ssl_info); 311 client_socket_->GetSSLInfo(&ssl_info);
312 EXPECT_EQ(CERT_STATUS_AUTHORITY_INVALID, ssl_info.cert_status); 312 EXPECT_EQ(CERT_STATUS_AUTHORITY_INVALID, ssl_info.cert_status);
313 } 313 }
314 314
315 TEST_F(SSLServerSocketTest, DataTransfer) { 315 TEST_F(SSLServerSocketTest, DataTransfer) {
316 Initialize(); 316 Initialize();
317 317
318 TestCompletionCallback connect_callback; 318 TestCompletionCallback connect_callback;
319 TestCompletionCallback accept_callback; 319 TestCompletionCallback accept_callback;
320 320
321 // Establish connection. 321 // Establish connection.
322 int client_ret = client_socket_->Connect(&connect_callback); 322 int client_ret = client_socket_->Connect(&connect_callback);
323 ASSERT_TRUE(client_ret == net::OK || client_ret == net::ERR_IO_PENDING); 323 ASSERT_TRUE(client_ret == net::OK || client_ret == net::ERR_IO_PENDING);
324 324
325 int server_ret = server_socket_->Accept(&accept_callback); 325 int server_ret = server_socket_->Connect(&accept_callback);
326 ASSERT_TRUE(server_ret == net::OK || server_ret == net::ERR_IO_PENDING); 326 ASSERT_TRUE(server_ret == net::OK || server_ret == net::ERR_IO_PENDING);
327 327
328 if (client_ret == net::ERR_IO_PENDING) { 328 if (client_ret == net::ERR_IO_PENDING) {
329 ASSERT_EQ(net::OK, connect_callback.WaitForResult()); 329 ASSERT_EQ(net::OK, connect_callback.WaitForResult());
330 } 330 }
331 if (server_ret == net::ERR_IO_PENDING) { 331 if (server_ret == net::ERR_IO_PENDING) {
332 ASSERT_EQ(net::OK, accept_callback.WaitForResult()); 332 ASSERT_EQ(net::OK, accept_callback.WaitForResult());
333 } 333 }
334 334
335 const int kReadBufSize = 1024; 335 const int kReadBufSize = 1024;
(...skipping 30 matching lines...) Expand all
366 EXPECT_GT(read_callback.WaitForResult(), 0); 366 EXPECT_GT(read_callback.WaitForResult(), 0);
367 } 367 }
368 if (client_ret == net::ERR_IO_PENDING) { 368 if (client_ret == net::ERR_IO_PENDING) {
369 EXPECT_GT(write_callback.WaitForResult(), 0); 369 EXPECT_GT(write_callback.WaitForResult(), 0);
370 } 370 }
371 EXPECT_EQ(0, memcmp(write_buf->data(), read_buf->data(), write_buf->size())); 371 EXPECT_EQ(0, memcmp(write_buf->data(), read_buf->data(), write_buf->size()));
372 } 372 }
373 #endif 373 #endif
374 374
375 } // namespace net 375 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698