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

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

Issue 46063010: Change dart:io Platform.script to return a Uri. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 7 years, 1 month 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 import "dart:io"; 5 import "dart:io";
6 import "dart:async"; 6 import "dart:async";
7 7
8 import "package:async_helper/async_helper.dart"; 8 import "package:async_helper/async_helper.dart";
9 import "package:expect/expect.dart"; 9 import "package:expect/expect.dart";
10 import "package:path/path.dart"; 10 import "package:path/path.dart";
11 11
12 void main(List<String> args) { 12 void main(List<String> args) {
13 if (!args.contains('--child')) { 13 if (!args.contains('--child')) {
14 runAllTestsInChildProcesses(); 14 runAllTestsInChildProcesses();
15 } else { 15 } else {
16 InitializeSSL(useDatabase: args.contains('--database'), 16 InitializeSSL(useDatabase: args.contains('--database'),
17 useBuiltinRoots: args.contains('--builtin-roots')); 17 useBuiltinRoots: args.contains('--builtin-roots'));
18 testGoogleUrl(args.contains('--builtin-roots')); 18 testGoogleUrl(args.contains('--builtin-roots'));
19 } 19 }
20 } 20 }
21 21
22 void InitializeSSL({bool useDatabase, bool useBuiltinRoots}) { 22 void InitializeSSL({bool useDatabase, bool useBuiltinRoots}) {
23 // If the built-in root certificates aren't loaded, the connection 23 // If the built-in root certificates aren't loaded, the connection
24 // should signal an error. Even when an external database is loaded, 24 // should signal an error. Even when an external database is loaded,
25 // they should not be loaded. 25 // they should not be loaded.
26 if (useDatabase) { 26 if (useDatabase) {
27 var certificateDatabase = join(dirname(Platform.script), 'pkcert'); 27 var certificateDatabase = Platform.script.resolve('pkcert').toFilePath();
28 SecureSocket.initialize(database: certificateDatabase, 28 SecureSocket.initialize(database: certificateDatabase,
29 password: 'dartdart', 29 password: 'dartdart',
30 useBuiltinRoots: useBuiltinRoots); 30 useBuiltinRoots: useBuiltinRoots);
31 } else { 31 } else {
32 SecureSocket.initialize(useBuiltinRoots: useBuiltinRoots); 32 SecureSocket.initialize(useBuiltinRoots: useBuiltinRoots);
33 } 33 }
34 } 34 }
35 35
36 void testGoogleUrl(bool expectSuccess) { 36 void testGoogleUrl(bool expectSuccess) {
37 // We need to use an external server that is backed by a 37 // We need to use an external server that is backed by a
(...skipping 21 matching lines...) Expand all
59 // Lookup failed. 59 // Lookup failed.
60 Expect.isTrue(e is SocketException); 60 Expect.isTrue(e is SocketException);
61 print('SUCCESS'); 61 print('SUCCESS');
62 }); 62 });
63 } 63 }
64 64
65 void runAllTestsInChildProcesses() { 65 void runAllTestsInChildProcesses() {
66 Future runChild(List<String> scriptArguments) { 66 Future runChild(List<String> scriptArguments) {
67 return Process.run(Platform.executable, 67 return Process.run(Platform.executable,
68 []..addAll(Platform.executableArguments) 68 []..addAll(Platform.executableArguments)
69 ..add(Platform.script) 69 ..add(Platform.script.toFilePath())
70 ..addAll(scriptArguments)) 70 ..addAll(scriptArguments))
71 .then((ProcessResult result) { 71 .then((ProcessResult result) {
72 if (result.exitCode != 0 || !result.stdout.contains('SUCCESS')) { 72 if (result.exitCode != 0 || !result.stdout.contains('SUCCESS')) {
73 print("Client failed"); 73 print("Client failed");
74 print(" stdout:"); 74 print(" stdout:");
75 print(result.stdout); 75 print(result.stdout);
76 print(" stderr:"); 76 print(" stderr:");
77 print(result.stderr); 77 print(result.stderr);
78 Expect.fail('Client subprocess exit code: ${result.exitCode}'); 78 Expect.fail('Client subprocess exit code: ${result.exitCode}');
79 } 79 }
80 }); 80 });
81 } 81 }
82 82
83 asyncStart(); 83 asyncStart();
84 Future.wait([runChild(['--child']), 84 Future.wait([runChild(['--child']),
85 runChild(['--child', '--database']), 85 runChild(['--child', '--database']),
86 runChild(['--child', '--builtin-roots']), 86 runChild(['--child', '--builtin-roots']),
87 runChild(['--child', '--builtin-roots', '--database'])]) 87 runChild(['--child', '--builtin-roots', '--database'])])
88 .then((_) => asyncEnd()); 88 .then((_) => asyncEnd());
89 } 89 }
OLDNEW
« no previous file with comments | « tests/standalone/io/secure_bad_certificate_test.dart ('k') | tests/standalone/io/secure_client_raw_server_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698