| 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 | 9 |
| 10 import "package:expect/expect.dart"; | 10 import "package:expect/expect.dart"; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 Future<SecureSocket> connectClient(int port) { | 153 Future<SecureSocket> connectClient(int port) { |
| 154 if (!handshakeBeforeSecure) { | 154 if (!handshakeBeforeSecure) { |
| 155 return Socket.connect(HOST_NAME, port).then((socket) { | 155 return Socket.connect(HOST_NAME, port).then((socket) { |
| 156 var future; | 156 var future; |
| 157 if (hostnameInConnect) { | 157 if (hostnameInConnect) { |
| 158 future = SecureSocket.secure(socket); | 158 future = SecureSocket.secure(socket); |
| 159 } else { | 159 } else { |
| 160 future = SecureSocket.secure(socket, host: HOST_NAME); | 160 future = SecureSocket.secure(socket, host: HOST_NAME); |
| 161 } | 161 } |
| 162 return future.then((secureSocket) { | 162 return future.then((secureSocket) { |
| 163 Expect.throws(() => socket.add([0])); | 163 socket.add([0]); |
| 164 return secureSocket; | 164 return secureSocket; |
| 165 }); | 165 }); |
| 166 }); | 166 }); |
| 167 } else { | 167 } else { |
| 168 return Socket.connect(HOST_NAME, port).then((socket) { | 168 return Socket.connect(HOST_NAME, port).then((socket) { |
| 169 return runClientHandshake(socket).then((_) { | 169 return runClientHandshake(socket).then((_) { |
| 170 var future; | 170 var future; |
| 171 if (hostnameInConnect) { | 171 if (hostnameInConnect) { |
| 172 future = SecureSocket.secure(socket); | 172 future = SecureSocket.secure(socket); |
| 173 } else { | 173 } else { |
| 174 future = SecureSocket.secure(socket, host: HOST_NAME); | 174 future = SecureSocket.secure(socket, host: HOST_NAME); |
| 175 } | 175 } |
| 176 return future.then((secureSocket) { | 176 return future.then((secureSocket) { |
| 177 Expect.throws(() => socket.add([0])); | 177 socket.add([0]); |
| 178 return secureSocket; | 178 return secureSocket; |
| 179 }); | 179 }); |
| 180 }); | 180 }); |
| 181 }); | 181 }); |
| 182 } | 182 } |
| 183 } | 183 } |
| 184 | 184 |
| 185 serverReady(server) { | 185 serverReady(server) { |
| 186 server.listen((client) { | 186 server.listen((client) { |
| 187 if (!handshakeBeforeSecure) { | 187 if (!handshakeBeforeSecure) { |
| 188 SecureSocket.secureServer(client, CERTIFICATE).then((secureClient) { | 188 SecureSocket.secureServer(client, CERTIFICATE).then((secureClient) { |
| 189 Expect.throws(() => client.add([0])); | 189 client.add([0]); |
| 190 runServer(secureClient).then((_) => server.close()); | 190 runServer(secureClient).then((_) => server.close()); |
| 191 }); | 191 }); |
| 192 } else { | 192 } else { |
| 193 runServerHandshake(client).then((carryOverData) { | 193 runServerHandshake(client).then((carryOverData) { |
| 194 SecureSocket.secureServer( | 194 SecureSocket.secureServer( |
| 195 client, | 195 client, |
| 196 CERTIFICATE, | 196 CERTIFICATE, |
| 197 bufferedData: carryOverData).then((secureClient) { | 197 bufferedData: carryOverData).then((secureClient) { |
| 198 Expect.throws(() => client.add([0])); | 198 client.add([0]); |
| 199 runServer(secureClient).then((_) => server.close()); | 199 runServer(secureClient).then((_) => server.close()); |
| 200 }); | 200 }); |
| 201 }); | 201 }); |
| 202 } | 202 } |
| 203 }); | 203 }); |
| 204 | 204 |
| 205 connectClient(server.port).then(runClient).then((socket) { | 205 connectClient(server.port).then(runClient).then((socket) { |
| 206 port.close(); | 206 port.close(); |
| 207 }); | 207 }); |
| 208 } | 208 } |
| 209 | 209 |
| 210 ServerSocket.bind(HOST_NAME, 0).then(serverReady); | 210 ServerSocket.bind(HOST_NAME, 0).then(serverReady); |
| 211 } | 211 } |
| 212 | 212 |
| 213 main() { | 213 main() { |
| 214 Path scriptDir = new Path(Platform.script).directoryPath; | 214 Path scriptDir = new Path(Platform.script).directoryPath; |
| 215 Path certificateDatabase = scriptDir.append('pkcert'); | 215 Path certificateDatabase = scriptDir.append('pkcert'); |
| 216 SecureSocket.initialize(database: certificateDatabase.toNativePath(), | 216 SecureSocket.initialize(database: certificateDatabase.toNativePath(), |
| 217 password: 'dartdart', | 217 password: 'dartdart', |
| 218 useBuiltinRoots: false); | 218 useBuiltinRoots: false); |
| 219 test(false, false); | 219 test(false, false); |
| 220 test(true, false); | 220 test(true, false); |
| 221 test(false, true); | 221 test(false, true); |
| 222 test(true, true); | 222 test(true, true); |
| 223 test(false, true, true); | 223 test(false, true, true); |
| 224 test(true, true, true); | 224 test(true, true, true); |
| 225 } | 225 } |
| OLD | NEW |