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
@@ -16,9 +16,6 @@ Dummy::Application.configure do
|
|
16
16
|
# Print deprecation notices to the Rails logger
|
17
17
|
config.active_support.deprecation = :log
|
18
18
|
|
19
|
-
# Only use best-standards-support built into browsers
|
20
|
-
config.action_dispatch.best_standards_support = :builtin
|
21
|
-
|
22
19
|
# Do not compress assets
|
23
20
|
config.assets.compress = false
|
24
21
|
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Metasploit::Model::Association do
|
2
4
|
subject(:base_class) do
|
3
5
|
described_class = self.described_class
|
4
6
|
|
@@ -52,7 +54,7 @@ RSpec.describe Metasploit::Model::Association do
|
|
52
54
|
end
|
53
55
|
|
54
56
|
it 'should be class on which association was called' do
|
55
|
-
|
57
|
+
model.should == base_class
|
56
58
|
end
|
57
59
|
end
|
58
60
|
|
@@ -62,7 +64,7 @@ RSpec.describe Metasploit::Model::Association do
|
|
62
64
|
end
|
63
65
|
|
64
66
|
it 'should be name passed to association as a Symbol' do
|
65
|
-
|
67
|
+
reflection_name.should == name.to_sym
|
66
68
|
end
|
67
69
|
end
|
68
70
|
|
@@ -72,7 +74,7 @@ RSpec.describe Metasploit::Model::Association do
|
|
72
74
|
end
|
73
75
|
|
74
76
|
it 'should be :class_name passed to association' do
|
75
|
-
|
77
|
+
reflection_class_name.should == class_name
|
76
78
|
end
|
77
79
|
end
|
78
80
|
end
|
@@ -85,7 +87,7 @@ RSpec.describe Metasploit::Model::Association do
|
|
85
87
|
end
|
86
88
|
|
87
89
|
it 'should default to empty Hash' do
|
88
|
-
|
90
|
+
association_by_name.should == {}
|
89
91
|
end
|
90
92
|
end
|
91
93
|
|
@@ -117,7 +119,7 @@ RSpec.describe Metasploit::Model::Association do
|
|
117
119
|
end
|
118
120
|
|
119
121
|
it 'should be class_name passed to association' do
|
120
|
-
|
122
|
+
reflection_class_name.should == class_name
|
121
123
|
end
|
122
124
|
end
|
123
125
|
|
@@ -127,7 +129,7 @@ RSpec.describe Metasploit::Model::Association do
|
|
127
129
|
end
|
128
130
|
|
129
131
|
it 'should have the reflected name' do
|
130
|
-
|
132
|
+
reflection.name.should == reflected_name
|
131
133
|
end
|
132
134
|
end
|
133
135
|
end
|
@@ -137,7 +139,7 @@ RSpec.describe Metasploit::Model::Association do
|
|
137
139
|
:unassociated_things
|
138
140
|
end
|
139
141
|
|
140
|
-
it {
|
142
|
+
it { should be_nil }
|
141
143
|
end
|
142
144
|
end
|
143
145
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Metasploit::Model::Base do
|
2
4
|
subject(:base_class) do
|
3
5
|
Class.new(described_class)
|
4
6
|
end
|
@@ -10,7 +12,7 @@ RSpec.describe Metasploit::Model::Base do
|
|
10
12
|
it 'should use public_send to set attributes' do
|
11
13
|
attribute = :attribute
|
12
14
|
value = double('Value')
|
13
|
-
|
15
|
+
base_class.any_instance.should_receive(:public_send).with("#{attribute}=", value)
|
14
16
|
|
15
17
|
base_class.new(attribute => value)
|
16
18
|
end
|
@@ -26,7 +28,7 @@ RSpec.describe Metasploit::Model::Base do
|
|
26
28
|
end
|
27
29
|
|
28
30
|
before(:each) do
|
29
|
-
|
31
|
+
base_instance.stub(:valid? => valid)
|
30
32
|
end
|
31
33
|
|
32
34
|
context 'with valid' do
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Metasploit::Model::Engine do
|
2
4
|
context 'config' do
|
3
5
|
subject(:config) do
|
4
6
|
described_class.config
|
@@ -19,13 +21,7 @@ RSpec.describe Metasploit::Model::Engine do
|
|
19
21
|
options[:factory_girl]
|
20
22
|
end
|
21
23
|
|
22
|
-
|
23
|
-
subject(:dir) {
|
24
|
-
factory_girl[:dir]
|
25
|
-
}
|
26
|
-
|
27
|
-
it { is_expected.to eq('spec/factories') }
|
28
|
-
end
|
24
|
+
its([:dir]) { should == 'spec/factories' }
|
29
25
|
end
|
30
26
|
|
31
27
|
context 'rails' do
|
@@ -33,37 +29,10 @@ RSpec.describe Metasploit::Model::Engine do
|
|
33
29
|
options[:rails]
|
34
30
|
end
|
35
31
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
it { is_expected.to eq(false) }
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'fixture_replacement' do
|
45
|
-
subject(:fixture_replacement) {
|
46
|
-
rails[:fixture_replacement]
|
47
|
-
}
|
48
|
-
|
49
|
-
it { is_expected.to eq(:factory_girl) }
|
50
|
-
end
|
51
|
-
|
52
|
-
context 'helper' do
|
53
|
-
subject(:helper) {
|
54
|
-
rails[:helper]
|
55
|
-
}
|
56
|
-
|
57
|
-
it { is_expected.to eq(false) }
|
58
|
-
end
|
59
|
-
|
60
|
-
context 'test_framework' do
|
61
|
-
subject(:test_framework) {
|
62
|
-
rails[:test_framework]
|
63
|
-
}
|
64
|
-
|
65
|
-
it { is_expected.to eq(:rspec) }
|
66
|
-
end
|
32
|
+
its([:assets]) { should be_false }
|
33
|
+
its([:fixture_replacement]) { should == :factory_girl }
|
34
|
+
its([:helper]) { should be_false }
|
35
|
+
its([:test_framework]) { should == :rspec }
|
67
36
|
end
|
68
37
|
|
69
38
|
context 'rspec' do
|
@@ -71,13 +40,7 @@ RSpec.describe Metasploit::Model::Engine do
|
|
71
40
|
options[:rspec]
|
72
41
|
end
|
73
42
|
|
74
|
-
|
75
|
-
subject(:fixture) {
|
76
|
-
rspec[:fixture]
|
77
|
-
}
|
78
|
-
|
79
|
-
it { is_expected.to eq(false) }
|
80
|
-
end
|
43
|
+
its([:fixture]) { should be_false }
|
81
44
|
end
|
82
45
|
end
|
83
46
|
end
|
@@ -98,7 +61,7 @@ RSpec.describe Metasploit::Model::Engine do
|
|
98
61
|
end
|
99
62
|
|
100
63
|
it 'should run after factory_girl.set_factory_paths' do
|
101
|
-
|
64
|
+
initializer.after.should == 'factory_girl.set_factory_paths'
|
102
65
|
end
|
103
66
|
|
104
67
|
context 'running' do
|
@@ -110,7 +73,7 @@ RSpec.describe Metasploit::Model::Engine do
|
|
110
73
|
it 'should prepend full path to spec/factories to FactoryGirl.definition_file_paths' do
|
111
74
|
definition_file_path = Metasploit::Model::Engine.root.join('spec', 'factories')
|
112
75
|
|
113
|
-
|
76
|
+
FactoryGirl.definition_file_paths.should_receive(:unshift).with(definition_file_path)
|
114
77
|
|
115
78
|
run
|
116
79
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Metasploit::Model::File do
|
2
4
|
unless RUBY_PLATFORM =~ /java/ && Gem::Version.new(JRUBY_VERSION) < Gem::Version.new('1.7.14')
|
3
5
|
it 'aliases ::File' do
|
4
6
|
expect(described_class).to equal(::File)
|
@@ -36,12 +38,12 @@ RSpec.describe Metasploit::Model::File do
|
|
36
38
|
|
37
39
|
if RUBY_PLATFORM =~ /java/ && Gem::Version.new(JRUBY_VERSION) < Gem::Version.new('1.7.14')
|
38
40
|
it 'should be necessary because File.realpath does not resolve symlinks' do
|
39
|
-
|
41
|
+
File.realpath(symlink_pathname.to_path).should_not == real_pathname.to_path
|
40
42
|
end
|
41
43
|
end
|
42
44
|
|
43
45
|
it 'should resolve symlink to real (canonical) path' do
|
44
|
-
|
46
|
+
realpath.should == real_pathname.to_path
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Metasploit::Model::Invalid do
|
2
4
|
subject(:invalid) do
|
3
5
|
described_class.new(model)
|
4
6
|
end
|
@@ -13,16 +15,16 @@ RSpec.describe Metasploit::Model::Invalid do
|
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
16
|
-
it {
|
18
|
+
it { should be_a Metasploit::Model::Error }
|
17
19
|
|
18
20
|
it 'should use ActiveModel::Errors#full_messages' do
|
19
|
-
|
21
|
+
model.errors.should_receive(:full_messages).and_call_original
|
20
22
|
|
21
23
|
described_class.new(model)
|
22
24
|
end
|
23
25
|
|
24
26
|
it 'should translate errors using metasploit.model.invalid' do
|
25
|
-
|
27
|
+
I18n.should_receive(:translate).with(
|
26
28
|
'metasploit.model.errors.messages.model_invalid',
|
27
29
|
hash_including(
|
28
30
|
:errors => anything
|
@@ -34,10 +36,10 @@ RSpec.describe Metasploit::Model::Invalid do
|
|
34
36
|
|
35
37
|
it 'should set translated errors as message' do
|
36
38
|
message = "translated message"
|
37
|
-
|
39
|
+
I18n.stub(:translate).with('metasploit.model.errors.messages.model_invalid', anything).and_return(message)
|
38
40
|
instance = described_class.new(model)
|
39
41
|
|
40
|
-
|
42
|
+
instance.message.should == message
|
41
43
|
end
|
42
44
|
|
43
45
|
context '#model' do
|
@@ -46,7 +48,7 @@ RSpec.describe Metasploit::Model::Invalid do
|
|
46
48
|
end
|
47
49
|
|
48
50
|
it 'should be the passed in model' do
|
49
|
-
|
51
|
+
error_model.should == model
|
50
52
|
end
|
51
53
|
end
|
52
54
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Metasploit::Model::NilifyBlanks do
|
2
4
|
let(:base_class) do
|
3
5
|
# capture for class_eval scope
|
4
6
|
described_class = self.described_class
|
@@ -22,7 +24,7 @@ RSpec.describe Metasploit::Model::NilifyBlanks do
|
|
22
24
|
end
|
23
25
|
|
24
26
|
it 'should register #nilify_blanks as a before validation callback' do
|
25
|
-
|
27
|
+
base_class.should_receive(:before_validation).with(:nilify_blanks)
|
26
28
|
|
27
29
|
# capture for class_eval scope
|
28
30
|
described_class = self.described_class
|
@@ -37,10 +39,10 @@ RSpec.describe Metasploit::Model::NilifyBlanks do
|
|
37
39
|
it 'should support adding multiple attributes' do
|
38
40
|
attributes = [:a, :b]
|
39
41
|
|
40
|
-
base_class.nilify_blank
|
42
|
+
base_class.nilify_blank *attributes
|
41
43
|
|
42
44
|
attributes.each do |attribute|
|
43
|
-
|
45
|
+
base_class.nilify_blank_attribute_set.should include(attribute)
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
@@ -50,7 +52,7 @@ RSpec.describe Metasploit::Model::NilifyBlanks do
|
|
50
52
|
base_class.nilify_blank attribute
|
51
53
|
base_class.nilify_blank attribute
|
52
54
|
|
53
|
-
|
55
|
+
base_class.nilify_blank_attribute_set.length.should == 1
|
54
56
|
end
|
55
57
|
end
|
56
58
|
|
@@ -88,14 +90,14 @@ RSpec.describe Metasploit::Model::NilifyBlanks do
|
|
88
90
|
end
|
89
91
|
|
90
92
|
it 'should check if value responds to blank?' do
|
91
|
-
|
93
|
+
value.should_receive(:respond_to?).with(:blank?)
|
92
94
|
|
93
95
|
nilify_blanks
|
94
96
|
end
|
95
97
|
|
96
98
|
context 'with value responds to blank?' do
|
97
99
|
it 'should call blank?' do
|
98
|
-
|
100
|
+
value.should_receive(:blank?)
|
99
101
|
|
100
102
|
nilify_blanks
|
101
103
|
end
|
@@ -108,7 +110,7 @@ RSpec.describe Metasploit::Model::NilifyBlanks do
|
|
108
110
|
it 'should set attribute to nil' do
|
109
111
|
nilify_blanks
|
110
112
|
|
111
|
-
|
113
|
+
base_instance.blank.should be_nil
|
112
114
|
end
|
113
115
|
end
|
114
116
|
|
@@ -131,11 +133,11 @@ RSpec.describe Metasploit::Model::NilifyBlanks do
|
|
131
133
|
end
|
132
134
|
|
133
135
|
before(:each) do
|
134
|
-
|
136
|
+
value.stub(:respond_to?).with(:blank?).and_return(false)
|
135
137
|
end
|
136
138
|
|
137
139
|
it 'should not call blank?' do
|
138
|
-
|
140
|
+
value.should_not_receive(:blank?)
|
139
141
|
|
140
142
|
nilify_blanks
|
141
143
|
end
|
@@ -148,7 +150,7 @@ RSpec.describe Metasploit::Model::NilifyBlanks do
|
|
148
150
|
end
|
149
151
|
|
150
152
|
it 'should default to an empty Set' do
|
151
|
-
|
153
|
+
nilify_blank_attribute_set.should == Set.new
|
152
154
|
end
|
153
155
|
end
|
154
156
|
end
|
@@ -1,12 +1,14 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Metasploit::Model::Realm::Key do
|
2
4
|
context 'CONSTANTS' do
|
3
5
|
context 'ACTIVE_DIRECTORY_DOMAIN' do
|
4
6
|
subject(:active_directory_domain) do
|
5
7
|
described_class::ACTIVE_DIRECTORY_DOMAIN
|
6
8
|
end
|
7
9
|
|
8
|
-
it {
|
9
|
-
it {
|
10
|
+
it { should == 'Active Directory Domain' }
|
11
|
+
it { should be_in described_class::ALL }
|
10
12
|
end
|
11
13
|
|
12
14
|
context 'ALL' do
|
@@ -14,10 +16,10 @@ RSpec.describe Metasploit::Model::Realm::Key do
|
|
14
16
|
described_class::ALL
|
15
17
|
end
|
16
18
|
|
17
|
-
it {
|
18
|
-
it {
|
19
|
-
it {
|
20
|
-
it {
|
19
|
+
it { should include described_class::ACTIVE_DIRECTORY_DOMAIN }
|
20
|
+
it { should include described_class::ORACLE_SYSTEM_IDENTIFIER }
|
21
|
+
it { should include described_class::POSTGRESQL_DATABASE }
|
22
|
+
it { should include described_class::WILDCARD }
|
21
23
|
end
|
22
24
|
|
23
25
|
context 'ORACLE_SYSTEM_IDENTIFIER' do
|
@@ -25,8 +27,8 @@ RSpec.describe Metasploit::Model::Realm::Key do
|
|
25
27
|
described_class::ORACLE_SYSTEM_IDENTIFIER
|
26
28
|
end
|
27
29
|
|
28
|
-
it {
|
29
|
-
it {
|
30
|
+
it { should == 'Oracle System Identifier' }
|
31
|
+
it { should be_in described_class::ALL }
|
30
32
|
end
|
31
33
|
|
32
34
|
context 'POSTGRESQL DATABASE' do
|
@@ -34,8 +36,8 @@ RSpec.describe Metasploit::Model::Realm::Key do
|
|
34
36
|
described_class::POSTGRESQL_DATABASE
|
35
37
|
end
|
36
38
|
|
37
|
-
it {
|
38
|
-
it {
|
39
|
+
it { should == 'PostgreSQL Database' }
|
40
|
+
it { should be_in described_class::ALL }
|
39
41
|
end
|
40
42
|
|
41
43
|
context 'WILDCARD' do
|
@@ -43,20 +45,20 @@ RSpec.describe Metasploit::Model::Realm::Key do
|
|
43
45
|
described_class::WILDCARD
|
44
46
|
end
|
45
47
|
|
46
|
-
it {
|
47
|
-
it {
|
48
|
+
it { should == '*' }
|
49
|
+
it { should be_in described_class::ALL }
|
48
50
|
end
|
49
51
|
|
50
52
|
context 'SHORT_NAMES' do
|
51
53
|
subject { described_class::SHORT_NAMES }
|
52
54
|
it 'should have String keys' do
|
53
55
|
subject.keys.each { |key|
|
54
|
-
|
56
|
+
key.should be_a(String)
|
55
57
|
}
|
56
58
|
end
|
57
59
|
context 'values' do
|
58
60
|
subject { described_class::SHORT_NAMES.values.sort }
|
59
|
-
it {
|
61
|
+
it { should match_array(described_class::ALL.sort) }
|
60
62
|
end
|
61
63
|
end
|
62
64
|
end
|