metasploit-model 0.30.0-java → 0.30.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -4
- data/Gemfile +1 -6
- data/lib/metasploit/model/version.rb +1 -1
- data/spec/app/models/metasploit/model/association/reflection_spec.rb +5 -7
- data/spec/app/models/metasploit/model/search/group/base_spec.rb +2 -4
- data/spec/app/models/metasploit/model/search/group/intersection_spec.rb +2 -4
- data/spec/app/models/metasploit/model/search/group/union_spec.rb +2 -4
- data/spec/app/models/metasploit/model/search/operation/association_spec.rb +7 -9
- data/spec/app/models/metasploit/model/search/operation/base_spec.rb +5 -7
- data/spec/app/models/metasploit/model/search/operation/boolean_spec.rb +14 -11
- data/spec/app/models/metasploit/model/search/operation/date_spec.rb +6 -8
- data/spec/app/models/metasploit/model/search/operation/group/base_spec.rb +12 -14
- data/spec/app/models/metasploit/model/search/operation/group/intersection_spec.rb +2 -4
- data/spec/app/models/metasploit/model/search/operation/group/union_spec.rb +2 -4
- data/spec/app/models/metasploit/model/search/operation/integer_spec.rb +2 -4
- data/spec/app/models/metasploit/model/search/operation/null_spec.rb +4 -6
- data/spec/app/models/metasploit/model/search/operation/set/integer_spec.rb +2 -4
- data/spec/app/models/metasploit/model/search/operation/set/string_spec.rb +2 -4
- data/spec/app/models/metasploit/model/search/operation/set_spec.rb +4 -6
- data/spec/app/models/metasploit/model/search/operation/string_spec.rb +2 -4
- data/spec/app/models/metasploit/model/search/operator/association_spec.rb +6 -8
- data/spec/app/models/metasploit/model/search/operator/attribute_spec.rb +12 -14
- data/spec/app/models/metasploit/model/search/operator/base_spec.rb +3 -5
- data/spec/app/models/metasploit/model/search/operator/delegation_spec.rb +13 -11
- data/spec/app/models/metasploit/model/search/operator/group/base_spec.rb +5 -7
- data/spec/app/models/metasploit/model/search/operator/group/intersection_spec.rb +3 -5
- data/spec/app/models/metasploit/model/search/operator/group/union_spec.rb +3 -5
- data/spec/app/models/metasploit/model/search/operator/null_spec.rb +5 -7
- data/spec/app/models/metasploit/model/search/operator/single_spec.rb +26 -28
- data/spec/app/models/metasploit/model/search/query_spec.rb +48 -50
- data/spec/app/models/metasploit/model/visitation/visitor_spec.rb +7 -9
- data/spec/app/validators/ip_format_validator_spec.rb +7 -9
- data/spec/app/validators/nil_validator_spec.rb +3 -5
- data/spec/app/validators/parameters_validator_spec.rb +29 -29
- data/spec/app/validators/password_is_strong_validator_spec.rb +17 -19
- data/spec/lib/metasploit/model/association/error_spec.rb +1 -3
- data/spec/lib/metasploit/model/association_spec.rb +8 -10
- data/spec/lib/metasploit/model/base_spec.rb +3 -5
- data/spec/lib/metasploit/model/engine_spec.rb +48 -11
- data/spec/lib/metasploit/model/file_spec.rb +3 -5
- data/spec/lib/metasploit/model/invalid_spec.rb +7 -9
- data/spec/lib/metasploit/model/login/status_spec.rb +1 -3
- data/spec/lib/metasploit/model/nilify_blanks_spec.rb +11 -13
- data/spec/lib/metasploit/model/realm/key_spec.rb +15 -17
- data/spec/lib/metasploit/model/search/association/tree_spec.rb +3 -5
- data/spec/lib/metasploit/model/search/association_spec.rb +2 -4
- data/spec/lib/metasploit/model/search/attribute_spec.rb +6 -8
- data/spec/lib/metasploit/model/search/operation/value/integer_spec.rb +1 -3
- data/spec/lib/metasploit/model/search/operation/value/string_spec.rb +1 -3
- data/spec/lib/metasploit/model/search/operation_spec.rb +11 -13
- data/spec/lib/metasploit/model/search/operator/help_spec.rb +1 -3
- data/spec/lib/metasploit/model/search/with_spec.rb +7 -9
- data/spec/lib/metasploit/model/search_spec.rb +11 -13
- data/spec/lib/metasploit/model/spec/error_spec.rb +2 -4
- data/spec/lib/metasploit/model/spec/i18n_exception_handler_spec.rb +5 -7
- data/spec/lib/metasploit/model/spec/pathname_collision_spec.rb +4 -6
- data/spec/lib/metasploit/model/spec_spec.rb +9 -7
- data/spec/lib/metasploit/model/translation_spec.rb +10 -12
- data/spec/lib/metasploit/model/version_spec.rb +3 -5
- data/spec/lib/metasploit/model/visitation/visit_spec.rb +28 -26
- data/spec/matchers/validate_nilness_of_spec.rb +0 -2
- data/spec/spec_helper.rb +69 -7
- data/spec/support/shared/contexts/metasploit/model/search/operator/union/children.rb +1 -1
- data/spec/support/shared/examples/metasploit/model/search/operation/value/integer.rb +8 -8
- data/spec/support/shared/examples/metasploit/model/search/operation/value/string.rb +5 -5
- data/spec/support/shared/examples/metasploit/model/search/operator/help.rb +18 -16
- data/spec/support/shared/examples/metasploit/model/translation.rb +4 -4
- data/spec/support/shared/examples/search/query.rb +3 -3
- data/spec/support/shared/examples/search_association.rb +2 -2
- data/spec/support/shared/examples/search_attribute.rb +3 -3
- data/spec/support/shared/examples/search_with.rb +3 -3
- metadata +2 -2
@@ -1,6 +1,4 @@
|
|
1
|
-
|
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].
|
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.
|
63
|
+
expect(record.errors).to be_empty
|
66
64
|
end
|
67
65
|
end
|
68
66
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
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.
|
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.
|
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.
|
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.
|
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.
|
82
|
+
expect(parameters_validator).to receive(:error_at) do |*args|
|
85
83
|
options = args.first
|
86
|
-
options[:prefix].
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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
|
-
|
331
|
-
|
332
|
-
|
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.
|
337
|
+
expect(error).to include(type_signature_sentence)
|
338
338
|
end
|
339
339
|
end
|
340
340
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
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 {
|
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 {
|
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 {
|
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 {
|
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 {
|
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 {
|
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 {
|
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.
|
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 {
|
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 {
|
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.
|
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].
|
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].
|
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].
|
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].
|
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.
|
240
|
+
expect(record.errors).to be_empty
|
243
241
|
end
|
244
242
|
end
|
245
243
|
end
|
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe Metasploit::Model::Association do
|
1
|
+
RSpec.describe Metasploit::Model::Association do
|
4
2
|
subject(:base_class) do
|
5
3
|
described_class = self.described_class
|
6
4
|
|
@@ -54,7 +52,7 @@ describe Metasploit::Model::Association do
|
|
54
52
|
end
|
55
53
|
|
56
54
|
it 'should be class on which association was called' do
|
57
|
-
model.
|
55
|
+
expect(model).to eq(base_class)
|
58
56
|
end
|
59
57
|
end
|
60
58
|
|
@@ -64,7 +62,7 @@ describe Metasploit::Model::Association do
|
|
64
62
|
end
|
65
63
|
|
66
64
|
it 'should be name passed to association as a Symbol' do
|
67
|
-
reflection_name.
|
65
|
+
expect(reflection_name).to eq(name.to_sym)
|
68
66
|
end
|
69
67
|
end
|
70
68
|
|
@@ -74,7 +72,7 @@ describe Metasploit::Model::Association do
|
|
74
72
|
end
|
75
73
|
|
76
74
|
it 'should be :class_name passed to association' do
|
77
|
-
reflection_class_name.
|
75
|
+
expect(reflection_class_name).to eq(class_name)
|
78
76
|
end
|
79
77
|
end
|
80
78
|
end
|
@@ -87,7 +85,7 @@ describe Metasploit::Model::Association do
|
|
87
85
|
end
|
88
86
|
|
89
87
|
it 'should default to empty Hash' do
|
90
|
-
association_by_name.
|
88
|
+
expect(association_by_name).to eq({})
|
91
89
|
end
|
92
90
|
end
|
93
91
|
|
@@ -119,7 +117,7 @@ describe Metasploit::Model::Association do
|
|
119
117
|
end
|
120
118
|
|
121
119
|
it 'should be class_name passed to association' do
|
122
|
-
reflection_class_name.
|
120
|
+
expect(reflection_class_name).to eq(class_name)
|
123
121
|
end
|
124
122
|
end
|
125
123
|
|
@@ -129,7 +127,7 @@ describe Metasploit::Model::Association do
|
|
129
127
|
end
|
130
128
|
|
131
129
|
it 'should have the reflected name' do
|
132
|
-
reflection.name.
|
130
|
+
expect(reflection.name).to eq(reflected_name)
|
133
131
|
end
|
134
132
|
end
|
135
133
|
end
|
@@ -139,7 +137,7 @@ describe Metasploit::Model::Association do
|
|
139
137
|
:unassociated_things
|
140
138
|
end
|
141
139
|
|
142
|
-
it {
|
140
|
+
it { is_expected.to be_nil }
|
143
141
|
end
|
144
142
|
end
|
145
143
|
end
|