OLD | NEW |
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"; |
| 9 import "package:path/path.dart"; |
8 import "package:unittest/unittest.dart"; | 10 import "package:unittest/unittest.dart"; |
9 import "package:http_server/http_server.dart"; | |
10 | 11 |
11 import 'utils.dart'; | 12 import 'utils.dart'; |
12 | 13 |
13 | 14 |
14 void main() { | 15 void main() { |
15 group('serve-root', () { | 16 group('serve-root', () { |
16 test('dir-exists', () { | 17 test('dir-exists', () { |
17 expect(HttpServer.bind('localhost', 0).then((server) { | 18 expect(HttpServer.bind('localhost', 0).then((server) { |
18 var dir = new Directory('').createTempSync(); | 19 var dir = new Directory('').createTempSync(); |
19 var virDir = new VirtualDirectory(dir.path); | 20 var virDir = new VirtualDirectory(dir.path); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 .whenComplete(() { | 290 .whenComplete(() { |
290 server.close(); | 291 server.close(); |
291 dir.deleteSync(recursive: true); | 292 dir.deleteSync(recursive: true); |
292 }); | 293 }); |
293 }), completion(equals(HttpStatus.NOT_FOUND))); | 294 }), completion(equals(HttpStatus.NOT_FOUND))); |
294 }); | 295 }); |
295 | 296 |
296 test('relative-parent-link', () { | 297 test('relative-parent-link', () { |
297 expect(HttpServer.bind('localhost', 0).then((server) { | 298 expect(HttpServer.bind('localhost', 0).then((server) { |
298 var dir = new Directory('').createTempSync(); | 299 var dir = new Directory('').createTempSync(); |
299 var name = new Path(dir.path).filename; | 300 var name = basename(dir.path); |
300 var file = new File('${dir.path}/file')..createSync(); | 301 var file = new File('${dir.path}/file')..createSync(); |
301 var link = new Link('${dir.path}/dir3') | 302 var link = new Link('${dir.path}/dir3') |
302 ..createSync('../$name/file'); | 303 ..createSync('../$name/file'); |
303 var virDir = new VirtualDirectory(dir.path); | 304 var virDir = new VirtualDirectory(dir.path); |
304 virDir.followLinks = true; | 305 virDir.followLinks = true; |
305 | 306 |
306 virDir.serve(server); | 307 virDir.serve(server); |
307 | 308 |
308 return new HttpClient().get('localhost', | 309 return new HttpClient().get('localhost', |
309 server.port, | 310 server.port, |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 } | 601 } |
601 testEncoding('..', HttpStatus.NOT_FOUND, false); | 602 testEncoding('..', HttpStatus.NOT_FOUND, false); |
602 testEncoding('%2e%2e', HttpStatus.OK); | 603 testEncoding('%2e%2e', HttpStatus.OK); |
603 testEncoding('%252e%252e', HttpStatus.OK); | 604 testEncoding('%252e%252e', HttpStatus.OK); |
604 testEncoding('/', HttpStatus.OK, false); | 605 testEncoding('/', HttpStatus.OK, false); |
605 testEncoding('%2f', HttpStatus.NOT_FOUND, false); | 606 testEncoding('%2f', HttpStatus.NOT_FOUND, false); |
606 testEncoding('%2f', HttpStatus.OK, true); | 607 testEncoding('%2f', HttpStatus.OK, true); |
607 }); | 608 }); |
608 } | 609 } |
609 | 610 |
OLD | NEW |