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

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

Issue 6297008: The SSL server's RSA private key must be imported with the... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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
« no previous file with comments | « net/socket/ssl_server_socket_nss.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')
Property Changes:
Added: svn:eol-style
+ LF
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 // 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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 TEST_F(SSLServerSocketTest, Initialize) { 276 TEST_F(SSLServerSocketTest, Initialize) {
277 Initialize(); 277 Initialize();
278 } 278 }
279 279
280 // This test executes Connect() of SSLClientSocket and Accept() of 280 // This test executes Connect() of SSLClientSocket and Accept() of
281 // SSLServerSocket to make sure handshaking between the two sockets are 281 // SSLServerSocket to make sure handshaking between the two sockets are
282 // completed successfully. 282 // completed successfully.
283 TEST_F(SSLServerSocketTest, Handshake) { 283 TEST_F(SSLServerSocketTest, Handshake) {
284 Initialize(); 284 Initialize();
285 285
286 if (!base::CheckNSSVersion("3.12.8"))
287 return;
288
289 TestCompletionCallback connect_callback; 286 TestCompletionCallback connect_callback;
290 TestCompletionCallback accept_callback; 287 TestCompletionCallback accept_callback;
291 288
292 int server_ret = server_socket_->Accept(&accept_callback); 289 int server_ret = server_socket_->Accept(&accept_callback);
293 EXPECT_TRUE(server_ret == net::OK || server_ret == net::ERR_IO_PENDING); 290 EXPECT_TRUE(server_ret == net::OK || server_ret == net::ERR_IO_PENDING);
294 291
295 int client_ret = client_socket_->Connect(&connect_callback); 292 int client_ret = client_socket_->Connect(&connect_callback);
296 EXPECT_TRUE(client_ret == net::OK || client_ret == net::ERR_IO_PENDING); 293 EXPECT_TRUE(client_ret == net::OK || client_ret == net::ERR_IO_PENDING);
297 294
298 if (client_ret == net::ERR_IO_PENDING) { 295 if (client_ret == net::ERR_IO_PENDING) {
299 EXPECT_EQ(net::OK, connect_callback.WaitForResult()); 296 EXPECT_EQ(net::OK, connect_callback.WaitForResult());
300 } 297 }
301 if (server_ret == net::ERR_IO_PENDING) { 298 if (server_ret == net::ERR_IO_PENDING) {
302 EXPECT_EQ(net::OK, accept_callback.WaitForResult()); 299 EXPECT_EQ(net::OK, accept_callback.WaitForResult());
303 } 300 }
304 } 301 }
305 302
306 TEST_F(SSLServerSocketTest, DataTransfer) { 303 TEST_F(SSLServerSocketTest, DataTransfer) {
307 Initialize(); 304 Initialize();
308 305
309 if (!base::CheckNSSVersion("3.12.8"))
310 return;
311
312 TestCompletionCallback connect_callback; 306 TestCompletionCallback connect_callback;
313 TestCompletionCallback accept_callback; 307 TestCompletionCallback accept_callback;
314 308
315 // Establish connection. 309 // Establish connection.
316 int client_ret = client_socket_->Connect(&connect_callback); 310 int client_ret = client_socket_->Connect(&connect_callback);
317 EXPECT_TRUE(client_ret == net::OK || client_ret == net::ERR_IO_PENDING); 311 ASSERT_TRUE(client_ret == net::OK || client_ret == net::ERR_IO_PENDING);
318 312
319 int server_ret = server_socket_->Accept(&accept_callback); 313 int server_ret = server_socket_->Accept(&accept_callback);
320 EXPECT_TRUE(server_ret == net::OK || server_ret == net::ERR_IO_PENDING); 314 ASSERT_TRUE(server_ret == net::OK || server_ret == net::ERR_IO_PENDING);
321 315
322 if (client_ret == net::ERR_IO_PENDING) { 316 if (client_ret == net::ERR_IO_PENDING) {
323 EXPECT_EQ(net::OK, connect_callback.WaitForResult()); 317 ASSERT_EQ(net::OK, connect_callback.WaitForResult());
324 } 318 }
325 if (server_ret == net::ERR_IO_PENDING) { 319 if (server_ret == net::ERR_IO_PENDING) {
326 EXPECT_EQ(net::OK, accept_callback.WaitForResult()); 320 ASSERT_EQ(net::OK, accept_callback.WaitForResult());
327 } 321 }
328 322
329 const int kReadBufSize = 1024; 323 const int kReadBufSize = 1024;
330 scoped_refptr<net::StringIOBuffer> write_buf = 324 scoped_refptr<net::StringIOBuffer> write_buf =
331 new net::StringIOBuffer("testing123"); 325 new net::StringIOBuffer("testing123");
332 scoped_refptr<net::IOBuffer> read_buf = new net::IOBuffer(kReadBufSize); 326 scoped_refptr<net::IOBuffer> read_buf = new net::IOBuffer(kReadBufSize);
333 327
334 // Write then read. 328 // Write then read.
335 TestCompletionCallback write_callback; 329 TestCompletionCallback write_callback;
336 TestCompletionCallback read_callback; 330 TestCompletionCallback read_callback;
(...skipping 23 matching lines...) Expand all
360 EXPECT_GT(read_callback.WaitForResult(), 0); 354 EXPECT_GT(read_callback.WaitForResult(), 0);
361 } 355 }
362 if (client_ret == net::ERR_IO_PENDING) { 356 if (client_ret == net::ERR_IO_PENDING) {
363 EXPECT_GT(write_callback.WaitForResult(), 0); 357 EXPECT_GT(write_callback.WaitForResult(), 0);
364 } 358 }
365 EXPECT_EQ(0, memcmp(write_buf->data(), read_buf->data(), write_buf->size())); 359 EXPECT_EQ(0, memcmp(write_buf->data(), read_buf->data(), write_buf->size()));
366 } 360 }
367 #endif 361 #endif
368 362
369 } // namespace net 363 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_server_socket_nss.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698