OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/base/address_list.h" | 5 #include "net/base/address_list.h" |
6 #include "net/base/client_socket_factory.h" | 6 #include "net/base/client_socket_factory.h" |
7 #include "net/base/host_resolver.h" | 7 #include "net/base/host_resolver.h" |
8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
9 #include "net/base/ssl_client_socket.h" | 9 #include "net/base/ssl_client_socket.h" |
10 #include "net/base/ssl_config_service.h" | 10 #include "net/base/ssl_config_service.h" |
11 #include "net/base/ssl_test_util.h" | 11 #include "net/base/ssl_test_util.h" |
12 #include "net/base/tcp_client_socket.h" | 12 #include "net/base/tcp_client_socket.h" |
13 #include "net/base/test_completion_callback.h" | 13 #include "net/base/test_completion_callback.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "testing/platform_test.h" | 15 #include "testing/platform_test.h" |
16 | 16 |
17 //----------------------------------------------------------------------------- | 17 //----------------------------------------------------------------------------- |
18 | 18 |
19 const net::SSLConfig kDefaultSSLConfig; | 19 const net::SSLConfig kDefaultSSLConfig; |
20 | 20 |
21 class SSLClientSocketTest : public PlatformTest { | 21 class SSLClientSocketTest : public PlatformTest { |
22 public: | 22 public: |
23 SSLClientSocketTest() | 23 SSLClientSocketTest() |
24 : socket_factory_(net::ClientSocketFactory::GetDefaultFactory()) { | 24 : socket_factory_(net::ClientSocketFactory::GetDefaultFactory()) { |
25 } | 25 } |
26 | 26 |
27 void StartOKServer() { | 27 void StartOKServer() { |
28 bool success = server_.Start(net::TestServerLauncher::ProtoHTTP, | 28 bool success = server_.Start(net::TestServerLauncher::ProtoHTTP, |
29 server_.kHostName, server_.kOKHTTPSPort, | 29 server_.kHostName, server_.kOKHTTPSPort, |
30 FilePath(), server_.GetOKCertPath()); | 30 FilePath(), server_.GetOKCertPath(), std::wstring()); |
31 ASSERT_TRUE(success); | 31 ASSERT_TRUE(success); |
32 } | 32 } |
33 | 33 |
34 void StartMismatchedServer() { | 34 void StartMismatchedServer() { |
35 bool success = server_.Start(net::TestServerLauncher::ProtoHTTP, | 35 bool success = server_.Start(net::TestServerLauncher::ProtoHTTP, |
36 server_.kMismatchedHostName, server_.kOKHTTPSPort, | 36 server_.kMismatchedHostName, server_.kOKHTTPSPort, |
37 FilePath(), server_.GetOKCertPath()); | 37 FilePath(), server_.GetOKCertPath(), std::wstring()); |
38 ASSERT_TRUE(success); | 38 ASSERT_TRUE(success); |
39 } | 39 } |
40 | 40 |
41 void StartExpiredServer() { | 41 void StartExpiredServer() { |
42 bool success = server_.Start(net::TestServerLauncher::ProtoHTTP, | 42 bool success = server_.Start(net::TestServerLauncher::ProtoHTTP, |
43 server_.kHostName, server_.kBadHTTPSPort, | 43 server_.kHostName, server_.kBadHTTPSPort, |
44 FilePath(), server_.GetExpiredCertPath()); | 44 FilePath(), server_.GetExpiredCertPath(), std::wstring()); |
45 ASSERT_TRUE(success); | 45 ASSERT_TRUE(success); |
46 } | 46 } |
47 | 47 |
48 protected: | 48 protected: |
49 net::ClientSocketFactory* socket_factory_; | 49 net::ClientSocketFactory* socket_factory_; |
50 net::TestServerLauncher server_; | 50 net::TestServerLauncher server_; |
51 }; | 51 }; |
52 | 52 |
53 //----------------------------------------------------------------------------- | 53 //----------------------------------------------------------------------------- |
54 | 54 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 // Do a partial read and then exit. This test should not crash! | 335 // Do a partial read and then exit. This test should not crash! |
336 char buf[512]; | 336 char buf[512]; |
337 rv = sock->Read(buf, sizeof(buf), &callback); | 337 rv = sock->Read(buf, sizeof(buf), &callback); |
338 EXPECT_TRUE(rv >= 0 || rv == net::ERR_IO_PENDING); | 338 EXPECT_TRUE(rv >= 0 || rv == net::ERR_IO_PENDING); |
339 | 339 |
340 if (rv == net::ERR_IO_PENDING) | 340 if (rv == net::ERR_IO_PENDING) |
341 rv = callback.WaitForResult(); | 341 rv = callback.WaitForResult(); |
342 | 342 |
343 EXPECT_NE(rv, 0); | 343 EXPECT_NE(rv, 0); |
344 } | 344 } |
OLD | NEW |