| 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 "dart:async"; | 10 import "dart:async"; | 
| 11 import "dart:io"; | 11 import "dart:io"; | 
| 12 | 12 | 
| 13 import "package:async_helper/async_helper.dart"; | 13 import "package:async_helper/async_helper.dart"; | 
| 14 import "package:expect/expect.dart"; | 14 import "package:expect/expect.dart"; | 
| 15 | 15 | 
| 16 InternetAddress HOST; | 16 InternetAddress HOST; | 
| 17 String localFile(path) => Platform.script.resolve(path).toFilePath(); | 17 String localFile(path) => Platform.script.resolve(path).toFilePath(); | 
|  | 18 List<int> readLocalFile(path) => (new File(localFile(path))).readAsBytesSync(); | 
| 18 | 19 | 
| 19 SecurityContext serverContext = new SecurityContext() | 20 SecurityContext serverContext = new SecurityContext() | 
| 20   ..useCertificateChain(localFile('certificates/server_chain.pem')) | 21   ..useCertificateChain(localFile('certificates/server_chain.pem')) | 
| 21   ..usePrivateKey(localFile('certificates/server_key.pem'), | 22   ..usePrivateKeyAsBytes(readLocalFile('certificates/server_key.pem'), | 
| 22                   password: 'dartdart'); | 23                        password: 'dartdart'); | 
| 23 | 24 | 
| 24 SecurityContext clientContext = new SecurityContext() | 25 SecurityContext clientContext = new SecurityContext() | 
| 25   ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); | 26   ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); | 
| 26 | 27 | 
| 27 void testSimpleBind() { | 28 void testSimpleBind() { | 
| 28   asyncStart(); | 29   asyncStart(); | 
| 29   RawSecureServerSocket.bind(HOST, 0, serverContext).then((s) { | 30   RawSecureServerSocket.bind(HOST, 0, serverContext).then((s) { | 
| 30     Expect.isTrue(s.port > 0); | 31     Expect.isTrue(s.port > 0); | 
| 31     s.close(); | 32     s.close(); | 
| 32     asyncEnd(); | 33     asyncEnd(); | 
| (...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 570   testSimpleConnect(); | 571   testSimpleConnect(); | 
| 571   SecurityContext context = new SecurityContext(); | 572   SecurityContext context = new SecurityContext(); | 
| 572   testSimpleConnectFail(context, false); | 573   testSimpleConnectFail(context, false); | 
| 573   testSimpleConnectFail(context, true); | 574   testSimpleConnectFail(context, true); | 
| 574   var chain = | 575   var chain = | 
| 575       Platform.script.resolve('certificates/untrusted_server_chain.pem') | 576       Platform.script.resolve('certificates/untrusted_server_chain.pem') | 
| 576       .toFilePath(); | 577       .toFilePath(); | 
| 577   context.useCertificateChain(chain); | 578   context.useCertificateChain(chain); | 
| 578   testSimpleConnectFail(context, false); | 579   testSimpleConnectFail(context, false); | 
| 579   testSimpleConnectFail(context, true); | 580   testSimpleConnectFail(context, true); | 
| 580   var key = | 581   var key = 'certificates/untrusted_server_key.pem'; | 
| 581       Platform.script.resolve('certificates/untrusted_server_key.pem') | 582   context.usePrivateKeyAsBytes(readLocalFile(key), password: 'dartdart'); | 
| 582        .toFilePath(); |  | 
| 583   context.usePrivateKey(key, password: 'dartdart'); |  | 
| 584   testSimpleConnectFail(context, false); | 583   testSimpleConnectFail(context, false); | 
| 585   testSimpleConnectFail(context, true); | 584   testSimpleConnectFail(context, true); | 
| 586   testServerListenAfterConnect(); | 585   testServerListenAfterConnect(); | 
| 587 | 586 | 
| 588   testSimpleReadWrite(listenSecure: true, | 587   testSimpleReadWrite(listenSecure: true, | 
| 589                       connectSecure: true, | 588                       connectSecure: true, | 
| 590                       handshakeBeforeSecure: false, | 589                       handshakeBeforeSecure: false, | 
| 591                       postponeSecure: false, | 590                       postponeSecure: false, | 
| 592                       dropReads: false); | 591                       dropReads: false); | 
| 593   testSimpleReadWrite(listenSecure: true, | 592   testSimpleReadWrite(listenSecure: true, | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 625   testSimpleReadWrite(listenSecure: false, | 624   testSimpleReadWrite(listenSecure: false, | 
| 626                       connectSecure: false, | 625                       connectSecure: false, | 
| 627                       handshakeBeforeSecure: true, | 626                       handshakeBeforeSecure: true, | 
| 628                       postponeSecure: true, | 627                       postponeSecure: true, | 
| 629                       dropReads: true); | 628                       dropReads: true); | 
| 630   testPausedSecuringSubscription(false, false); | 629   testPausedSecuringSubscription(false, false); | 
| 631   testPausedSecuringSubscription(true, false); | 630   testPausedSecuringSubscription(true, false); | 
| 632   testPausedSecuringSubscription(false, true); | 631   testPausedSecuringSubscription(false, true); | 
| 633   testPausedSecuringSubscription(true, true); | 632   testPausedSecuringSubscription(true, true); | 
| 634 } | 633 } | 
| OLD | NEW | 
|---|