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