mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Clarify route encoding test
Since this test changed in 9220935
I noticed that it really doesn't make
sense anymore. I split the tests into 2 groups to explain what each one
does.
First these routes should throw a `bad_request` when the encoding isn't
valid. We're expecting UTF8 encoding and passing binary, that should be
a bad request.
For the second test we are setting the `show` route to set
`self.binary_params_for?` for that route which will convert the
parameters and return a `:ok` instead of a `:bad_request`.
This commit is contained in:
parent
9e3d8cbd07
commit
789f3be020
1 changed files with 12 additions and 6 deletions
|
@ -4425,17 +4425,15 @@ class TestInvalidUrls < ActionDispatch::IntegrationTest
|
|||
end
|
||||
end
|
||||
|
||||
test "invalid UTF-8 encoding is treated as ASCII 8BIT encode" do
|
||||
test "invalid UTF-8 encoding returns a bad request" do
|
||||
with_routing do |set|
|
||||
set.draw do
|
||||
get "/bar/:id", to: redirect("/foo/show/%{id}")
|
||||
get "/foo/show(/:id)", to: "test_invalid_urls/foo#show"
|
||||
|
||||
ok = lambda { |env| [200, { "Content-Type" => "text/plain" }, []] }
|
||||
get "/foobar/:id", to: ok
|
||||
|
||||
ActiveSupport::Deprecation.silence do
|
||||
get "/foo(/:action(/:id))", controller: "test_invalid_urls/foo"
|
||||
get "/:controller(/:action(/:id))"
|
||||
end
|
||||
end
|
||||
|
@ -4446,9 +4444,6 @@ class TestInvalidUrls < ActionDispatch::IntegrationTest
|
|||
get "/foo/%E2%EF%BF%BD%A6"
|
||||
assert_response :bad_request
|
||||
|
||||
get "/foo/show/%E2%EF%BF%BD%A6"
|
||||
assert_response :ok
|
||||
|
||||
get "/bar/%E2%EF%BF%BD%A6"
|
||||
assert_response :bad_request
|
||||
|
||||
|
@ -4456,6 +4451,17 @@ class TestInvalidUrls < ActionDispatch::IntegrationTest
|
|||
assert_response :bad_request
|
||||
end
|
||||
end
|
||||
|
||||
test "params encoded with binary_params_for? are treated as ASCII 8bit" do
|
||||
with_routing do |set|
|
||||
set.draw do
|
||||
get "/foo/show(/:id)", to: "test_invalid_urls/foo#show"
|
||||
end
|
||||
|
||||
get "/foo/show/%E2%EF%BF%BD%A6"
|
||||
assert_response :ok
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class TestOptionalRootSegments < ActionDispatch::IntegrationTest
|
||||
|
|
Loading…
Reference in a new issue