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