-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
regression tests for existing kinds of bad params currently handled okay
But in past versions of bl_range_limit i know from my own app resulted in uncaught exception 500s
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 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,46 @@ | ||
require 'spec_helper' | ||
|
||
describe CatalogController, type: :request do | ||
let(:range_facet_field) { "pub_date_si" } | ||
|
||
let(:parsed_body) { Nokogiri::HTML(response.body) } | ||
|
||
describe "bad params should not produce uncaught exception when" do | ||
it "bad root range" do | ||
get "/catalog?range=bad" | ||
|
||
expect(response.code).to eq("200") | ||
expect(parsed_body.css("span.applied-filter")).not_to be_present | ||
end | ||
|
||
it "facet params are ill structured" do | ||
get "/catalog?#{ {"f" => { range_facet_field => [{"=Library&q="=>""}] } }.to_param }" | ||
|
||
expect(response.code).to eq("200") | ||
expect(parsed_body.css("span.applied-filter")).not_to be_present | ||
end | ||
|
||
it "newline in range facet does not interupt facet" do | ||
get "/catalog?#{ {"range"=>{ range_facet_field => {"begin"=>"1588\n", "end"=>"2020\n"}}}.to_param }" | ||
|
||
expect(response.code).to eq("200") | ||
expect(parsed_body.css("span.applied-filter")).to be_present | ||
expect(parsed_body.css("span.applied-filter").collect(&:text)).to include(/1588.*to.*2020/) | ||
end | ||
|
||
it "weird attack in range value is ignored" do | ||
param_hash = {"range"=>{"year_facet_isim"=>{"begin"=>"1989',(;))#- --", "end"=>"1989',(;))#- --"}}} | ||
get "/catalog?#{ param_hash.to_param }" | ||
|
||
expect(response.code).to eq("200") | ||
expect(parsed_body.css("span.applied-filter")).not_to be_present | ||
end | ||
|
||
it "empty range param is ignored" do | ||
get "/catalog?#{ { "range" => { "year_facet_isim" => nil } }.to_param }" | ||
|
||
expect(response.code).to eq("200") | ||
expect(parsed_body.css("span.applied-filter")).not_to be_present | ||
end | ||
end | ||
end |