|
| 1 | +require "../../func_spec.cr" |
| 2 | + |
| 3 | +expected_endpoints = [ |
| 4 | + Endpoint.new("/health", "GET", [ |
| 5 | + Param.new("name", "", "query"), |
| 6 | + Param.new("X-Trace-Id", "", "header"), |
| 7 | + Param.new("session", "", "cookie"), |
| 8 | + ]), |
| 9 | + Endpoint.new("/users", "POST", [ |
| 10 | + Param.new("body", "", "json"), |
| 11 | + ]), |
| 12 | + Endpoint.new("/profiles", "PATCH", [ |
| 13 | + Param.new("X-Profile-Mode", "", "header"), |
| 14 | + ]), |
| 15 | + Endpoint.new("/files", "GET"), |
| 16 | + Endpoint.new("/reports", "DELETE"), |
| 17 | + Endpoint.new("/uploads", "POST", [ |
| 18 | + Param.new("body", "", "json"), |
| 19 | + ]), |
| 20 | + Endpoint.new("/switch-users", "PUT"), |
| 21 | + Endpoint.new("/status", "GET"), |
| 22 | +] |
| 23 | + |
| 24 | +tester = FunctionalTester.new("fixtures/dart/http/", { |
| 25 | + :techs => 1, |
| 26 | + :endpoints => expected_endpoints.size, |
| 27 | +}, expected_endpoints) |
| 28 | +tester.perform_tests |
| 29 | + |
| 30 | +it "does not leak pre-route body reads into previous endpoints" do |
| 31 | + reports = tester.app.endpoints.find { |found| found.url == "/reports" && found.method == "DELETE" } |
| 32 | + reports.should_not be_nil |
| 33 | + reports.try do |endpoint| |
| 34 | + endpoint.params.any? { |param| param.name == "body" && param.param_type == "json" }.should be_false |
| 35 | + end |
| 36 | + |
| 37 | + uploads = tester.app.endpoints.find { |found| found.url == "/uploads" && found.method == "POST" } |
| 38 | + uploads.should_not be_nil |
| 39 | + uploads.try do |endpoint| |
| 40 | + endpoint.params.any? { |param| param.name == "body" && param.param_type == "json" }.should be_true |
| 41 | + end |
| 42 | +end |
0 commit comments