1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-11-05 14:57:30 +01:00

Land #7375, mock some rex tests for DNS lookups

Fixes #6467, as far as @lsato-r7 and I can tell.
This commit is contained in:
Tod Beardsley 2016-09-29 16:37:38 -05:00
commit de9434870c
No known key found for this signature in database
GPG Key ID: 08B5B91DC85943FE

View File

@ -54,6 +54,10 @@ RSpec.shared_examples_for 'Metasploit::Framework::LoginScanner::Base' do | opts
[ pub_blank, pub_pub, pub_pri]
}
let(:socket_error) {
::SocketError.new("getaddrinfo: nodename nor servname provided, or not known")
}
it { is_expected.to respond_to :connection_timeout }
it { is_expected.to respond_to :cred_details }
it { is_expected.to respond_to :host }
@ -101,6 +105,12 @@ RSpec.shared_examples_for 'Metasploit::Framework::LoginScanner::Base' do | opts
end
context 'host' do
before do
allow(::Rex::Socket).to receive(:getaddress).with('192.168.1.1.5', true).and_raise(socket_error)
allow(::Rex::Socket).to receive(:getaddress).with('192.168', true).and_return('192.0.0.168')
allow(::Rex::Socket).to receive(:getaddress).with('192.300.675.123', true).and_raise(socket_error)
allow(::Rex::Socket).to receive(:getaddress).with('nosuchplace.metasploit.com', true).and_raise(socket_error)
end
it 'is not valid for not set' do
expect(login_scanner).to_not be_valid