OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <set> | 5 #include <set> |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/common/extensions/api/sockets/sockets_manifest_permission.h" | 10 #include "extensions/common/api/sockets/sockets_manifest_permission.h" |
11 #include "extensions/common/extension_messages.h" | 11 #include "extensions/common/extension_messages.h" |
12 #include "extensions/common/manifest_constants.h" | 12 #include "extensions/common/manifest_constants.h" |
13 #include "ipc/ipc_message.h" | 13 #include "ipc/ipc_message.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 using content::SocketPermissionRequest; | 16 using content::SocketPermissionRequest; |
17 | 17 |
18 namespace extensions { | 18 namespace extensions { |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 const char kUdpBindPermission[]= | 22 const char kUdpBindPermission[] = |
23 "{ \"udp\": { \"bind\": [\"127.0.0.1:3007\", \"a.com:80\"] } }"; | 23 "{ \"udp\": { \"bind\": [\"127.0.0.1:3007\", \"a.com:80\"] } }"; |
24 | 24 |
25 const char kUdpSendPermission[]= | 25 const char kUdpSendPermission[] = |
26 "{ \"udp\": { \"send\": [\"\", \"a.com:80\"] } }"; | 26 "{ \"udp\": { \"send\": [\"\", \"a.com:80\"] } }"; |
27 | 27 |
28 const char kTcpConnectPermission[]= | 28 const char kTcpConnectPermission[] = |
29 "{ \"tcp\": { \"connect\": [\"127.0.0.1:80\", \"a.com:80\"] } }"; | 29 "{ \"tcp\": { \"connect\": [\"127.0.0.1:80\", \"a.com:80\"] } }"; |
30 | 30 |
31 const char kTcpServerListenPermission[]= | 31 const char kTcpServerListenPermission[] = |
32 "{ \"tcpServer\": { \"listen\": [\"127.0.0.1:80\", \"a.com:80\"] } }"; | 32 "{ \"tcpServer\": { \"listen\": [\"127.0.0.1:80\", \"a.com:80\"] } }"; |
33 | 33 |
34 static void AssertEmptyPermission(const SocketsManifestPermission* permission) { | 34 static void AssertEmptyPermission(const SocketsManifestPermission* permission) { |
35 EXPECT_TRUE(permission); | 35 EXPECT_TRUE(permission); |
36 EXPECT_EQ(std::string(extensions::manifest_keys::kSockets), permission->id()); | 36 EXPECT_EQ(std::string(extensions::manifest_keys::kSockets), permission->id()); |
37 EXPECT_EQ(permission->id(), permission->name()); | 37 EXPECT_EQ(permission->id(), permission->name()); |
38 EXPECT_FALSE(permission->HasMessages()); | 38 EXPECT_FALSE(permission->HasMessages()); |
39 EXPECT_EQ(0u, permission->entries().size()); | 39 EXPECT_EQ(0u, permission->entries().size()); |
40 } | 40 } |
41 | 41 |
42 static scoped_ptr<base::Value> ParsePermissionJSON(const std::string& json) { | 42 static scoped_ptr<base::Value> ParsePermissionJSON(const std::string& json) { |
43 scoped_ptr<base::Value> result(base::JSONReader::Read(json)); | 43 scoped_ptr<base::Value> result(base::JSONReader::Read(json)); |
44 EXPECT_TRUE(result) << "Invalid JSON string: " << json; | 44 EXPECT_TRUE(result) << "Invalid JSON string: " << json; |
45 return result.Pass(); | 45 return result.Pass(); |
46 } | 46 } |
47 | 47 |
48 static scoped_ptr<SocketsManifestPermission> PermissionFromValue( | 48 static scoped_ptr<SocketsManifestPermission> PermissionFromValue( |
49 const base::Value& value) { | 49 const base::Value& value) { |
50 base::string16 error16; | 50 base::string16 error16; |
51 scoped_ptr<SocketsManifestPermission> permission( | 51 scoped_ptr<SocketsManifestPermission> permission( |
52 SocketsManifestPermission::FromValue(value, &error16)); | 52 SocketsManifestPermission::FromValue(value, &error16)); |
53 EXPECT_TRUE(permission) | 53 EXPECT_TRUE(permission) << "Error parsing Value into permission: " << error16; |
54 << "Error parsing Value into permission: " << error16; | |
55 return permission.Pass(); | 54 return permission.Pass(); |
56 } | 55 } |
57 | 56 |
58 static scoped_ptr<SocketsManifestPermission> PermissionFromJSON( | 57 static scoped_ptr<SocketsManifestPermission> PermissionFromJSON( |
59 const std::string& json) { | 58 const std::string& json) { |
60 scoped_ptr<base::Value> value(ParsePermissionJSON(json)); | 59 scoped_ptr<base::Value> value(ParsePermissionJSON(json)); |
61 return PermissionFromValue(*value); | 60 return PermissionFromValue(*value); |
62 } | 61 } |
63 | 62 |
64 struct CheckFormatEntry { | 63 struct CheckFormatEntry { |
65 CheckFormatEntry(SocketPermissionRequest::OperationType operation_type, | 64 CheckFormatEntry(SocketPermissionRequest::OperationType operation_type, |
66 std::string host_pattern) | 65 std::string host_pattern) |
67 : operation_type(operation_type), | 66 : operation_type(operation_type), host_pattern(host_pattern) {} |
68 host_pattern(host_pattern) { | |
69 } | |
70 | 67 |
71 // operators <, == are needed by container std::set and algorithms | 68 // operators <, == are needed by container std::set and algorithms |
72 // std::set_includes and std::set_differences. | 69 // std::set_includes and std::set_differences. |
73 bool operator<(const CheckFormatEntry& rhs) const { | 70 bool operator<(const CheckFormatEntry& rhs) const { |
74 if (operation_type == rhs.operation_type) | 71 if (operation_type == rhs.operation_type) |
75 return host_pattern < rhs.host_pattern; | 72 return host_pattern < rhs.host_pattern; |
76 | 73 |
77 return operation_type < rhs.operation_type; | 74 return operation_type < rhs.operation_type; |
78 } | 75 } |
79 | 76 |
80 bool operator==(const CheckFormatEntry& rhs) const { | 77 bool operator==(const CheckFormatEntry& rhs) const { |
81 return operation_type == rhs.operation_type && | 78 return operation_type == rhs.operation_type && |
82 host_pattern == rhs.host_pattern; | 79 host_pattern == rhs.host_pattern; |
83 } | 80 } |
84 | 81 |
85 SocketPermissionRequest::OperationType operation_type; | 82 SocketPermissionRequest::OperationType operation_type; |
86 std::string host_pattern; | 83 std::string host_pattern; |
87 }; | 84 }; |
88 | 85 |
89 static testing::AssertionResult CheckFormat( | 86 static testing::AssertionResult CheckFormat( |
90 std::multiset<CheckFormatEntry> permissions, | 87 std::multiset<CheckFormatEntry> permissions, |
91 const std::string& json) { | 88 const std::string& json) { |
92 scoped_ptr<SocketsManifestPermission> permission(PermissionFromJSON(json)); | 89 scoped_ptr<SocketsManifestPermission> permission(PermissionFromJSON(json)); |
93 if (!permission) | 90 if (!permission) |
94 return testing::AssertionFailure() << "Invalid permission " << json; | 91 return testing::AssertionFailure() << "Invalid permission " << json; |
95 | 92 |
96 if (permissions.size() != permission->entries().size()) { | 93 if (permissions.size() != permission->entries().size()) { |
97 return testing::AssertionFailure() | 94 return testing::AssertionFailure() |
98 << "Incorrect # of entries in json: " << json; | 95 << "Incorrect # of entries in json: " << json; |
99 } | 96 } |
100 | 97 |
101 // Note: We use multiset because SocketsManifestPermission does not have to | 98 // Note: We use multiset because SocketsManifestPermission does not have to |
102 // store entries in the order found in the json message. | 99 // store entries in the order found in the json message. |
103 std::multiset<CheckFormatEntry> parsed_permissions; | 100 std::multiset<CheckFormatEntry> parsed_permissions; |
104 for (SocketsManifestPermission::SocketPermissionEntrySet::const_iterator | 101 for (SocketsManifestPermission::SocketPermissionEntrySet::const_iterator it = |
105 it = permission->entries().begin(); it != permission->entries().end(); | 102 permission->entries().begin(); |
106 ++it) { | 103 it != permission->entries().end(); |
| 104 ++it) { |
107 parsed_permissions.insert( | 105 parsed_permissions.insert( |
108 CheckFormatEntry(it->pattern().type, it->GetHostPatternAsString())); | 106 CheckFormatEntry(it->pattern().type, it->GetHostPatternAsString())); |
109 } | 107 } |
110 | 108 |
111 if (!std::equal(permissions.begin(), permissions.end(), | 109 if (!std::equal( |
112 parsed_permissions.begin())) { | 110 permissions.begin(), permissions.end(), parsed_permissions.begin())) { |
113 return testing::AssertionFailure() << "Incorrect socket operations."; | 111 return testing::AssertionFailure() << "Incorrect socket operations."; |
114 } | 112 } |
115 return testing::AssertionSuccess(); | 113 return testing::AssertionSuccess(); |
116 } | 114 } |
117 | 115 |
118 static testing::AssertionResult CheckFormat(const std::string& json) { | 116 static testing::AssertionResult CheckFormat(const std::string& json) { |
119 return CheckFormat(std::multiset<CheckFormatEntry>(), json); | 117 return CheckFormat(std::multiset<CheckFormatEntry>(), json); |
120 } | 118 } |
121 | 119 |
122 static testing::AssertionResult CheckFormat( | 120 static testing::AssertionResult CheckFormat(const std::string& json, |
123 const std::string& json, | 121 const CheckFormatEntry& op1) { |
124 const CheckFormatEntry& op1) { | 122 CheckFormatEntry entries[] = {op1}; |
125 CheckFormatEntry entries[] = { | 123 return CheckFormat( |
126 op1 | 124 std::multiset<CheckFormatEntry>(entries, entries + arraysize(entries)), |
127 }; | 125 json); |
128 return CheckFormat(std::multiset<CheckFormatEntry>( | |
129 entries, entries + arraysize(entries)), json); | |
130 } | 126 } |
131 | 127 |
132 static testing::AssertionResult CheckFormat( | 128 static testing::AssertionResult CheckFormat(const std::string& json, |
133 const std::string& json, | 129 const CheckFormatEntry& op1, |
134 const CheckFormatEntry& op1, | 130 const CheckFormatEntry& op2) { |
135 const CheckFormatEntry& op2) { | 131 CheckFormatEntry entries[] = {op1, op2}; |
136 CheckFormatEntry entries[] = { | 132 return CheckFormat( |
137 op1, op2 | 133 std::multiset<CheckFormatEntry>(entries, entries + arraysize(entries)), |
138 }; | 134 json); |
139 return CheckFormat(std::multiset<CheckFormatEntry>( | |
140 entries, entries + arraysize(entries)), json); | |
141 } | 135 } |
142 | 136 |
143 static testing::AssertionResult CheckFormat( | 137 static testing::AssertionResult CheckFormat(const std::string& json, |
144 const std::string& json, | 138 const CheckFormatEntry& op1, |
145 const CheckFormatEntry& op1, | 139 const CheckFormatEntry& op2, |
146 const CheckFormatEntry& op2, | 140 const CheckFormatEntry& op3, |
147 const CheckFormatEntry& op3, | 141 const CheckFormatEntry& op4, |
148 const CheckFormatEntry& op4, | 142 const CheckFormatEntry& op5, |
149 const CheckFormatEntry& op5, | 143 const CheckFormatEntry& op6, |
150 const CheckFormatEntry& op6, | 144 const CheckFormatEntry& op7, |
151 const CheckFormatEntry& op7, | 145 const CheckFormatEntry& op8, |
152 const CheckFormatEntry& op8, | 146 const CheckFormatEntry& op9) { |
153 const CheckFormatEntry& op9) { | 147 CheckFormatEntry entries[] = {op1, op2, op3, op4, op5, op6, op7, op8, op9}; |
154 CheckFormatEntry entries[] = { | 148 return CheckFormat( |
155 op1, op2, op3, op4, op5, op6, op7, op8, op9 | 149 std::multiset<CheckFormatEntry>(entries, entries + arraysize(entries)), |
156 }; | 150 json); |
157 return CheckFormat(std::multiset<CheckFormatEntry>( | |
158 entries, entries + arraysize(entries)), json); | |
159 } | 151 } |
160 | 152 |
161 } // namespace | 153 } // namespace |
162 | 154 |
163 TEST(SocketsManifestPermissionTest, Empty) { | 155 TEST(SocketsManifestPermissionTest, Empty) { |
164 // Construction | 156 // Construction |
165 scoped_ptr<SocketsManifestPermission> permission( | 157 scoped_ptr<SocketsManifestPermission> permission( |
166 new SocketsManifestPermission()); | 158 new SocketsManifestPermission()); |
167 AssertEmptyPermission(permission.get()); | 159 AssertEmptyPermission(permission.get()); |
168 | 160 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 new SocketsManifestPermission()); | 195 new SocketsManifestPermission()); |
204 | 196 |
205 IPC::Message m; | 197 IPC::Message m; |
206 ipc_perm->Write(&m); | 198 ipc_perm->Write(&m); |
207 PickleIterator iter(m); | 199 PickleIterator iter(m); |
208 EXPECT_TRUE(ipc_perm2->Read(&m, &iter)); | 200 EXPECT_TRUE(ipc_perm2->Read(&m, &iter)); |
209 AssertEmptyPermission(ipc_perm2.get()); | 201 AssertEmptyPermission(ipc_perm2.get()); |
210 } | 202 } |
211 | 203 |
212 TEST(SocketsManifestPermissionTest, JSONFormats) { | 204 TEST(SocketsManifestPermissionTest, JSONFormats) { |
213 EXPECT_TRUE(CheckFormat("{\"udp\":{\"send\":\"\"}}", | 205 EXPECT_TRUE(CheckFormat( |
| 206 "{\"udp\":{\"send\":\"\"}}", |
214 CheckFormatEntry(SocketPermissionRequest::UDP_SEND_TO, "*:*"))); | 207 CheckFormatEntry(SocketPermissionRequest::UDP_SEND_TO, "*:*"))); |
215 EXPECT_TRUE(CheckFormat("{\"udp\":{\"send\":[]}}")); | 208 EXPECT_TRUE(CheckFormat("{\"udp\":{\"send\":[]}}")); |
216 EXPECT_TRUE(CheckFormat("{\"udp\":{\"send\":[\"\"]}}", | 209 EXPECT_TRUE(CheckFormat( |
| 210 "{\"udp\":{\"send\":[\"\"]}}", |
217 CheckFormatEntry(SocketPermissionRequest::UDP_SEND_TO, "*:*"))); | 211 CheckFormatEntry(SocketPermissionRequest::UDP_SEND_TO, "*:*"))); |
218 EXPECT_TRUE(CheckFormat("{\"udp\":{\"send\":[\"a:80\", \"b:10\"]}}", | 212 EXPECT_TRUE(CheckFormat( |
| 213 "{\"udp\":{\"send\":[\"a:80\", \"b:10\"]}}", |
219 CheckFormatEntry(SocketPermissionRequest::UDP_SEND_TO, "a:80"), | 214 CheckFormatEntry(SocketPermissionRequest::UDP_SEND_TO, "a:80"), |
220 CheckFormatEntry(SocketPermissionRequest::UDP_SEND_TO, "b:10"))); | 215 CheckFormatEntry(SocketPermissionRequest::UDP_SEND_TO, "b:10"))); |
221 | 216 |
222 EXPECT_TRUE(CheckFormat("{\"udp\":{\"bind\":\"\"}}", | 217 EXPECT_TRUE( |
223 CheckFormatEntry(SocketPermissionRequest::UDP_BIND, "*:*"))); | 218 CheckFormat("{\"udp\":{\"bind\":\"\"}}", |
| 219 CheckFormatEntry(SocketPermissionRequest::UDP_BIND, "*:*"))); |
224 EXPECT_TRUE(CheckFormat("{\"udp\":{\"bind\":[]}}")); | 220 EXPECT_TRUE(CheckFormat("{\"udp\":{\"bind\":[]}}")); |
225 EXPECT_TRUE(CheckFormat("{\"udp\":{\"bind\":[\"\"]}}", | 221 EXPECT_TRUE( |
226 CheckFormatEntry(SocketPermissionRequest::UDP_BIND, "*:*"))); | 222 CheckFormat("{\"udp\":{\"bind\":[\"\"]}}", |
227 EXPECT_TRUE(CheckFormat("{\"udp\":{\"bind\":[\"a:80\", \"b:10\"]}}", | 223 CheckFormatEntry(SocketPermissionRequest::UDP_BIND, "*:*"))); |
228 CheckFormatEntry(SocketPermissionRequest::UDP_BIND, "a:80"), | 224 EXPECT_TRUE( |
229 CheckFormatEntry(SocketPermissionRequest::UDP_BIND, "b:10"))); | 225 CheckFormat("{\"udp\":{\"bind\":[\"a:80\", \"b:10\"]}}", |
| 226 CheckFormatEntry(SocketPermissionRequest::UDP_BIND, "a:80"), |
| 227 CheckFormatEntry(SocketPermissionRequest::UDP_BIND, "b:10"))); |
230 | 228 |
231 EXPECT_TRUE(CheckFormat("{\"udp\":{\"multicastMembership\":\"\"}}", | 229 EXPECT_TRUE(CheckFormat( |
| 230 "{\"udp\":{\"multicastMembership\":\"\"}}", |
232 CheckFormatEntry(SocketPermissionRequest::UDP_MULTICAST_MEMBERSHIP, ""))); | 231 CheckFormatEntry(SocketPermissionRequest::UDP_MULTICAST_MEMBERSHIP, ""))); |
233 EXPECT_TRUE(CheckFormat("{\"udp\":{\"multicastMembership\":[]}}")); | 232 EXPECT_TRUE(CheckFormat("{\"udp\":{\"multicastMembership\":[]}}")); |
234 EXPECT_TRUE(CheckFormat("{\"udp\":{\"multicastMembership\":[\"\"]}}", | 233 EXPECT_TRUE(CheckFormat( |
| 234 "{\"udp\":{\"multicastMembership\":[\"\"]}}", |
235 CheckFormatEntry(SocketPermissionRequest::UDP_MULTICAST_MEMBERSHIP, ""))); | 235 CheckFormatEntry(SocketPermissionRequest::UDP_MULTICAST_MEMBERSHIP, ""))); |
236 EXPECT_TRUE(CheckFormat("{\"udp\":{\"multicastMembership\":[\"\", \"\"]}}", | 236 EXPECT_TRUE(CheckFormat( |
| 237 "{\"udp\":{\"multicastMembership\":[\"\", \"\"]}}", |
237 CheckFormatEntry(SocketPermissionRequest::UDP_MULTICAST_MEMBERSHIP, ""))); | 238 CheckFormatEntry(SocketPermissionRequest::UDP_MULTICAST_MEMBERSHIP, ""))); |
238 | 239 |
239 EXPECT_TRUE(CheckFormat("{\"tcp\":{\"connect\":\"\"}}", | 240 EXPECT_TRUE(CheckFormat( |
| 241 "{\"tcp\":{\"connect\":\"\"}}", |
240 CheckFormatEntry(SocketPermissionRequest::TCP_CONNECT, "*:*"))); | 242 CheckFormatEntry(SocketPermissionRequest::TCP_CONNECT, "*:*"))); |
241 EXPECT_TRUE(CheckFormat("{\"tcp\":{\"connect\":[]}}")); | 243 EXPECT_TRUE(CheckFormat("{\"tcp\":{\"connect\":[]}}")); |
242 EXPECT_TRUE(CheckFormat("{\"tcp\":{\"connect\":[\"\"]}}", | 244 EXPECT_TRUE(CheckFormat( |
| 245 "{\"tcp\":{\"connect\":[\"\"]}}", |
243 CheckFormatEntry(SocketPermissionRequest::TCP_CONNECT, "*:*"))); | 246 CheckFormatEntry(SocketPermissionRequest::TCP_CONNECT, "*:*"))); |
244 EXPECT_TRUE(CheckFormat("{\"tcp\":{\"connect\":[\"a:80\", \"b:10\"]}}", | 247 EXPECT_TRUE(CheckFormat( |
| 248 "{\"tcp\":{\"connect\":[\"a:80\", \"b:10\"]}}", |
245 CheckFormatEntry(SocketPermissionRequest::TCP_CONNECT, "a:80"), | 249 CheckFormatEntry(SocketPermissionRequest::TCP_CONNECT, "a:80"), |
246 CheckFormatEntry(SocketPermissionRequest::TCP_CONNECT, "b:10"))); | 250 CheckFormatEntry(SocketPermissionRequest::TCP_CONNECT, "b:10"))); |
247 | 251 |
248 EXPECT_TRUE(CheckFormat("{\"tcpServer\":{\"listen\":\"\"}}", | 252 EXPECT_TRUE(CheckFormat( |
| 253 "{\"tcpServer\":{\"listen\":\"\"}}", |
249 CheckFormatEntry(SocketPermissionRequest::TCP_LISTEN, "*:*"))); | 254 CheckFormatEntry(SocketPermissionRequest::TCP_LISTEN, "*:*"))); |
250 EXPECT_TRUE(CheckFormat("{\"tcpServer\":{\"listen\":[]}}")); | 255 EXPECT_TRUE(CheckFormat("{\"tcpServer\":{\"listen\":[]}}")); |
251 EXPECT_TRUE(CheckFormat("{\"tcpServer\":{\"listen\":[\"\"]}}", | 256 EXPECT_TRUE(CheckFormat( |
| 257 "{\"tcpServer\":{\"listen\":[\"\"]}}", |
252 CheckFormatEntry(SocketPermissionRequest::TCP_LISTEN, "*:*"))); | 258 CheckFormatEntry(SocketPermissionRequest::TCP_LISTEN, "*:*"))); |
253 EXPECT_TRUE(CheckFormat("{\"tcpServer\":{\"listen\":[\"a:80\", \"b:10\"]}}", | 259 EXPECT_TRUE(CheckFormat( |
| 260 "{\"tcpServer\":{\"listen\":[\"a:80\", \"b:10\"]}}", |
254 CheckFormatEntry(SocketPermissionRequest::TCP_LISTEN, "a:80"), | 261 CheckFormatEntry(SocketPermissionRequest::TCP_LISTEN, "a:80"), |
255 CheckFormatEntry(SocketPermissionRequest::TCP_LISTEN, "b:10"))); | 262 CheckFormatEntry(SocketPermissionRequest::TCP_LISTEN, "b:10"))); |
256 | 263 |
257 EXPECT_TRUE(CheckFormat( | 264 EXPECT_TRUE(CheckFormat( |
258 "{" | 265 "{" |
259 "\"udp\":{" | 266 "\"udp\":{" |
260 "\"send\":[\"a:80\", \"b:10\"]," | 267 "\"send\":[\"a:80\", \"b:10\"]," |
261 "\"bind\":[\"a:80\", \"b:10\"]," | 268 "\"bind\":[\"a:80\", \"b:10\"]," |
262 "\"multicastMembership\":\"\"" | 269 "\"multicastMembership\":\"\"" |
263 "}," | 270 "}," |
264 "\"tcp\":{\"connect\":[\"a:80\", \"b:10\"]}," | 271 "\"tcp\":{\"connect\":[\"a:80\", \"b:10\"]}," |
265 "\"tcpServer\":{\"listen\":[\"a:80\", \"b:10\"]}" | 272 "\"tcpServer\":{\"listen\":[\"a:80\", \"b:10\"]}" |
266 "}", | 273 "}", |
267 CheckFormatEntry(SocketPermissionRequest::UDP_SEND_TO, "a:80"), | 274 CheckFormatEntry(SocketPermissionRequest::UDP_SEND_TO, "a:80"), |
268 CheckFormatEntry(SocketPermissionRequest::UDP_SEND_TO, "b:10"), | 275 CheckFormatEntry(SocketPermissionRequest::UDP_SEND_TO, "b:10"), |
269 CheckFormatEntry(SocketPermissionRequest::UDP_BIND, "a:80"), | 276 CheckFormatEntry(SocketPermissionRequest::UDP_BIND, "a:80"), |
270 CheckFormatEntry(SocketPermissionRequest::UDP_BIND, "b:10"), | 277 CheckFormatEntry(SocketPermissionRequest::UDP_BIND, "b:10"), |
271 CheckFormatEntry(SocketPermissionRequest::UDP_MULTICAST_MEMBERSHIP, ""), | 278 CheckFormatEntry(SocketPermissionRequest::UDP_MULTICAST_MEMBERSHIP, ""), |
272 CheckFormatEntry(SocketPermissionRequest::TCP_CONNECT, "a:80"), | 279 CheckFormatEntry(SocketPermissionRequest::TCP_CONNECT, "a:80"), |
273 CheckFormatEntry(SocketPermissionRequest::TCP_CONNECT, "b:10"), | 280 CheckFormatEntry(SocketPermissionRequest::TCP_CONNECT, "b:10"), |
274 CheckFormatEntry(SocketPermissionRequest::TCP_LISTEN, "a:80"), | 281 CheckFormatEntry(SocketPermissionRequest::TCP_LISTEN, "a:80"), |
275 CheckFormatEntry(SocketPermissionRequest::TCP_LISTEN, "b:10"))); | 282 CheckFormatEntry(SocketPermissionRequest::TCP_LISTEN, "b:10"))); |
276 | |
277 } | 283 } |
278 | 284 |
279 TEST(SocketsManifestPermissionTest, FromToValue) { | 285 TEST(SocketsManifestPermissionTest, FromToValue) { |
280 scoped_ptr<base::Value> udp_send(ParsePermissionJSON(kUdpBindPermission)); | 286 scoped_ptr<base::Value> udp_send(ParsePermissionJSON(kUdpBindPermission)); |
281 scoped_ptr<base::Value> udp_bind(ParsePermissionJSON(kUdpSendPermission)); | 287 scoped_ptr<base::Value> udp_bind(ParsePermissionJSON(kUdpSendPermission)); |
282 scoped_ptr<base::Value> tcp_connect( | 288 scoped_ptr<base::Value> tcp_connect( |
283 ParsePermissionJSON(kTcpConnectPermission)); | 289 ParsePermissionJSON(kTcpConnectPermission)); |
284 scoped_ptr<base::Value> tcp_server_listen( | 290 scoped_ptr<base::Value> tcp_server_listen( |
285 ParsePermissionJSON(kTcpServerListenPermission)); | 291 ParsePermissionJSON(kTcpServerListenPermission)); |
286 | 292 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 new SocketsManifestPermission()); | 400 new SocketsManifestPermission()); |
395 | 401 |
396 IPC::Message m; | 402 IPC::Message m; |
397 ipc_perm->Write(&m); | 403 ipc_perm->Write(&m); |
398 PickleIterator iter(m); | 404 PickleIterator iter(m); |
399 EXPECT_TRUE(ipc_perm2->Read(&m, &iter)); | 405 EXPECT_TRUE(ipc_perm2->Read(&m, &iter)); |
400 EXPECT_TRUE(permission->Equal(ipc_perm2.get())); | 406 EXPECT_TRUE(permission->Equal(ipc_perm2.get())); |
401 } | 407 } |
402 | 408 |
403 } // namespace extensions | 409 } // namespace extensions |
OLD | NEW |