Skip to content

Commit de94348

Browse files
author
Tod Beardsley
committed
Land rapid7#7375, mock some rex tests for DNS lookups
Fixes rapid7#6467, as far as @lsato-r7 and I can tell.
2 parents e0cd4d0 + ca68357 commit de94348

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

spec/support/shared/examples/metasploit/framework/login_scanner/login_scanner_base.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@
5454
[ pub_blank, pub_pub, pub_pri]
5555
}
5656

57+
let(:socket_error) {
58+
::SocketError.new("getaddrinfo: nodename nor servname provided, or not known")
59+
}
60+
5761
it { is_expected.to respond_to :connection_timeout }
5862
it { is_expected.to respond_to :cred_details }
5963
it { is_expected.to respond_to :host }
@@ -101,6 +105,12 @@
101105
end
102106

103107
context 'host' do
108+
before do
109+
allow(::Rex::Socket).to receive(:getaddress).with('192.168.1.1.5', true).and_raise(socket_error)
110+
allow(::Rex::Socket).to receive(:getaddress).with('192.168', true).and_return('192.0.0.168')
111+
allow(::Rex::Socket).to receive(:getaddress).with('192.300.675.123', true).and_raise(socket_error)
112+
allow(::Rex::Socket).to receive(:getaddress).with('nosuchplace.metasploit.com', true).and_raise(socket_error)
113+
end
104114

105115
it 'is not valid for not set' do
106116
expect(login_scanner).to_not be_valid

0 commit comments

Comments
 (0)