File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed
lib/metasploit/framework/login_scanner
spec/lib/metasploit/framework/login_scanner Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -57,8 +57,8 @@ module Base
57
57
inclusion : { in : [ true , false ] }
58
58
59
59
validates :bruteforce_speed ,
60
- presence : false ,
61
60
numericality : {
61
+ allow_nil : true ,
62
62
only_integer : true ,
63
63
greater_than_or_equal_to : 0 ,
64
64
less_than_or_equal_to : 5
Original file line number Diff line number Diff line change @@ -12,12 +12,33 @@ def self.model_name
12
12
end
13
13
}
14
14
15
- subject ( :login_scanner ) { base_class . new }
15
+ let ( :options ) {
16
+
17
+ {
18
+ connection_timeout : 1 ,
19
+ cred_details : [ "user" , "pass" ] ,
20
+ host : '1.2.3.4' ,
21
+ port : 4444 ,
22
+ stop_on_success : true ,
23
+ bruteforce_speed : 5 ,
24
+
25
+ }
26
+ }
27
+
28
+ subject ( :login_scanner ) {
29
+ base_class . new ( options )
30
+ }
16
31
17
32
it { should respond_to :bruteforce_speed }
18
33
19
34
context 'validations' do
35
+
36
+ it 'is valid!' do
37
+ expect ( login_scanner ) . to be_valid
38
+ end
39
+
20
40
context 'bruteforce_speed' do
41
+
21
42
it 'is not valid for a non-number' do
22
43
login_scanner . bruteforce_speed = "a"
23
44
expect ( login_scanner ) . to_not be_valid
@@ -36,11 +57,17 @@ def self.model_name
36
57
expect ( login_scanner . errors [ :bruteforce_speed ] ) . to include "must be greater than or equal to 0"
37
58
end
38
59
60
+ it 'is nil' do
61
+ login_scanner . bruteforce_speed = nil
62
+ expect ( login_scanner ) . to be_valid
63
+ end
64
+
39
65
it 'is not greater than five' do
40
66
login_scanner . bruteforce_speed = "6"
41
67
expect ( login_scanner ) . to_not be_valid
42
68
expect ( login_scanner . errors [ :bruteforce_speed ] ) . to include "must be less than or equal to 5"
43
69
end
70
+
44
71
end
45
72
46
73
it { should respond_to :sleep_time }
You can’t perform that action at this time.
0 commit comments