Add specs for new methods.

bug/bundler_fix
Joe Vennix 2014-03-02 20:23:20 -06:00
parent 6825fd2486
commit b458b8ad63
3 changed files with 32 additions and 2 deletions

View File

@ -57,8 +57,8 @@ class Network
# @param [Hash] opts the options hash
# @option opts [Boolean] :obfuscate toggles js obfuscation. defaults to true.
# @return [String] javascript code to perform a POST of the specified params
def self.ajax_post(opts={})
# @return [String] javascript code to build and submit a form that POSTs the params
def self.form_post(opts={})
should_obfuscate = opts.fetch(:obfuscate, true)
js = ::File.read(::File.join(Msf::Config.data_directory, "js", "network", "form_post.js"))

View File

@ -16,7 +16,13 @@ describe Rex::Exploitation::Js::Network do
js = Rex::Exploitation::Js::Network.ajax_post
js.should =~ /function postInfo/
end
end
context ".form_post" do
it "should load the postForm javascript" do
js = Rex::Exploitation::Js::Network.form_post
js.should =~ /function postForm/
end
end
end

View File

@ -216,6 +216,14 @@ describe Rex::Proto::Http::ClientRequest do
str.should include("bar=baz")
str.should include("frobnicate=the froozle?")
end
describe "#serialize_get_params" do
subject(:serialize_get_params) { client_request.serialize_get_params }
it { should include("foo[]=bar") }
it { should include("bar=baz") }
it { should include("frobnicate=the froozle?") }
end
end
context "with 'encode_params'" do
@ -227,6 +235,14 @@ describe Rex::Proto::Http::ClientRequest do
str.should include("bar=baz")
str.should include("frobnicate=the%20froozle%3f")
end
describe "#serialize_get_params" do
subject(:serialize_get_params) { client_request.serialize_get_params }
it { should include("foo%5b%5d=bar") }
it { should include("bar=baz") }
it { should include("frobnicate=the%20froozle%3f") }
end
end
context "and 'uri_encode_mode' = hex-all" do
@ -237,6 +253,14 @@ describe Rex::Proto::Http::ClientRequest do
str.should include("%62%61%72=%62%61%7a")
str.should include("%66%72%6f%62%6e%69%63%61%74%65=%74%68%65%20%66%72%6f%6f%7a%6c%65%3f")
end
describe "#serialize_get_params" do
subject(:serialize_get_params) { client_request.serialize_get_params }
it { should include("%66%6f%6f%5b%5d=%62%61%72") }
it { should include("%62%61%72=%62%61%7a") }
it { should include("%66%72%6f%62%6e%69%63%61%74%65=%74%68%65%20%66%72%6f%6f%7a%6c%65%3f") }
end
end
describe "#to_s" do