-
-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Omitting filters fix for lowercase methods requests (#647)
- Loading branch information
Showing
5 changed files
with
45 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require "./spec_helper" | ||
|
||
describe "Kemal::FilterHandler" do | ||
it "handles with upcased 'POST'" do | ||
filter_handler = Kemal::FilterHandler.new | ||
filter_handler._add_route_filter("POST", "*", :before) do |env| | ||
env.set "sensitive", "1" | ||
end | ||
Kemal.config.add_filter_handler(filter_handler) | ||
|
||
post "/sensitive_post" do |env| | ||
env.get "sensitive" | ||
end | ||
|
||
request = HTTP::Request.new("POST", "/sensitive_post") | ||
client_response = call_request_on_app(request) | ||
client_response.status_code.should eq(200) | ||
client_response.body.should eq("1") | ||
end | ||
|
||
it "handles with downcased 'post'" do | ||
filter_handler = Kemal::FilterHandler.new | ||
filter_handler._add_route_filter("POST", "*", :before) do |env| | ||
env.set "sensitive", "1" | ||
end | ||
Kemal.config.add_filter_handler(filter_handler) | ||
|
||
post "/sensitive_post" do | ||
"sensitive" | ||
end | ||
|
||
request = HTTP::Request.new("post", "/sensitive_post") | ||
client_response = call_request_on_app(request) | ||
client_response.status_code.should eq(200) | ||
client_response.body.should eq("") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters