| 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 }); | 22 }); |
| 23 | 23 |
| 24 integration("responds with an error if 'path' is not a string", () { | 24 integration("responds with an error if 'path' is not a string", () { |
| 25 pubServe(); | 25 pubServe(shouldGetFirst: true); |
| 26 expectWebSocketError("serveDirectory", {"path": 123}, | 26 expectWebSocketError("serveDirectory", {"path": 123}, |
| 27 rpc_error_code.INVALID_PARAMS, | 27 rpc_error_code.INVALID_PARAMS, |
| 28 'Parameter "path" for method "serveDirectory" must be a string, but ' | 28 'Parameter "path" for method "serveDirectory" must be a string, but ' |
| 29 'was 123.'); | 29 'was 123.'); |
| 30 endPubServe(); | 30 endPubServe(); |
| 31 }); | 31 }); |
| 32 | 32 |
| 33 integration("responds with an error if 'path' is absolute", () { | 33 integration("responds with an error if 'path' is absolute", () { |
| 34 pubServe(); | 34 pubServe(shouldGetFirst: true); |
| 35 expectWebSocketError("serveDirectory", {"path": "/absolute.txt"}, | 35 expectWebSocketError("serveDirectory", {"path": "/absolute.txt"}, |
| 36 rpc_error_code.INVALID_PARAMS, | 36 rpc_error_code.INVALID_PARAMS, |
| 37 '"path" must be a relative path. Got "/absolute.txt".'); | 37 '"path" must be a relative path. Got "/absolute.txt".'); |
| 38 endPubServe(); | 38 endPubServe(); |
| 39 }); | 39 }); |
| 40 | 40 |
| 41 integration("responds with an error if 'path' reaches out", () { | 41 integration("responds with an error if 'path' reaches out", () { |
| 42 pubServe(); | 42 pubServe(shouldGetFirst: true); |
| 43 expectWebSocketError("serveDirectory", {"path": "a/../../bad.txt"}, | 43 expectWebSocketError("serveDirectory", {"path": "a/../../bad.txt"}, |
| 44 rpc_error_code.INVALID_PARAMS, | 44 rpc_error_code.INVALID_PARAMS, |
| 45 '"path" cannot reach out of its containing directory. Got ' | 45 '"path" cannot reach out of its containing directory. Got ' |
| 46 '"a/../../bad.txt".'); | 46 '"a/../../bad.txt".'); |
| 47 endPubServe(); | 47 endPubServe(); |
| 48 }); | 48 }); |
| 49 } | 49 } |
| OLD | NEW |