Add specs for connection error conditions

bug/bundler_fix
James Lee 2014-05-15 10:06:17 -05:00
parent 59050d9bf1
commit 8a9abb90c0
No known key found for this signature in database
GPG Key ID: 2D6094C7CEA0A321
2 changed files with 31 additions and 1 deletions

View File

@ -52,8 +52,8 @@ module Metasploit
http_client.set_config('domain' => credential.realm)
end
http_client.connect
begin
http_client.connect
request = http_client.request_cgi(
'uri' => uri,
'method' => method

View File

@ -54,4 +54,34 @@ describe Metasploit::Framework::LoginScanner::HTTP do
end
end
context "#attempt_login" do
let(:pub_blank) {
Metasploit::Framework::LoginScanner::Credential.new(
paired: true,
public: "public",
private: ''
)
}
it "Rex::ConnectionError should result in status :connection_error" do
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:connect).and_raise(Rex::ConnectionError)
expect(http_scanner.attempt_login(pub_blank).status).to eq(:connection_error)
end
it "Timeout::Error should result in status :connection_error" do
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:connect).and_raise(Timeout::Error)
expect(http_scanner.attempt_login(pub_blank).status).to eq(:connection_error)
end
it "EOFError should result in status :connection_error" do
allow_any_instance_of(Rex::Proto::Http::Client).to receive(:connect).and_raise(EOFError)
expect(http_scanner.attempt_login(pub_blank).status).to eq(:connection_error)
end
end
end