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 socket.add([0]); | 167 Expect.throws(() { |
| 168 socket.add([0]); |
| 169 }); |
168 return secureSocket; | 170 return secureSocket; |
169 }); | 171 }); |
170 }); | 172 }); |
171 } else { | 173 } else { |
172 return Socket.connect(HOST, port).then((socket) { | 174 return Socket.connect(HOST, port).then((socket) { |
173 return runClientHandshake(socket).then((_) { | 175 return runClientHandshake(socket).then((_) { |
174 var future; | 176 var future; |
175 if (hostnameInConnect) { | 177 if (hostnameInConnect) { |
176 future = SecureSocket.secure(socket, context: clientContext); | 178 future = SecureSocket.secure(socket, context: clientContext); |
177 } else { | 179 } else { |
178 future = | 180 future = |
179 SecureSocket.secure(socket, host: HOST, context: clientContext); | 181 SecureSocket.secure(socket, host: HOST, context: clientContext); |
180 } | 182 } |
181 return future.then((secureSocket) { | 183 return future.then((secureSocket) { |
182 socket.add([0]); | 184 Expect.throws(() { |
| 185 socket.add([0]); |
| 186 }); |
183 return secureSocket; | 187 return secureSocket; |
184 }); | 188 }); |
185 }); | 189 }); |
186 }); | 190 }); |
187 } | 191 } |
188 } | 192 } |
189 | 193 |
190 serverReady(server) { | 194 serverReady(server) { |
191 server.listen((client) { | 195 server.listen((client) { |
192 if (!handshakeBeforeSecure) { | 196 if (!handshakeBeforeSecure) { |
193 SecureSocket.secureServer(client, serverContext).then((secureClient) { | 197 SecureSocket.secureServer(client, serverContext).then((secureClient) { |
194 client.add([0]); | 198 Expect.throws(() { |
| 199 client.add([0]); |
| 200 }); |
195 runServer(secureClient).then((_) => server.close()); | 201 runServer(secureClient).then((_) => server.close()); |
196 }); | 202 }); |
197 } else { | 203 } else { |
198 runServerHandshake(client).then((carryOverData) { | 204 runServerHandshake(client).then((carryOverData) { |
199 SecureSocket | 205 SecureSocket |
200 .secureServer(client, serverContext, bufferedData: carryOverData) | 206 .secureServer(client, serverContext, bufferedData: carryOverData) |
201 .then((secureClient) { | 207 .then((secureClient) { |
202 client.add([0]); | 208 Expect.throws(() { |
| 209 client.add([0]); |
| 210 }); |
203 runServer(secureClient).then((_) => server.close()); | 211 runServer(secureClient).then((_) => server.close()); |
204 }); | 212 }); |
205 }); | 213 }); |
206 } | 214 } |
207 }); | 215 }); |
208 | 216 |
209 connectClient(server.port).then(runClient).then((socket) { | 217 connectClient(server.port).then(runClient).then((socket) { |
210 asyncEnd(); | 218 asyncEnd(); |
211 }); | 219 }); |
212 } | 220 } |
213 | 221 |
214 ServerSocket.bind(HOST, 0).then(serverReady); | 222 ServerSocket.bind(HOST, 0).then(serverReady); |
215 } | 223 } |
216 | 224 |
217 main() { | 225 main() { |
218 asyncStart(); | 226 asyncStart(); |
219 InternetAddress.lookup("localhost").then((hosts) { | 227 InternetAddress.lookup("localhost").then((hosts) { |
220 HOST = hosts.first; | 228 HOST = hosts.first; |
221 test(false, false); | 229 test(false, false); |
222 // TODO(whesse): Enable the test with all argument combinations: | 230 // TODO(whesse): Enable the test with all argument combinations: |
223 // test(true, false); | 231 // test(true, false); |
224 // test(false, true); | 232 // test(false, true); |
225 // test(true, true); | 233 // test(true, true); |
226 // test(false, true, true); | 234 // test(false, true, true); |
227 // test(true, true, true); | 235 // test(true, true, true); |
228 asyncEnd(); | 236 asyncEnd(); |
229 }); | 237 }); |
230 } | 238 } |
OLD | NEW |