metasploit_data_models 1.0.0.pre.rails.pre.4.0b → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +2 -2
  3. data/.travis.yml +6 -3
  4. data/CHANGELOG.md +6 -0
  5. data/CONTRIBUTING.md +10 -52
  6. data/Gemfile +4 -6
  7. data/RELEASING.md +88 -0
  8. data/Rakefile +23 -0
  9. data/UPGRADING.md +1 -0
  10. data/app/models/mdm/api_key.rb +41 -1
  11. data/app/models/mdm/client.rb +41 -1
  12. data/app/models/mdm/cred.rb +116 -28
  13. data/app/models/mdm/event.rb +47 -0
  14. data/app/models/mdm/exploit_attempt.rb +65 -16
  15. data/app/models/mdm/exploited_host.rb +27 -0
  16. data/app/models/mdm/host_detail.rb +44 -0
  17. data/app/models/mdm/host_tag.rb +6 -8
  18. data/app/models/mdm/listener.rb +52 -0
  19. data/app/models/mdm/macro.rb +42 -0
  20. data/app/models/mdm/mod_ref.rb +21 -1
  21. data/app/models/mdm/module/action.rb +15 -0
  22. data/app/models/mdm/module/arch.rb +10 -0
  23. data/app/models/mdm/module/author.rb +17 -1
  24. data/app/models/mdm/module/mixin.rb +13 -0
  25. data/app/models/mdm/module/platform.rb +11 -0
  26. data/app/models/mdm/module/target.rb +18 -0
  27. data/app/models/mdm/nexpose_console.rb +82 -4
  28. data/app/models/mdm/profile.rb +36 -0
  29. data/app/models/mdm/route.rb +16 -4
  30. data/app/models/mdm/session_event.rb +32 -0
  31. data/app/models/mdm/tag.rb +48 -9
  32. data/app/models/mdm/task.rb +85 -46
  33. data/app/models/mdm/task_cred.rb +29 -0
  34. data/app/models/mdm/task_host.rb +25 -0
  35. data/app/models/mdm/task_service.rb +25 -0
  36. data/app/models/mdm/task_session.rb +25 -0
  37. data/app/models/mdm/user.rb +192 -6
  38. data/app/models/mdm/vuln_attempt.rb +37 -12
  39. data/app/models/mdm/vuln_detail.rb +138 -5
  40. data/app/models/mdm/vuln_ref.rb +3 -0
  41. data/app/models/mdm/web_form.rb +34 -0
  42. data/app/models/mdm/web_page.rb +69 -0
  43. data/app/models/mdm/web_site.rb +50 -0
  44. data/app/models/mdm/wmap_request.rb +85 -0
  45. data/app/models/mdm/wmap_target.rb +40 -0
  46. data/app/models/mdm/workspace.rb +160 -17
  47. data/app/models/metasploit_data_models/automatic_exploitation/match.rb +13 -23
  48. data/app/models/metasploit_data_models/automatic_exploitation/match_result.rb +25 -4
  49. data/app/models/metasploit_data_models/automatic_exploitation/match_set.rb +15 -4
  50. data/app/models/metasploit_data_models/automatic_exploitation/run.rb +7 -3
  51. data/app/models/metasploit_data_models/ip_address/v4/segmented.rb +1 -1
  52. data/app/models/metasploit_data_models/module_run.rb +1 -1
  53. data/app/models/metasploit_data_models/search/visitor/where.rb +1 -1
  54. data/app/validators/ip_format_validator.rb +4 -0
  55. data/app/validators/parameters_validator.rb +12 -0
  56. data/app/validators/password_is_strong_validator.rb +10 -1
  57. data/lib/mdm/host/operating_system_normalization.rb +7 -10
  58. data/lib/metasploit_data_models.rb +4 -0
  59. data/lib/metasploit_data_models/automatic_exploitation.rb +25 -0
  60. data/lib/metasploit_data_models/engine.rb +2 -0
  61. data/lib/metasploit_data_models/serialized_prefs.rb +6 -0
  62. data/lib/metasploit_data_models/version.rb +30 -7
  63. data/metasploit_data_models.gemspec +9 -2
  64. data/spec/app/models/mdm/api_key_spec.rb +1 -3
  65. data/spec/app/models/mdm/client_spec.rb +9 -11
  66. data/spec/app/models/mdm/cred_spec.rb +42 -54
  67. data/spec/app/models/mdm/event_spec.rb +22 -24
  68. data/spec/app/models/mdm/exploit_attempt_spec.rb +19 -21
  69. data/spec/app/models/mdm/exploited_host_spec.rb +11 -13
  70. data/spec/app/models/mdm/host_detail_spec.rb +15 -17
  71. data/spec/app/models/mdm/host_spec.rb +262 -260
  72. data/spec/app/models/mdm/host_tag_spec.rb +6 -8
  73. data/spec/app/models/mdm/listener_spec.rb +30 -32
  74. data/spec/app/models/mdm/loot_spec.rb +21 -23
  75. data/spec/app/models/mdm/macro_spec.rb +1 -3
  76. data/spec/app/models/mdm/mod_ref_spec.rb +1 -3
  77. data/spec/app/models/mdm/module/action_spec.rb +8 -10
  78. data/spec/app/models/mdm/module/arch_spec.rb +8 -10
  79. data/spec/app/models/mdm/module/author_spec.rb +19 -14
  80. data/spec/app/models/mdm/module/detail_spec.rb +184 -75
  81. data/spec/app/models/mdm/module/mixin_spec.rb +8 -10
  82. data/spec/app/models/mdm/module/platform_spec.rb +8 -10
  83. data/spec/app/models/mdm/module/ref_spec.rb +8 -10
  84. data/spec/app/models/mdm/module/target_spec.rb +10 -12
  85. data/spec/app/models/mdm/nexpose_console_spec.rb +35 -37
  86. data/spec/app/models/mdm/note_spec.rb +23 -25
  87. data/spec/app/models/mdm/profile_spec.rb +1 -3
  88. data/spec/app/models/mdm/ref_spec.rb +9 -12
  89. data/spec/app/models/mdm/route_spec.rb +6 -8
  90. data/spec/app/models/mdm/service_spec.rb +38 -40
  91. data/spec/app/models/mdm/session_event_spec.rb +10 -12
  92. data/spec/app/models/mdm/session_spec.rb +13 -15
  93. data/spec/app/models/mdm/tag_spec.rb +29 -30
  94. data/spec/app/models/mdm/task_cred_spec.rb +9 -11
  95. data/spec/app/models/mdm/task_host_spec.rb +9 -11
  96. data/spec/app/models/mdm/task_service_spec.rb +9 -11
  97. data/spec/app/models/mdm/task_session_spec.rb +7 -9
  98. data/spec/app/models/mdm/task_spec.rb +27 -29
  99. data/spec/app/models/mdm/user_spec.rb +17 -19
  100. data/spec/app/models/mdm/vuln_attempt_spec.rb +14 -16
  101. data/spec/app/models/mdm/vuln_detail_spec.rb +26 -28
  102. data/spec/app/models/mdm/vuln_ref_spec.rb +8 -10
  103. data/spec/app/models/mdm/vuln_spec.rb +24 -26
  104. data/spec/app/models/mdm/web_form_spec.rb +11 -13
  105. data/spec/app/models/mdm/web_page_spec.rb +19 -21
  106. data/spec/app/models/mdm/web_site_spec.rb +21 -23
  107. data/spec/app/models/mdm/web_vuln_spec.rb +63 -65
  108. data/spec/app/models/mdm/wmap_request_spec.rb +1 -3
  109. data/spec/app/models/mdm/wmap_target_spec.rb +1 -3
  110. data/spec/app/models/mdm/workspace_spec.rb +97 -100
  111. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_result_spec.rb +3 -5
  112. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_set_spec.rb +13 -15
  113. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_spec.rb +1 -3
  114. data/spec/app/models/metasploit_data_models/automatic_exploitation/run_spec.rb +1 -3
  115. data/spec/app/models/metasploit_data_models/ip_address/v4/cidr_spec.rb +10 -12
  116. data/spec/app/models/metasploit_data_models/ip_address/v4/nmap_spec.rb +4 -6
  117. data/spec/app/models/metasploit_data_models/ip_address/v4/range_spec.rb +21 -23
  118. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list_spec.rb +9 -11
  119. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/range_spec.rb +21 -23
  120. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/segmented_spec.rb +4 -6
  121. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/single_spec.rb +22 -15
  122. data/spec/app/models/metasploit_data_models/ip_address/v4/single_spec.rb +4 -6
  123. data/spec/app/models/metasploit_data_models/module_run_spec.rb +1 -3
  124. data/spec/app/models/metasploit_data_models/search/operation/ip_address_spec.rb +18 -20
  125. data/spec/app/models/metasploit_data_models/search/operation/port/number_spec.rb +6 -8
  126. data/spec/app/models/metasploit_data_models/search/operation/port/range_spec.rb +8 -10
  127. data/spec/app/models/metasploit_data_models/search/operation/range_spec.rb +8 -10
  128. data/spec/app/models/metasploit_data_models/search/operator/ip_address_spec.rb +2 -4
  129. data/spec/app/models/metasploit_data_models/search/operator/multitext_spec.rb +8 -10
  130. data/spec/app/models/metasploit_data_models/search/operator/port/list_spec.rb +6 -8
  131. data/spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb +9 -11
  132. data/spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb +5 -7
  133. data/spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb +17 -19
  134. data/spec/app/models/metasploit_data_models/search/visitor/method_spec.rb +5 -7
  135. data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +61 -23
  136. data/spec/app/models/metasploit_data_models/search/visitor/where_spec.rb +8 -10
  137. data/spec/app/validators/parameters_validator_spec.rb +29 -29
  138. data/spec/app/validators/password_is_strong_validator_spec.rb +54 -46
  139. data/spec/lib/base64_serializer_spec.rb +19 -21
  140. data/spec/lib/ipaddr_spec.rb +1 -3
  141. data/spec/lib/metasploit_data_models/ip_address/cidr_spec.rb +18 -12
  142. data/spec/lib/metasploit_data_models/ip_address/range_spec.rb +4 -6
  143. data/spec/lib/metasploit_data_models/match/child_spec.rb +2 -4
  144. data/spec/lib/metasploit_data_models/match/parent_spec.rb +4 -6
  145. data/spec/lib/metasploit_data_models/version_spec.rb +3 -139
  146. data/spec/lib/metasploit_data_models_spec.rb +4 -0
  147. data/spec/spec_helper.rb +86 -12
  148. data/spec/support/shared/examples/mdm/module/detail/does_not_support_stance_with_mtype.rb +2 -2
  149. data/spec/support/shared/examples/mdm/module/detail/supports_stance_with_mtype.rb +4 -4
  150. data/spec/support/shared/examples/metasploit_data_models/search/operation/ipaddress/match.rb +2 -2
  151. data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb +5 -5
  152. data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_metasploit_model_search_operation_base.rb +5 -5
  153. data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_equality.rb +3 -3
  154. data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb +7 -6
  155. metadata +74 -14
  156. data/app/models/metasploit_data_models/automatic_exploitation.rb +0 -16
  157. data/lib/tasks/yard.rake +0 -33
@@ -1,13 +1,11 @@
1
- require 'spec_helper'
2
-
3
- describe MetasploitDataModels::IPAddress::V4::Segmented do
1
+ RSpec.describe MetasploitDataModels::IPAddress::V4::Segmented, type: :model do
4
2
  context 'CONSTANTS' do
5
3
  context 'SEGMENT_COUNT' do
6
4
  subject(:segment_count) {
7
5
  described_class::SEGMENT_COUNT
8
6
  }
9
7
 
10
- it { should == 4 }
8
+ it { is_expected.to eq(4) }
11
9
  end
12
10
 
13
11
  context 'SEPARATOR' do
@@ -15,7 +13,7 @@ describe MetasploitDataModels::IPAddress::V4::Segmented do
15
13
  described_class::SEPARATOR
16
14
  }
17
15
 
18
- it { should == '.' }
16
+ it { is_expected.to eq('.') }
19
17
  end
20
18
  end
21
19
 
@@ -24,6 +22,6 @@ describe MetasploitDataModels::IPAddress::V4::Segmented do
24
22
  described_class.segment_count
25
23
  }
26
24
 
27
- it { should == 4 }
25
+ it { is_expected.to eq(4) }
28
26
  end
29
27
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe MetasploitDataModels::IPAddress::V4::Segment::Single do
1
+ RSpec.describe MetasploitDataModels::IPAddress::V4::Segment::Single, type: :model do
4
2
  subject(:single) {
5
3
  described_class.new(
6
4
  value: formatted_value
@@ -12,7 +10,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Single do
12
10
  }
13
11
 
14
12
  context 'validations' do
15
- it { should validate_numericality_of(:value).is_greater_than_or_equal_to(0).is_less_than_or_equal_to(255).only_integer }
13
+ it { is_expected.to validate_numericality_of(:value).is_greater_than_or_equal_to(0).is_less_than_or_equal_to(255).only_integer }
16
14
  end
17
15
 
18
16
  it 'can be used in a Range' do
@@ -137,7 +135,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Single do
137
135
  described_class.bits
138
136
  }
139
137
 
140
- it { should == 8 }
138
+ it { is_expected.to eq(8) }
141
139
  end
142
140
 
143
141
  context 'match_regexp' do
@@ -159,15 +157,22 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Single do
159
157
  single <=> other
160
158
  }
161
159
 
160
+ let(:formatted_value) {
161
+ '1'
162
+ }
163
+
162
164
  let(:other) {
163
165
  double('Other')
164
166
  }
165
167
 
166
168
  it 'compares #values' do
167
169
  other_value = double('other.value')
170
+ single_value = double('single.value')
168
171
 
169
172
  expect(other).to receive(:value).and_return(other_value)
170
- expect(single.value).to receive(:<=>).with(other_value)
173
+ # have to use a double because can't expect().to receive on an Integer
174
+ expect(single).to receive(:value).and_return(single_value)
175
+ expect(single_value).to receive(:<=>).with(other_value)
171
176
 
172
177
  compare
173
178
  end
@@ -185,7 +190,9 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Single do
185
190
  }
186
191
 
187
192
  specify {
188
- expect(succ).not_to raise_error
193
+ expect {
194
+ succ
195
+ }.not_to raise_error
189
196
  }
190
197
  end
191
198
 
@@ -198,7 +205,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Single do
198
205
  1
199
206
  }
200
207
 
201
- it { should be_a described_class }
208
+ it { is_expected.to be_a described_class }
202
209
 
203
210
  context 'succ.value' do
204
211
  it 'is succ of #value' do
@@ -212,7 +219,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Single do
212
219
  'a'
213
220
  }
214
221
 
215
- it { should be_a described_class }
222
+ it { is_expected.to be_a described_class }
216
223
 
217
224
  context 'succ.value' do
218
225
  it 'is succ of #value' do
@@ -262,7 +269,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Single do
262
269
  end
263
270
 
264
271
  it 'should pass through Integer' do
265
- value.should == formatted_value
272
+ expect(value).to eq(formatted_value)
266
273
  end
267
274
  end
268
275
 
@@ -276,7 +283,7 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Single do
276
283
  end
277
284
 
278
285
  it 'should convert String to Integer' do
279
- value.should == integer
286
+ expect(value).to eq(integer)
280
287
  end
281
288
  end
282
289
 
@@ -290,11 +297,11 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Single do
290
297
  end
291
298
 
292
299
  it 'should not extract the number' do
293
- value.should_not == integer
300
+ expect(value).not_to eq(integer)
294
301
  end
295
302
 
296
303
  it 'should pass through the full value' do
297
- value.should == formatted_value
304
+ expect(value).to eq(formatted_value)
298
305
  end
299
306
  end
300
307
 
@@ -304,11 +311,11 @@ describe MetasploitDataModels::IPAddress::V4::Segment::Single do
304
311
  end
305
312
 
306
313
  it 'should not truncate Float to Integer' do
307
- value.should_not == formatted_value.to_i
314
+ expect(value).not_to eq(formatted_value.to_i)
308
315
  end
309
316
 
310
317
  it 'should pass through Float' do
311
- value.should == formatted_value
318
+ expect(value).to eq(formatted_value)
312
319
  end
313
320
  end
314
321
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe MetasploitDataModels::IPAddress::V4::Single do
1
+ RSpec.describe MetasploitDataModels::IPAddress::V4::Single, type: :model do
4
2
  subject(:single) {
5
3
  described_class.new(
6
4
  value: formatted_value
@@ -22,7 +20,7 @@ describe MetasploitDataModels::IPAddress::V4::Single do
22
20
  '1.2.3.4'
23
21
  }
24
22
 
25
- it { should be_empty }
23
+ it { is_expected.to be_empty }
26
24
  end
27
25
 
28
26
  context 'without segments' do
@@ -37,7 +35,7 @@ describe MetasploitDataModels::IPAddress::V4::Single do
37
35
  )
38
36
  }
39
37
 
40
- it { should include length_error }
38
+ it { is_expected.to include length_error }
41
39
  end
42
40
  end
43
41
  end
@@ -142,7 +140,7 @@ describe MetasploitDataModels::IPAddress::V4::Single do
142
140
  nil
143
141
  }
144
142
 
145
- it { should be_nil }
143
+ it { is_expected.to be_nil }
146
144
  end
147
145
 
148
146
  context 'with matching formatted value' do
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe MetasploitDataModels::ModuleRun do
1
+ RSpec.describe MetasploitDataModels::ModuleRun, type: :model do
4
2
 
5
3
  subject(:module_run){FactoryGirl.build(:metasploit_data_models_module_run)}
6
4
 
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe MetasploitDataModels::Search::Operation::IPAddress do
1
+ RSpec.describe MetasploitDataModels::Search::Operation::IPAddress, type: :model do
4
2
  subject(:operation) {
5
3
  described_class.new(
6
4
  operator: operator,
@@ -45,7 +43,7 @@ describe MetasploitDataModels::Search::Operation::IPAddress do
45
43
  '1.2.3.4/8'
46
44
  }
47
45
 
48
- it { should be_empty }
46
+ it { is_expected.to be_empty }
49
47
  end
50
48
 
51
49
  context 'without valid prefix_length' do
@@ -53,17 +51,17 @@ describe MetasploitDataModels::Search::Operation::IPAddress do
53
51
  '1.2.3.4/36'
54
52
  }
55
53
 
56
- it { should include invalid_error }
54
+ it { is_expected.to include invalid_error }
57
55
  end
58
56
  end
59
57
 
60
- context 'with Nmap', pending: 'MSP-10712' do
61
- context 'with valid segment range' do
58
+ context 'with Nmap' do
59
+ context 'with valid segment range', pending: 'MSP-10712' do
62
60
  let(:formatted_value) {
63
61
  '1-2.3.4.5'
64
62
  }
65
63
 
66
- it { should be_empty }
64
+ it { is_expected.to be_empty }
67
65
  end
68
66
 
69
67
  context 'without valid segment range' do
@@ -71,7 +69,7 @@ describe MetasploitDataModels::Search::Operation::IPAddress do
71
69
  '2-1.3.4.5'
72
70
  }
73
71
 
74
- it { should include invalid_error }
72
+ it { is_expected.to include invalid_error }
75
73
  end
76
74
  end
77
75
 
@@ -81,7 +79,7 @@ describe MetasploitDataModels::Search::Operation::IPAddress do
81
79
  '2.2.2.2-1.1.1.1'
82
80
  }
83
81
 
84
- it { should include invalid_error }
82
+ it { is_expected.to include invalid_error }
85
83
  end
86
84
 
87
85
  context 'without ordered range' do
@@ -89,7 +87,7 @@ describe MetasploitDataModels::Search::Operation::IPAddress do
89
87
  '1.1.1.1-2.2.2.2'
90
88
  }
91
89
 
92
- it { should be_empty }
90
+ it { is_expected.to be_empty }
93
91
  end
94
92
  end
95
93
 
@@ -107,8 +105,8 @@ describe MetasploitDataModels::Search::Operation::IPAddress do
107
105
  nil
108
106
  }
109
107
 
110
- it { should include blank_error }
111
- it { should_not include invalid_error }
108
+ it { is_expected.to include blank_error }
109
+ it { is_expected.not_to include invalid_error }
112
110
  end
113
111
 
114
112
  context 'with empty string' do
@@ -116,8 +114,8 @@ describe MetasploitDataModels::Search::Operation::IPAddress do
116
114
  ''
117
115
  }
118
116
 
119
- it { should include blank_error }
120
- it { should_not include invalid_error }
117
+ it { is_expected.to include blank_error }
118
+ it { is_expected.not_to include invalid_error }
121
119
  end
122
120
 
123
121
  context 'without matching formatted value' do
@@ -125,7 +123,7 @@ describe MetasploitDataModels::Search::Operation::IPAddress do
125
123
  'non_matching_value'
126
124
  }
127
125
 
128
- it { should include invalid_error }
126
+ it { is_expected.to include invalid_error }
129
127
  end
130
128
  end
131
129
  end
@@ -141,7 +139,7 @@ describe MetasploitDataModels::Search::Operation::IPAddress do
141
139
  '1.2.3.4/8'
142
140
  }
143
141
 
144
- it { should be_a MetasploitDataModels::IPAddress::V4::CIDR }
142
+ it { is_expected.to be_a MetasploitDataModels::IPAddress::V4::CIDR }
145
143
  end
146
144
 
147
145
  context 'with Nmap', pending: 'MSP-10712' do
@@ -149,7 +147,7 @@ describe MetasploitDataModels::Search::Operation::IPAddress do
149
147
  '1.2.3.4-5'
150
148
  }
151
149
 
152
- it { should be_a MetasploitDataModels::IPAddress::V4::Nmap }
150
+ it { is_expected.to be_a MetasploitDataModels::IPAddress::V4::Nmap }
153
151
  end
154
152
 
155
153
  context 'with Range' do
@@ -157,7 +155,7 @@ describe MetasploitDataModels::Search::Operation::IPAddress do
157
155
  '1.1.1.1-2.2.2.2'
158
156
  }
159
157
 
160
- it { should be_a MetasploitDataModels::IPAddress::V4::Range }
158
+ it { is_expected.to be_a MetasploitDataModels::IPAddress::V4::Range }
161
159
  end
162
160
 
163
161
  context 'with address' do
@@ -165,7 +163,7 @@ describe MetasploitDataModels::Search::Operation::IPAddress do
165
163
  '1.2.3.4'
166
164
  }
167
165
 
168
- it { should be_a MetasploitDataModels::IPAddress::V4::Single }
166
+ it { is_expected.to be_a MetasploitDataModels::IPAddress::V4::Single }
169
167
  end
170
168
  end
171
169
 
@@ -1,13 +1,11 @@
1
- require 'spec_helper'
2
-
3
- describe MetasploitDataModels::Search::Operation::Port::Number do
1
+ RSpec.describe MetasploitDataModels::Search::Operation::Port::Number, type: :model do
4
2
  context 'CONSTANTS' do
5
3
  context 'BITS' do
6
4
  subject(:bits) {
7
5
  described_class::BITS
8
6
  }
9
7
 
10
- it { should == 16 }
8
+ it { is_expected.to eq(16) }
11
9
  end
12
10
 
13
11
  context 'MAXIMUM' do
@@ -15,7 +13,7 @@ describe MetasploitDataModels::Search::Operation::Port::Number do
15
13
  described_class::MAXIMUM
16
14
  }
17
15
 
18
- it { should == 65535 }
16
+ it { is_expected.to eq(65535) }
19
17
  end
20
18
 
21
19
  context 'MINIMUM' do
@@ -23,7 +21,7 @@ describe MetasploitDataModels::Search::Operation::Port::Number do
23
21
  described_class::MINIMUM
24
22
  }
25
23
 
26
- it { should == 0 }
24
+ it { is_expected.to eq(0) }
27
25
  end
28
26
 
29
27
  context 'RANGE' do
@@ -31,11 +29,11 @@ describe MetasploitDataModels::Search::Operation::Port::Number do
31
29
  described_class::RANGE
32
30
  }
33
31
 
34
- it { should == (0..65535) }
32
+ it { is_expected.to eq((0..65535)) }
35
33
  end
36
34
  end
37
35
 
38
36
  context 'validations' do
39
- it { should validate_inclusion_of(:value).in_range(described_class::RANGE) }
37
+ it { is_expected.to validate_inclusion_of(:value).in_range(described_class::RANGE) }
40
38
  end
41
39
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe MetasploitDataModels::Search::Operation::Port::Range do
1
+ RSpec.describe MetasploitDataModels::Search::Operation::Port::Range, type: :model do
4
2
  subject(:port_range_operation) {
5
3
  described_class.new(
6
4
  value: formatted_value
@@ -11,7 +9,7 @@ describe MetasploitDataModels::Search::Operation::Port::Range do
11
9
  '1'
12
10
  }
13
11
 
14
- it { should be_a MetasploitDataModels::Search::Operation::Range }
12
+ it { is_expected.to be_a MetasploitDataModels::Search::Operation::Range }
15
13
 
16
14
  context 'validations' do
17
15
  before(:each) do
@@ -30,7 +28,7 @@ describe MetasploitDataModels::Search::Operation::Port::Range do
30
28
  '1-2'
31
29
  }
32
30
 
33
- it { should be_empty }
31
+ it { is_expected.to be_empty }
34
32
  end
35
33
 
36
34
  # this can't actually happen because the minimum is 0 and a negative number can't be parsed, but validation
@@ -64,7 +62,7 @@ describe MetasploitDataModels::Search::Operation::Port::Range do
64
62
  1
65
63
  }
66
64
 
67
- it { should include error }
65
+ it { is_expected.to include error }
68
66
  end
69
67
 
70
68
  context 'without Range#begin covered by MetasploitDataModels::Search::Operation::Port::Number::RANGE' do
@@ -86,7 +84,7 @@ describe MetasploitDataModels::Search::Operation::Port::Range do
86
84
  MetasploitDataModels::Search::Operation::Port::Number::MAXIMUM + 1
87
85
  }
88
86
 
89
- it { should include error }
87
+ it { is_expected.to include error }
90
88
  end
91
89
  end
92
90
 
@@ -119,8 +117,8 @@ describe MetasploitDataModels::Search::Operation::Port::Range do
119
117
  'b'
120
118
  }
121
119
 
122
- it { should include begin_error }
123
- it { should include end_error }
120
+ it { is_expected.to include begin_error }
121
+ it { is_expected.to include end_error }
124
122
  end
125
123
  end
126
124
 
@@ -133,7 +131,7 @@ describe MetasploitDataModels::Search::Operation::Port::Range do
133
131
  '1'
134
132
  }
135
133
 
136
- it { should include(error) }
134
+ it { is_expected.to include(error) }
137
135
  end
138
136
  end
139
137
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe MetasploitDataModels::Search::Operation::Range do
1
+ RSpec.describe MetasploitDataModels::Search::Operation::Range, type: :model do
4
2
  subject(:range_operation) {
5
3
  described_class.new(attributes)
6
4
  }
@@ -11,7 +9,7 @@ describe MetasploitDataModels::Search::Operation::Range do
11
9
  described_class::SEPARATOR
12
10
  }
13
11
 
14
- it { should == '-' }
12
+ it { is_expected.to eq('-') }
15
13
  end
16
14
  end
17
15
 
@@ -57,7 +55,7 @@ describe MetasploitDataModels::Search::Operation::Range do
57
55
  '1-2'
58
56
  }
59
57
 
60
- it { should_not include(error) }
58
+ it { is_expected.not_to include(error) }
61
59
  end
62
60
 
63
61
  context 'with begin same as end' do
@@ -72,7 +70,7 @@ describe MetasploitDataModels::Search::Operation::Range do
72
70
  '1-1'
73
71
  }
74
72
 
75
- it { should_not include(error) }
73
+ it { is_expected.not_to include(error) }
76
74
  end
77
75
 
78
76
  context 'with begin after end' do
@@ -87,7 +85,7 @@ describe MetasploitDataModels::Search::Operation::Range do
87
85
  '2-1'
88
86
  }
89
87
 
90
- it { should include error }
88
+ it { is_expected.to include error }
91
89
  end
92
90
  end
93
91
 
@@ -103,7 +101,7 @@ describe MetasploitDataModels::Search::Operation::Range do
103
101
  '1..2'
104
102
  }
105
103
 
106
- it { should_not include(error) }
104
+ it { is_expected.not_to include(error) }
107
105
  end
108
106
  end
109
107
 
@@ -113,7 +111,7 @@ describe MetasploitDataModels::Search::Operation::Range do
113
111
  '1-2'
114
112
  }
115
113
 
116
- it { should be_empty }
114
+ it { is_expected.to be_empty }
117
115
  end
118
116
 
119
117
  context 'without Range' do
@@ -125,7 +123,7 @@ describe MetasploitDataModels::Search::Operation::Range do
125
123
  '1..2'
126
124
  }
127
125
 
128
- it { should include error }
126
+ it { is_expected.to include error }
129
127
  end
130
128
  end
131
129
  end