specs for port validation

created specs for port validation

MSP-9683
bug/bundler_fix
David Maloney 2014-04-15 17:25:55 -05:00
parent 02a17b8612
commit 60c879c824
No known key found for this signature in database
GPG Key ID: DEDBA9DC3A913DB2
1 changed files with 42 additions and 4 deletions

View File

@ -1,10 +1,48 @@
require 'spec_helper'
require 'msf/core/auxiliary/login_scanner/ssh'
require 'metasploit/framework/login_scanner/ssh'
describe Msf::Auxiliary::LoginScanner::SSH do
describe Metasploit::Framework::LoginScanner::SSH do
it 'should do something' do
subject(:ssh_scanner) {
described_class.new
}
true.should == false
it { should respond_to :port }
it { should respond_to :host }
it { should respond_to :cred_pairs }
context 'validations' do
context 'port' do
it 'is not valid for a non-number' do
ssh_scanner.port = "a"
expect(ssh_scanner).to_not be_valid
expect(ssh_scanner.errors[:port]).to include "is not a number"
end
it 'is not valid for a floating point' do
ssh_scanner.port = 5.76
expect(ssh_scanner).to_not be_valid
expect(ssh_scanner.errors[:port]).to include "must be an integer"
end
it 'is not valid for a negative number' do
ssh_scanner.port = -8
expect(ssh_scanner).to_not be_valid
expect(ssh_scanner.errors[:port]).to include "must be greater than or equal to 1"
end
it 'is not valid for 0' do
ssh_scanner.port = 0
expect(ssh_scanner).to_not be_valid
expect(ssh_scanner.errors[:port]).to include "must be greater than or equal to 1"
end
it 'is not valid for a number greater than 65535' do
ssh_scanner.port = rand(1000) + 65535
expect(ssh_scanner).to_not be_valid
expect(ssh_scanner.errors[:port]).to include "must be less than or equal to 65535"
end
end
end
end