OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS d.file | |
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. | |
4 | |
5 library pub_tests; | 1 library pub_tests; |
6 | |
7 import 'package:json_rpc_2/error_code.dart' as rpc_error_code; | 2 import 'package:json_rpc_2/error_code.dart' as rpc_error_code; |
8 import 'package:scheduled_test/scheduled_test.dart'; | 3 import 'package:scheduled_test/scheduled_test.dart'; |
9 | |
10 import '../../descriptor.dart' as d; | 4 import '../../descriptor.dart' as d; |
11 import '../../test_pub.dart'; | 5 import '../../test_pub.dart'; |
12 import '../utils.dart'; | 6 import '../utils.dart'; |
13 | |
14 main() { | 7 main() { |
15 initConfig(); | 8 initConfig(); |
16 | |
17 setUp(() { | 9 setUp(() { |
18 d.dir(appPath, [ | 10 d.dir( |
19 d.appPubspec(), | 11 appPath, |
20 d.dir("web", [ | 12 [d.appPubspec(), d.dir("web", [d.file("index.html", "<body>")])]).create
(); |
21 d.file("index.html", "<body>") | |
22 ]) | |
23 ]).create(); | |
24 }); | 13 }); |
25 | |
26 integration("responds with an error if 'path' is not a string", () { | 14 integration("responds with an error if 'path' is not a string", () { |
27 pubServe(); | 15 pubServe(); |
28 expectWebSocketError("unserveDirectory", {"path": 123}, | 16 expectWebSocketError("unserveDirectory", { |
| 17 "path": 123 |
| 18 }, |
29 rpc_error_code.INVALID_PARAMS, | 19 rpc_error_code.INVALID_PARAMS, |
30 'Parameter "path" for method "unserveDirectory" must be a string, but ' | 20 'Parameter "path" for method "unserveDirectory" must be a string, but ' |
31 'was 123.'); | 21 'was 123.'); |
32 endPubServe(); | 22 endPubServe(); |
33 }); | 23 }); |
34 | |
35 integration("responds with an error if 'path' is absolute", () { | 24 integration("responds with an error if 'path' is absolute", () { |
36 pubServe(); | 25 pubServe(); |
37 expectWebSocketError("unserveDirectory", {"path": "/absolute.txt"}, | 26 expectWebSocketError("unserveDirectory", { |
| 27 "path": "/absolute.txt" |
| 28 }, |
38 rpc_error_code.INVALID_PARAMS, | 29 rpc_error_code.INVALID_PARAMS, |
39 '"path" must be a relative path. Got "/absolute.txt".'); | 30 '"path" must be a relative path. Got "/absolute.txt".'); |
40 endPubServe(); | 31 endPubServe(); |
41 }); | 32 }); |
42 | |
43 integration("responds with an error if 'path' reaches out", () { | 33 integration("responds with an error if 'path' reaches out", () { |
44 pubServe(); | 34 pubServe(); |
45 expectWebSocketError("unserveDirectory", {"path": "a/../../bad.txt"}, | 35 expectWebSocketError("unserveDirectory", { |
| 36 "path": "a/../../bad.txt" |
| 37 }, |
46 rpc_error_code.INVALID_PARAMS, | 38 rpc_error_code.INVALID_PARAMS, |
47 '"path" cannot reach out of its containing directory. Got ' | 39 '"path" cannot reach out of its containing directory. Got ' |
48 '"a/../../bad.txt".'); | 40 '"a/../../bad.txt".'); |
49 endPubServe(); | 41 endPubServe(); |
50 }); | 42 }); |
51 } | 43 } |
OLD | NEW |