OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // | 4 // |
5 // VMOptions= | 5 // VMOptions= |
6 // VMOptions=--short_socket_read | 6 // VMOptions=--short_socket_read |
7 // VMOptions=--short_socket_write | 7 // VMOptions=--short_socket_write |
8 // VMOptions=--short_socket_read --short_socket_write | 8 // VMOptions=--short_socket_read --short_socket_write |
9 // OtherResources=certificates/server_chain.pem | 9 // OtherResources=certificates/server_chain.pem |
10 // OtherResources=certificates/server_key.pem | 10 // OtherResources=certificates/server_key.pem |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 if (!handshakeBeforeSecure) { | 157 if (!handshakeBeforeSecure) { |
158 return Socket.connect(HOST, port).then((socket) { | 158 return Socket.connect(HOST, port).then((socket) { |
159 var future; | 159 var future; |
160 if (hostnameInConnect) { | 160 if (hostnameInConnect) { |
161 future = SecureSocket.secure(socket, context: clientContext); | 161 future = SecureSocket.secure(socket, context: clientContext); |
162 } else { | 162 } else { |
163 future = | 163 future = |
164 SecureSocket.secure(socket, host: HOST, context: clientContext); | 164 SecureSocket.secure(socket, host: HOST, context: clientContext); |
165 } | 165 } |
166 return future.then((secureSocket) { | 166 return future.then((secureSocket) { |
167 Expect.throws(() { | 167 socket.add([0]); |
168 socket.add([0]); | |
169 }); | |
170 return secureSocket; | 168 return secureSocket; |
171 }); | 169 }); |
172 }); | 170 }); |
173 } else { | 171 } else { |
174 return Socket.connect(HOST, port).then((socket) { | 172 return Socket.connect(HOST, port).then((socket) { |
175 return runClientHandshake(socket).then((_) { | 173 return runClientHandshake(socket).then((_) { |
176 var future; | 174 var future; |
177 if (hostnameInConnect) { | 175 if (hostnameInConnect) { |
178 future = SecureSocket.secure(socket, context: clientContext); | 176 future = SecureSocket.secure(socket, context: clientContext); |
179 } else { | 177 } else { |
180 future = | 178 future = |
181 SecureSocket.secure(socket, host: HOST, context: clientContext); | 179 SecureSocket.secure(socket, host: HOST, context: clientContext); |
182 } | 180 } |
183 return future.then((secureSocket) { | 181 return future.then((secureSocket) { |
184 Expect.throws(() { | 182 socket.add([0]); |
185 socket.add([0]); | |
186 }); | |
187 return secureSocket; | 183 return secureSocket; |
188 }); | 184 }); |
189 }); | 185 }); |
190 }); | 186 }); |
191 } | 187 } |
192 } | 188 } |
193 | 189 |
194 serverReady(server) { | 190 serverReady(server) { |
195 server.listen((client) { | 191 server.listen((client) { |
196 if (!handshakeBeforeSecure) { | 192 if (!handshakeBeforeSecure) { |
197 SecureSocket.secureServer(client, serverContext).then((secureClient) { | 193 SecureSocket.secureServer(client, serverContext).then((secureClient) { |
198 Expect.throws(() { | 194 client.add([0]); |
199 client.add([0]); | |
200 }); | |
201 runServer(secureClient).then((_) => server.close()); | 195 runServer(secureClient).then((_) => server.close()); |
202 }); | 196 }); |
203 } else { | 197 } else { |
204 runServerHandshake(client).then((carryOverData) { | 198 runServerHandshake(client).then((carryOverData) { |
205 SecureSocket | 199 SecureSocket |
206 .secureServer(client, serverContext, bufferedData: carryOverData) | 200 .secureServer(client, serverContext, bufferedData: carryOverData) |
207 .then((secureClient) { | 201 .then((secureClient) { |
208 Expect.throws(() { | 202 client.add([0]); |
209 client.add([0]); | |
210 }); | |
211 runServer(secureClient).then((_) => server.close()); | 203 runServer(secureClient).then((_) => server.close()); |
212 }); | 204 }); |
213 }); | 205 }); |
214 } | 206 } |
215 }); | 207 }); |
216 | 208 |
217 connectClient(server.port).then(runClient).then((socket) { | 209 connectClient(server.port).then(runClient).then((socket) { |
218 asyncEnd(); | 210 asyncEnd(); |
219 }); | 211 }); |
220 } | 212 } |
221 | 213 |
222 ServerSocket.bind(HOST, 0).then(serverReady); | 214 ServerSocket.bind(HOST, 0).then(serverReady); |
223 } | 215 } |
224 | 216 |
225 main() { | 217 main() { |
226 asyncStart(); | 218 asyncStart(); |
227 InternetAddress.lookup("localhost").then((hosts) { | 219 InternetAddress.lookup("localhost").then((hosts) { |
228 HOST = hosts.first; | 220 HOST = hosts.first; |
229 test(false, false); | 221 test(false, false); |
230 // TODO(whesse): Enable the test with all argument combinations: | 222 // TODO(whesse): Enable the test with all argument combinations: |
231 // test(true, false); | 223 // test(true, false); |
232 // test(false, true); | 224 // test(false, true); |
233 // test(true, true); | 225 // test(true, true); |
234 // test(false, true, true); | 226 // test(false, true, true); |
235 // test(true, true, true); | 227 // test(true, true, true); |
236 asyncEnd(); | 228 asyncEnd(); |
237 }); | 229 }); |
238 } | 230 } |
OLD | NEW |