Skip to content

Commit

Permalink
Speced SQLi#place_holder.
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Jan 23, 2013
1 parent c7705f7 commit 2230948
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions spec/exploits/sqli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,64 @@
its(:terminate) { should be(false) }
end

describe "#place_holder" do
it "should return an Integer" do
subject.place_holder.should == query_param_value.to_i
end

context "when escape is 'decimal'" do
before { subject.escape = 'decimal' }

it "should return a Float" do
subject.place_holder.should == query_param_value.to_f
end
end

context "when escape is 'string'" do
before { subject.escape = 'string' }

it "should return a String" do
subject.place_holder.should == query_param_value
end
end

context "when escape is 'list'" do
before { subject.escape = 'list' }

context "and url_query_param_value is an integer value" do
let(:query_param_value) { '2' }

it "should return an Array containing an Integer" do
subject.place_holder.should == [query_param_value.to_i]
end
end

context "and url_query_param_value is a decimal value" do
let(:query_param_value) { '2.0' }

it "should return an Array containing a Float" do
subject.place_holder.should == [query_param_value.to_f]
end
end

context "and url_query_param_value is a string value" do
let(:query_param_value) { 'A' }

it "should return an Array containing a String" do
subject.place_holder.should == [query_param_value]
end
end
end

context "when escape is 'column'" do
before { subject.escape = 'column' }

it "should return a Symbol" do
subject.place_holder.should == query_param_value.to_sym
end
end
end

describe "#exploit_url" do
context "when passed a object that responds to #to_sql" do
let(:sql) { subject.sqli.or { 1 == 1 } }
Expand Down

0 comments on commit 2230948

Please sign in to comment.