| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // |
| 5 // VMOptions= |
| 6 // VMOptions=--short_socket_read |
| 7 // VMOptions=--short_socket_write |
| 8 // VMOptions=--short_socket_read --short_socket_write |
| 9 |
| 10 // This test repeats a subtest from raw_secure_server_socket_test 100 times. |
| 11 // This may help to reproduce a reported crash in issue dartbug.com/8798. |
| 12 // This test should be removed within a week (2013/3/8), if it always succeeds. |
| 13 |
| 14 import "dart:async"; |
| 15 import "dart:io"; |
| 16 import "dart:isolate"; |
| 17 |
| 18 const SERVER_ADDRESS = "127.0.0.1"; |
| 19 const HOST_NAME = "localhost"; |
| 20 const CERTIFICATE = "localhost_cert"; |
| 21 |
| 22 void testSimpleConnectFail(String certificate) { |
| 23 ReceivePort port = new ReceivePort(); |
| 24 RawSecureServerSocket.bind(SERVER_ADDRESS, 0, 5, certificate).then((server) { |
| 25 var clientEndFuture = RawSecureSocket.connect(HOST_NAME, server.port) |
| 26 .then((clientEnd) { |
| 27 Expect.fail("No client connection expected."); |
| 28 }) |
| 29 .catchError((e) { |
| 30 Expect.isTrue(e is AsyncError); |
| 31 Expect.isTrue(e.error is SocketIOException); |
| 32 }); |
| 33 server.listen((serverEnd) { |
| 34 Expect.fail("No server connection expected."); |
| 35 }, |
| 36 onError: (e) { |
| 37 Expect.isTrue(e is AsyncError); |
| 38 Expect.isTrue(e.error is SocketIOException); |
| 39 clientEndFuture.then((_) => port.close()); |
| 40 }); |
| 41 }); |
| 42 } |
| 43 |
| 44 main() { |
| 45 Path scriptDir = new Path(new Options().script).directoryPath; |
| 46 Path certificateDatabase = scriptDir.append('pkcert'); |
| 47 SecureSocket.initialize(database: certificateDatabase.toNativePath(), |
| 48 password: 'dartdart', |
| 49 useBuiltinRoots: false); |
| 50 for (int i = 0; i < 100; ++i) { |
| 51 testSimpleConnectFail("not_a_nickname"); |
| 52 testSimpleConnectFail("CN=notARealDistinguishedName"); |
| 53 } |
| 54 } |
| OLD | NEW |