Land #4385, fixes bruteforce_speed validator

bruteforce_speed validator now accepts nil
bug/bundler_fix
David Maloney 2015-01-07 12:09:25 -06:00
commit 5d68d48ca5
No known key found for this signature in database
GPG Key ID: DEDBA9DC3A913DB2
2 changed files with 29 additions and 2 deletions

View File

@ -57,8 +57,8 @@ module Metasploit
inclusion: { in: [true, false] }
validates :bruteforce_speed,
presence: false,
numericality: {
allow_nil: true,
only_integer: true,
greater_than_or_equal_to: 0,
less_than_or_equal_to: 5

View File

@ -12,12 +12,33 @@ describe Metasploit::Framework::LoginScanner::Base do
end
}
subject(:login_scanner) { base_class.new }
let(:options) {
{
connection_timeout: 1,
cred_details: ["user", "pass"],
host: '1.2.3.4',
port: 4444,
stop_on_success: true,
bruteforce_speed: 5,
}
}
subject(:login_scanner) {
base_class.new(options)
}
it { should respond_to :bruteforce_speed }
context 'validations' do
it 'is valid!' do
expect(login_scanner).to be_valid
end
context 'bruteforce_speed' do
it 'is not valid for a non-number' do
login_scanner.bruteforce_speed = "a"
expect(login_scanner).to_not be_valid
@ -36,11 +57,17 @@ describe Metasploit::Framework::LoginScanner::Base do
expect(login_scanner.errors[:bruteforce_speed]).to include "must be greater than or equal to 0"
end
it 'is nil' do
login_scanner.bruteforce_speed = nil
expect(login_scanner).to be_valid
end
it 'is not greater than five' do
login_scanner.bruteforce_speed = "6"
expect(login_scanner).to_not be_valid
expect(login_scanner.errors[:bruteforce_speed]).to include "must be less than or equal to 5"
end
end
it { should respond_to :sleep_time }