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.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +2 -4
  3. data/Gemfile +1 -6
  4. data/lib/metasploit/model/version.rb +1 -1
  5. data/spec/app/models/metasploit/model/association/reflection_spec.rb +5 -7
  6. data/spec/app/models/metasploit/model/search/group/base_spec.rb +2 -4
  7. data/spec/app/models/metasploit/model/search/group/intersection_spec.rb +2 -4
  8. data/spec/app/models/metasploit/model/search/group/union_spec.rb +2 -4
  9. data/spec/app/models/metasploit/model/search/operation/association_spec.rb +7 -9
  10. data/spec/app/models/metasploit/model/search/operation/base_spec.rb +5 -7
  11. data/spec/app/models/metasploit/model/search/operation/boolean_spec.rb +14 -11
  12. data/spec/app/models/metasploit/model/search/operation/date_spec.rb +6 -8
  13. data/spec/app/models/metasploit/model/search/operation/group/base_spec.rb +12 -14
  14. data/spec/app/models/metasploit/model/search/operation/group/intersection_spec.rb +2 -4
  15. data/spec/app/models/metasploit/model/search/operation/group/union_spec.rb +2 -4
  16. data/spec/app/models/metasploit/model/search/operation/integer_spec.rb +2 -4
  17. data/spec/app/models/metasploit/model/search/operation/null_spec.rb +4 -6
  18. data/spec/app/models/metasploit/model/search/operation/set/integer_spec.rb +2 -4
  19. data/spec/app/models/metasploit/model/search/operation/set/string_spec.rb +2 -4
  20. data/spec/app/models/metasploit/model/search/operation/set_spec.rb +4 -6
  21. data/spec/app/models/metasploit/model/search/operation/string_spec.rb +2 -4
  22. data/spec/app/models/metasploit/model/search/operator/association_spec.rb +6 -8
  23. data/spec/app/models/metasploit/model/search/operator/attribute_spec.rb +12 -14
  24. data/spec/app/models/metasploit/model/search/operator/base_spec.rb +3 -5
  25. data/spec/app/models/metasploit/model/search/operator/delegation_spec.rb +13 -11
  26. data/spec/app/models/metasploit/model/search/operator/group/base_spec.rb +5 -7
  27. data/spec/app/models/metasploit/model/search/operator/group/intersection_spec.rb +3 -5
  28. data/spec/app/models/metasploit/model/search/operator/group/union_spec.rb +3 -5
  29. data/spec/app/models/metasploit/model/search/operator/null_spec.rb +5 -7
  30. data/spec/app/models/metasploit/model/search/operator/single_spec.rb +26 -28
  31. data/spec/app/models/metasploit/model/search/query_spec.rb +48 -50
  32. data/spec/app/models/metasploit/model/visitation/visitor_spec.rb +7 -9
  33. data/spec/app/validators/ip_format_validator_spec.rb +7 -9
  34. data/spec/app/validators/nil_validator_spec.rb +3 -5
  35. data/spec/app/validators/parameters_validator_spec.rb +29 -29
  36. data/spec/app/validators/password_is_strong_validator_spec.rb +17 -19
  37. data/spec/lib/metasploit/model/association/error_spec.rb +1 -3
  38. data/spec/lib/metasploit/model/association_spec.rb +8 -10
  39. data/spec/lib/metasploit/model/base_spec.rb +3 -5
  40. data/spec/lib/metasploit/model/engine_spec.rb +48 -11
  41. data/spec/lib/metasploit/model/file_spec.rb +3 -5
  42. data/spec/lib/metasploit/model/invalid_spec.rb +7 -9
  43. data/spec/lib/metasploit/model/login/status_spec.rb +1 -3
  44. data/spec/lib/metasploit/model/nilify_blanks_spec.rb +11 -13
  45. data/spec/lib/metasploit/model/realm/key_spec.rb +15 -17
  46. data/spec/lib/metasploit/model/search/association/tree_spec.rb +3 -5
  47. data/spec/lib/metasploit/model/search/association_spec.rb +2 -4
  48. data/spec/lib/metasploit/model/search/attribute_spec.rb +6 -8
  49. data/spec/lib/metasploit/model/search/operation/value/integer_spec.rb +1 -3
  50. data/spec/lib/metasploit/model/search/operation/value/string_spec.rb +1 -3
  51. data/spec/lib/metasploit/model/search/operation_spec.rb +11 -13
  52. data/spec/lib/metasploit/model/search/operator/help_spec.rb +1 -3
  53. data/spec/lib/metasploit/model/search/with_spec.rb +7 -9
  54. data/spec/lib/metasploit/model/search_spec.rb +11 -13
  55. data/spec/lib/metasploit/model/spec/error_spec.rb +2 -4
  56. data/spec/lib/metasploit/model/spec/i18n_exception_handler_spec.rb +5 -7
  57. data/spec/lib/metasploit/model/spec/pathname_collision_spec.rb +4 -6
  58. data/spec/lib/metasploit/model/spec_spec.rb +9 -7
  59. data/spec/lib/metasploit/model/translation_spec.rb +10 -12
  60. data/spec/lib/metasploit/model/version_spec.rb +3 -5
  61. data/spec/lib/metasploit/model/visitation/visit_spec.rb +28 -26
  62. data/spec/matchers/validate_nilness_of_spec.rb +0 -2
  63. data/spec/spec_helper.rb +69 -7
  64. data/spec/support/shared/contexts/metasploit/model/search/operator/union/children.rb +1 -1
  65. data/spec/support/shared/examples/metasploit/model/search/operation/value/integer.rb +8 -8
  66. data/spec/support/shared/examples/metasploit/model/search/operation/value/string.rb +5 -5
  67. data/spec/support/shared/examples/metasploit/model/search/operator/help.rb +18 -16
  68. data/spec/support/shared/examples/metasploit/model/translation.rb +4 -4
  69. data/spec/support/shared/examples/search/query.rb +3 -3
  70. data/spec/support/shared/examples/search_association.rb +2 -2
  71. data/spec/support/shared/examples/search_attribute.rb +3 -3
  72. data/spec/support/shared/examples/search_with.rb +3 -3
  73. metadata +2 -2
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Base do
1
+ RSpec.describe Metasploit::Model::Base do
4
2
  subject(:base_class) do
5
3
  Class.new(described_class)
6
4
  end
@@ -12,7 +10,7 @@ describe Metasploit::Model::Base do
12
10
  it 'should use public_send to set attributes' do
13
11
  attribute = :attribute
14
12
  value = double('Value')
15
- base_class.any_instance.should_receive(:public_send).with("#{attribute}=", value)
13
+ expect_any_instance_of(base_class).to receive(:public_send).with("#{attribute}=", value)
16
14
 
17
15
  base_class.new(attribute => value)
18
16
  end
@@ -28,7 +26,7 @@ describe Metasploit::Model::Base do
28
26
  end
29
27
 
30
28
  before(:each) do
31
- base_instance.stub(:valid? => valid)
29
+ allow(base_instance).to receive(:valid?).and_return(valid)
32
30
  end
33
31
 
34
32
  context 'with valid' do
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Engine do
1
+ RSpec.describe Metasploit::Model::Engine do
4
2
  context 'config' do
5
3
  subject(:config) do
6
4
  described_class.config
@@ -21,7 +19,13 @@ describe Metasploit::Model::Engine do
21
19
  options[:factory_girl]
22
20
  end
23
21
 
24
- its([:dir]) { should == 'spec/factories' }
22
+ context 'dir' do
23
+ subject(:dir) {
24
+ factory_girl[:dir]
25
+ }
26
+
27
+ it { is_expected.to eq('spec/factories') }
28
+ end
25
29
  end
26
30
 
27
31
  context 'rails' do
@@ -29,10 +33,37 @@ describe Metasploit::Model::Engine do
29
33
  options[:rails]
30
34
  end
31
35
 
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 }
36
+ context 'assets' do
37
+ subject(:assets) {
38
+ rails[:assets]
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
36
67
  end
37
68
 
38
69
  context 'rspec' do
@@ -40,7 +71,13 @@ describe Metasploit::Model::Engine do
40
71
  options[:rspec]
41
72
  end
42
73
 
43
- its([:fixture]) { should be_false }
74
+ context 'fixture' do
75
+ subject(:fixture) {
76
+ rspec[:fixture]
77
+ }
78
+
79
+ it { is_expected.to eq(false) }
80
+ end
44
81
  end
45
82
  end
46
83
  end
@@ -61,7 +98,7 @@ describe Metasploit::Model::Engine do
61
98
  end
62
99
 
63
100
  it 'should run after factory_girl.set_factory_paths' do
64
- initializer.after.should == 'factory_girl.set_factory_paths'
101
+ expect(initializer.after).to eq('factory_girl.set_factory_paths')
65
102
  end
66
103
 
67
104
  context 'running' do
@@ -73,7 +110,7 @@ describe Metasploit::Model::Engine do
73
110
  it 'should prepend full path to spec/factories to FactoryGirl.definition_file_paths' do
74
111
  definition_file_path = Metasploit::Model::Engine.root.join('spec', 'factories')
75
112
 
76
- FactoryGirl.definition_file_paths.should_receive(:unshift).with(definition_file_path)
113
+ expect(FactoryGirl.definition_file_paths).to receive(:unshift).with(definition_file_path)
77
114
 
78
115
  run
79
116
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::File do
1
+ RSpec.describe Metasploit::Model::File do
4
2
  unless RUBY_PLATFORM =~ /java/ && Gem::Version.new(JRUBY_VERSION) < Gem::Version.new('1.7.14')
5
3
  it 'aliases ::File' do
6
4
  expect(described_class).to equal(::File)
@@ -38,12 +36,12 @@ describe Metasploit::Model::File do
38
36
 
39
37
  if RUBY_PLATFORM =~ /java/ && Gem::Version.new(JRUBY_VERSION) < Gem::Version.new('1.7.14')
40
38
  it 'should be necessary because File.realpath does not resolve symlinks' do
41
- File.realpath(symlink_pathname.to_path).should_not == real_pathname.to_path
39
+ expect(File.realpath(symlink_pathname.to_path)).not_to eq(real_pathname.to_path)
42
40
  end
43
41
  end
44
42
 
45
43
  it 'should resolve symlink to real (canonical) path' do
46
- realpath.should == real_pathname.to_path
44
+ expect(realpath).to eq(real_pathname.to_path)
47
45
  end
48
46
  end
49
47
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Invalid do
1
+ RSpec.describe Metasploit::Model::Invalid do
4
2
  subject(:invalid) do
5
3
  described_class.new(model)
6
4
  end
@@ -15,16 +13,16 @@ describe Metasploit::Model::Invalid do
15
13
  end
16
14
  end
17
15
 
18
- it { should be_a Metasploit::Model::Error }
16
+ it { is_expected.to be_a Metasploit::Model::Error }
19
17
 
20
18
  it 'should use ActiveModel::Errors#full_messages' do
21
- model.errors.should_receive(:full_messages).and_call_original
19
+ expect(model.errors).to receive(:full_messages).and_call_original
22
20
 
23
21
  described_class.new(model)
24
22
  end
25
23
 
26
24
  it 'should translate errors using metasploit.model.invalid' do
27
- I18n.should_receive(:translate).with(
25
+ expect(I18n).to receive(:translate).with(
28
26
  'metasploit.model.errors.messages.model_invalid',
29
27
  hash_including(
30
28
  :errors => anything
@@ -36,10 +34,10 @@ describe Metasploit::Model::Invalid do
36
34
 
37
35
  it 'should set translated errors as message' do
38
36
  message = "translated message"
39
- I18n.stub(:translate).with('metasploit.model.errors.messages.model_invalid', anything).and_return(message)
37
+ allow(I18n).to receive(:translate).with('metasploit.model.errors.messages.model_invalid', anything).and_return(message)
40
38
  instance = described_class.new(model)
41
39
 
42
- instance.message.should == message
40
+ expect(instance.message).to eq(message)
43
41
  end
44
42
 
45
43
  context '#model' do
@@ -48,7 +46,7 @@ describe Metasploit::Model::Invalid do
48
46
  end
49
47
 
50
48
  it 'should be the passed in model' do
51
- error_model.should == model
49
+ expect(error_model).to eq(model)
52
50
  end
53
51
  end
54
52
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Login::Status do
1
+ RSpec.describe Metasploit::Model::Login::Status do
4
2
  context 'CONSTANTS' do
5
3
  context 'ALL' do
6
4
  subject(:all) {
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::NilifyBlanks do
1
+ RSpec.describe Metasploit::Model::NilifyBlanks do
4
2
  let(:base_class) do
5
3
  # capture for class_eval scope
6
4
  described_class = self.described_class
@@ -24,7 +22,7 @@ describe Metasploit::Model::NilifyBlanks do
24
22
  end
25
23
 
26
24
  it 'should register #nilify_blanks as a before validation callback' do
27
- base_class.should_receive(:before_validation).with(:nilify_blanks)
25
+ expect(base_class).to receive(:before_validation).with(:nilify_blanks)
28
26
 
29
27
  # capture for class_eval scope
30
28
  described_class = self.described_class
@@ -39,10 +37,10 @@ describe Metasploit::Model::NilifyBlanks do
39
37
  it 'should support adding multiple attributes' do
40
38
  attributes = [:a, :b]
41
39
 
42
- base_class.nilify_blank *attributes
40
+ base_class.nilify_blank(*attributes)
43
41
 
44
42
  attributes.each do |attribute|
45
- base_class.nilify_blank_attribute_set.should include(attribute)
43
+ expect(base_class.nilify_blank_attribute_set).to include(attribute)
46
44
  end
47
45
  end
48
46
 
@@ -52,7 +50,7 @@ describe Metasploit::Model::NilifyBlanks do
52
50
  base_class.nilify_blank attribute
53
51
  base_class.nilify_blank attribute
54
52
 
55
- base_class.nilify_blank_attribute_set.length.should == 1
53
+ expect(base_class.nilify_blank_attribute_set.length).to eq(1)
56
54
  end
57
55
  end
58
56
 
@@ -90,14 +88,14 @@ describe Metasploit::Model::NilifyBlanks do
90
88
  end
91
89
 
92
90
  it 'should check if value responds to blank?' do
93
- value.should_receive(:respond_to?).with(:blank?)
91
+ expect(value).to receive(:respond_to?).with(:blank?)
94
92
 
95
93
  nilify_blanks
96
94
  end
97
95
 
98
96
  context 'with value responds to blank?' do
99
97
  it 'should call blank?' do
100
- value.should_receive(:blank?)
98
+ expect(value).to receive(:blank?)
101
99
 
102
100
  nilify_blanks
103
101
  end
@@ -110,7 +108,7 @@ describe Metasploit::Model::NilifyBlanks do
110
108
  it 'should set attribute to nil' do
111
109
  nilify_blanks
112
110
 
113
- base_instance.blank.should be_nil
111
+ expect(base_instance.blank).to be_nil
114
112
  end
115
113
  end
116
114
 
@@ -133,11 +131,11 @@ describe Metasploit::Model::NilifyBlanks do
133
131
  end
134
132
 
135
133
  before(:each) do
136
- value.stub(:respond_to?).with(:blank?).and_return(false)
134
+ allow(value).to receive(:respond_to?).with(:blank?).and_return(false)
137
135
  end
138
136
 
139
137
  it 'should not call blank?' do
140
- value.should_not_receive(:blank?)
138
+ expect(value).not_to receive(:blank?)
141
139
 
142
140
  nilify_blanks
143
141
  end
@@ -150,7 +148,7 @@ describe Metasploit::Model::NilifyBlanks do
150
148
  end
151
149
 
152
150
  it 'should default to an empty Set' do
153
- nilify_blank_attribute_set.should == Set.new
151
+ expect(nilify_blank_attribute_set).to eq(Set.new)
154
152
  end
155
153
  end
156
154
  end
@@ -1,14 +1,12 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Realm::Key do
1
+ RSpec.describe Metasploit::Model::Realm::Key do
4
2
  context 'CONSTANTS' do
5
3
  context 'ACTIVE_DIRECTORY_DOMAIN' do
6
4
  subject(:active_directory_domain) do
7
5
  described_class::ACTIVE_DIRECTORY_DOMAIN
8
6
  end
9
7
 
10
- it { should == 'Active Directory Domain' }
11
- it { should be_in described_class::ALL }
8
+ it { is_expected.to eq('Active Directory Domain') }
9
+ it { is_expected.to be_in described_class::ALL }
12
10
  end
13
11
 
14
12
  context 'ALL' do
@@ -16,10 +14,10 @@ describe Metasploit::Model::Realm::Key do
16
14
  described_class::ALL
17
15
  end
18
16
 
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 }
17
+ it { is_expected.to include described_class::ACTIVE_DIRECTORY_DOMAIN }
18
+ it { is_expected.to include described_class::ORACLE_SYSTEM_IDENTIFIER }
19
+ it { is_expected.to include described_class::POSTGRESQL_DATABASE }
20
+ it { is_expected.to include described_class::WILDCARD }
23
21
  end
24
22
 
25
23
  context 'ORACLE_SYSTEM_IDENTIFIER' do
@@ -27,8 +25,8 @@ describe Metasploit::Model::Realm::Key do
27
25
  described_class::ORACLE_SYSTEM_IDENTIFIER
28
26
  end
29
27
 
30
- it { should == 'Oracle System Identifier' }
31
- it { should be_in described_class::ALL }
28
+ it { is_expected.to eq('Oracle System Identifier') }
29
+ it { is_expected.to be_in described_class::ALL }
32
30
  end
33
31
 
34
32
  context 'POSTGRESQL DATABASE' do
@@ -36,8 +34,8 @@ describe Metasploit::Model::Realm::Key do
36
34
  described_class::POSTGRESQL_DATABASE
37
35
  end
38
36
 
39
- it { should == 'PostgreSQL Database' }
40
- it { should be_in described_class::ALL }
37
+ it { is_expected.to eq('PostgreSQL Database') }
38
+ it { is_expected.to be_in described_class::ALL }
41
39
  end
42
40
 
43
41
  context 'WILDCARD' do
@@ -45,20 +43,20 @@ describe Metasploit::Model::Realm::Key do
45
43
  described_class::WILDCARD
46
44
  end
47
45
 
48
- it { should == '*' }
49
- it { should be_in described_class::ALL }
46
+ it { is_expected.to eq('*') }
47
+ it { is_expected.to be_in described_class::ALL }
50
48
  end
51
49
 
52
50
  context 'SHORT_NAMES' do
53
51
  subject { described_class::SHORT_NAMES }
54
52
  it 'should have String keys' do
55
53
  subject.keys.each { |key|
56
- key.should be_a(String)
54
+ expect(key).to be_a(String)
57
55
  }
58
56
  end
59
57
  context 'values' do
60
58
  subject { described_class::SHORT_NAMES.values.sort }
61
- it { should match_array(described_class::ALL.sort) }
59
+ it { is_expected.to match_array(described_class::ALL.sort) }
62
60
  end
63
61
  end
64
62
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Association::Tree do
1
+ RSpec.describe Metasploit::Model::Association::Tree do
4
2
  context 'expand' do
5
3
  subject(:expand) {
6
4
  described_class.expand(associations)
@@ -99,7 +97,7 @@ describe Metasploit::Model::Association::Tree do
99
97
  nil
100
98
  }
101
99
 
102
- it { should be_nil }
100
+ it { is_expected.to be_nil }
103
101
  end
104
102
 
105
103
  context 'without nil' do
@@ -311,7 +309,7 @@ describe Metasploit::Model::Association::Tree do
311
309
  nil
312
310
  }
313
311
 
314
- it { should == [] }
312
+ it { is_expected.to eq([]) }
315
313
  end
316
314
  end
317
315
 
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Search::Association do
1
+ RSpec.describe Metasploit::Model::Search::Association do
4
2
  subject(:base_class) do
5
3
  described_class = self.described_class
6
4
 
@@ -56,7 +54,7 @@ describe Metasploit::Model::Search::Association do
56
54
 
57
55
  context 'search_associations' do
58
56
  subject(:search_associations) {
59
- base_class.search_associations *associations
57
+ base_class.search_associations(*associations)
60
58
  }
61
59
 
62
60
  let(:associations) {
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Search::Attribute do
1
+ RSpec.describe Metasploit::Model::Search::Attribute do
4
2
  subject(:base_class) do
5
3
  described_class = self.described_class
6
4
 
@@ -26,7 +24,7 @@ describe Metasploit::Model::Search::Attribute do
26
24
  end
27
25
 
28
26
  it 'should call search_with' do
29
- base_class.should_receive(:search_with).with(
27
+ expect(base_class).to receive(:search_with).with(
30
28
  Metasploit::Model::Search::Operator::Attribute,
31
29
  hash_including(
32
30
  :attribute => attribute,
@@ -40,7 +38,7 @@ describe Metasploit::Model::Search::Attribute do
40
38
  it 'should be in search_attribute_operator_by_attribute' do
41
39
  # grab operator first since it calls search_attribute and populates search_attribute_operator_by_attribute
42
40
  cached = operator
43
- base_class.search_with_operator_by_name[attribute].should == cached
41
+ expect(base_class.search_with_operator_by_name[attribute]).to eq(cached)
44
42
  end
45
43
 
46
44
  context 'attribute' do
@@ -49,7 +47,7 @@ describe Metasploit::Model::Search::Attribute do
49
47
  end
50
48
 
51
49
  it 'should be the attribute passed to search_attribute' do
52
- operator_attribute.should == attribute
50
+ expect(operator_attribute).to eq(attribute)
53
51
  end
54
52
  end
55
53
 
@@ -59,7 +57,7 @@ describe Metasploit::Model::Search::Attribute do
59
57
  end
60
58
 
61
59
  it 'should be class on which search_attribute was called' do
62
- klass.should == base_class
60
+ expect(klass).to eq(base_class)
63
61
  end
64
62
  end
65
63
 
@@ -69,7 +67,7 @@ describe Metasploit::Model::Search::Attribute do
69
67
  end
70
68
 
71
69
  it 'should be type passed to search_attribute' do
72
- operator_type.should == type
70
+ expect(operator_type).to eq(type)
73
71
  end
74
72
  end
75
73
  end