Merge branch 'http-client-spec-restructure' of github.com:jlee-r7/metasploit-framework into jlee-r7-http-client-spec-restructure
commit
a7eba7a44a
|
@ -11,7 +11,7 @@ describe Msf::Exploit::Remote::HttpClient do
|
|||
mod
|
||||
end
|
||||
|
||||
context 'normalize_uri' do
|
||||
describe '#normalize_uri' do
|
||||
let(:expected_normalized_uri) do
|
||||
'/a/b/c'
|
||||
end
|
||||
|
@ -20,6 +20,20 @@ describe Msf::Exploit::Remote::HttpClient do
|
|||
subject.normalize_uri(unnormalized_uri)
|
||||
end
|
||||
|
||||
context "with just '/'" do
|
||||
let(:unnormalized_uri) do
|
||||
'/'
|
||||
end
|
||||
|
||||
it "should be '/'" do
|
||||
unnormalized_uri.should == '/'
|
||||
end
|
||||
|
||||
it "should return '/'" do
|
||||
normalized_uri.should == '/'
|
||||
end
|
||||
end
|
||||
|
||||
context "with starting '/'" do
|
||||
let(:unnormalized_uri) do
|
||||
expected_normalized_uri
|
||||
|
@ -30,7 +44,17 @@ describe Msf::Exploit::Remote::HttpClient do
|
|||
end
|
||||
|
||||
it "should not add another starting '/'" do
|
||||
normalized_uri.should == expected_normalized_uri
|
||||
normalized_uri.should == expected_normalized_uri
|
||||
end
|
||||
|
||||
context "with multiple internal '/'" do
|
||||
let(:unnormalized_uri) do
|
||||
"/#{expected_normalized_uri.gsub("/", "////")}"
|
||||
end
|
||||
|
||||
it "should remove doubled internal '/'" do
|
||||
normalized_uri.should == expected_normalized_uri
|
||||
end
|
||||
end
|
||||
|
||||
context "with multiple starting '/'" do
|
||||
|
@ -48,39 +72,25 @@ describe Msf::Exploit::Remote::HttpClient do
|
|||
end
|
||||
|
||||
context "with trailing '/'" do
|
||||
let(:unnormalized_uri) do
|
||||
"#{expected_normalized_uri}/"
|
||||
let(:expected_normalized_uri) do
|
||||
'/a/b/c/'
|
||||
end
|
||||
|
||||
it "should end with '/'" do
|
||||
unnormalized_uri[-1, 1].should == '/'
|
||||
let(:unnormalized_uri) do
|
||||
"#{expected_normalized_uri}/"
|
||||
end
|
||||
|
||||
it "should end with '/'" do
|
||||
normalized_uri[-1, 1].should == '/'
|
||||
end
|
||||
|
||||
context "with just '/'" do
|
||||
context "with multiple trailing '/'" do
|
||||
let(:unnormalized_uri) do
|
||||
'/'
|
||||
"#{expected_normalized_uri}/"
|
||||
end
|
||||
|
||||
it "should be '/'" do
|
||||
unnormalized_uri.should == '/'
|
||||
end
|
||||
|
||||
it "should return '/'" do
|
||||
normalized_uri.should == '/'
|
||||
end
|
||||
end
|
||||
|
||||
context "with multiple multiple trailing '/'" do
|
||||
let(:unnormalized_uri) do
|
||||
"#{expected_normalized_uri}"
|
||||
end
|
||||
|
||||
it "should have single trailing '/'" do
|
||||
unnormalized_uri[-2,1].should == '/'
|
||||
it "should have multiple trailing '/'" do
|
||||
unnormalized_uri[-2,2].should == '//'
|
||||
end
|
||||
|
||||
it "should return only one trailing '/'" do
|
||||
|
@ -105,16 +115,15 @@ describe Msf::Exploit::Remote::HttpClient do
|
|||
end
|
||||
|
||||
context "without starting '/'" do
|
||||
let(:unnormalized_uri) do
|
||||
'a/b/c'
|
||||
end
|
||||
|
||||
context "with trailing '/'" do
|
||||
let(:unnormalized_uri) do
|
||||
'a/b/c/'
|
||||
end
|
||||
let(:expected_normalized_uri) do
|
||||
'/a/b/c/'
|
||||
end
|
||||
|
||||
it "'should have trailing '/'" do
|
||||
it "should have trailing '/'" do
|
||||
unnormalized_uri[-1, 1].should == '/'
|
||||
end
|
||||
|
||||
|
@ -122,17 +131,31 @@ describe Msf::Exploit::Remote::HttpClient do
|
|||
normalized_uri[0, 1].should == '/'
|
||||
end
|
||||
|
||||
it "'should not remove trailing '/'" do
|
||||
it "should not remove trailing '/'" do
|
||||
normalized_uri[-1, 1].should == '/'
|
||||
end
|
||||
|
||||
it 'should normalize the uri' do
|
||||
normalized_uri.should == "#{expected_normalized_uri}/"
|
||||
normalized_uri.should == "#{expected_normalized_uri}"
|
||||
end
|
||||
|
||||
context "with multiple internal '/'" do
|
||||
let(:unnormalized_uri) do
|
||||
"/#{expected_normalized_uri.gsub("/", "////")}"
|
||||
end
|
||||
|
||||
it "should remove doubled internal '/'" do
|
||||
normalized_uri.should == expected_normalized_uri
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "without trailing '/'" do
|
||||
it "'should not have trailing '/'" do
|
||||
let(:unnormalized_uri) do
|
||||
'a/b/c'
|
||||
end
|
||||
|
||||
it "should not have trailing '/'" do
|
||||
unnormalized_uri[-1, 1].should_not == '/'
|
||||
end
|
||||
|
||||
|
@ -143,35 +166,35 @@ describe Msf::Exploit::Remote::HttpClient do
|
|||
it "should add trailing '/'" do
|
||||
normalized_uri[-1, 1].should_not == '/'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with empty string' do
|
||||
let(:unnormalized_uri) do
|
||||
''
|
||||
end
|
||||
context 'with empty string' do
|
||||
let(:unnormalized_uri) do
|
||||
''
|
||||
end
|
||||
|
||||
it "should be empty" do
|
||||
unnormalized_uri.should be_empty
|
||||
end
|
||||
it "should be empty" do
|
||||
unnormalized_uri.should be_empty
|
||||
end
|
||||
|
||||
it "should return '/'" do
|
||||
normalized_uri.should == '/'
|
||||
end
|
||||
end
|
||||
it "should return '/'" do
|
||||
normalized_uri.should == '/'
|
||||
end
|
||||
end
|
||||
|
||||
context 'with nil' do
|
||||
let(:unnormalized_uri) do
|
||||
nil
|
||||
end
|
||||
context 'with nil' do
|
||||
let(:unnormalized_uri) do
|
||||
nil
|
||||
end
|
||||
|
||||
it 'should be nil' do
|
||||
unnormalized_uri.should be_nil
|
||||
end
|
||||
it 'should be nil' do
|
||||
unnormalized_uri.should be_nil
|
||||
end
|
||||
|
||||
it "should return '/" do
|
||||
normalized_uri.should == '/'
|
||||
end
|
||||
end
|
||||
it "should return '/" do
|
||||
normalized_uri.should == '/'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue