Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: tests/standalone/io/raw_secure_server_socket_test.dart

Issue 13860006: Fix static type errors in a number of tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
11 import "dart:async"; 11 import "dart:async";
12 import "dart:io"; 12 import "dart:io";
13 import "dart:isolate"; 13 import "dart:isolate";
14 14
15 const SERVER_ADDRESS = "127.0.0.1"; 15 const SERVER_ADDRESS = "127.0.0.1";
16 const HOST_NAME = "localhost"; 16 const HOST_NAME = "localhost";
17 const CERTIFICATE = "localhost_cert"; 17 const CERTIFICATE = "localhost_cert";
18 18
19 void testArguments() {
20 Expect.throws(() =>
21 RawSecureServerSocket.bind(SERVER_ADDRESS, 65536, 5, CERTIFICATE));
22 Expect.throws(() =>
23 RawSecureServerSocket.bind(SERVER_ADDRESS, -1, CERTIFICATE));
24 Expect.throws(() =>
25 RawSecureServerSocket.bind(SERVER_ADDRESS, 0, -1, CERTIFICATE));
26 }
27
28 void testSimpleBind() { 19 void testSimpleBind() {
29 ReceivePort port = new ReceivePort(); 20 ReceivePort port = new ReceivePort();
30 RawSecureServerSocket.bind(SERVER_ADDRESS, 0, 5, CERTIFICATE).then((s) { 21 RawSecureServerSocket.bind(SERVER_ADDRESS, 0, 5, CERTIFICATE).then((s) {
31 Expect.isTrue(s.port > 0); 22 Expect.isTrue(s.port > 0);
32 s.close(); 23 s.close();
33 port.close(); 24 port.close();
34 }); 25 });
35 } 26 }
36 27
37 void testInvalidBind() { 28 void testInvalidBind() {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // has been written. When this argument is true the securing of the 152 // has been written. When this argument is true the securing of the
162 // server will not happen until the first TLS handshake data has been 153 // server will not happen until the first TLS handshake data has been
163 // received from the client. This argument only takes effect when 154 // received from the client. This argument only takes effect when
164 // handshakeBeforeSecure is true. 155 // handshakeBeforeSecure is true.
165 void testSimpleReadWrite(bool listenSecure, 156 void testSimpleReadWrite(bool listenSecure,
166 bool connectSecure, 157 bool connectSecure,
167 bool handshakeBeforeSecure, 158 bool handshakeBeforeSecure,
168 [bool postponeSecure = false]) { 159 [bool postponeSecure = false]) {
169 if (handshakeBeforeSecure == true && 160 if (handshakeBeforeSecure == true &&
170 (listenSecure == true || connectSecure == true)) { 161 (listenSecure == true || connectSecure == true)) {
171 Expect.fails("Invalid arguments to testSimpleReadWrite"); 162 Expect.fail("Invalid arguments to testSimpleReadWrite");
172 } 163 }
173 164
174 ReceivePort port = new ReceivePort(); 165 ReceivePort port = new ReceivePort();
175 166
176 const messageSize = 1000; 167 const messageSize = 1000;
177 const handshakeMessageSize = 100; 168 const handshakeMessageSize = 100;
178 169
179 List<int> createTestData() { 170 List<int> createTestData() {
180 List<int> data = new List<int>(messageSize); 171 List<int> data = new List<int>(messageSize);
181 for (int i = 0; i < messageSize; i++) { 172 for (int i = 0; i < messageSize; i++) {
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 RawServerSocket.bind(SERVER_ADDRESS, 0, 5).then(serverReady); 437 RawServerSocket.bind(SERVER_ADDRESS, 0, 5).then(serverReady);
447 } 438 }
448 } 439 }
449 440
450 main() { 441 main() {
451 Path scriptDir = new Path(new Options().script).directoryPath; 442 Path scriptDir = new Path(new Options().script).directoryPath;
452 Path certificateDatabase = scriptDir.append('pkcert'); 443 Path certificateDatabase = scriptDir.append('pkcert');
453 SecureSocket.initialize(database: certificateDatabase.toNativePath(), 444 SecureSocket.initialize(database: certificateDatabase.toNativePath(),
454 password: 'dartdart', 445 password: 'dartdart',
455 useBuiltinRoots: false); 446 useBuiltinRoots: false);
456 testArguments();
457 testSimpleBind(); 447 testSimpleBind();
458 testInvalidBind(); 448 testInvalidBind();
459 testSimpleConnect(CERTIFICATE); 449 testSimpleConnect(CERTIFICATE);
460 testSimpleConnect("CN=localhost"); 450 testSimpleConnect("CN=localhost");
461 testSimpleConnectFail("not_a_nickname"); 451 testSimpleConnectFail("not_a_nickname");
462 testSimpleConnectFail("CN=notARealDistinguishedName"); 452 testSimpleConnectFail("CN=notARealDistinguishedName");
463 testServerListenAfterConnect(); 453 testServerListenAfterConnect();
464 testSimpleReadWrite(true, true, false); 454 testSimpleReadWrite(true, true, false);
465 testSimpleReadWrite(true, false, false); 455 testSimpleReadWrite(true, false, false);
466 testSimpleReadWrite(false, true, false); 456 testSimpleReadWrite(false, true, false);
467 testSimpleReadWrite(false, false, false); 457 testSimpleReadWrite(false, false, false);
468 testSimpleReadWrite(false, false, true, true); 458 testSimpleReadWrite(false, false, true, true);
469 testSimpleReadWrite(false, false, true, false); 459 testSimpleReadWrite(false, false, true, false);
470 } 460 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698