Shared Examples for RexSocket mixin
shared example group for the Loginscanner RexSocket mixin. Pretty simple stuff, just trying to keep it DRY.bug/bundler_fix
parent
2483a37c04
commit
4995fcdced
|
@ -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
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue