| Index: tests/standalone/io/secure_bad_certificate_test.dart
|
| diff --git a/tests/standalone/io/secure_bad_certificate_test.dart b/tests/standalone/io/secure_bad_certificate_test.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ccdbf324b9d589dd6b1792bd8c28077e2550179e
|
| --- /dev/null
|
| +++ b/tests/standalone/io/secure_bad_certificate_test.dart
|
| @@ -0,0 +1,63 @@
|
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
| +// for details. All rights reserved. Use of this source code is governed by a
|
| +// BSD-style license that can be found in the LICENSE file.
|
| +
|
| +// This test verifies that the bad certificate callback works.
|
| +
|
| +import "package:expect/expect.dart";
|
| +import "package:path/path.dart";
|
| +import "dart:async";
|
| +import "dart:io";
|
| +
|
| +const HOST_NAME = "localhost";
|
| +const CERTIFICATE = "localhost_cert";
|
| +
|
| +
|
| +String certificateDatabase() =>
|
| + join(dirname(new Options().script), 'pkcert');
|
| +
|
| +Future<SecureServerSocket> runServer() {
|
| + SecureSocket.initialize(database: certificateDatabase(),
|
| + password: 'dartdart');
|
| +
|
| + return SecureServerSocket.bind(HOST_NAME, 0, CERTIFICATE)
|
| + .then((SecureServerSocket server) {
|
| + server.listen((SecureSocket socket) {
|
| + socket.listen((_) { },
|
| + onDone: () {
|
| + socket.close();
|
| + });
|
| + }, onError: (e) => Expect.isTrue(e is HandshakeException));
|
| + return server;
|
| + });
|
| +}
|
| +
|
| +
|
| +void main() {
|
| + final options = new Options();
|
| + var clientScript = join(dirname(options.script),
|
| + 'secure_bad_certificate_client.dart');
|
| +
|
| + Future clientProcess(int port, String acceptCertificate) {
|
| + return Process.run(options.executable,
|
| + [clientScript, port.toString(), acceptCertificate])
|
| + .then((ProcessResult result) {
|
| + if (result.exitCode != 0) {
|
| + print("Client failed, stdout:");
|
| + print(result.stdout);
|
| + print(" stderr:");
|
| + print(result.stderr);
|
| + Expect.fail('Client subprocess exit code: ${result.exitCode}');
|
| + }
|
| + });
|
| + }
|
| +
|
| + runServer().then((server) {
|
| + Future.wait([clientProcess(server.port, 'true'),
|
| + clientProcess(server.port, 'false'),
|
| + clientProcess(server.port, 'fisk'),
|
| + clientProcess(server.port, 'exception')]).then((_) {
|
| + server.close();
|
| + });
|
| + });
|
| +}
|
|
|