| 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:convert"; | 11 import "dart:convert"; |
| 12 import "dart:io"; | 12 import "dart:io"; |
| 13 import "dart:typed_data"; | 13 import "dart:typed_data"; |
| 14 | 14 |
| 15 import "package:async_helper/async_helper.dart"; | 15 import "package:async_helper/async_helper.dart"; |
| 16 import "package:crypto/crypto.dart"; | 16 import "package:crypto/crypto.dart"; |
| 17 import "package:expect/expect.dart"; | 17 import "package:expect/expect.dart"; |
| 18 import "package:path/path.dart"; | 18 import "package:path/path.dart"; |
| 19 | 19 |
| 20 const WEB_SOCKET_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; | 20 const WEB_SOCKET_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; |
| 21 | 21 |
| 22 const String HOST_NAME = 'localhost'; | 22 const String HOST_NAME = 'localhost'; |
| 23 | 23 |
| 24 String localFile(path) => Platform.script.resolve(path).toFilePath(); | 24 String localFile(path) => Platform.script.resolve(path).toFilePath(); |
| 25 List<int> readLocalFile(path) => (new File(localFile(path))).readAsBytesSync(); |
| 25 | 26 |
| 26 SecurityContext serverContext = new SecurityContext() | 27 SecurityContext serverContext = new SecurityContext() |
| 27 ..useCertificateChain(localFile('certificates/server_chain.pem')) | 28 ..useCertificateChain(localFile('certificates/server_chain.pem')) |
| 28 ..usePrivateKey(localFile('certificates/server_key.pem'), | 29 ..usePrivateKeyAsBytes(readLocalFile('certificates/server_key.pem'), |
| 29 password: 'dartdart'); | 30 password: 'dartdart'); |
| 30 | 31 |
| 31 SecurityContext clientContext = new SecurityContext() | 32 SecurityContext clientContext = new SecurityContext() |
| 32 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); | 33 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem')); |
| 33 | 34 |
| 34 /** | 35 /** |
| 35 * A SecurityConfiguration lets us run the tests over HTTP or HTTPS. | 36 * A SecurityConfiguration lets us run the tests over HTTP or HTTPS. |
| 36 */ | 37 */ |
| 37 class SecurityConfiguration { | 38 class SecurityConfiguration { |
| 38 final bool secure; | 39 final bool secure; |
| 39 | 40 |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 testBasicAuthentication(); | 590 testBasicAuthentication(); |
| 590 } | 591 } |
| 591 } | 592 } |
| 592 | 593 |
| 593 | 594 |
| 594 main() { | 595 main() { |
| 595 new SecurityConfiguration(secure: false).runTests(); | 596 new SecurityConfiguration(secure: false).runTests(); |
| 596 // TODO(whesse): Make WebSocket.connect() take an optional context: parameter. | 597 // TODO(whesse): Make WebSocket.connect() take an optional context: parameter. |
| 597 // new SecurityConfiguration(secure: true).runTests(); | 598 // new SecurityConfiguration(secure: true).runTests(); |
| 598 } | 599 } |
| OLD | NEW |