OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/unix_domain_server_socket_posix.h" | 5 #include "net/socket/unix_domain_server_socket_posix.h" |
6 | 6 |
| 7 #include <memory> |
7 #include <vector> | 8 #include <vector> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
11 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "net/base/io_buffer.h" | 15 #include "net/base/io_buffer.h" |
16 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
17 #include "net/base/test_completion_callback.h" | 17 #include "net/base/test_completion_callback.h" |
18 #include "net/socket/unix_domain_client_socket_posix.h" | 18 #include "net/socket/unix_domain_client_socket_posix.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 | 20 |
21 namespace net { | 21 namespace net { |
22 namespace { | 22 namespace { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 EXPECT_EQ(OK, server_socket.BindAndListen(socket_path_, /*backlog=*/1)); | 79 EXPECT_EQ(OK, server_socket.BindAndListen(socket_path_, /*backlog=*/1)); |
80 } | 80 } |
81 | 81 |
82 TEST_F(UnixDomainServerSocketTest, AcceptWithForbiddenUser) { | 82 TEST_F(UnixDomainServerSocketTest, AcceptWithForbiddenUser) { |
83 const bool kUseAbstractNamespace = false; | 83 const bool kUseAbstractNamespace = false; |
84 | 84 |
85 UnixDomainServerSocket server_socket(CreateAuthCallback(false), | 85 UnixDomainServerSocket server_socket(CreateAuthCallback(false), |
86 kUseAbstractNamespace); | 86 kUseAbstractNamespace); |
87 EXPECT_EQ(OK, server_socket.BindAndListen(socket_path_, /*backlog=*/1)); | 87 EXPECT_EQ(OK, server_socket.BindAndListen(socket_path_, /*backlog=*/1)); |
88 | 88 |
89 scoped_ptr<StreamSocket> accepted_socket; | 89 std::unique_ptr<StreamSocket> accepted_socket; |
90 TestCompletionCallback accept_callback; | 90 TestCompletionCallback accept_callback; |
91 EXPECT_EQ(ERR_IO_PENDING, | 91 EXPECT_EQ(ERR_IO_PENDING, |
92 server_socket.Accept(&accepted_socket, accept_callback.callback())); | 92 server_socket.Accept(&accepted_socket, accept_callback.callback())); |
93 EXPECT_FALSE(accepted_socket); | 93 EXPECT_FALSE(accepted_socket); |
94 | 94 |
95 UnixDomainClientSocket client_socket(socket_path_, kUseAbstractNamespace); | 95 UnixDomainClientSocket client_socket(socket_path_, kUseAbstractNamespace); |
96 EXPECT_FALSE(client_socket.IsConnected()); | 96 EXPECT_FALSE(client_socket.IsConnected()); |
97 | 97 |
98 // Connect() will return OK before the server rejects the connection. | 98 // Connect() will return OK before the server rejects the connection. |
99 TestCompletionCallback connect_callback; | 99 TestCompletionCallback connect_callback; |
(...skipping 30 matching lines...) Expand all Loading... |
130 0, | 130 0, |
131 /*backlog=*/1)); | 131 /*backlog=*/1)); |
132 | 132 |
133 EXPECT_EQ(ERR_ADDRESS_INVALID, server_socket.GetLocalAddress(&ep)); | 133 EXPECT_EQ(ERR_ADDRESS_INVALID, server_socket.GetLocalAddress(&ep)); |
134 } | 134 } |
135 | 135 |
136 // Normal cases including read/write are tested by UnixDomainClientSocketTest. | 136 // Normal cases including read/write are tested by UnixDomainClientSocketTest. |
137 | 137 |
138 } // namespace | 138 } // namespace |
139 } // namespace net | 139 } // namespace net |
OLD | NEW |