Skip to content

Commit 111e3fc

Browse files
committed
Add rspec for #send_request
1 parent 8f95624 commit 111e3fc

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

spec/lib/metasploit/framework/login_scanner/http_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,26 @@
88
it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket'
99
it_behaves_like 'Metasploit::Framework::LoginScanner::HTTP'
1010

11+
subject do
12+
described_class.new
13+
end
14+
15+
let(:response) { Rex::Proto::Http::Response.new(200, 'OK') }
16+
17+
before(:each) do
18+
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:request_cgi).with(any_args)
19+
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:send_recv).with(any_args).and_return(response)
20+
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:set_config).with(any_args)
21+
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:close)
22+
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:connect)
23+
end
24+
25+
describe '#send_request' do
26+
context 'when a valid request is sent' do
27+
it 'returns a response object' do
28+
expect(subject.send_request({'uri'=>'/'})).to be_kind_of(Rex::Proto::Http::Response)
29+
end
30+
end
31+
end
32+
1133
end

0 commit comments

Comments
 (0)