metasploit_data_models 0.24.0 → 0.24.1.pre.rspec.pre.3.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +3 -3
  3. data/Gemfile +1 -3
  4. data/app/models/metasploit_data_models/ip_address/v4/segmented.rb +1 -1
  5. data/app/models/metasploit_data_models/search/visitor/where.rb +1 -1
  6. data/app/validators/password_is_strong_validator.rb +1 -1
  7. data/lib/mdm/host/operating_system_normalization.rb +0 -10
  8. data/lib/metasploit_data_models/version.rb +2 -2
  9. data/metasploit_data_models.gemspec +1 -1
  10. data/spec/app/models/mdm/api_key_spec.rb +1 -3
  11. data/spec/app/models/mdm/client_spec.rb +9 -11
  12. data/spec/app/models/mdm/cred_spec.rb +42 -54
  13. data/spec/app/models/mdm/event_spec.rb +21 -23
  14. data/spec/app/models/mdm/exploit_attempt_spec.rb +19 -21
  15. data/spec/app/models/mdm/exploited_host_spec.rb +11 -13
  16. data/spec/app/models/mdm/host_detail_spec.rb +15 -17
  17. data/spec/app/models/mdm/host_spec.rb +261 -260
  18. data/spec/app/models/mdm/host_tag_spec.rb +6 -8
  19. data/spec/app/models/mdm/listener_spec.rb +30 -32
  20. data/spec/app/models/mdm/loot_spec.rb +21 -23
  21. data/spec/app/models/mdm/macro_spec.rb +1 -3
  22. data/spec/app/models/mdm/mod_ref_spec.rb +1 -3
  23. data/spec/app/models/mdm/module/action_spec.rb +10 -12
  24. data/spec/app/models/mdm/module/arch_spec.rb +10 -12
  25. data/spec/app/models/mdm/module/author_spec.rb +22 -17
  26. data/spec/app/models/mdm/module/detail_spec.rb +184 -75
  27. data/spec/app/models/mdm/module/mixin_spec.rb +10 -12
  28. data/spec/app/models/mdm/module/platform_spec.rb +10 -12
  29. data/spec/app/models/mdm/module/ref_spec.rb +10 -12
  30. data/spec/app/models/mdm/module/target_spec.rb +13 -15
  31. data/spec/app/models/mdm/nexpose_console_spec.rb +35 -37
  32. data/spec/app/models/mdm/note_spec.rb +23 -25
  33. data/spec/app/models/mdm/profile_spec.rb +1 -3
  34. data/spec/app/models/mdm/ref_spec.rb +10 -12
  35. data/spec/app/models/mdm/route_spec.rb +6 -8
  36. data/spec/app/models/mdm/service_spec.rb +38 -40
  37. data/spec/app/models/mdm/session_event_spec.rb +10 -12
  38. data/spec/app/models/mdm/session_spec.rb +13 -15
  39. data/spec/app/models/mdm/tag_spec.rb +29 -29
  40. data/spec/app/models/mdm/task_cred_spec.rb +9 -11
  41. data/spec/app/models/mdm/task_host_spec.rb +9 -11
  42. data/spec/app/models/mdm/task_service_spec.rb +9 -11
  43. data/spec/app/models/mdm/task_session_spec.rb +7 -9
  44. data/spec/app/models/mdm/task_spec.rb +27 -29
  45. data/spec/app/models/mdm/user_spec.rb +17 -19
  46. data/spec/app/models/mdm/vuln_attempt_spec.rb +14 -16
  47. data/spec/app/models/mdm/vuln_detail_spec.rb +26 -28
  48. data/spec/app/models/mdm/vuln_ref_spec.rb +8 -10
  49. data/spec/app/models/mdm/vuln_spec.rb +24 -26
  50. data/spec/app/models/mdm/web_form_spec.rb +11 -13
  51. data/spec/app/models/mdm/web_page_spec.rb +19 -21
  52. data/spec/app/models/mdm/web_site_spec.rb +21 -23
  53. data/spec/app/models/mdm/web_vuln_spec.rb +63 -65
  54. data/spec/app/models/mdm/wmap_request_spec.rb +1 -3
  55. data/spec/app/models/mdm/wmap_target_spec.rb +1 -3
  56. data/spec/app/models/mdm/workspace_spec.rb +97 -100
  57. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_result_spec.rb +3 -5
  58. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_set_spec.rb +13 -15
  59. data/spec/app/models/metasploit_data_models/automatic_exploitation/match_spec.rb +1 -3
  60. data/spec/app/models/metasploit_data_models/automatic_exploitation/run_spec.rb +1 -3
  61. data/spec/app/models/metasploit_data_models/ip_address/v4/cidr_spec.rb +10 -12
  62. data/spec/app/models/metasploit_data_models/ip_address/v4/nmap_spec.rb +4 -6
  63. data/spec/app/models/metasploit_data_models/ip_address/v4/range_spec.rb +21 -23
  64. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list_spec.rb +9 -11
  65. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/range_spec.rb +21 -23
  66. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/segmented_spec.rb +4 -6
  67. data/spec/app/models/metasploit_data_models/ip_address/v4/segment/single_spec.rb +22 -15
  68. data/spec/app/models/metasploit_data_models/ip_address/v4/single_spec.rb +4 -6
  69. data/spec/app/models/metasploit_data_models/module_run_spec.rb +1 -3
  70. data/spec/app/models/metasploit_data_models/search/operation/ip_address_spec.rb +18 -20
  71. data/spec/app/models/metasploit_data_models/search/operation/port/number_spec.rb +6 -8
  72. data/spec/app/models/metasploit_data_models/search/operation/port/range_spec.rb +8 -10
  73. data/spec/app/models/metasploit_data_models/search/operation/range_spec.rb +8 -10
  74. data/spec/app/models/metasploit_data_models/search/operator/ip_address_spec.rb +2 -4
  75. data/spec/app/models/metasploit_data_models/search/operator/multitext_spec.rb +8 -10
  76. data/spec/app/models/metasploit_data_models/search/operator/port/list_spec.rb +6 -8
  77. data/spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb +9 -11
  78. data/spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb +5 -7
  79. data/spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb +17 -19
  80. data/spec/app/models/metasploit_data_models/search/visitor/method_spec.rb +5 -7
  81. data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +61 -23
  82. data/spec/app/models/metasploit_data_models/search/visitor/where_spec.rb +8 -10
  83. data/spec/app/validators/parameters_validator_spec.rb +29 -29
  84. data/spec/app/validators/password_is_strong_validator_spec.rb +54 -46
  85. data/spec/dummy/db/structure.sql +1 -0
  86. data/spec/lib/base64_serializer_spec.rb +19 -19
  87. data/spec/lib/metasploit_data_models/ip_address/cidr_spec.rb +18 -12
  88. data/spec/lib/metasploit_data_models/ip_address/range_spec.rb +4 -6
  89. data/spec/lib/metasploit_data_models/match/child_spec.rb +2 -4
  90. data/spec/lib/metasploit_data_models/match/parent_spec.rb +4 -6
  91. data/spec/lib/metasploit_data_models/version_spec.rb +3 -5
  92. data/spec/spec_helper.rb +72 -6
  93. data/spec/support/shared/examples/mdm/module/detail/does_not_support_stance_with_mtype.rb +2 -2
  94. data/spec/support/shared/examples/mdm/module/detail/supports_stance_with_mtype.rb +4 -4
  95. data/spec/support/shared/examples/metasploit_data_models/search/operation/ipaddress/match.rb +2 -2
  96. data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb +5 -5
  97. data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_metasploit_model_search_operation_base.rb +5 -5
  98. data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_equality.rb +3 -3
  99. data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb +7 -6
  100. metadata +6 -6
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::VulnRef do
1
+ RSpec.describe Mdm::VulnRef, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
 
6
4
  context 'factories' do
@@ -9,27 +7,27 @@ describe Mdm::VulnRef do
9
7
  FactoryGirl.build(:mdm_vuln_ref)
10
8
  end
11
9
 
12
- it { should be_valid }
10
+ it { is_expected.to be_valid }
13
11
  end
14
12
  end
15
13
 
16
14
  context 'database' do
17
15
  context 'columns' do
18
- it { should have_db_column(:id).of_type(:integer) }
19
- it { should have_db_column(:ref_id).of_type(:integer) }
20
- it { should have_db_column(:vuln_id).of_type(:integer) }
16
+ it { is_expected.to have_db_column(:id).of_type(:integer) }
17
+ it { is_expected.to have_db_column(:ref_id).of_type(:integer) }
18
+ it { is_expected.to have_db_column(:vuln_id).of_type(:integer) }
21
19
  end
22
20
  end
23
21
 
24
22
  context 'associations' do
25
- it { should belong_to(:vuln).class_name('Mdm::Vuln') }
26
- it { should belong_to(:ref).class_name('Mdm::Ref') }
23
+ it { is_expected.to belong_to(:vuln).class_name('Mdm::Vuln') }
24
+ it { is_expected.to belong_to(:ref).class_name('Mdm::Ref') }
27
25
  end
28
26
 
29
27
  context 'factory' do
30
28
  it 'should be valid' do
31
29
  vuln_ref = FactoryGirl.build(:mdm_vuln_ref)
32
- vuln_ref.should be_valid
30
+ expect(vuln_ref).to be_valid
33
31
  end
34
32
  end
35
33
 
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::Vuln do
1
+ RSpec.describe Mdm::Vuln, type: :model do
4
2
  subject(:vuln) do
5
3
  FactoryGirl.build(:mdm_vuln)
6
4
  end
@@ -44,7 +42,7 @@ describe Mdm::Vuln do
44
42
  it { is_expected.to have_many(:notes).class_name('Mdm::Note').dependent(:delete_all).order('notes.created_at') }
45
43
 
46
44
  context 'module_details' do
47
- it { should have_many(:module_details).class_name('Mdm::Module::Detail').through(:module_refs) }
45
+ it { is_expected.to have_many(:module_details).class_name('Mdm::Module::Detail').through(:module_refs) }
48
46
 
49
47
  context 'with Mdm::Refs' do
50
48
  let(:names) do
@@ -114,8 +112,8 @@ describe Mdm::Vuln do
114
112
  module_details << module_ref.detail
115
113
  end
116
114
 
117
- vuln.module_details.count.should < module_details.length
118
- module_details.uniq.count.should == vuln.module_details.count
115
+ expect(vuln.module_details.count).to be < module_details.length
116
+ expect(module_details.uniq.count).to eq(vuln.module_details.count)
119
117
  end
120
118
  end
121
119
  end
@@ -126,20 +124,20 @@ describe Mdm::Vuln do
126
124
 
127
125
  context 'database' do
128
126
  context 'columns' do
129
- it { should have_db_column(:exploited_at).of_type(:datetime) }
130
- it { should have_db_column(:host_id).of_type(:integer) }
131
- it { should have_db_column(:info).of_type(:string) }
132
- it { should have_db_column(:name).of_type(:string) }
133
- it { should have_db_column(:service_id).of_type(:integer) }
127
+ it { is_expected.to have_db_column(:exploited_at).of_type(:datetime) }
128
+ it { is_expected.to have_db_column(:host_id).of_type(:integer) }
129
+ it { is_expected.to have_db_column(:info).of_type(:string) }
130
+ it { is_expected.to have_db_column(:name).of_type(:string) }
131
+ it { is_expected.to have_db_column(:service_id).of_type(:integer) }
134
132
 
135
133
  context 'counter caches' do
136
- it { should have_db_column(:vuln_attempt_count).of_type(:integer).with_options(:default => 0) }
137
- it { should have_db_column(:vuln_detail_count).of_type(:integer).with_options(:default => 0) }
134
+ it { is_expected.to have_db_column(:vuln_attempt_count).of_type(:integer).with_options(:default => 0) }
135
+ it { is_expected.to have_db_column(:vuln_detail_count).of_type(:integer).with_options(:default => 0) }
138
136
  end
139
137
 
140
138
  context 'timestamps' do
141
- it { should have_db_column(:created_at).of_type(:datetime) }
142
- it { should have_db_column(:updated_at).of_type(:datetime) }
139
+ it { is_expected.to have_db_column(:created_at).of_type(:datetime) }
140
+ it { is_expected.to have_db_column(:updated_at).of_type(:datetime) }
143
141
  end
144
142
  end
145
143
  end
@@ -150,7 +148,7 @@ describe Mdm::Vuln do
150
148
  FactoryGirl.build(:mdm_host_vuln)
151
149
  end
152
150
 
153
- it { should be_valid }
151
+ it { is_expected.to be_valid }
154
152
  end
155
153
 
156
154
  context 'mdm_service_vuln' do
@@ -158,7 +156,7 @@ describe Mdm::Vuln do
158
156
  FactoryGirl.build(:mdm_service_vuln)
159
157
  end
160
158
 
161
- it { should be_valid }
159
+ it { is_expected.to be_valid }
162
160
  end
163
161
 
164
162
  context 'mdm_vuln' do
@@ -166,7 +164,7 @@ describe Mdm::Vuln do
166
164
  FactoryGirl.build(:mdm_vuln)
167
165
  end
168
166
 
169
- it { should be_valid }
167
+ it { is_expected.to be_valid }
170
168
  end
171
169
  end
172
170
 
@@ -197,7 +195,7 @@ describe Mdm::Vuln do
197
195
  end
198
196
 
199
197
  it 'should match Mdm::Vuln' do
200
- results.should =~ [vuln]
198
+ expect(results).to match_array [vuln]
201
199
  end
202
200
  end
203
201
 
@@ -207,7 +205,7 @@ describe Mdm::Vuln do
207
205
  end
208
206
 
209
207
  it 'should not match Mdm::Vuln' do
210
- results.should be_empty
208
+ expect(results).to be_empty
211
209
  end
212
210
  end
213
211
  end
@@ -219,7 +217,7 @@ describe Mdm::Vuln do
219
217
  end
220
218
 
221
219
  it 'should match Mdm::Vuln' do
222
- results.should =~ [vuln]
220
+ expect(results).to match_array [vuln]
223
221
  end
224
222
  end
225
223
 
@@ -229,7 +227,7 @@ describe Mdm::Vuln do
229
227
  end
230
228
 
231
229
  it 'should not match Mdm::Vuln' do
232
- results.should be_empty
230
+ expect(results).to be_empty
233
231
  end
234
232
  end
235
233
 
@@ -239,7 +237,7 @@ describe Mdm::Vuln do
239
237
  end
240
238
 
241
239
  it 'should match Mdm::Vuln' do
242
- results.should =~ [vuln]
240
+ expect(results).to match_array [vuln]
243
241
  end
244
242
  end
245
243
 
@@ -249,7 +247,7 @@ describe Mdm::Vuln do
249
247
  end
250
248
 
251
249
  it 'should not match Mdm::Vuln' do
252
- results.should be_empty
250
+ expect(results).to be_empty
253
251
  end
254
252
  end
255
253
  end
@@ -259,7 +257,7 @@ describe Mdm::Vuln do
259
257
  end
260
258
 
261
259
  context 'validations' do
262
- it { should validate_presence_of :name }
260
+ it { is_expected.to validate_presence_of :name }
263
261
 
264
262
  context "invalid" do
265
263
  let(:mdm_vuln) do
@@ -270,7 +268,7 @@ describe Mdm::Vuln do
270
268
  str = Faker::Lorem.characters(256)
271
269
  mdm_vuln.name = str
272
270
  mdm_vuln.valid?
273
- mdm_vuln.errors[:name][0].should include "is too long"
271
+ expect(mdm_vuln.errors[:name][0]).to include "is too long"
274
272
  end
275
273
  end
276
274
  end
@@ -1,36 +1,34 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::WebForm do
1
+ RSpec.describe Mdm::WebForm, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
 
6
4
  context 'associations' do
7
- it { should belong_to(:web_site).class_name('Mdm::WebSite') }
5
+ it { is_expected.to belong_to(:web_site).class_name('Mdm::WebSite') }
8
6
  end
9
7
 
10
8
  context 'database' do
11
9
 
12
10
  context 'timestamps'do
13
- it { should have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
14
- it { should have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
11
+ it { is_expected.to have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
12
+ it { is_expected.to have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
15
13
  end
16
14
 
17
15
  context 'columns' do
18
- it { should have_db_column(:web_site_id).of_type(:integer).with_options(:null => false) }
19
- it { should have_db_column(:path).of_type(:text) }
20
- it { should have_db_column(:method).of_type(:string) }
21
- it { should have_db_column(:params).of_type(:text) }
22
- it { should have_db_column(:query).of_type(:text) }
16
+ it { is_expected.to have_db_column(:web_site_id).of_type(:integer).with_options(:null => false) }
17
+ it { is_expected.to have_db_column(:path).of_type(:text) }
18
+ it { is_expected.to have_db_column(:method).of_type(:string) }
19
+ it { is_expected.to have_db_column(:params).of_type(:text) }
20
+ it { is_expected.to have_db_column(:query).of_type(:text) }
23
21
  end
24
22
 
25
23
  context 'indices' do
26
- it { should have_db_index(:path) }
24
+ it { is_expected.to have_db_index(:path) }
27
25
  end
28
26
  end
29
27
 
30
28
  context 'factory' do
31
29
  it 'should be valid' do
32
30
  web_form = FactoryGirl.build(:mdm_web_form)
33
- web_form.should be_valid
31
+ expect(web_form).to be_valid
34
32
  end
35
33
  end
36
34
 
@@ -1,44 +1,42 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::WebPage do
1
+ RSpec.describe Mdm::WebPage, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
 
6
4
  context 'associations' do
7
- it { should belong_to(:web_site).class_name('Mdm::WebSite') }
5
+ it { is_expected.to belong_to(:web_site).class_name('Mdm::WebSite') }
8
6
  end
9
7
 
10
8
  context 'database' do
11
9
 
12
10
  context 'timestamps'do
13
- it { should have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
14
- it { should have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
15
- it { should have_db_column(:mtime).of_type(:datetime) }
11
+ it { is_expected.to have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
12
+ it { is_expected.to have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
13
+ it { is_expected.to have_db_column(:mtime).of_type(:datetime) }
16
14
  end
17
15
 
18
16
  context 'columns' do
19
- it { should have_db_column(:web_site_id).of_type(:integer).with_options(:null => false) }
20
- it { should have_db_column(:path).of_type(:text) }
21
- it { should have_db_column(:query).of_type(:text) }
22
- it { should have_db_column(:code).of_type(:integer).with_options(:null => false) }
23
- it { should have_db_column(:cookie).of_type(:text) }
24
- it { should have_db_column(:auth).of_type(:text) }
25
- it { should have_db_column(:ctype).of_type(:text) }
26
- it { should have_db_column(:location).of_type(:text) }
27
- it { should have_db_column(:headers).of_type(:text) }
28
- it { should have_db_column(:body).of_type(:binary) }
29
- it { should have_db_column(:request).of_type(:binary) }
17
+ it { is_expected.to have_db_column(:web_site_id).of_type(:integer).with_options(:null => false) }
18
+ it { is_expected.to have_db_column(:path).of_type(:text) }
19
+ it { is_expected.to have_db_column(:query).of_type(:text) }
20
+ it { is_expected.to have_db_column(:code).of_type(:integer).with_options(:null => false) }
21
+ it { is_expected.to have_db_column(:cookie).of_type(:text) }
22
+ it { is_expected.to have_db_column(:auth).of_type(:text) }
23
+ it { is_expected.to have_db_column(:ctype).of_type(:text) }
24
+ it { is_expected.to have_db_column(:location).of_type(:text) }
25
+ it { is_expected.to have_db_column(:headers).of_type(:text) }
26
+ it { is_expected.to have_db_column(:body).of_type(:binary) }
27
+ it { is_expected.to have_db_column(:request).of_type(:binary) }
30
28
  end
31
29
 
32
30
  context 'indices' do
33
- it { should have_db_index(:path) }
34
- it { should have_db_index(:query) }
31
+ it { is_expected.to have_db_index(:path) }
32
+ it { is_expected.to have_db_index(:query) }
35
33
  end
36
34
  end
37
35
 
38
36
  context 'factory' do
39
37
  it 'should be valid' do
40
38
  web_page = FactoryGirl.build(:mdm_web_page)
41
- web_page.should be_valid
39
+ expect(web_page).to be_valid
42
40
  end
43
41
  end
44
42
 
@@ -1,33 +1,31 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::WebSite do
1
+ RSpec.describe Mdm::WebSite, type: :model do
4
2
  it_should_behave_like 'Metasploit::Concern.run'
5
3
 
6
4
  context 'factory' do
7
5
  it 'should be valid' do
8
6
  web_site = FactoryGirl.build(:mdm_web_site)
9
- web_site.should be_valid
7
+ expect(web_site).to be_valid
10
8
  end
11
9
  end
12
10
 
13
11
  context 'database' do
14
12
 
15
13
  context 'timestamps'do
16
- it { should have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
17
- it { should have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
14
+ it { is_expected.to have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
15
+ it { is_expected.to have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
18
16
  end
19
17
 
20
18
  context 'columns' do
21
- it { should have_db_column(:service_id).of_type(:integer).with_options(:null => false) }
22
- it { should have_db_column(:vhost).of_type(:string) }
23
- it { should have_db_column(:comments).of_type(:text) }
24
- it { should have_db_column(:options).of_type(:text) }
19
+ it { is_expected.to have_db_column(:service_id).of_type(:integer).with_options(:null => false) }
20
+ it { is_expected.to have_db_column(:vhost).of_type(:string) }
21
+ it { is_expected.to have_db_column(:comments).of_type(:text) }
22
+ it { is_expected.to have_db_column(:options).of_type(:text) }
25
23
  end
26
24
 
27
25
  context 'indices' do
28
- it { should have_db_index(:comments) }
29
- it { should have_db_index(:options) }
30
- it { should have_db_index(:vhost) }
26
+ it { is_expected.to have_db_index(:comments) }
27
+ it { is_expected.to have_db_index(:options) }
28
+ it { is_expected.to have_db_index(:vhost) }
31
29
  end
32
30
  end
33
31
 
@@ -44,10 +42,10 @@ describe Mdm::WebSite do
44
42
  end
45
43
 
46
44
  context 'associations' do
47
- it { should belong_to(:service).class_name('Mdm::Service') }
48
- it { should have_many(:web_forms).class_name('Mdm::WebForm').dependent(:destroy) }
49
- it { should have_many(:web_pages).class_name('Mdm::WebPage').dependent(:destroy) }
50
- it { should have_many(:web_vulns).class_name('Mdm::WebVuln').dependent(:destroy) }
45
+ it { is_expected.to belong_to(:service).class_name('Mdm::Service') }
46
+ it { is_expected.to have_many(:web_forms).class_name('Mdm::WebForm').dependent(:destroy) }
47
+ it { is_expected.to have_many(:web_pages).class_name('Mdm::WebPage').dependent(:destroy) }
48
+ it { is_expected.to have_many(:web_vulns).class_name('Mdm::WebVuln').dependent(:destroy) }
51
49
  end
52
50
 
53
51
  context 'methods' do
@@ -56,9 +54,9 @@ describe Mdm::WebSite do
56
54
  mysite = FactoryGirl.create(:mdm_web_site)
57
55
  FactoryGirl.create(:mdm_web_form, :web_site => mysite)
58
56
  FactoryGirl.create(:mdm_web_form, :web_site => mysite)
59
- mysite.form_count.should == 2
57
+ expect(mysite.form_count).to eq(2)
60
58
  FactoryGirl.create(:mdm_web_form, :web_site => mysite)
61
- mysite.form_count.should == 3
59
+ expect(mysite.form_count).to eq(3)
62
60
  end
63
61
  end
64
62
 
@@ -67,9 +65,9 @@ describe Mdm::WebSite do
67
65
  mysite = FactoryGirl.create(:mdm_web_site)
68
66
  FactoryGirl.create(:mdm_web_page, :web_site => mysite)
69
67
  FactoryGirl.create(:mdm_web_page, :web_site => mysite)
70
- mysite.page_count.should == 2
68
+ expect(mysite.page_count).to eq(2)
71
69
  FactoryGirl.create(:mdm_web_page, :web_site => mysite)
72
- mysite.page_count.should == 3
70
+ expect(mysite.page_count).to eq(3)
73
71
  end
74
72
  end
75
73
 
@@ -78,9 +76,9 @@ describe Mdm::WebSite do
78
76
  mysite = FactoryGirl.create(:mdm_web_site)
79
77
  FactoryGirl.create(:mdm_web_vuln, :web_site => mysite)
80
78
  FactoryGirl.create(:mdm_web_vuln, :web_site => mysite)
81
- mysite.vuln_count.should == 2
79
+ expect(mysite.vuln_count).to eq(2)
82
80
  FactoryGirl.create(:mdm_web_vuln, :web_site => mysite)
83
- mysite.vuln_count.should == 3
81
+ expect(mysite.vuln_count).to eq(3)
84
82
  end
85
83
  end
86
84
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Mdm::WebVuln do
1
+ RSpec.describe Mdm::WebVuln, type: :model do
4
2
  let(:confidence_range) do
5
3
  0 .. 100
6
4
  end
@@ -29,20 +27,20 @@ describe Mdm::WebVuln do
29
27
  it_should_behave_like 'Metasploit::Concern.run'
30
28
 
31
29
  context 'associations' do
32
- it { should belong_to(:web_site).class_name('Mdm::WebSite') }
30
+ it { is_expected.to belong_to(:web_site).class_name('Mdm::WebSite') }
33
31
  end
34
32
 
35
33
  context 'CONSTANTS' do
36
34
  it 'should define CONFIDENCE_RANGE' do
37
- described_class::CONFIDENCE_RANGE.should == confidence_range
35
+ expect(described_class::CONFIDENCE_RANGE).to eq(confidence_range)
38
36
  end
39
37
 
40
38
  it 'should define METHODS in any order' do
41
- described_class::METHODS.should =~ methods
39
+ expect(described_class::METHODS).to match_array methods
42
40
  end
43
41
 
44
42
  it 'should define RISK_RANGE' do
45
- described_class::RISK_RANGE.should == risk_range
43
+ expect(described_class::RISK_RANGE).to eq(risk_range)
46
44
  end
47
45
  end
48
46
 
@@ -60,33 +58,33 @@ describe Mdm::WebVuln do
60
58
 
61
59
  context 'database' do
62
60
  context 'columns' do
63
- it { should have_db_column(:blame).of_type(:text) }
64
- it { should have_db_column(:category).of_type(:text).with_options(:null => false) }
65
- it { should have_db_column(:confidence).of_type(:integer).with_options(:null => false) }
66
- it { should have_db_column(:description).of_type(:text) }
67
- it { should have_db_column(:method).of_type(:string).with_options(:limit => 1024, :null => false) }
68
- it { should have_db_column(:name).of_type(:string).with_options(:limit => 1024, :null => false) }
69
- it { should have_db_column(:owner).of_type(:string) }
70
- it { should have_db_column(:params).of_type(:text).with_options(:null => false) }
71
- it { should have_db_column(:path).of_type(:text).with_options(:null => false) }
72
- it { should have_db_column(:payload).of_type(:text) }
73
- it { should have_db_column(:pname).of_type(:text) }
74
- it { should have_db_column(:proof).of_type(:binary).with_options(:null => false) }
75
- it { should have_db_column(:query).of_type(:text) }
76
- it { should have_db_column(:request).of_type(:binary) }
77
- it { should have_db_column(:risk).of_type(:integer).with_options(:null => false) }
78
- it { should have_db_column(:web_site_id).of_type(:integer).with_options(:null => false) }
61
+ it { is_expected.to have_db_column(:blame).of_type(:text) }
62
+ it { is_expected.to have_db_column(:category).of_type(:text).with_options(:null => false) }
63
+ it { is_expected.to have_db_column(:confidence).of_type(:integer).with_options(:null => false) }
64
+ it { is_expected.to have_db_column(:description).of_type(:text) }
65
+ it { is_expected.to have_db_column(:method).of_type(:string).with_options(:limit => 1024, :null => false) }
66
+ it { is_expected.to have_db_column(:name).of_type(:string).with_options(:limit => 1024, :null => false) }
67
+ it { is_expected.to have_db_column(:owner).of_type(:string) }
68
+ it { is_expected.to have_db_column(:params).of_type(:text).with_options(:null => false) }
69
+ it { is_expected.to have_db_column(:path).of_type(:text).with_options(:null => false) }
70
+ it { is_expected.to have_db_column(:payload).of_type(:text) }
71
+ it { is_expected.to have_db_column(:pname).of_type(:text) }
72
+ it { is_expected.to have_db_column(:proof).of_type(:binary).with_options(:null => false) }
73
+ it { is_expected.to have_db_column(:query).of_type(:text) }
74
+ it { is_expected.to have_db_column(:request).of_type(:binary) }
75
+ it { is_expected.to have_db_column(:risk).of_type(:integer).with_options(:null => false) }
76
+ it { is_expected.to have_db_column(:web_site_id).of_type(:integer).with_options(:null => false) }
79
77
 
80
78
  context 'timestamps' do
81
- it { should have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
82
- it { should have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
79
+ it { is_expected.to have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
80
+ it { is_expected.to have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
83
81
  end
84
82
  end
85
83
 
86
84
  context 'indices' do
87
- it { should have_db_index(:method) }
88
- it { should have_db_index(:name) }
89
- it { should have_db_index(:path) }
85
+ it { is_expected.to have_db_index(:method) }
86
+ it { is_expected.to have_db_index(:name) }
87
+ it { is_expected.to have_db_index(:path) }
90
88
  end
91
89
  end
92
90
 
@@ -96,7 +94,7 @@ describe Mdm::WebVuln do
96
94
  FactoryGirl.build(:mdm_web_vuln)
97
95
  end
98
96
 
99
- it { should be_valid }
97
+ it { is_expected.to be_valid }
100
98
 
101
99
  context 'after reloading' do
102
100
  before(:each) do
@@ -104,21 +102,21 @@ describe Mdm::WebVuln do
104
102
  mdm_web_vuln.reload
105
103
  end
106
104
 
107
- it { should be_valid }
105
+ it { is_expected.to be_valid }
108
106
  end
109
107
  end
110
108
  end
111
109
 
112
110
  context 'validations' do
113
- it { should validate_presence_of :category }
114
- it { should ensure_inclusion_of(:confidence).in_range(confidence_range) }
115
- it { should ensure_inclusion_of(:method).in_array(methods) }
116
- it { should validate_presence_of :name }
117
- it { should validate_presence_of :path }
111
+ it { is_expected.to validate_presence_of :category }
112
+ it { is_expected.to ensure_inclusion_of(:confidence).in_range(confidence_range) }
113
+ it { is_expected.to ensure_inclusion_of(:method).in_array(methods) }
114
+ it { is_expected.to validate_presence_of :name }
115
+ it { is_expected.to validate_presence_of :path }
118
116
 
119
117
  context 'params' do
120
118
  it 'should not validate presence of params because it default to [] and can never be nil' do
121
- web_vuln.should_not validate_presence_of(:params)
119
+ expect(web_vuln).not_to validate_presence_of(:params)
122
120
  end
123
121
 
124
122
  context 'validates parameters' do
@@ -129,9 +127,9 @@ describe Mdm::WebVuln do
129
127
  it 'should validate params is an Array' do
130
128
  web_vuln.params = ''
131
129
 
132
- web_vuln.params.should_not be_an Array
133
- web_vuln.should_not be_valid
134
- web_vuln.errors[:params].should include(
130
+ expect(web_vuln.params).not_to be_an Array
131
+ expect(web_vuln).not_to be_valid
132
+ expect(web_vuln.errors[:params]).to include(
135
133
  "is not an Array. #{type_signature_sentence}"
136
134
  )
137
135
  end
@@ -140,7 +138,7 @@ describe Mdm::WebVuln do
140
138
  web_vuln.params = []
141
139
  web_vuln.valid?
142
140
 
143
- web_vuln.errors[:params].should be_empty
141
+ expect(web_vuln.errors[:params]).to be_empty
144
142
  end
145
143
 
146
144
  context 'with bad element' do
@@ -158,12 +156,12 @@ describe Mdm::WebVuln do
158
156
  end
159
157
 
160
158
  it 'should not be an Array' do
161
- web_vuln.params.first.should_not be_an Array
159
+ expect(web_vuln.params.first).not_to be_an Array
162
160
  end
163
161
 
164
162
  it 'should validate elements of params are Arrays' do
165
- web_vuln.should_not be_valid
166
- web_vuln.errors[:params].should include(
163
+ expect(web_vuln).not_to be_valid
164
+ expect(web_vuln.errors[:params]).to include(
167
165
  "has non-Array at index #{index} (#{element.inspect}). " \
168
166
  "#{type_signature_sentence}"
169
167
  )
@@ -176,12 +174,12 @@ describe Mdm::WebVuln do
176
174
  end
177
175
 
178
176
  it 'should have length < 2' do
179
- web_vuln.params.first.length.should < 2
177
+ expect(web_vuln.params.first.length).to be < 2
180
178
  end
181
179
 
182
180
  it 'should validate elements of params are not too short' do
183
- web_vuln.should_not be_valid
184
- web_vuln.errors[:params].should include(
181
+ expect(web_vuln).not_to be_valid
182
+ expect(web_vuln.errors[:params]).to include(
185
183
  "has too few elements at index #{index} (#{element.inspect}). " \
186
184
  "#{type_signature_sentence}"
187
185
  )
@@ -194,12 +192,12 @@ describe Mdm::WebVuln do
194
192
  end
195
193
 
196
194
  it 'should have length > 2' do
197
- web_vuln.params.first.length.should > 2
195
+ expect(web_vuln.params.first.length).to be > 2
198
196
  end
199
197
 
200
198
  it 'should validate elements of params are not too long' do
201
- web_vuln.should_not be_valid
202
- web_vuln.errors[:params].should include(
199
+ expect(web_vuln).not_to be_valid
200
+ expect(web_vuln.errors[:params]).to include(
203
201
  "has too many elements at index #{index} (#{element.inspect}). " \
204
202
  "#{type_signature_sentence}"
205
203
  )
@@ -218,12 +216,12 @@ describe Mdm::WebVuln do
218
216
  end
219
217
 
220
218
  it 'should have blank parameter name' do
221
- web_vuln.params.first.first.should be_empty
219
+ expect(web_vuln.params.first.first).to be_empty
222
220
  end
223
221
 
224
222
  it 'should validate that parameter name is not empty' do
225
- web_vuln.should_not be_valid
226
- web_vuln.errors[:params].should include(
223
+ expect(web_vuln).not_to be_valid
224
+ expect(web_vuln.errors[:params]).to include(
227
225
  "has blank parameter name at index #{index} " \
228
226
  "(#{element.inspect}). " \
229
227
  "#{type_signature_sentence}"
@@ -238,12 +236,12 @@ describe Mdm::WebVuln do
238
236
  end
239
237
 
240
238
  it 'should not have String for parameter name' do
241
- web_vuln.params.first.first.should_not be_a String
239
+ expect(web_vuln.params.first.first).not_to be_a String
242
240
  end
243
241
 
244
242
  it 'should validate that parameter name is a String' do
245
- web_vuln.should_not be_valid
246
- web_vuln.errors[:params].should include(
243
+ expect(web_vuln).not_to be_valid
244
+ expect(web_vuln.errors[:params]).to include(
247
245
  "has non-String parameter name (#{parameter_name.inspect}) " \
248
246
  "at index #{index} (#{element.inspect}). " \
249
247
  "#{type_signature_sentence}"
@@ -263,12 +261,12 @@ describe Mdm::WebVuln do
263
261
  end
264
262
 
265
263
  it 'should not have String for parameter name' do
266
- web_vuln.params.first.second.should_not be_a String
264
+ expect(web_vuln.params.first.second).not_to be_a String
267
265
  end
268
266
 
269
267
  it 'should validate that parameter value is a String' do
270
- web_vuln.should_not be_valid
271
- web_vuln.errors[:params].should include(
268
+ expect(web_vuln).not_to be_valid
269
+ expect(web_vuln.errors[:params]).to include(
272
270
  "has non-String parameter value (#{parameter_value}) " \
273
271
  "at index #{index} (#{element.inspect}). " \
274
272
  "#{type_signature_sentence}"
@@ -280,13 +278,13 @@ describe Mdm::WebVuln do
280
278
  end
281
279
  end
282
280
 
283
- it { should validate_presence_of :proof }
284
- it { should ensure_inclusion_of(:risk).in_range(risk_range) }
285
- it { should validate_presence_of :web_site }
281
+ it { is_expected.to validate_presence_of :proof }
282
+ it { is_expected.to ensure_inclusion_of(:risk).in_range(risk_range) }
283
+ it { is_expected.to validate_presence_of :web_site }
286
284
  end
287
285
 
288
286
  context 'serializations' do
289
- it { should serialize(:params).as_instance_of(MetasploitDataModels::Base64Serializer) }
287
+ it { is_expected.to serialize(:params).as_instance_of(MetasploitDataModels::Base64Serializer) }
290
288
  end
291
289
 
292
290
  context '#params' do
@@ -299,12 +297,12 @@ describe Mdm::WebVuln do
299
297
  end
300
298
 
301
299
  it 'should default to []' do
302
- params.should == default
300
+ expect(params).to eq(default)
303
301
  end
304
302
 
305
303
  it 'should return default if set to nil' do
306
304
  web_vuln.params = nil
307
- web_vuln.params.should == default
305
+ expect(web_vuln.params).to eq(default)
308
306
  end
309
307
 
310
308
  it 'should return default if set to nil and saved' do
@@ -312,7 +310,7 @@ describe Mdm::WebVuln do
312
310
  web_vuln.params = nil
313
311
  web_vuln.save!
314
312
 
315
- web_vuln.params.should == default
313
+ expect(web_vuln.params).to eq(default)
316
314
  end
317
315
  end
318
316
  end