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

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

Issue 382143005: Supports DevTools socket access authentication based on Android permissions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merged 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
OLDNEW
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 <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
12 #include "base/memory/scoped_ptr.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 {
23 23
24 const char kSocketFilename[] = "socket_for_testing"; 24 const char kSocketFilename[] = "socket_for_testing";
25 const char kInvalidSocketPath[] = "/invalid/path"; 25 const char kInvalidSocketPath[] = "/invalid/path";
26 26
27 bool UserCanConnectCallback(bool allow_user, uid_t uid, gid_t gid) { 27 bool UserCanConnectCallback(bool allow_user, pid_t pid, uid_t uid, gid_t gid) {
28 // Here peers are running in same process. 28 // Here peers are running in same process.
29 #if defined(OS_LINUX) || defined(OS_ANDROID)
30 EXPECT_EQ(getpid(), pid);
31 #else
32 EXPECT_EQ(0, pid);
33 #endif
29 EXPECT_EQ(getuid(), uid); 34 EXPECT_EQ(getuid(), uid);
30 EXPECT_EQ(getgid(), gid); 35 EXPECT_EQ(getgid(), gid);
31 return allow_user; 36 return allow_user;
32 } 37 }
33 38
34 UnixDomainServerSocket::AuthCallback CreateAuthCallback(bool allow_user) { 39 UnixDomainServerSocket::AuthCallback CreateAuthCallback(bool allow_user) {
35 return base::Bind(&UserCanConnectCallback, allow_user); 40 return base::Bind(&UserCanConnectCallback, allow_user);
36 } 41 }
37 42
38 class UnixDomainServerSocketTest : public testing::Test { 43 class UnixDomainServerSocketTest : public testing::Test {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // The server socket should not have called |accept_callback| or modified 108 // The server socket should not have called |accept_callback| or modified
104 // |accepted_socket|. 109 // |accepted_socket|.
105 EXPECT_FALSE(accept_callback.have_result()); 110 EXPECT_FALSE(accept_callback.have_result());
106 EXPECT_FALSE(accepted_socket); 111 EXPECT_FALSE(accepted_socket);
107 } 112 }
108 113
109 // Normal cases including read/write are tested by UnixDomainClientSocketTest. 114 // Normal cases including read/write are tested by UnixDomainClientSocketTest.
110 115
111 } // namespace 116 } // namespace
112 } // namespace net 117 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698