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

Side by Side Diff: pkg/http_server/test/virtual_directory_test.dart

Issue 424063002: Add 'pathPrefix' optional argument to VirtualDirectory constructor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Push version. Created 6 years, 4 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
« no previous file with comments | « pkg/http_server/pubspec.yaml ('k') | no next file » | 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:io'; 6 import 'dart:io';
7 7
8 import "package:http_server/http_server.dart"; 8 import "package:http_server/http_server.dart";
9 import 'package:path/path.dart' as pathos; 9 import 'package:path/path.dart' as pathos;
10 import "package:unittest/unittest.dart"; 10 import "package:unittest/unittest.dart";
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 // Redirect directory-requests to index.html files. 298 // Redirect directory-requests to index.html files.
299 var indexUri = new Uri.file(dir2.path).resolve('index.html'); 299 var indexUri = new Uri.file(dir2.path).resolve('index.html');
300 virDir.serveFile(new File(indexUri.toFilePath()), request); 300 virDir.serveFile(new File(indexUri.toFilePath()), request);
301 }; 301 };
302 return getAsString(virDir, '/dir/') 302 return getAsString(virDir, '/dir/')
303 .then((result) { 303 .then((result) {
304 expect(result, 'index file'); 304 expect(result, 'index file');
305 }); 305 });
306 }); 306 });
307 }); 307 });
308
309 group('path-prefix', () {
310 testVirtualDir('simple', (dir) {
311 var virDir = new VirtualDirectory(dir.path, pathPrefix: '/path');
312 virDir.allowDirectoryListing = true;
313 virDir.directoryHandler = (d, request) {
314 expect(FileSystemEntity.identicalSync(dir.path, d.path), isTrue);
315 return request.response.close();
316 };
317
318 return getStatusCodeForVirtDir(virDir, '/path')
319 .then((result) {
320 expect(result, HttpStatus.OK);
321 });
322 });
323
324 testVirtualDir('trailing-slash', (dir) {
325 var virDir = new VirtualDirectory(dir.path, pathPrefix: '/path/');
326 virDir.allowDirectoryListing = true;
327 virDir.directoryHandler = (d, request) {
328 expect(FileSystemEntity.identicalSync(dir.path, d.path), isTrue);
329 return request.response.close();
330 };
331
332 return getStatusCodeForVirtDir(virDir, '/path')
333 .then((result) {
334 expect(result, HttpStatus.OK);
335 });
336 });
337
338 testVirtualDir('not-matching', (dir) {
339 var virDir = new VirtualDirectory(dir.path, pathPrefix: '/path/');
340 return getStatusCodeForVirtDir(virDir, '/')
341 .then((result) {
342 expect(result, HttpStatus.NOT_FOUND);
343 });
344 });
345 });
308 }); 346 });
309 347
310 group('links', () { 348 group('links', () {
311 if (!Platform.isWindows) { 349 if (!Platform.isWindows) {
312 group('follow-links', () { 350 group('follow-links', () {
313 testVirtualDir('dir-link', (dir) { 351 testVirtualDir('dir-link', (dir) {
314 var dir2 = new Directory('${dir.path}/dir2')..createSync(); 352 var dir2 = new Directory('${dir.path}/dir2')..createSync();
315 var link = new Link('${dir.path}/dir3')..createSync('dir2'); 353 var link = new Link('${dir.path}/dir3')..createSync('dir2');
316 var file = new File('${dir2.path}/file')..createSync(); 354 var file = new File('${dir2.path}/file')..createSync();
317 var virDir = new VirtualDirectory(dir.path); 355 var virDir = new VirtualDirectory(dir.path);
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 return virDir.serveFile(new File('${d.path}/file'), request); 636 return virDir.serveFile(new File('${d.path}/file'), request);
599 }; 637 };
600 638
601 return getAsString(virDir, '/') 639 return getAsString(virDir, '/')
602 .then((result) { 640 .then((result) {
603 expect(result, 'file contents'); 641 expect(result, 'file contents');
604 }); 642 });
605 }); 643 });
606 }); 644 });
607 } 645 }
OLDNEW
« no previous file with comments | « pkg/http_server/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698