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,21 +1,24 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Search::Operation::Boolean do
1
+ RSpec.describe Metasploit::Model::Search::Operation::Boolean, type: :model do
4
2
  context 'CONSTANTS' do
5
3
  context 'FORMATTED_VALUE_TO_VALUE' do
6
4
  subject(:formatted_value_to_value) do
7
5
  described_class::FORMATTED_VALUE_TO_VALUE
8
6
  end
9
7
 
10
- its(['false']) { should be_false }
11
- its(['true']) { should be_true }
8
+ it "maps 'false' to false" do
9
+ expect(formatted_value_to_value['false']).to eq(false)
10
+ end
11
+
12
+ it "maps 'true' to true" do
13
+ expect(formatted_value_to_value['true']).to eq(true)
14
+ end
12
15
  end
13
16
  end
14
17
 
15
18
  context 'validations' do
16
- it { should allow_value(false).for(:value) }
17
- it { should allow_value(true).for(:value) }
18
- it { should_not allow_value(nil).for(:value) }
19
+ it { is_expected.to allow_value(false).for(:value) }
20
+ it { is_expected.to allow_value(true).for(:value) }
21
+ it { is_expected.not_to allow_value(nil).for(:value) }
19
22
  end
20
23
 
21
24
  context '#value' do
@@ -32,7 +35,7 @@ describe Metasploit::Model::Search::Operation::Boolean do
32
35
  'false'
33
36
  end
34
37
 
35
- it { should be_false }
38
+ it { is_expected.to eq(false) }
36
39
  end
37
40
 
38
41
  context "with 'true'" do
@@ -40,7 +43,7 @@ describe Metasploit::Model::Search::Operation::Boolean do
40
43
  'true'
41
44
  end
42
45
 
43
- it { should be_true }
46
+ it { is_expected.to eq(true) }
44
47
  end
45
48
 
46
49
  context 'with other' do
@@ -49,7 +52,7 @@ describe Metasploit::Model::Search::Operation::Boolean do
49
52
  end
50
53
 
51
54
  it 'should return value unparsed' do
52
- value.should == formatted_value
55
+ expect(value).to eq(formatted_value)
53
56
  end
54
57
  end
55
58
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Search::Operation::Date do
1
+ RSpec.describe Metasploit::Model::Search::Operation::Date, type: :model do
4
2
  context 'validation' do
5
3
  context 'value' do
6
4
  before(:each) do
@@ -25,7 +23,7 @@ describe Metasploit::Model::Search::Operation::Date do
25
23
  end
26
24
 
27
25
  it 'should not record error' do
28
- errors.should_not include(error)
26
+ expect(errors).not_to include(error)
29
27
  end
30
28
  end
31
29
 
@@ -35,7 +33,7 @@ describe Metasploit::Model::Search::Operation::Date do
35
33
  end
36
34
 
37
35
  it 'should record error' do
38
- errors.should include(error)
36
+ expect(errors).to include(error)
39
37
  end
40
38
  end
41
39
  end
@@ -56,7 +54,7 @@ describe Metasploit::Model::Search::Operation::Date do
56
54
  end
57
55
 
58
56
  it 'should be passed in Date' do
59
- value.should == formatted_value
57
+ expect(value).to eq(formatted_value)
60
58
  end
61
59
  end
62
60
 
@@ -71,7 +69,7 @@ describe Metasploit::Model::Search::Operation::Date do
71
69
  end
72
70
 
73
71
  it 'should be parsed Date' do
74
- value.should == date
72
+ expect(value).to eq(date)
75
73
  end
76
74
  end
77
75
 
@@ -81,7 +79,7 @@ describe Metasploit::Model::Search::Operation::Date do
81
79
  end
82
80
 
83
81
  it 'should pass through value' do
84
- value.should be formatted_value
82
+ expect(value).to be formatted_value
85
83
  end
86
84
  end
87
85
  end
@@ -1,15 +1,13 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Search::Operation::Group::Base do
1
+ RSpec.describe Metasploit::Model::Search::Operation::Group::Base, type: :model do
4
2
  subject(:group) do
5
3
  described_class.new
6
4
  end
7
5
 
8
- it { should be_a Metasploit::Model::Search::Operation::Base }
6
+ it { is_expected.to be_a Metasploit::Model::Search::Operation::Base }
9
7
 
10
8
  context 'validations' do
11
9
  context 'children' do
12
- it { should ensure_length_of(:children).is_at_least(1).with_short_message('is too short (minimum is 1 child)') }
10
+ it { is_expected.to ensure_length_of(:children).is_at_least(1).with_short_message('is too short (minimum is 1 child)') }
13
11
 
14
12
  context '#children_valid' do
15
13
  subject(:children_valid) do
@@ -48,25 +46,25 @@ describe Metasploit::Model::Search::Operation::Group::Base do
48
46
  context 'with all valid' do
49
47
  before(:each) do
50
48
  children.each do |child|
51
- child.stub(valid?: true)
49
+ allow(child).to receive(:valid?).and_return(true)
52
50
  end
53
51
  end
54
52
 
55
53
  it 'does not add error on :children' do
56
54
  group.valid?
57
55
 
58
- group.errors[:children].should_not include(error)
56
+ expect(group.errors[:children]).not_to include(error)
59
57
  end
60
58
  end
61
59
 
62
60
  context 'with later valid' do
63
61
  before(:each) do
64
- children.first.stub(valid?: false)
65
- children.second.stub(valid?: true)
62
+ allow(children.first).to receive(:valid?).and_return(false)
63
+ allow(children.second).to receive(:valid?).and_return(true)
66
64
  end
67
65
 
68
66
  it 'does not short-circuit and validates all children' do
69
- children.second.should_receive(:valid?).and_return(true)
67
+ expect(children.second).to receive(:valid?).and_return(true)
70
68
 
71
69
  children_valid
72
70
  end
@@ -74,7 +72,7 @@ describe Metasploit::Model::Search::Operation::Group::Base do
74
72
  it 'should add error on :children' do
75
73
  group.valid?
76
74
 
77
- group.errors[:children].should include(error)
75
+ expect(group.errors[:children]).to include(error)
78
76
  end
79
77
  end
80
78
  end
@@ -87,7 +85,7 @@ describe Metasploit::Model::Search::Operation::Group::Base do
87
85
  it 'does not add error on :children' do
88
86
  group.valid?
89
87
 
90
- group.errors[:children].should_not include(error)
88
+ expect(group.errors[:children]).not_to include(error)
91
89
  end
92
90
  end
93
91
  end
@@ -100,7 +98,7 @@ describe Metasploit::Model::Search::Operation::Group::Base do
100
98
  end
101
99
 
102
100
  context 'default' do
103
- it { should == [] }
101
+ it { is_expected.to eq([]) }
104
102
  end
105
103
 
106
104
  context 'with attribute' do
@@ -117,7 +115,7 @@ describe Metasploit::Model::Search::Operation::Group::Base do
117
115
  end
118
116
 
119
117
  it 'is the value passed with :children to #new' do
120
- children.should == expected_children
118
+ expect(children).to eq(expected_children)
121
119
  end
122
120
  end
123
121
  end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Search::Operation::Group::Intersection do
4
- it { should be_a Metasploit::Model::Search::Operation::Group::Base }
1
+ RSpec.describe Metasploit::Model::Search::Operation::Group::Intersection, type: :model do
2
+ it { is_expected.to be_a Metasploit::Model::Search::Operation::Group::Base }
5
3
  end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Search::Operation::Group::Union do
4
- it { should be_a Metasploit::Model::Search::Operation::Group::Base }
1
+ RSpec.describe Metasploit::Model::Search::Operation::Group::Union, type: :model do
2
+ it { is_expected.to be_a Metasploit::Model::Search::Operation::Group::Base }
5
3
  end
@@ -1,8 +1,6 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Search::Operation::Integer do
1
+ RSpec.describe Metasploit::Model::Search::Operation::Integer, type: :model do
4
2
  context 'validation' do
5
- it { should validate_numericality_of(:value).only_integer }
3
+ it { is_expected.to validate_numericality_of(:value).only_integer }
6
4
  end
7
5
 
8
6
  it_should_behave_like 'Metasploit::Model::Search::Operation::Value::Integer'
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Search::Operation::Null do
1
+ RSpec.describe Metasploit::Model::Search::Operation::Null, type: :model do
4
2
  context 'validation' do
5
3
  context 'operator' do
6
4
  context 'null' do
@@ -41,7 +39,7 @@ describe Metasploit::Model::Search::Operation::Null do
41
39
  end
42
40
 
43
41
  it 'should not record error' do
44
- errors.should_not include(error)
42
+ expect(errors).not_to include(error)
45
43
  end
46
44
  end
47
45
 
@@ -51,11 +49,11 @@ describe Metasploit::Model::Search::Operation::Null do
51
49
  end
52
50
 
53
51
  it 'should record error' do
54
- errors.should include(error)
52
+ expect(errors).to include(error)
55
53
  end
56
54
 
57
55
  it 'should have no other errors, so that it would be valid without this type check on operator' do
58
- operation.errors.size.should == 1
56
+ expect(operation.errors.size).to eq(1)
59
57
  end
60
58
  end
61
59
  end
@@ -1,7 +1,5 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Search::Operation::Set::Integer do
4
- it { should be_a Metasploit::Model::Search::Operation::Set }
1
+ RSpec.describe Metasploit::Model::Search::Operation::Set::Integer, type: :model do
2
+ it { is_expected.to be_a Metasploit::Model::Search::Operation::Set }
5
3
 
6
4
  it_should_behave_like 'Metasploit::Model::Search::Operation::Value::Integer'
7
5
  end
@@ -1,7 +1,5 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Search::Operation::Set::String do
4
- it { should be_a Metasploit::Model::Search::Operation::Set }
1
+ RSpec.describe Metasploit::Model::Search::Operation::Set::String, type: :model do
2
+ it { is_expected.to be_a Metasploit::Model::Search::Operation::Set }
5
3
 
6
4
  it_should_behave_like 'Metasploit::Model::Search::Operation::Value::String'
7
5
  end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Search::Operation::Set do
1
+ RSpec.describe Metasploit::Model::Search::Operation::Set, type: :model do
4
2
  subject(:set) do
5
3
  described_class.new(
6
4
  operator: operator,
@@ -97,7 +95,7 @@ describe Metasploit::Model::Search::Operation::Set do
97
95
  attribute_set.sample
98
96
  end
99
97
 
100
- it { should_not include(error) }
98
+ it { is_expected.not_to include(error) }
101
99
  end
102
100
 
103
101
  context 'without value in attribute_set' do
@@ -105,7 +103,7 @@ describe Metasploit::Model::Search::Operation::Set do
105
103
  :not_an_member
106
104
  end
107
105
 
108
- it { should include(error) }
106
+ it { is_expected.to include(error) }
109
107
  end
110
108
  end
111
109
 
@@ -118,7 +116,7 @@ describe Metasploit::Model::Search::Operation::Set do
118
116
  nil
119
117
  end
120
118
 
121
- it { should_not include(error) }
119
+ it { is_expected.not_to include(error) }
122
120
  end
123
121
  end
124
122
  end
@@ -1,8 +1,6 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Search::Operation::String do
1
+ RSpec.describe Metasploit::Model::Search::Operation::String, type: :model do
4
2
  context 'validation' do
5
- it { should validate_presence_of(:value) }
3
+ it { is_expected.to validate_presence_of(:value) }
6
4
  end
7
5
 
8
6
  it_should_behave_like 'Metasploit::Model::Search::Operation::Value::String'
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Search::Operator::Association do
1
+ RSpec.describe Metasploit::Model::Search::Operator::Association, type: :model do
4
2
  subject(:operator) do
5
3
  described_class.new(
6
4
  :association => association,
@@ -16,11 +14,11 @@ describe Metasploit::Model::Search::Operator::Association do
16
14
  double('Metasploit::Model::Search::Operator::Base')
17
15
  end
18
16
 
19
- it { should be_a Metasploit::Model::Search::Operator::Base }
17
+ it { is_expected.to be_a Metasploit::Model::Search::Operator::Base }
20
18
 
21
19
  context 'validations' do
22
- it { should validate_presence_of(:association) }
23
- it { should validate_presence_of(:source_operator) }
20
+ it { is_expected.to validate_presence_of(:association) }
21
+ it { is_expected.to validate_presence_of(:source_operator) }
24
22
  end
25
23
 
26
24
  context '#help' do
@@ -51,7 +49,7 @@ describe Metasploit::Model::Search::Operator::Association do
51
49
  'source_operator_name'
52
50
  }
53
51
 
54
- it { should be_a Symbol }
52
+ it { is_expected.to be_a Symbol }
55
53
 
56
54
  it 'should be <association>.<source_operator.name>' do
57
55
  expect(name).to eq :"#{association}.#{source_operator_name}"
@@ -81,7 +79,7 @@ describe Metasploit::Model::Search::Operator::Association do
81
79
  }
82
80
  }
83
81
 
84
- it { should be_a Metasploit::Model::Search::Operation::Association }
82
+ it { is_expected.to be_a Metasploit::Model::Search::Operation::Association }
85
83
 
86
84
  context 'Metasploit::Model::Search::Operation::Association' do
87
85
  context '#operator' do
@@ -1,7 +1,5 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Search::Operator::Attribute do
4
- it { should be_a Metasploit::Model::Search::Operator::Single }
1
+ RSpec.describe Metasploit::Model::Search::Operator::Attribute, type: :model do
2
+ it { is_expected.to be_a Metasploit::Model::Search::Operator::Single }
5
3
 
6
4
  context 'CONSTANTS' do
7
5
  context 'TYPES' do
@@ -9,30 +7,30 @@ describe Metasploit::Model::Search::Operator::Attribute do
9
7
  described_class::TYPES
10
8
  end
11
9
 
12
- it { should include(:boolean) }
13
- it { should include(:date) }
10
+ it { is_expected.to include(:boolean) }
11
+ it { is_expected.to include(:date) }
14
12
  it {
15
- should include(
13
+ is_expected.to include(
16
14
  {
17
15
  set: :integer
18
16
  }
19
17
  )
20
18
  }
21
19
  it {
22
- should include(
20
+ is_expected.to include(
23
21
  {
24
22
  set: :string
25
23
  }
26
24
  )
27
25
  }
28
- it { should include(:integer) }
29
- it { should include(:string) }
26
+ it { is_expected.to include(:integer) }
27
+ it { is_expected.to include(:string) }
30
28
  end
31
29
  end
32
30
 
33
31
  context 'validations' do
34
- it { should validate_presence_of(:attribute) }
35
- it { should validate_inclusion_of(:type).in_array(described_class::TYPES) }
32
+ it { is_expected.to validate_presence_of(:attribute) }
33
+ it { is_expected.to validate_inclusion_of(:type).in_array(described_class::TYPES) }
36
34
  end
37
35
 
38
36
  context '#attribute_enumerable' do
@@ -77,7 +75,7 @@ describe Metasploit::Model::Search::Operator::Attribute do
77
75
  end
78
76
 
79
77
  it 'should be #klass #<attribute>_set' do
80
- attribute_set.should == expected_attribute_set
78
+ expect(attribute_set).to eq(expected_attribute_set)
81
79
  end
82
80
  end
83
81
  end
@@ -98,7 +96,7 @@ describe Metasploit::Model::Search::Operator::Attribute do
98
96
  end
99
97
 
100
98
  it 'should be #attribute' do
101
- name.should == attribute
99
+ expect(name).to eq(attribute)
102
100
  end
103
101
  end
104
- end
102
+ end
@@ -1,6 +1,4 @@
1
- require 'spec_helper'
2
-
3
- describe Metasploit::Model::Search::Operator::Base do
1
+ RSpec.describe Metasploit::Model::Search::Operator::Base, type: :model do
4
2
  subject(:operator) do
5
3
  described_class.new
6
4
  end
@@ -12,12 +10,12 @@ describe Metasploit::Model::Search::Operator::Base do
12
10
 
13
11
  before(:each) do
14
12
  # have to stub since it's not implemented on base
15
- operator.stub(name: name)
13
+ allow(operator).to receive(:name).and_return(name)
16
14
  end
17
15
  end
18
16
 
19
17
  context 'validations' do
20
- it { should validate_presence_of(:klass) }
18
+ it { is_expected.to validate_presence_of(:klass) }
21
19
  end
22
20
 
23
21
  context '#name' do