diff --git a/spec/lib/metasploit/framework/login_scanner/ftp_spec.rb b/spec/lib/metasploit/framework/login_scanner/ftp_spec.rb index 0278f1f05d..5a3de97e94 100644 --- a/spec/lib/metasploit/framework/login_scanner/ftp_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/ftp_spec.rb @@ -46,12 +46,8 @@ describe Metasploit::Framework::LoginScanner::FTP do } it_behaves_like 'Metasploit::Framework::LoginScanner::Base' + it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket' - it { should respond_to :proxies } - it { should respond_to :send_delay } - it { should respond_to :max_send_size } - it { should respond_to :ssl } - it { should respond_to :ssl_version } context 'validations' do @@ -91,55 +87,7 @@ describe Metasploit::Framework::LoginScanner::FTP do end end - context 'send_delay' do - it 'is not valid for a non-number' do - ftp_scanner.send_delay = "a" - expect(ftp_scanner).to_not be_valid - expect(ftp_scanner.errors[:send_delay]).to include "is not a number" - end - it 'is not valid for a floating point' do - ftp_scanner.send_delay = 5.76 - expect(ftp_scanner).to_not be_valid - expect(ftp_scanner.errors[:send_delay]).to include "must be an integer" - end - - it 'is not valid for a negative number' do - ftp_scanner.send_delay = -8 - expect(ftp_scanner).to_not be_valid - expect(ftp_scanner.errors[:send_delay]).to include "must be greater than or equal to 0" - end - - it 'is valid for a legitimate number' do - ftp_scanner.send_delay = rand(1000) + 1 - expect(ftp_scanner.errors[:send_delay]).to be_empty - end - end - - context 'max_send_size' do - it 'is not valid for a non-number' do - ftp_scanner.max_send_size = "a" - expect(ftp_scanner).to_not be_valid - expect(ftp_scanner.errors[:max_send_size]).to include "is not a number" - end - - it 'is not valid for a floating point' do - ftp_scanner.max_send_size = 5.76 - expect(ftp_scanner).to_not be_valid - expect(ftp_scanner.errors[:max_send_size]).to include "must be an integer" - end - - it 'is not valid for a negative number' do - ftp_scanner.max_send_size = -8 - expect(ftp_scanner).to_not be_valid - expect(ftp_scanner.errors[:max_send_size]).to include "must be greater than or equal to 0" - end - - it 'is valid for a legitimate number' do - ftp_scanner.max_send_size = rand(1000) + 1 - expect(ftp_scanner.errors[:max_send_size]).to be_empty - end - end end context '#attempt_login' do diff --git a/spec/support/shared/examples/lib/metasploit/framework/login_scanner/rex_socket.rb b/spec/support/shared/examples/lib/metasploit/framework/login_scanner/rex_socket.rb new file mode 100644 index 0000000000..0c481d6090 --- /dev/null +++ b/spec/support/shared/examples/lib/metasploit/framework/login_scanner/rex_socket.rb @@ -0,0 +1,60 @@ +shared_examples_for 'Metasploit::Framework::LoginScanner::RexSocket' do + subject(:login_scanner) { described_class.new } + + it { should respond_to :send_delay } + it { should respond_to :max_send_size } + it { should respond_to :ssl } + it { should respond_to :ssl_version } + + context 'send_delay' do + it 'is not valid for a non-number' do + ftp_scanner.send_delay = "a" + expect(ftp_scanner).to_not be_valid + expect(ftp_scanner.errors[:send_delay]).to include "is not a number" + end + + it 'is not valid for a floating point' do + ftp_scanner.send_delay = 5.76 + expect(ftp_scanner).to_not be_valid + expect(ftp_scanner.errors[:send_delay]).to include "must be an integer" + end + + it 'is not valid for a negative number' do + ftp_scanner.send_delay = -8 + expect(ftp_scanner).to_not be_valid + expect(ftp_scanner.errors[:send_delay]).to include "must be greater than or equal to 0" + end + + it 'is valid for a legitimate number' do + ftp_scanner.send_delay = rand(1000) + 1 + expect(ftp_scanner.errors[:send_delay]).to be_empty + end + end + + context 'max_send_size' do + it 'is not valid for a non-number' do + ftp_scanner.max_send_size = "a" + expect(ftp_scanner).to_not be_valid + expect(ftp_scanner.errors[:max_send_size]).to include "is not a number" + end + + it 'is not valid for a floating point' do + ftp_scanner.max_send_size = 5.76 + expect(ftp_scanner).to_not be_valid + expect(ftp_scanner.errors[:max_send_size]).to include "must be an integer" + end + + it 'is not valid for a negative number' do + ftp_scanner.max_send_size = -8 + expect(ftp_scanner).to_not be_valid + expect(ftp_scanner.errors[:max_send_size]).to include "must be greater than or equal to 0" + end + + it 'is valid for a legitimate number' do + ftp_scanner.max_send_size = rand(1000) + 1 + expect(ftp_scanner.errors[:max_send_size]).to be_empty + end + end + + +end