metasploit-model 0.30.2 → 1.0.0.pre.rails.pre.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +4 -2
- data/CONTRIBUTING.md +49 -9
- data/Gemfile +8 -3
- data/lib/metasploit/model.rb +5 -0
- data/lib/metasploit/model/engine.rb +1 -1
- data/lib/metasploit/model/version.rb +14 -26
- data/metasploit-model.gemspec +5 -3
- data/spec/app/models/metasploit/model/association/reflection_spec.rb +7 -5
- data/spec/app/models/metasploit/model/search/group/base_spec.rb +4 -2
- data/spec/app/models/metasploit/model/search/group/intersection_spec.rb +4 -2
- data/spec/app/models/metasploit/model/search/group/union_spec.rb +4 -2
- data/spec/app/models/metasploit/model/search/operation/association_spec.rb +9 -7
- data/spec/app/models/metasploit/model/search/operation/base_spec.rb +7 -5
- data/spec/app/models/metasploit/model/search/operation/boolean_spec.rb +11 -14
- data/spec/app/models/metasploit/model/search/operation/date_spec.rb +8 -6
- data/spec/app/models/metasploit/model/search/operation/group/base_spec.rb +14 -12
- data/spec/app/models/metasploit/model/search/operation/group/intersection_spec.rb +4 -2
- data/spec/app/models/metasploit/model/search/operation/group/union_spec.rb +4 -2
- data/spec/app/models/metasploit/model/search/operation/integer_spec.rb +4 -2
- data/spec/app/models/metasploit/model/search/operation/null_spec.rb +6 -4
- data/spec/app/models/metasploit/model/search/operation/set/integer_spec.rb +4 -2
- data/spec/app/models/metasploit/model/search/operation/set/string_spec.rb +4 -2
- data/spec/app/models/metasploit/model/search/operation/set_spec.rb +6 -4
- data/spec/app/models/metasploit/model/search/operation/string_spec.rb +4 -2
- data/spec/app/models/metasploit/model/search/operator/association_spec.rb +8 -6
- data/spec/app/models/metasploit/model/search/operator/attribute_spec.rb +14 -12
- data/spec/app/models/metasploit/model/search/operator/base_spec.rb +5 -3
- data/spec/app/models/metasploit/model/search/operator/delegation_spec.rb +11 -13
- data/spec/app/models/metasploit/model/search/operator/group/base_spec.rb +7 -5
- data/spec/app/models/metasploit/model/search/operator/group/intersection_spec.rb +5 -3
- data/spec/app/models/metasploit/model/search/operator/group/union_spec.rb +5 -3
- data/spec/app/models/metasploit/model/search/operator/null_spec.rb +7 -5
- data/spec/app/models/metasploit/model/search/operator/single_spec.rb +28 -26
- data/spec/app/models/metasploit/model/search/query_spec.rb +50 -48
- data/spec/app/models/metasploit/model/visitation/visitor_spec.rb +9 -7
- data/spec/app/validators/ip_format_validator_spec.rb +9 -7
- data/spec/app/validators/nil_validator_spec.rb +5 -3
- data/spec/app/validators/parameters_validator_spec.rb +29 -29
- data/spec/app/validators/password_is_strong_validator_spec.rb +19 -17
- data/spec/dummy/config/application.rb +3 -1
- data/spec/dummy/config/environments/development.rb +0 -3
- data/spec/lib/metasploit/model/association/error_spec.rb +3 -1
- data/spec/lib/metasploit/model/association_spec.rb +10 -8
- data/spec/lib/metasploit/model/base_spec.rb +5 -3
- data/spec/lib/metasploit/model/engine_spec.rb +11 -48
- data/spec/lib/metasploit/model/file_spec.rb +5 -3
- data/spec/lib/metasploit/model/invalid_spec.rb +9 -7
- data/spec/lib/metasploit/model/login/status_spec.rb +3 -1
- data/spec/lib/metasploit/model/nilify_blanks_spec.rb +13 -11
- data/spec/lib/metasploit/model/realm/key_spec.rb +17 -15
- data/spec/lib/metasploit/model/search/association/tree_spec.rb +5 -3
- data/spec/lib/metasploit/model/search/association_spec.rb +4 -2
- data/spec/lib/metasploit/model/search/attribute_spec.rb +8 -6
- data/spec/lib/metasploit/model/search/operation/value/integer_spec.rb +3 -1
- data/spec/lib/metasploit/model/search/operation/value/string_spec.rb +3 -1
- data/spec/lib/metasploit/model/search/operation_spec.rb +13 -11
- data/spec/lib/metasploit/model/search/operator/help_spec.rb +3 -1
- data/spec/lib/metasploit/model/search/with_spec.rb +9 -7
- data/spec/lib/metasploit/model/search_spec.rb +13 -11
- data/spec/lib/metasploit/model/spec/error_spec.rb +4 -2
- data/spec/lib/metasploit/model/spec/i18n_exception_handler_spec.rb +7 -5
- data/spec/lib/metasploit/model/spec/pathname_collision_spec.rb +6 -4
- data/spec/lib/metasploit/model/spec_spec.rb +7 -9
- data/spec/lib/metasploit/model/translation_spec.rb +12 -10
- data/spec/lib/metasploit/model/version_spec.rb +139 -3
- data/spec/lib/metasploit/model/visitation/visit_spec.rb +26 -28
- data/spec/matchers/validate_nilness_of_spec.rb +2 -0
- data/spec/spec_helper.rb +10 -80
- 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 +16 -18
- 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 +20 -27
- data/CHANGELOG.md +0 -6
- data/RELEASING.md +0 -86
- data/UPGRADING.md +0 -1
- data/spec/lib/metasploit/model_spec.rb +0 -4
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Metasploit::Model::Search::Operator::Group::Base do
|
2
4
|
subject(:operator) do
|
3
5
|
described_class.new
|
4
6
|
end
|
@@ -48,10 +50,10 @@ RSpec.describe Metasploit::Model::Search::Operator::Group::Base, type: :model do
|
|
48
50
|
#
|
49
51
|
|
50
52
|
before(:each) do
|
51
|
-
|
53
|
+
operator.stub(:children => children)
|
52
54
|
end
|
53
55
|
|
54
|
-
it {
|
56
|
+
it { should be_a Metasploit::Model::Search::Operation::Group::Base }
|
55
57
|
|
56
58
|
context 'children' do
|
57
59
|
subject(:operation_children) do
|
@@ -73,7 +75,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Group::Base, type: :model do
|
|
73
75
|
end
|
74
76
|
|
75
77
|
it 'should be the operator itself' do
|
76
|
-
|
78
|
+
operation_operator.should == operator
|
77
79
|
end
|
78
80
|
end
|
79
81
|
|
@@ -83,7 +85,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Group::Base, type: :model do
|
|
83
85
|
end
|
84
86
|
|
85
87
|
it 'should be formatted value' do
|
86
|
-
|
88
|
+
value.should == formatted_value
|
87
89
|
end
|
88
90
|
end
|
89
91
|
end
|
@@ -1,11 +1,13 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Metasploit::Model::Search::Operator::Group::Intersection do
|
4
|
+
it { should be_a Metasploit::Model::Search::Operator::Group::Base }
|
3
5
|
|
4
6
|
context 'operation_class_name' do
|
5
7
|
subject(:operation_class_name) {
|
6
8
|
described_class.operation_class_name
|
7
9
|
}
|
8
10
|
|
9
|
-
it {
|
11
|
+
it { should == 'Metasploit::Model::Search::Operation::Group::Intersection' }
|
10
12
|
end
|
11
13
|
end
|
@@ -1,11 +1,13 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Metasploit::Model::Search::Operator::Group::Union do
|
4
|
+
it { should be_a Metasploit::Model::Search::Operator::Group::Base }
|
3
5
|
|
4
6
|
context 'operation_class_name' do
|
5
7
|
subject(:operation_class_name) {
|
6
8
|
described_class.operation_class_name
|
7
9
|
}
|
8
10
|
|
9
|
-
it {
|
11
|
+
it { should == 'Metasploit::Model::Search::Operation::Group::Union' }
|
10
12
|
end
|
11
13
|
end
|
@@ -1,9 +1,11 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Metasploit::Model::Search::Operator::Null do
|
2
4
|
subject(:operator) do
|
3
5
|
described_class.new
|
4
6
|
end
|
5
7
|
|
6
|
-
it {
|
8
|
+
it { should be_a Metasploit::Model::Search::Operator::Single }
|
7
9
|
|
8
10
|
context 'validations' do
|
9
11
|
context 'name' do
|
@@ -16,7 +18,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Null, type: :model do
|
|
16
18
|
end
|
17
19
|
|
18
20
|
it 'should record error' do
|
19
|
-
|
21
|
+
operator.errors[:name].should include(error)
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|
@@ -26,7 +28,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Null, type: :model do
|
|
26
28
|
operator.type
|
27
29
|
end
|
28
30
|
|
29
|
-
it {
|
31
|
+
it { should be_nil }
|
30
32
|
end
|
31
33
|
|
32
34
|
context '#operation_class' do
|
@@ -34,6 +36,6 @@ RSpec.describe Metasploit::Model::Search::Operator::Null, type: :model do
|
|
34
36
|
operator.send(:operation_class)
|
35
37
|
end
|
36
38
|
|
37
|
-
it {
|
39
|
+
it { should == Metasploit::Model::Search::Operation::Null }
|
38
40
|
end
|
39
41
|
end
|
@@ -1,9 +1,11 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Metasploit::Model::Search::Operator::Single do
|
2
4
|
subject(:operator) do
|
3
5
|
described_class.new
|
4
6
|
end
|
5
7
|
|
6
|
-
it {
|
8
|
+
it { should be_a Metasploit::Model::Search::Operator::Base }
|
7
9
|
|
8
10
|
context 'CONSTANTS' do
|
9
11
|
context 'MODULE_SEPARATOR' do
|
@@ -11,7 +13,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Single, type: :model do
|
|
11
13
|
described_class::MODULE_SEPARATOR
|
12
14
|
end
|
13
15
|
|
14
|
-
it {
|
16
|
+
it { should == '::' }
|
15
17
|
end
|
16
18
|
|
17
19
|
context 'OPERATION_NAMESPACE_NAME' do
|
@@ -19,7 +21,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Single, type: :model do
|
|
19
21
|
described_class::OPERATION_NAMESPACE_NAME
|
20
22
|
end
|
21
23
|
|
22
|
-
it {
|
24
|
+
it { should == 'Metasploit::Model::Search::Operation' }
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
@@ -65,7 +67,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Single, type: :model do
|
|
65
67
|
end
|
66
68
|
|
67
69
|
it 'should be the constant_name of the key and value separated by MODULE_SEPARATOR' do
|
68
|
-
|
70
|
+
constant_name.should == "#{key_constant_name}#{described_class::MODULE_SEPARATOR}#{value_constant_name}"
|
69
71
|
end
|
70
72
|
end
|
71
73
|
|
@@ -91,7 +93,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Single, type: :model do
|
|
91
93
|
end
|
92
94
|
|
93
95
|
it 'should constantize string version of Symbol' do
|
94
|
-
|
96
|
+
constant_name.should == 'Integer'
|
95
97
|
end
|
96
98
|
end
|
97
99
|
|
@@ -122,20 +124,20 @@ RSpec.describe Metasploit::Model::Search::Operator::Single, type: :model do
|
|
122
124
|
end
|
123
125
|
|
124
126
|
before(:each) do
|
125
|
-
|
127
|
+
operator.stub(:operation_class => operation_class)
|
126
128
|
end
|
127
129
|
|
128
130
|
it 'should call new on #operation_class' do
|
129
|
-
|
131
|
+
operation_class.should_receive(:new).with(:value => formatted_value, :operator => operator)
|
130
132
|
|
131
133
|
operate_on
|
132
134
|
end
|
133
135
|
|
134
136
|
it 'should return instance of #operation_class' do
|
135
137
|
operation = double('Operation')
|
136
|
-
|
138
|
+
operation_class.stub(:new => operation)
|
137
139
|
|
138
|
-
|
140
|
+
operate_on.should == operation
|
139
141
|
end
|
140
142
|
end
|
141
143
|
|
@@ -145,7 +147,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Single, type: :model do
|
|
145
147
|
end
|
146
148
|
|
147
149
|
before(:each) do
|
148
|
-
|
150
|
+
operator.stub(:type => type)
|
149
151
|
end
|
150
152
|
|
151
153
|
context 'type' do
|
@@ -154,7 +156,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Single, type: :model do
|
|
154
156
|
:boolean
|
155
157
|
end
|
156
158
|
|
157
|
-
it {
|
159
|
+
it { should == Metasploit::Model::Search::Operation::Boolean }
|
158
160
|
end
|
159
161
|
|
160
162
|
context 'with :date' do
|
@@ -162,7 +164,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Single, type: :model do
|
|
162
164
|
:date
|
163
165
|
end
|
164
166
|
|
165
|
-
it {
|
167
|
+
it { should == Metasploit::Model::Search::Operation::Date }
|
166
168
|
end
|
167
169
|
|
168
170
|
context 'with set: :integer' do
|
@@ -172,7 +174,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Single, type: :model do
|
|
172
174
|
}
|
173
175
|
end
|
174
176
|
|
175
|
-
it {
|
177
|
+
it { should == Metasploit::Model::Search::Operation::Set::Integer }
|
176
178
|
end
|
177
179
|
|
178
180
|
context 'with set: :string' do
|
@@ -182,7 +184,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Single, type: :model do
|
|
182
184
|
}
|
183
185
|
end
|
184
186
|
|
185
|
-
it {
|
187
|
+
it { should == Metasploit::Model::Search::Operation::Set::String }
|
186
188
|
end
|
187
189
|
|
188
190
|
context 'with :integer' do
|
@@ -190,7 +192,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Single, type: :model do
|
|
190
192
|
:integer
|
191
193
|
end
|
192
194
|
|
193
|
-
it {
|
195
|
+
it { should == Metasploit::Model::Search::Operation::Integer }
|
194
196
|
end
|
195
197
|
|
196
198
|
context 'with :string' do
|
@@ -198,7 +200,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Single, type: :model do
|
|
198
200
|
:string
|
199
201
|
end
|
200
202
|
|
201
|
-
it {
|
203
|
+
it { should == Metasploit::Model::Search::Operation::String }
|
202
204
|
end
|
203
205
|
|
204
206
|
context 'with nil' do
|
@@ -211,7 +213,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Single, type: :model do
|
|
211
213
|
end
|
212
214
|
|
213
215
|
before(:each) do
|
214
|
-
|
216
|
+
operator.stub(:name => name)
|
215
217
|
end
|
216
218
|
|
217
219
|
it 'should raise ArgumentError' do
|
@@ -231,7 +233,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Single, type: :model do
|
|
231
233
|
end
|
232
234
|
|
233
235
|
before(:each) do
|
234
|
-
|
236
|
+
operator.stub(:type => type)
|
235
237
|
end
|
236
238
|
|
237
239
|
context 'type' do
|
@@ -240,7 +242,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Single, type: :model do
|
|
240
242
|
:boolean
|
241
243
|
end
|
242
244
|
|
243
|
-
it {
|
245
|
+
it { should == 'Metasploit::Model::Search::Operation::Boolean' }
|
244
246
|
end
|
245
247
|
|
246
248
|
context 'with :date' do
|
@@ -248,7 +250,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Single, type: :model do
|
|
248
250
|
:date
|
249
251
|
end
|
250
252
|
|
251
|
-
it {
|
253
|
+
it { should == 'Metasploit::Model::Search::Operation::Date' }
|
252
254
|
end
|
253
255
|
|
254
256
|
context 'with set: :integer' do
|
@@ -258,7 +260,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Single, type: :model do
|
|
258
260
|
}
|
259
261
|
end
|
260
262
|
|
261
|
-
it {
|
263
|
+
it { should == 'Metasploit::Model::Search::Operation::Set::Integer' }
|
262
264
|
end
|
263
265
|
|
264
266
|
context 'with set: :string' do
|
@@ -268,7 +270,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Single, type: :model do
|
|
268
270
|
}
|
269
271
|
end
|
270
272
|
|
271
|
-
it {
|
273
|
+
it { should == 'Metasploit::Model::Search::Operation::Set::String' }
|
272
274
|
end
|
273
275
|
|
274
276
|
context 'with :integer' do
|
@@ -276,7 +278,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Single, type: :model do
|
|
276
278
|
:integer
|
277
279
|
end
|
278
280
|
|
279
|
-
it {
|
281
|
+
it { should == 'Metasploit::Model::Search::Operation::Integer' }
|
280
282
|
end
|
281
283
|
|
282
284
|
context 'with :string' do
|
@@ -284,7 +286,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Single, type: :model do
|
|
284
286
|
:string
|
285
287
|
end
|
286
288
|
|
287
|
-
it {
|
289
|
+
it { should == 'Metasploit::Model::Search::Operation::String' }
|
288
290
|
end
|
289
291
|
|
290
292
|
context 'with nil' do
|
@@ -297,7 +299,7 @@ RSpec.describe Metasploit::Model::Search::Operator::Single, type: :model do
|
|
297
299
|
end
|
298
300
|
|
299
301
|
before(:each) do
|
300
|
-
|
302
|
+
operator.stub(:name => name)
|
301
303
|
end
|
302
304
|
|
303
305
|
it 'should raise ArgumentError' do
|
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Metasploit::Model::Search::Query do
|
2
4
|
context 'validations' do
|
3
|
-
it {
|
5
|
+
it { should validate_presence_of :klass }
|
4
6
|
|
5
7
|
context 'operations' do
|
6
8
|
let(:errors) do
|
@@ -43,11 +45,11 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
43
45
|
end
|
44
46
|
|
45
47
|
it 'should have no operations' do
|
46
|
-
|
48
|
+
query.operations.length.should == 0
|
47
49
|
end
|
48
50
|
|
49
51
|
it 'should record error on operations' do
|
50
|
-
|
52
|
+
errors.should include(error)
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
@@ -57,7 +59,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
57
59
|
end
|
58
60
|
|
59
61
|
it 'should not record error on operations' do
|
60
|
-
|
62
|
+
errors.should_not include(error)
|
61
63
|
end
|
62
64
|
end
|
63
65
|
end
|
@@ -73,7 +75,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
73
75
|
|
74
76
|
before(:each) do
|
75
77
|
operation = double('Invalid Operation', :valid? => valid)
|
76
|
-
|
78
|
+
query.stub(:operations).and_return([operation])
|
77
79
|
end
|
78
80
|
|
79
81
|
context 'with invalid operation' do
|
@@ -82,7 +84,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
82
84
|
end
|
83
85
|
|
84
86
|
it 'should record error on operations' do
|
85
|
-
|
87
|
+
errors.should_not include(error)
|
86
88
|
end
|
87
89
|
end
|
88
90
|
|
@@ -92,7 +94,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
92
94
|
end
|
93
95
|
|
94
96
|
it 'should not record error on options' do
|
95
|
-
|
97
|
+
errors.should_not include(error)
|
96
98
|
end
|
97
99
|
end
|
98
100
|
end
|
@@ -115,11 +117,11 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
115
117
|
end
|
116
118
|
|
117
119
|
it 'should include operation with space in value' do
|
118
|
-
|
120
|
+
formatted_operations.should include('formatted_operator1:formatted value:1')
|
119
121
|
end
|
120
122
|
|
121
123
|
it 'should include operation without space in value' do
|
122
|
-
|
124
|
+
formatted_operations.should include('formatted_operator2:formatted_value2')
|
123
125
|
end
|
124
126
|
end
|
125
127
|
|
@@ -170,7 +172,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
170
172
|
end
|
171
173
|
|
172
174
|
it 'should equal attribute passed to #initialize' do
|
173
|
-
|
175
|
+
formatted_operations.should == expected_formatted_operations
|
174
176
|
end
|
175
177
|
end
|
176
178
|
|
@@ -206,7 +208,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
206
208
|
end
|
207
209
|
|
208
210
|
it 'should parse #formatted with formatted_operations' do
|
209
|
-
|
211
|
+
described_class.should_receive(:formatted_operations).with(formatted).and_return([])
|
210
212
|
|
211
213
|
formatted_operations
|
212
214
|
end
|
@@ -230,7 +232,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
230
232
|
end
|
231
233
|
|
232
234
|
it 'should use attribute passed to #initialize' do
|
233
|
-
|
235
|
+
operations.should == expected_operations
|
234
236
|
end
|
235
237
|
end
|
236
238
|
|
@@ -270,7 +272,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
270
272
|
end
|
271
273
|
|
272
274
|
it 'should call #formatted_operations' do
|
273
|
-
|
275
|
+
query.should_receive(:formatted_operations).and_return([])
|
274
276
|
|
275
277
|
operations
|
276
278
|
end
|
@@ -297,14 +299,14 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
297
299
|
:boolean
|
298
300
|
end
|
299
301
|
|
300
|
-
it {
|
302
|
+
it { should be_a Metasploit::Model::Search::Operation::Boolean }
|
301
303
|
|
302
304
|
context "with 'true'" do
|
303
305
|
let(:formatted_value) do
|
304
306
|
'true'
|
305
307
|
end
|
306
308
|
|
307
|
-
it {
|
309
|
+
it { should be_valid }
|
308
310
|
end
|
309
311
|
|
310
312
|
context "with 'false'" do
|
@@ -312,7 +314,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
312
314
|
'false'
|
313
315
|
end
|
314
316
|
|
315
|
-
it {
|
317
|
+
it { should be_valid }
|
316
318
|
end
|
317
319
|
|
318
320
|
context "without 'false' or 'true'" do
|
@@ -320,7 +322,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
320
322
|
'no'
|
321
323
|
end
|
322
324
|
|
323
|
-
it {
|
325
|
+
it { should_not be_valid }
|
324
326
|
end
|
325
327
|
end
|
326
328
|
|
@@ -329,14 +331,14 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
329
331
|
:date
|
330
332
|
end
|
331
333
|
|
332
|
-
it {
|
334
|
+
it { should be_a Metasploit::Model::Search::Operation::Date }
|
333
335
|
|
334
336
|
context 'with date' do
|
335
337
|
let(:formatted_value) do
|
336
338
|
Date.today.to_s
|
337
339
|
end
|
338
340
|
|
339
|
-
it {
|
341
|
+
it { should be_valid }
|
340
342
|
end
|
341
343
|
|
342
344
|
context 'without date' do
|
@@ -344,7 +346,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
344
346
|
'yesterday'
|
345
347
|
end
|
346
348
|
|
347
|
-
it {
|
349
|
+
it { should_not be_valid }
|
348
350
|
end
|
349
351
|
end
|
350
352
|
|
@@ -353,14 +355,14 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
353
355
|
:integer
|
354
356
|
end
|
355
357
|
|
356
|
-
it {
|
358
|
+
it { should be_a Metasploit::Model::Search::Operation::Integer }
|
357
359
|
|
358
360
|
context 'with integer' do
|
359
361
|
let(:formatted_value) do
|
360
362
|
'100'
|
361
363
|
end
|
362
364
|
|
363
|
-
it {
|
365
|
+
it { should be_valid }
|
364
366
|
end
|
365
367
|
|
366
368
|
context 'with float' do
|
@@ -368,7 +370,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
368
370
|
'100.5'
|
369
371
|
end
|
370
372
|
|
371
|
-
it {
|
373
|
+
it { should be_invalid }
|
372
374
|
end
|
373
375
|
|
374
376
|
context 'with integer embedded in text' do
|
@@ -376,7 +378,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
376
378
|
'a2c'
|
377
379
|
end
|
378
380
|
|
379
|
-
it {
|
381
|
+
it { should be_invalid }
|
380
382
|
end
|
381
383
|
end
|
382
384
|
|
@@ -385,14 +387,14 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
385
387
|
:string
|
386
388
|
end
|
387
389
|
|
388
|
-
it {
|
390
|
+
it { should be_a Metasploit::Model::Search::Operation::String }
|
389
391
|
|
390
392
|
context 'with value' do
|
391
393
|
let(:formatted_value) do
|
392
394
|
'formatted_value'
|
393
395
|
end
|
394
396
|
|
395
|
-
it {
|
397
|
+
it { should be_valid }
|
396
398
|
end
|
397
399
|
|
398
400
|
context 'without value' do
|
@@ -400,7 +402,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
400
402
|
''
|
401
403
|
end
|
402
404
|
|
403
|
-
it {
|
405
|
+
it { should_not be_valid }
|
404
406
|
end
|
405
407
|
end
|
406
408
|
end
|
@@ -418,9 +420,9 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
418
420
|
'unknown_value'
|
419
421
|
end
|
420
422
|
|
421
|
-
it {
|
423
|
+
it { should be_a Metasploit::Model::Search::Operation::Base }
|
422
424
|
|
423
|
-
it {
|
425
|
+
it { should be_invalid }
|
424
426
|
end
|
425
427
|
end
|
426
428
|
end
|
@@ -466,7 +468,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
466
468
|
end
|
467
469
|
|
468
470
|
it 'should have correct number of groups' do
|
469
|
-
|
471
|
+
operations_by_operator.length.should == @operators.length
|
470
472
|
end
|
471
473
|
|
472
474
|
it 'should have correct value for each operator' do
|
@@ -487,7 +489,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
487
489
|
query
|
488
490
|
end
|
489
491
|
|
490
|
-
it {
|
492
|
+
it { should be_valid }
|
491
493
|
end
|
492
494
|
end
|
493
495
|
|
@@ -501,7 +503,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
501
503
|
query
|
502
504
|
end
|
503
505
|
|
504
|
-
it {
|
506
|
+
it { should_not be_valid }
|
505
507
|
end
|
506
508
|
end
|
507
509
|
end
|
@@ -540,7 +542,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
540
542
|
|
541
543
|
context 'with String' do
|
542
544
|
it 'should find operator' do
|
543
|
-
|
545
|
+
parse_operator.should == @operator
|
544
546
|
end
|
545
547
|
end
|
546
548
|
|
@@ -550,7 +552,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
550
552
|
end
|
551
553
|
|
552
554
|
it 'should find operator' do
|
553
|
-
|
555
|
+
parse_operator.should == @operator
|
554
556
|
end
|
555
557
|
end
|
556
558
|
end
|
@@ -560,7 +562,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
560
562
|
'unknown_operator'
|
561
563
|
end
|
562
564
|
|
563
|
-
it {
|
565
|
+
it { should be_a Metasploit::Model::Search::Operator::Null }
|
564
566
|
end
|
565
567
|
end
|
566
568
|
|
@@ -597,7 +599,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
597
599
|
tree
|
598
600
|
end
|
599
601
|
|
600
|
-
it {
|
602
|
+
it { should be_a Metasploit::Model::Search::Group::Intersection }
|
601
603
|
|
602
604
|
context 'children' do
|
603
605
|
subject(:children) do
|
@@ -606,17 +608,17 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
606
608
|
|
607
609
|
it 'should be an Array<Metasploit::Model::Search::Group::Union>' do
|
608
610
|
children.each do |child|
|
609
|
-
|
611
|
+
child.should be_a Metasploit::Model::Search::Group::Union
|
610
612
|
end
|
611
613
|
end
|
612
614
|
|
613
615
|
it 'should have same operator for each child of a union' do
|
614
616
|
children.each do |child|
|
615
|
-
operator_set = child.children.inject(Set.new) { |
|
616
|
-
|
617
|
+
operator_set = child.children.inject(Set.new) { |operator_set, operation|
|
618
|
+
operator_set.add operation.operator
|
617
619
|
}
|
618
620
|
|
619
|
-
|
621
|
+
operator_set.length.should == 1
|
620
622
|
end
|
621
623
|
end
|
622
624
|
|
@@ -633,7 +635,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
633
635
|
|
634
636
|
it 'should be Array<Metasploit::Model::Search::Operation::Base>' do
|
635
637
|
grandchildren.each do |grandchild|
|
636
|
-
|
638
|
+
grandchild.should be_a Metasploit::Model::Search::Operation::Base
|
637
639
|
end
|
638
640
|
end
|
639
641
|
end
|
@@ -699,15 +701,15 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
699
701
|
end
|
700
702
|
|
701
703
|
it 'should return a new query' do
|
702
|
-
|
704
|
+
without_operator.should_not be query
|
703
705
|
end
|
704
706
|
|
705
707
|
it 'should not have operations on the removed operator' do
|
706
|
-
|
708
|
+
without_operator.operations_by_operator[filtered_operator].should be_blank
|
707
709
|
end
|
708
710
|
|
709
711
|
it 'should have same #klass as this query' do
|
710
|
-
|
712
|
+
without_operator.klass.should == query.klass
|
711
713
|
end
|
712
714
|
|
713
715
|
context 'with no other operators' do
|
@@ -717,11 +719,11 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
717
719
|
]
|
718
720
|
end
|
719
721
|
|
720
|
-
it {
|
722
|
+
it { should_not be_valid }
|
721
723
|
end
|
722
724
|
|
723
725
|
context 'with other operators' do
|
724
|
-
it {
|
726
|
+
it { should be_valid }
|
725
727
|
end
|
726
728
|
end
|
727
729
|
|
@@ -733,7 +735,7 @@ RSpec.describe Metasploit::Model::Search::Query, type: :model do
|
|
733
735
|
end
|
734
736
|
|
735
737
|
it 'should return this query' do
|
736
|
-
|
738
|
+
without_operator.should be query
|
737
739
|
end
|
738
740
|
end
|
739
741
|
end
|