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

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

Issue 448293002: This CL is a follow up to https://codereview.chromium.org/416683002/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed nits Created 6 years, 4 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
« no previous file with comments | « net/socket/ssl_client_socket_openssl.cc ('k') | net/socket/ssl_session_cache_openssl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/socket/ssl_client_socket.h" 5 #include "net/socket/ssl_client_socket.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 2676 matching lines...) Expand 10 before | Expand all | Expand 10 after
2687 rv = callback.GetResult(sock->Connect(callback.callback())); 2687 rv = callback.GetResult(sock->Connect(callback.callback()));
2688 EXPECT_EQ(ERR_CONNECTION_RESET, rv); 2688 EXPECT_EQ(ERR_CONNECTION_RESET, rv);
2689 EXPECT_FALSE(sock->IsConnected()); 2689 EXPECT_FALSE(sock->IsConnected());
2690 2690
2691 EXPECT_TRUE(ran_handshake_completion_callback_); 2691 EXPECT_TRUE(ran_handshake_completion_callback_);
2692 } 2692 }
2693 2693
2694 // Tests that the completion callback is run when an SSL connection 2694 // Tests that the completion callback is run when an SSL connection
2695 // completes successfully. 2695 // completes successfully.
2696 TEST_F(SSLClientSocketTest, HandshakeCallbackIsRun_WithSuccess) { 2696 TEST_F(SSLClientSocketTest, HandshakeCallbackIsRun_WithSuccess) {
2697 SpawnedTestServer::SSLOptions ssl_options;
2698 SpawnedTestServer test_server(SpawnedTestServer::TYPE_HTTPS, 2697 SpawnedTestServer test_server(SpawnedTestServer::TYPE_HTTPS,
2699 SpawnedTestServer::kLocalhost, 2698 SpawnedTestServer::kLocalhost,
2700 base::FilePath()); 2699 base::FilePath());
2701 ASSERT_TRUE(test_server.Start()); 2700 ASSERT_TRUE(test_server.Start());
2702 2701
2703 AddressList addr; 2702 AddressList addr;
2704 ASSERT_TRUE(test_server.GetAddressList(&addr)); 2703 ASSERT_TRUE(test_server.GetAddressList(&addr));
2705 2704
2706 scoped_ptr<StreamSocket> transport( 2705 scoped_ptr<StreamSocket> transport(
2707 new TCPClientSocket(addr, NULL, NetLog::Source())); 2706 new TCPClientSocket(addr, NULL, NetLog::Source()));
(...skipping 13 matching lines...) Expand all
2721 sock->SetHandshakeCompletionCallback(base::Bind( 2720 sock->SetHandshakeCompletionCallback(base::Bind(
2722 &SSLClientSocketTest::RecordCompletedHandshake, base::Unretained(this))); 2721 &SSLClientSocketTest::RecordCompletedHandshake, base::Unretained(this)));
2723 2722
2724 rv = callback.GetResult(sock->Connect(callback.callback())); 2723 rv = callback.GetResult(sock->Connect(callback.callback()));
2725 2724
2726 EXPECT_EQ(OK, rv); 2725 EXPECT_EQ(OK, rv);
2727 EXPECT_TRUE(sock->IsConnected()); 2726 EXPECT_TRUE(sock->IsConnected());
2728 EXPECT_TRUE(ran_handshake_completion_callback_); 2727 EXPECT_TRUE(ran_handshake_completion_callback_);
2729 } 2728 }
2730 2729
2731 // Tests that the completion callback is run with connections 2730 // Tests that the completion callback is run with a server that doesn't cache
2732 // that do not cache their session. 2731 // sessions.
2733 TEST_F(SSLClientSocketTest, HandshakeCallbackIsRun_WithDisabledSessionCache) { 2732 TEST_F(SSLClientSocketTest, HandshakeCallbackIsRun_WithDisabledSessionCache) {
2734 SpawnedTestServer::SSLOptions ssl_options; 2733 SpawnedTestServer::SSLOptions ssl_options;
2735 ssl_options.disable_session_cache = true; 2734 ssl_options.disable_session_cache = true;
2736 SpawnedTestServer test_server( 2735 SpawnedTestServer test_server(
2737 SpawnedTestServer::TYPE_HTTPS, ssl_options, base::FilePath()); 2736 SpawnedTestServer::TYPE_HTTPS, ssl_options, base::FilePath());
2738 ASSERT_TRUE(test_server.Start()); 2737 ASSERT_TRUE(test_server.Start());
2739 2738
2740 AddressList addr; 2739 AddressList addr;
2741 ASSERT_TRUE(test_server.GetAddressList(&addr)); 2740 ASSERT_TRUE(test_server.GetAddressList(&addr));
2742 2741
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2928 ssl_config.channel_id_enabled = true; 2927 ssl_config.channel_id_enabled = true;
2929 2928
2930 int rv; 2929 int rv;
2931 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); 2930 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv));
2932 2931
2933 EXPECT_EQ(ERR_UNEXPECTED, rv); 2932 EXPECT_EQ(ERR_UNEXPECTED, rv);
2934 EXPECT_FALSE(sock_->IsConnected()); 2933 EXPECT_FALSE(sock_->IsConnected());
2935 } 2934 }
2936 2935
2937 } // namespace net 2936 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket_openssl.cc ('k') | net/socket/ssl_session_cache_openssl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698