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

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

Issue 670183003: Update from chromium 62675d9fb31fb8cedc40f68e78e8445a74f362e7 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 2 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/tools/quic/quic_client_session_test.cc » ('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 1855 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 rv = callback.GetResult(sock->Connect(callback.callback())); 1866 rv = callback.GetResult(sock->Connect(callback.callback()));
1867 EXPECT_EQ(OK, rv); 1867 EXPECT_EQ(OK, rv);
1868 EXPECT_TRUE(sock->IsConnected()); 1868 EXPECT_TRUE(sock->IsConnected());
1869 1869
1870 raw_transport->SetNextReadError(0); 1870 raw_transport->SetNextReadError(0);
1871 scoped_refptr<IOBuffer> buf(new IOBuffer(4096)); 1871 scoped_refptr<IOBuffer> buf(new IOBuffer(4096));
1872 rv = callback.GetResult(sock->Read(buf.get(), 4096, callback.callback())); 1872 rv = callback.GetResult(sock->Read(buf.get(), 4096, callback.callback()));
1873 EXPECT_EQ(0, rv); 1873 EXPECT_EQ(0, rv);
1874 } 1874 }
1875 1875
1876 // Tests that SSLClientSocket cleanly returns a Read of size 0 if the
1877 // underlying socket is cleanly closed asynchronously.
1878 // This is a regression test for https://crbug.com/422246
1879 TEST_F(SSLClientSocketTest, Read_WithAsyncZeroReturn) {
1880 SpawnedTestServer test_server(SpawnedTestServer::TYPE_HTTPS,
1881 SpawnedTestServer::kLocalhost,
1882 base::FilePath());
1883 ASSERT_TRUE(test_server.Start());
1884
1885 AddressList addr;
1886 ASSERT_TRUE(test_server.GetAddressList(&addr));
1887
1888 TestCompletionCallback callback;
1889 scoped_ptr<StreamSocket> real_transport(
1890 new TCPClientSocket(addr, NULL, NetLog::Source()));
1891 scoped_ptr<SynchronousErrorStreamSocket> error_socket(
1892 new SynchronousErrorStreamSocket(real_transport.Pass()));
1893 SynchronousErrorStreamSocket* raw_error_socket = error_socket.get();
1894 scoped_ptr<FakeBlockingStreamSocket> transport(
1895 new FakeBlockingStreamSocket(error_socket.Pass()));
1896 FakeBlockingStreamSocket* raw_transport = transport.get();
1897 int rv = callback.GetResult(transport->Connect(callback.callback()));
1898 EXPECT_EQ(OK, rv);
1899
1900 // Disable TLS False Start to ensure the handshake has completed.
1901 SSLConfig ssl_config;
1902 ssl_config.false_start_enabled = false;
1903
1904 scoped_ptr<SSLClientSocket> sock(
1905 CreateSSLClientSocket(transport.Pass(),
1906 test_server.host_port_pair(),
1907 ssl_config));
1908
1909 rv = callback.GetResult(sock->Connect(callback.callback()));
1910 EXPECT_EQ(OK, rv);
1911 EXPECT_TRUE(sock->IsConnected());
1912
1913 raw_error_socket->SetNextReadError(0);
1914 raw_transport->BlockReadResult();
1915 scoped_refptr<IOBuffer> buf(new IOBuffer(4096));
1916 rv = sock->Read(buf.get(), 4096, callback.callback());
1917 EXPECT_EQ(ERR_IO_PENDING, rv);
1918
1919 raw_transport->UnblockReadResult();
1920 rv = callback.GetResult(rv);
1921 EXPECT_EQ(0, rv);
1922 }
1923
1876 TEST_F(SSLClientSocketTest, Read_SmallChunks) { 1924 TEST_F(SSLClientSocketTest, Read_SmallChunks) {
1877 SpawnedTestServer test_server(SpawnedTestServer::TYPE_HTTPS, 1925 SpawnedTestServer test_server(SpawnedTestServer::TYPE_HTTPS,
1878 SpawnedTestServer::kLocalhost, 1926 SpawnedTestServer::kLocalhost,
1879 base::FilePath()); 1927 base::FilePath());
1880 ASSERT_TRUE(test_server.Start()); 1928 ASSERT_TRUE(test_server.Start());
1881 1929
1882 AddressList addr; 1930 AddressList addr;
1883 ASSERT_TRUE(test_server.GetAddressList(&addr)); 1931 ASSERT_TRUE(test_server.GetAddressList(&addr));
1884 1932
1885 TestCompletionCallback callback; 1933 TestCompletionCallback callback;
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after
3025 ssl_config.channel_id_enabled = true; 3073 ssl_config.channel_id_enabled = true;
3026 3074
3027 int rv; 3075 int rv;
3028 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); 3076 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv));
3029 3077
3030 EXPECT_EQ(ERR_UNEXPECTED, rv); 3078 EXPECT_EQ(ERR_UNEXPECTED, rv);
3031 EXPECT_FALSE(sock_->IsConnected()); 3079 EXPECT_FALSE(sock_->IsConnected());
3032 } 3080 }
3033 3081
3034 } // namespace net 3082 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket_openssl.cc ('k') | net/tools/quic/quic_client_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698