| Index: tests/standalone/io/secure_socket_bad_certificate_test.dart
|
| diff --git a/tests/standalone/io/secure_socket_bad_certificate_test.dart b/tests/standalone/io/secure_socket_bad_certificate_test.dart
|
| deleted file mode 100644
|
| index 5edba315f38835fe8cd3dd680b8c7c6d87a675cf..0000000000000000000000000000000000000000
|
| --- a/tests/standalone/io/secure_socket_bad_certificate_test.dart
|
| +++ /dev/null
|
| @@ -1,61 +0,0 @@
|
| -// 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.
|
| -//
|
| -// VMOptions=
|
| -// VMOptions=--short_socket_read
|
| -// VMOptions=--short_socket_write
|
| -// VMOptions=--short_socket_write --short_socket_read
|
| -// The --short_socket_write option does not work with external server
|
| -// www.google.dk. Add this to the test when we have secure server sockets.
|
| -// See TODO below.
|
| -
|
| -import "package:expect/expect.dart";
|
| -import "dart:async";
|
| -import "dart:isolate";
|
| -import "dart:io";
|
| -
|
| -void main() {
|
| - ReceivePort keepAlive = new ReceivePort();
|
| - SecureSocket.initialize(useBuiltinRoots: false);
|
| - testCertificateCallback(host: "www.google.com",
|
| - acceptCertificate: false)
|
| - .then((_) =>
|
| - testCertificateCallback(host: "www.google.com",
|
| - acceptCertificate: true))
|
| - .then((_) =>
|
| - keepAlive.close());
|
| -}
|
| -
|
| -Future testCertificateCallback({String host, bool acceptCertificate}) {
|
| - var x = 7;
|
| - Expect.throws(() => SecureSocket.connect(host, 443, onBadCertificate: x),
|
| - (e) => e is ArgumentError || e is TypeError);
|
| -
|
| - bool badCertificateCallback(X509Certificate certificate) {
|
| - Expect.isTrue(certificate.subject.contains("O=Google Inc"));
|
| - Expect.isTrue(certificate.startValidity.isBefore(new DateTime.now()));
|
| - Expect.isTrue(certificate.endValidity.isAfter(new DateTime.now()));
|
| - return acceptCertificate;
|
| - };
|
| -
|
| - return SecureSocket.connect(host,
|
| - 443,
|
| - onBadCertificate: badCertificateCallback)
|
| - .then((socket) {
|
| - Expect.isTrue(acceptCertificate);
|
| - socket.write("GET / HTTP/1.0\r\nHost: $host\r\n\r\n");
|
| - socket.close();
|
| - return socket.fold(<int>[], (message, data) => message..addAll(data))
|
| - .then((message) {
|
| - String received = new String.fromCharCodes(message);
|
| - Expect.isTrue(received.startsWith('HTTP/1.0 '));
|
| - });
|
| - }).catchError((e) {
|
| - if (e is HandshakeException) {
|
| - Expect.isFalse(acceptCertificate);
|
| - } else {
|
| - Expect.isTrue(e is SocketException);
|
| - }
|
| - });
|
| -}
|
|
|