This commit is contained in:
Sdogruyol 2016-07-17 14:31:45 +03:00
parent 6ffa4af0e1
commit 4edebcf8eb
6 changed files with 12 additions and 13 deletions

View file

@ -1,7 +1,6 @@
require "../spec_helper"
describe "Kemal::Middleware::CSRF" do
it "sends GETs to next handler" do
handler = Kemal::Middleware::CSRF.new
request = HTTP::Request.new("GET", "/")
@ -33,7 +32,7 @@ describe "Kemal::Middleware::CSRF" do
request = HTTP::Request.new("POST", "/",
body: "authenticity_token=#{current_token}&hasan=lamec",
headers: HTTP::Headers{"Content-Type" => "application/x-www-form-urlencoded",
"Set-Cookie" => client_response.headers["Set-Cookie"]})
"Set-Cookie" => client_response.headers["Set-Cookie"]})
io, context = process_request(handler, request)
client_response = HTTP::Client::Response.from_io(io, decompress: false)
client_response.status_code.should eq 404
@ -54,8 +53,8 @@ describe "Kemal::Middleware::CSRF" do
request = HTTP::Request.new("POST", "/",
body: "hasan=lamec",
headers: HTTP::Headers{"Content-Type" => "application/x-www-form-urlencoded",
"Set-Cookie" => client_response.headers["Set-Cookie"],
"x-csrf-token" => current_token })
"Set-Cookie" => client_response.headers["Set-Cookie"],
"x-csrf-token" => current_token})
io, context = process_request(handler, request)
client_response = HTTP::Client::Response.from_io(io, decompress: false)
client_response.status_code.should eq 404