| 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 library dart.io; | 10 library dart.io; | 
| 11 | 11 | 
| 12 import "dart:async"; | 12 import "dart:async"; | 
| 13 import "dart:io"; | 13 import "dart:io"; | 
| 14 import "dart:math"; | 14 import "dart:math"; | 
| 15 import "dart:typed_data"; | 15 import "dart:typed_data"; | 
| 16 | 16 | 
| 17 import "package:async_helper/async_helper.dart"; | 17 import "package:async_helper/async_helper.dart"; | 
| 18 import "package:expect/expect.dart"; | 18 import "package:expect/expect.dart"; | 
| 19 import "package:path/path.dart"; | 19 import "package:path/path.dart"; | 
| 20 | 20 | 
| 21 part "../../../sdk/lib/io/crypto.dart"; | 21 part "../../../sdk/lib/io/crypto.dart"; | 
| 22 | 22 | 
| 23 | 23 | 
| 24 const String webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; | 24 const String webSocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; | 
| 25 const String CERT_NAME = 'localhost_cert'; | 25 const String CERT_NAME = 'localhost_cert'; | 
| 26 const String HOST_NAME = 'localhost'; | 26 const String HOST_NAME = 'localhost'; | 
| 27 | 27 | 
| 28 String localFile(path) => Platform.script.resolve(path).toFilePath(); | 28 String localFile(path) => Platform.script.resolve(path).toFilePath(); | 
|  | 29 List<int> readLocalFile(path) => (new File(localFile(path))).readAsBytesSync(); | 
| 29 | 30 | 
| 30 SecurityContext serverContext = new SecurityContext() | 31 SecurityContext serverContext = new SecurityContext() | 
| 31   ..useCertificateChain(localFile('certificates/server_chain.pem')) | 32   ..useCertificateChain(localFile('certificates/server_chain.pem')) | 
| 32   ..usePrivateKey(localFile('certificates/server_key.pem'), | 33   ..usePrivateKeyAsBytes(readLocalFile('certificates/server_key.pem'), | 
| 33                   password: 'dartdart'); | 34                          password: 'dartdart'); | 
| 34 | 35 | 
| 35 SecurityContext clientContext = new SecurityContext() | 36 SecurityContext clientContext = new SecurityContext() | 
| 36   ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); | 37   ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); | 
| 37 | 38 | 
| 38 /** | 39 /** | 
| 39  * A SecurityConfiguration lets us run the tests over HTTP or HTTPS. | 40  * A SecurityConfiguration lets us run the tests over HTTP or HTTPS. | 
| 40  */ | 41  */ | 
| 41 class SecurityConfiguration { | 42 class SecurityConfiguration { | 
| 42   final bool secure; | 43   final bool secure; | 
| 43 | 44 | 
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 101 | 102 | 
| 102 | 103 | 
| 103 main() { | 104 main() { | 
| 104   asyncStart(); | 105   asyncStart(); | 
| 105   new SecurityConfiguration(secure: false).runTests(); | 106   new SecurityConfiguration(secure: false).runTests(); | 
| 106   // TODO(whesse): WebSocket.connect needs an optional context: parameter | 107   // TODO(whesse): WebSocket.connect needs an optional context: parameter | 
| 107   // new SecurityConfiguration(secure: true).runTests(); | 108   // new SecurityConfiguration(secure: true).runTests(); | 
| 108   asyncEnd(); | 109   asyncEnd(); | 
| 109 } | 110 } | 
| 110 | 111 | 
| OLD | NEW | 
|---|