| OLD | NEW |
| 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 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1224 // message with no client certificate in it. ssl_info.client_cert_sent | 1224 // message with no client certificate in it. ssl_info.client_cert_sent |
| 1225 // should be false in this case. | 1225 // should be false in this case. |
| 1226 SSLInfo ssl_info; | 1226 SSLInfo ssl_info; |
| 1227 sock->GetSSLInfo(&ssl_info); | 1227 sock->GetSSLInfo(&ssl_info); |
| 1228 EXPECT_FALSE(ssl_info.client_cert_sent); | 1228 EXPECT_FALSE(ssl_info.client_cert_sent); |
| 1229 | 1229 |
| 1230 sock->Disconnect(); | 1230 sock->Disconnect(); |
| 1231 EXPECT_FALSE(sock->IsConnected()); | 1231 EXPECT_FALSE(sock->IsConnected()); |
| 1232 } | 1232 } |
| 1233 | 1233 |
| 1234 TEST_F(SSLClientSocketTest, ConnectNoVerifier) { |
| 1235 context_.cert_verifier = nullptr; |
| 1236 |
| 1237 SpawnedTestServer::SSLOptions ssl_options; |
| 1238 ASSERT_TRUE(ConnectToTestServer(ssl_options)); |
| 1239 SSLConfig ssl_config; |
| 1240 int rv; |
| 1241 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); |
| 1242 EXPECT_EQ(ERR_CERT_INVALID, rv); |
| 1243 } |
| 1244 |
| 1234 // TODO(wtc): Add unit tests for IsConnectedAndIdle: | 1245 // TODO(wtc): Add unit tests for IsConnectedAndIdle: |
| 1235 // - Server closes an SSL connection (with a close_notify alert message). | 1246 // - Server closes an SSL connection (with a close_notify alert message). |
| 1236 // - Server closes the underlying TCP connection directly. | 1247 // - Server closes the underlying TCP connection directly. |
| 1237 // - Server sends data unexpectedly. | 1248 // - Server sends data unexpectedly. |
| 1238 | 1249 |
| 1239 // Tests that the socket can be read from successfully. Also test that a peer's | 1250 // Tests that the socket can be read from successfully. Also test that a peer's |
| 1240 // close_notify alert is successfully processed without error. | 1251 // close_notify alert is successfully processed without error. |
| 1241 TEST_F(SSLClientSocketTest, Read) { | 1252 TEST_F(SSLClientSocketTest, Read) { |
| 1242 SpawnedTestServer test_server(SpawnedTestServer::TYPE_HTTPS, | 1253 SpawnedTestServer test_server(SpawnedTestServer::TYPE_HTTPS, |
| 1243 SpawnedTestServer::kLocalhost, | 1254 SpawnedTestServer::kLocalhost, |
| (...skipping 2187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3431 ssl_config.channel_id_enabled = true; | 3442 ssl_config.channel_id_enabled = true; |
| 3432 | 3443 |
| 3433 int rv; | 3444 int rv; |
| 3434 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); | 3445 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); |
| 3435 | 3446 |
| 3436 EXPECT_EQ(ERR_UNEXPECTED, rv); | 3447 EXPECT_EQ(ERR_UNEXPECTED, rv); |
| 3437 EXPECT_FALSE(sock_->IsConnected()); | 3448 EXPECT_FALSE(sock_->IsConnected()); |
| 3438 } | 3449 } |
| 3439 | 3450 |
| 3440 } // namespace net | 3451 } // namespace net |
| OLD | NEW |