metasploit-model 1.0.0.pre.rails.pre.4.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +2 -4
  3. data/CHANGELOG.md +6 -0
  4. data/CONTRIBUTING.md +9 -49
  5. data/Gemfile +1 -6
  6. data/RELEASING.md +89 -0
  7. data/UPGRADING.md +1 -0
  8. data/lib/metasploit/model/version.rb +23 -11
  9. data/metasploit-model.gemspec +3 -1
  10. data/spec/app/models/metasploit/model/association/reflection_spec.rb +5 -7
  11. data/spec/app/models/metasploit/model/search/group/base_spec.rb +2 -4
  12. data/spec/app/models/metasploit/model/search/group/intersection_spec.rb +2 -4
  13. data/spec/app/models/metasploit/model/search/group/union_spec.rb +2 -4
  14. data/spec/app/models/metasploit/model/search/operation/association_spec.rb +7 -9
  15. data/spec/app/models/metasploit/model/search/operation/base_spec.rb +5 -7
  16. data/spec/app/models/metasploit/model/search/operation/boolean_spec.rb +14 -11
  17. data/spec/app/models/metasploit/model/search/operation/date_spec.rb +6 -8
  18. data/spec/app/models/metasploit/model/search/operation/group/base_spec.rb +12 -14
  19. data/spec/app/models/metasploit/model/search/operation/group/intersection_spec.rb +2 -4
  20. data/spec/app/models/metasploit/model/search/operation/group/union_spec.rb +2 -4
  21. data/spec/app/models/metasploit/model/search/operation/integer_spec.rb +2 -4
  22. data/spec/app/models/metasploit/model/search/operation/null_spec.rb +4 -6
  23. data/spec/app/models/metasploit/model/search/operation/set/integer_spec.rb +2 -4
  24. data/spec/app/models/metasploit/model/search/operation/set/string_spec.rb +2 -4
  25. data/spec/app/models/metasploit/model/search/operation/set_spec.rb +4 -6
  26. data/spec/app/models/metasploit/model/search/operation/string_spec.rb +2 -4
  27. data/spec/app/models/metasploit/model/search/operator/association_spec.rb +6 -8
  28. data/spec/app/models/metasploit/model/search/operator/attribute_spec.rb +13 -15
  29. data/spec/app/models/metasploit/model/search/operator/base_spec.rb +3 -5
  30. data/spec/app/models/metasploit/model/search/operator/delegation_spec.rb +13 -11
  31. data/spec/app/models/metasploit/model/search/operator/group/base_spec.rb +5 -7
  32. data/spec/app/models/metasploit/model/search/operator/group/intersection_spec.rb +3 -5
  33. data/spec/app/models/metasploit/model/search/operator/group/union_spec.rb +3 -5
  34. data/spec/app/models/metasploit/model/search/operator/null_spec.rb +5 -7
  35. data/spec/app/models/metasploit/model/search/operator/single_spec.rb +26 -28
  36. data/spec/app/models/metasploit/model/search/query_spec.rb +48 -50
  37. data/spec/app/models/metasploit/model/visitation/visitor_spec.rb +7 -9
  38. data/spec/app/validators/ip_format_validator_spec.rb +7 -9
  39. data/spec/app/validators/nil_validator_spec.rb +3 -5
  40. data/spec/app/validators/parameters_validator_spec.rb +29 -29
  41. data/spec/app/validators/password_is_strong_validator_spec.rb +17 -19
  42. data/spec/lib/metasploit/model/association/error_spec.rb +1 -3
  43. data/spec/lib/metasploit/model/association_spec.rb +8 -10
  44. data/spec/lib/metasploit/model/base_spec.rb +3 -5
  45. data/spec/lib/metasploit/model/engine_spec.rb +48 -11
  46. data/spec/lib/metasploit/model/file_spec.rb +3 -5
  47. data/spec/lib/metasploit/model/invalid_spec.rb +7 -9
  48. data/spec/lib/metasploit/model/login/status_spec.rb +1 -3
  49. data/spec/lib/metasploit/model/nilify_blanks_spec.rb +11 -13
  50. data/spec/lib/metasploit/model/realm/key_spec.rb +15 -17
  51. data/spec/lib/metasploit/model/search/association/tree_spec.rb +3 -5
  52. data/spec/lib/metasploit/model/search/association_spec.rb +2 -4
  53. data/spec/lib/metasploit/model/search/attribute_spec.rb +6 -8
  54. data/spec/lib/metasploit/model/search/operation/value/integer_spec.rb +1 -3
  55. data/spec/lib/metasploit/model/search/operation/value/string_spec.rb +1 -3
  56. data/spec/lib/metasploit/model/search/operation_spec.rb +11 -13
  57. data/spec/lib/metasploit/model/search/operator/help_spec.rb +1 -3
  58. data/spec/lib/metasploit/model/search/with_spec.rb +7 -9
  59. data/spec/lib/metasploit/model/search_spec.rb +11 -13
  60. data/spec/lib/metasploit/model/spec/error_spec.rb +2 -4
  61. data/spec/lib/metasploit/model/spec/i18n_exception_handler_spec.rb +5 -7
  62. data/spec/lib/metasploit/model/spec/pathname_collision_spec.rb +4 -6
  63. data/spec/lib/metasploit/model/spec_spec.rb +9 -7
  64. data/spec/lib/metasploit/model/translation_spec.rb +10 -12
  65. data/spec/lib/metasploit/model/version_spec.rb +3 -139
  66. data/spec/lib/metasploit/model/visitation/visit_spec.rb +28 -26
  67. data/spec/lib/metasploit/model_spec.rb +4 -0
  68. data/spec/matchers/validate_nilness_of_spec.rb +0 -2
  69. data/spec/spec_helper.rb +80 -10
  70. data/spec/support/shared/contexts/metasploit/model/search/operator/union/children.rb +1 -1
  71. data/spec/support/shared/examples/metasploit/model/search/operation/value/integer.rb +8 -8
  72. data/spec/support/shared/examples/metasploit/model/search/operation/value/string.rb +5 -5
  73. data/spec/support/shared/examples/metasploit/model/search/operator/help.rb +18 -16
  74. data/spec/support/shared/examples/metasploit/model/translation.rb +4 -4
  75. data/spec/support/shared/examples/search/query.rb +3 -3
  76. data/spec/support/shared/examples/search_association.rb +2 -2
  77. data/spec/support/shared/examples/search_attribute.rb +3 -3
  78. data/spec/support/shared/examples/search_with.rb +3 -3
  79. metadata +43 -4
@@ -1,10 +1,8 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Visitation::Visitor do
1
+ RSpec.describe Metasploit::Model::Visitation::Visitor, type: :model do
4
2
  context 'validations' do
5
- it { should validate_presence_of :block }
6
- it { should validate_presence_of :module_name }
7
- it { should validate_presence_of :parent }
3
+ it { is_expected.to validate_presence_of :block }
4
+ it { is_expected.to validate_presence_of :module_name }
5
+ it { is_expected.to validate_presence_of :parent }
8
6
  end
9
7
 
10
8
  context '#initialize' do
@@ -31,15 +29,15 @@ describe Metasploit::Model::Visitation::Visitor do
31
29
  end
32
30
 
33
31
  it 'should set #block from &block' do
34
- instance.block.should == block
32
+ expect(instance.block).to eq(block)
35
33
  end
36
34
 
37
35
  it 'should set #module_name from :module_name' do
38
- instance.module_name.should == module_name
36
+ expect(instance.module_name).to eq(module_name)
39
37
  end
40
38
 
41
39
  it 'should set #parent from :parent' do
42
- instance.parent.should == parent
40
+ expect(instance.parent).to eq(parent)
43
41
  end
44
42
  end
45
43
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe IpFormatValidator do
1
+ RSpec.describe IpFormatValidator do
4
2
  subject(:ip_format_validator) do
5
3
  described_class.new(
6
4
  :attributes => attributes
@@ -55,7 +53,7 @@ describe IpFormatValidator do
55
53
  it 'should not record any errors' do
56
54
  validate_each
57
55
 
58
- record.errors.should be_empty
56
+ expect(record.errors).to be_empty
59
57
  end
60
58
  end
61
59
 
@@ -67,7 +65,7 @@ describe IpFormatValidator do
67
65
  it 'should not record any errors' do
68
66
  validate_each
69
67
 
70
- record.errors.should be_empty
68
+ expect(record.errors).to be_empty
71
69
  end
72
70
  end
73
71
 
@@ -79,7 +77,7 @@ describe IpFormatValidator do
79
77
  it 'should record error' do
80
78
  validate_each
81
79
 
82
- record.errors[attribute].should include("#{error} and not an IPv4 address range in CIDR or netmask notation")
80
+ expect(record.errors[attribute]).to include("#{error} and not an IPv4 address range in CIDR or netmask notation")
83
81
  end
84
82
  end
85
83
 
@@ -91,7 +89,7 @@ describe IpFormatValidator do
91
89
  it 'should record error' do
92
90
  validate_each
93
91
 
94
- record.errors[attribute].should include("#{error} and not an IPv6 address range in CIDR or netmask notation")
92
+ expect(record.errors[attribute]).to include("#{error} and not an IPv6 address range in CIDR or netmask notation")
95
93
  end
96
94
  end
97
95
 
@@ -103,7 +101,7 @@ describe IpFormatValidator do
103
101
  it 'should record error' do
104
102
  validate_each
105
103
 
106
- record.errors[attribute].should include(error)
104
+ expect(record.errors[attribute]).to include(error)
107
105
  end
108
106
  end
109
107
 
@@ -117,7 +115,7 @@ describe IpFormatValidator do
117
115
  it 'should record error on attribute' do
118
116
  validate_each
119
117
 
120
- record.errors[attribute].should include(error)
118
+ expect(record.errors[attribute]).to include(error)
121
119
  end
122
120
  end
123
121
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe NilValidator do
1
+ RSpec.describe NilValidator do
4
2
  subject(:nil_validator) do
5
3
  described_class.new(
6
4
  :attributes => attributes
@@ -50,7 +48,7 @@ describe NilValidator do
50
48
  it 'should record error on attribute' do
51
49
  validate_each
52
50
 
53
- record.errors[attribute].should include('must be nil')
51
+ expect(record.errors[attribute]).to include('must be nil')
54
52
  end
55
53
  end
56
54
 
@@ -62,7 +60,7 @@ describe NilValidator do
62
60
  it 'should not record any error' do
63
61
  validate_each
64
62
 
65
- record.errors.should be_empty
63
+ expect(record.errors).to be_empty
66
64
  end
67
65
  end
68
66
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe ParametersValidator do
1
+ RSpec.describe ParametersValidator do
4
2
  subject(:parameters_validator) do
5
3
  described_class.new(
6
4
  :attributes => attributes
@@ -29,7 +27,7 @@ describe ParametersValidator do
29
27
 
30
28
  context 'CONSTANTS' do
31
29
  it 'should define TYPE_SIGNATURE_SENTENCE' do
32
- described_class::TYPE_SIGNATURE_SENTENCE.should == type_signature_sentence
30
+ expect(described_class::TYPE_SIGNATURE_SENTENCE).to eq(type_signature_sentence)
33
31
  end
34
32
  end
35
33
 
@@ -48,7 +46,7 @@ describe ParametersValidator do
48
46
  end
49
47
 
50
48
  it 'should include prefix' do
51
- error_at.should include(prefix)
49
+ expect(error_at).to include(prefix)
52
50
  end
53
51
 
54
52
  it 'should include location_clause in same sentence as prefix' do
@@ -58,11 +56,11 @@ describe ParametersValidator do
58
56
  :index => index
59
57
  )
60
58
 
61
- error_at.should include("#{prefix} #{location_clause}.")
59
+ expect(error_at).to include("#{prefix} #{location_clause}.")
62
60
  end
63
61
 
64
62
  it 'should include TYPE_SIGNATURE_SENTENCE' do
65
- error_at.should include(type_signature_sentence)
63
+ expect(error_at).to include(type_signature_sentence)
66
64
  end
67
65
  end
68
66
 
@@ -81,9 +79,9 @@ describe ParametersValidator do
81
79
  end
82
80
 
83
81
  it 'should include extreme in prefix' do
84
- parameters_validator.should_receive(:error_at) do |*args|
82
+ expect(parameters_validator).to receive(:error_at) do |*args|
85
83
  options = args.first
86
- options[:prefix].should include(extreme.to_s)
84
+ expect(options[:prefix]).to include(extreme.to_s)
87
85
  end
88
86
 
89
87
  length_error_at
@@ -100,11 +98,11 @@ describe ParametersValidator do
100
98
  end
101
99
 
102
100
  it 'should include numerical index' do
103
- location_clause.should include("at index #{index}")
101
+ expect(location_clause).to include("at index #{index}")
104
102
  end
105
103
 
106
104
  it 'should include inspect of element' do
107
- location_clause.should include(element.inspect)
105
+ expect(location_clause).to include(element.inspect)
108
106
  end
109
107
  end
110
108
 
@@ -144,7 +142,7 @@ describe ParametersValidator do
144
142
  end
145
143
 
146
144
  it 'should call #length_error_at with :extreme => :few' do
147
- parameters_validator.should_receive(:length_error_at).with(
145
+ expect(parameters_validator).to receive(:length_error_at).with(
148
146
  hash_including(
149
147
  :extreme => :few
150
148
  )
@@ -156,7 +154,7 @@ describe ParametersValidator do
156
154
  it 'should record error' do
157
155
  validate_each
158
156
 
159
- errors.should_not be_empty
157
+ expect(errors).not_to be_empty
160
158
  end
161
159
  end
162
160
 
@@ -166,7 +164,7 @@ describe ParametersValidator do
166
164
  end
167
165
 
168
166
  it 'should call #length_error_at with :extreme => :many' do
169
- parameters_validator.should_receive(:length_error_at).with(
167
+ expect(parameters_validator).to receive(:length_error_at).with(
170
168
  hash_including(
171
169
  :extreme => :many
172
170
  )
@@ -178,7 +176,7 @@ describe ParametersValidator do
178
176
  it 'should record error' do
179
177
  validate_each
180
178
 
181
- errors.should_not be_empty
179
+ expect(errors).not_to be_empty
182
180
  end
183
181
  end
184
182
 
@@ -203,7 +201,7 @@ describe ParametersValidator do
203
201
  end
204
202
 
205
203
  it 'should call error_at with blank parameter name prefix' do
206
- parameters_validator.should_receive(:error_at).with(
204
+ expect(parameters_validator).to receive(:error_at).with(
207
205
  hash_including(
208
206
  :prefix => 'has blank parameter name'
209
207
  )
@@ -215,7 +213,7 @@ describe ParametersValidator do
215
213
  it 'should record error' do
216
214
  validate_each
217
215
 
218
- errors.should_not be_empty
216
+ expect(errors).not_to be_empty
219
217
  end
220
218
  end
221
219
 
@@ -227,7 +225,7 @@ describe ParametersValidator do
227
225
  it 'should not record error' do
228
226
  validate_each
229
227
 
230
- errors.should be_blank
228
+ expect(errors).to be_blank
231
229
  end
232
230
  end
233
231
  end
@@ -238,7 +236,7 @@ describe ParametersValidator do
238
236
  end
239
237
 
240
238
  it 'should call error_at with non-String prefix' do
241
- parameters_validator.should_receive(:error_at).with(
239
+ expect(parameters_validator).to receive(:error_at).with(
242
240
  hash_including(
243
241
  :prefix => "has non-String parameter name (#{parameter_name.inspect})"
244
242
  )
@@ -250,7 +248,7 @@ describe ParametersValidator do
250
248
  it 'should record error' do
251
249
  validate_each
252
250
 
253
- errors.should_not be_empty
251
+ expect(errors).not_to be_empty
254
252
  end
255
253
  end
256
254
  end
@@ -264,7 +262,7 @@ describe ParametersValidator do
264
262
  it 'should not record error' do
265
263
  validate_each
266
264
 
267
- errors.should be_blank
265
+ expect(errors).to be_blank
268
266
  end
269
267
  end
270
268
 
@@ -274,7 +272,7 @@ describe ParametersValidator do
274
272
  end
275
273
 
276
274
  it 'should call error_at with non-String prefix' do
277
- parameters_validator.should_receive(:error_at).with(
275
+ expect(parameters_validator).to receive(:error_at).with(
278
276
  hash_including(
279
277
  :prefix => "has non-String parameter value (#{parameter_value.inspect})"
280
278
  )
@@ -286,7 +284,7 @@ describe ParametersValidator do
286
284
  it 'should record error' do
287
285
  validate_each
288
286
 
289
- errors.should_not be_empty
287
+ expect(errors).not_to be_empty
290
288
  end
291
289
  end
292
290
  end
@@ -299,7 +297,7 @@ describe ParametersValidator do
299
297
  end
300
298
 
301
299
  it 'should use #error_at with has non-Array for prefix' do
302
- parameters_validator.should_receive(:error_at).with(
300
+ expect(parameters_validator).to receive(:error_at).with(
303
301
  hash_including(
304
302
  :prefix => 'has non-Array'
305
303
  )
@@ -311,7 +309,7 @@ describe ParametersValidator do
311
309
  it 'should record error' do
312
310
  validate_each
313
311
 
314
- errors.should_not be_empty
312
+ expect(errors).not_to be_empty
315
313
  end
316
314
  end
317
315
  end
@@ -327,14 +325,16 @@ describe ParametersValidator do
327
325
  end
328
326
 
329
327
  it 'should error that attribute is not an array' do
330
- errors.any? { |error|
331
- error.include? 'is not an Array.'
332
- }.should be_true
328
+ expect(
329
+ errors.any? { |error|
330
+ error.include? 'is not an Array.'
331
+ }
332
+ ).to eq(true)
333
333
  end
334
334
 
335
335
  it 'should include TYPE_SIGNATURE_SENTENCE' do
336
336
  errors.each do |error|
337
- error.should include(type_signature_sentence)
337
+ expect(error).to include(type_signature_sentence)
338
338
  end
339
339
  end
340
340
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe PasswordIsStrongValidator do
1
+ RSpec.describe PasswordIsStrongValidator do
4
2
  subject(:password_is_strong_validator) do
5
3
  described_class.new(
6
4
  :attributes => attributes
@@ -27,7 +25,7 @@ describe PasswordIsStrongValidator do
27
25
  'aaaaa'
28
26
  end
29
27
 
30
- it { should be_true }
28
+ it { is_expected.to eq(true) }
31
29
  end
32
30
 
33
31
  context 'with repeats of 2 characters' do
@@ -35,7 +33,7 @@ describe PasswordIsStrongValidator do
35
33
  'abab'
36
34
  end
37
35
 
38
- it { should be_true }
36
+ it { is_expected.to eq(true) }
39
37
  end
40
38
 
41
39
  context 'with repeats of 3 characters' do
@@ -43,7 +41,7 @@ describe PasswordIsStrongValidator do
43
41
  'abcabc'
44
42
  end
45
43
 
46
- it { should be_true }
44
+ it { is_expected.to eq(true) }
47
45
  end
48
46
 
49
47
  context 'with repeats of 4 characters' do
@@ -51,7 +49,7 @@ describe PasswordIsStrongValidator do
51
49
  'abcdabcd'
52
50
  end
53
51
 
54
- it { should be_true }
52
+ it { is_expected.to eq(true) }
55
53
  end
56
54
 
57
55
  context 'without any repeats' do
@@ -59,7 +57,7 @@ describe PasswordIsStrongValidator do
59
57
  'abcdefgh'
60
58
  end
61
59
 
62
- it { should be_false }
60
+ it { is_expected.to eq(false) }
63
61
  end
64
62
  end
65
63
 
@@ -77,7 +75,7 @@ describe PasswordIsStrongValidator do
77
75
  ''
78
76
  end
79
77
 
80
- it { should be_false }
78
+ it { is_expected.to eq(false) }
81
79
  end
82
80
 
83
81
  context 'without blank password' do
@@ -90,7 +88,7 @@ describe PasswordIsStrongValidator do
90
88
  ''
91
89
  end
92
90
 
93
- it { should be_false }
91
+ it { is_expected.to eq(false) }
94
92
  end
95
93
 
96
94
  context 'without blank username' do
@@ -99,7 +97,7 @@ describe PasswordIsStrongValidator do
99
97
  end
100
98
 
101
99
  it 'should escape username' do
102
- Regexp.should_receive(:escape).with(username).and_call_original
100
+ expect(Regexp).to receive(:escape).with(username).and_call_original
103
101
 
104
102
  contains_username?
105
103
  end
@@ -110,7 +108,7 @@ describe PasswordIsStrongValidator do
110
108
  username.titleize
111
109
  end
112
110
 
113
- it { should be_true }
111
+ it { is_expected.to eq(true) }
114
112
  end
115
113
 
116
114
  context 'of same case' do
@@ -118,7 +116,7 @@ describe PasswordIsStrongValidator do
118
116
  username
119
117
  end
120
118
 
121
- it { should be_true }
119
+ it { is_expected.to eq(true) }
122
120
  end
123
121
  end
124
122
  end
@@ -167,7 +165,7 @@ describe PasswordIsStrongValidator do
167
165
  it 'should not record any error' do
168
166
  validate_each
169
167
 
170
- record.errors.should be_empty
168
+ expect(record.errors).to be_empty
171
169
  end
172
170
  end
173
171
 
@@ -180,7 +178,7 @@ describe PasswordIsStrongValidator do
180
178
  it 'should record error on attributes' do
181
179
  validate_each
182
180
 
183
- record.errors[attribute].should include('must contain letters, numbers, and at least one special character')
181
+ expect(record.errors[attribute]).to include('must contain letters, numbers, and at least one special character')
184
182
  end
185
183
  end
186
184
 
@@ -201,7 +199,7 @@ describe PasswordIsStrongValidator do
201
199
  it 'should record error on attribute' do
202
200
  validate_each
203
201
 
204
- record.errors[attribute].should include('must not contain the username')
202
+ expect(record.errors[attribute]).to include('must not contain the username')
205
203
  end
206
204
  end
207
205
 
@@ -214,7 +212,7 @@ describe PasswordIsStrongValidator do
214
212
  it 'should record error on attribute' do
215
213
  validate_each
216
214
 
217
- record.errors[attribute].should include('must not be a common password')
215
+ expect(record.errors[attribute]).to include('must not be a common password')
218
216
  end
219
217
  end
220
218
 
@@ -227,7 +225,7 @@ describe PasswordIsStrongValidator do
227
225
  it 'should record error on attribute' do
228
226
  validate_each
229
227
 
230
- record.errors[attribute].should include('must not be a predictable sequence of characters')
228
+ expect(record.errors[attribute]).to include('must not be a predictable sequence of characters')
231
229
  end
232
230
  end
233
231
 
@@ -239,7 +237,7 @@ describe PasswordIsStrongValidator do
239
237
  it 'should not record any errors' do
240
238
  validate_each
241
239
 
242
- record.errors.should be_empty
240
+ expect(record.errors).to be_empty
243
241
  end
244
242
  end
245
243
  end