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

Side by Side Diff: test/utils.dart

Issue 1432143003: Update the tests to run with Dart 1.13. (Closed) Base URL: git@github.com:dart-lang/http_server.git@master
Patch Set: Created 5 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
« no previous file with comments | « test/certificates/trusted_certs.pem ('k') | test/virtual_host_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library utils; 5 library utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 import "package:unittest/unittest.dart"; 10 import "package:unittest/unittest.dart";
11 11
12 import 'package:http_server/http_server.dart'; 12 import 'package:http_server/http_server.dart';
13 13
14 import 'http_mock.dart'; 14 import 'http_mock.dart';
15 15
16 SecurityContext serverContext;
17 SecurityContext clientContext;
18
16 /** 19 /**
17 * Used to flag a given test case as being a mock or not. 20 * Used to flag a given test case as being a mock or not.
18 */ 21 */
19 final _isMockTestExpando = new Expando<bool>('isMockTest'); 22 final _isMockTestExpando = new Expando<bool>('isMockTest');
20 23
21 void testVirtualDir(String name, Future func(Directory dir)) { 24 void testVirtualDir(String name, Future func(Directory dir)) {
22 _testVirtualDir(name, false, func); 25 _testVirtualDir(name, false, func);
23 _testVirtualDir(name, true, func); 26 _testVirtualDir(name, true, func);
24 } 27 }
25 28
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 String path, 81 String path,
79 {String host, 82 {String host,
80 bool secure: false, 83 bool secure: false,
81 DateTime ifModifiedSince, 84 DateTime ifModifiedSince,
82 bool rawPath: false, 85 bool rawPath: false,
83 bool followRedirects: true, 86 bool followRedirects: true,
84 int from, 87 int from,
85 int to}) { 88 int to}) {
86 var uri = _getUri(port, path, secure: secure, rawPath: rawPath); 89 var uri = _getUri(port, path, secure: secure, rawPath: rawPath);
87 90
88 var client = new HttpClient(); 91 if (secure) print(clientContext);
Bill Hesse 2015/11/11 17:43:22 Debug printing? Does a context print anything?
Søren Gjesse 2015/11/12 07:37:29 Removed.
92 var client;
93 if (secure) {
94 client = new HttpClient(context: clientContext);
Bill Hesse 2015/11/11 17:43:22 This is actually OK to call with clientContext nul
Søren Gjesse 2015/11/12 07:37:29 There are tests which combine secure and non-secur
95 } else {
96 client = new HttpClient();
97 }
89 return client.getUrl(uri) 98 return client.getUrl(uri)
90 .then((request) { 99 .then((request) {
91 if (!followRedirects) request.followRedirects = false; 100 if (!followRedirects) request.followRedirects = false;
92 if (host != null) request.headers.host = host; 101 if (host != null) request.headers.host = host;
93 if (ifModifiedSince != null) { 102 if (ifModifiedSince != null) {
94 request.headers.ifModifiedSince = ifModifiedSince; 103 request.headers.ifModifiedSince = ifModifiedSince;
95 } 104 }
96 _addRangeHeader(request, from, to); 105 _addRangeHeader(request, from, to);
97 return request.close(); 106 return request.close();
98 }) 107 })
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 var toStr = to != null ? '$to' : ''; 296 var toStr = to != null ? '$to' : '';
288 if (fromStr.isNotEmpty || toStr.isNotEmpty) { 297 if (fromStr.isNotEmpty || toStr.isNotEmpty) {
289 request.headers.set(HttpHeaders.RANGE, 'bytes=$fromStr-$toStr'); 298 request.headers.set(HttpHeaders.RANGE, 'bytes=$fromStr-$toStr');
290 } 299 }
291 } 300 }
292 301
293 const CERTIFICATE = "localhost_cert"; 302 const CERTIFICATE = "localhost_cert";
294 303
295 304
296 void setupSecure() { 305 void setupSecure() {
297 String certificateDatabase = Platform.script.resolve('pkcert').toFilePath(); 306 String localFile(path) => Platform.script.resolve(path).toFilePath();
298 SecureSocket.initialize(database: certificateDatabase, 307
299 password: 'dartdart'); 308 serverContext = new SecurityContext()
309 ..useCertificateChain(localFile('certificates/server_chain.pem'))
310 ..usePrivateKey(localFile('certificates/server_key.pem'),
311 password: 'dartdart');
312
313 clientContext = new SecurityContext()
314 ..setTrustedCertificates(file: localFile('certificates/trusted_certs.pem'));
300 } 315 }
OLDNEW
« no previous file with comments | « test/certificates/trusted_certs.pem ('k') | test/virtual_host_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698