| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 } | 76 } |
| 77 | 77 |
| 78 void testSimpleConnectFail(String certificate, bool cancelOnError) { | 78 void testSimpleConnectFail(String certificate, bool cancelOnError) { |
| 79 ReceivePort port = new ReceivePort(); | 79 ReceivePort port = new ReceivePort(); |
| 80 SecureServerSocket.bind(HOST_NAME, 0, certificate).then((server) { | 80 SecureServerSocket.bind(HOST_NAME, 0, certificate).then((server) { |
| 81 var clientEndFuture = SecureSocket.connect(HOST_NAME, server.port) | 81 var clientEndFuture = SecureSocket.connect(HOST_NAME, server.port) |
| 82 .then((clientEnd) { | 82 .then((clientEnd) { |
| 83 Expect.fail("No client connection expected."); | 83 Expect.fail("No client connection expected."); |
| 84 }) | 84 }) |
| 85 .catchError((error) { | 85 .catchError((error) { |
| 86 Expect.isTrue(error is SocketException); | 86 Expect.isTrue(error is HandshakeException); |
| 87 }); | 87 }); |
| 88 server.listen((serverEnd) { | 88 server.listen((serverEnd) { |
| 89 Expect.fail("No server connection expected."); | 89 Expect.fail("No server connection expected."); |
| 90 }, | 90 }, |
| 91 onError: (error) { | 91 onError: (error) { |
| 92 Expect.isTrue(error is SocketException); | 92 Expect.isTrue(error is CertificateException); |
| 93 clientEndFuture.then((_) { | 93 clientEndFuture.then((_) { |
| 94 if (!cancelOnError) server.close(); | 94 if (!cancelOnError) server.close(); |
| 95 port.close(); | 95 port.close(); |
| 96 }); | 96 }); |
| 97 }, | 97 }, |
| 98 cancelOnError: cancelOnError); | 98 cancelOnError: cancelOnError); |
| 99 }); | 99 }); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void testServerListenAfterConnect() { | 102 void testServerListenAfterConnect() { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 testInvalidBind(); | 195 testInvalidBind(); |
| 196 testSimpleConnect(CERTIFICATE); | 196 testSimpleConnect(CERTIFICATE); |
| 197 testSimpleConnect("CN=localhost"); | 197 testSimpleConnect("CN=localhost"); |
| 198 testSimpleConnectFail("not_a_nickname", false); | 198 testSimpleConnectFail("not_a_nickname", false); |
| 199 testSimpleConnectFail("CN=notARealDistinguishedName", false); | 199 testSimpleConnectFail("CN=notARealDistinguishedName", false); |
| 200 testSimpleConnectFail("not_a_nickname", true); | 200 testSimpleConnectFail("not_a_nickname", true); |
| 201 testSimpleConnectFail("CN=notARealDistinguishedName", true); | 201 testSimpleConnectFail("CN=notARealDistinguishedName", true); |
| 202 testServerListenAfterConnect(); | 202 testServerListenAfterConnect(); |
| 203 testSimpleReadWrite(); | 203 testSimpleReadWrite(); |
| 204 } | 204 } |
| OLD | NEW |