metasploit_data_models 0.24.0 → 0.24.1.pre.rspec.pre.3.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +3 -3
- data/Gemfile +1 -3
- data/app/models/metasploit_data_models/ip_address/v4/segmented.rb +1 -1
- data/app/models/metasploit_data_models/search/visitor/where.rb +1 -1
- data/app/validators/password_is_strong_validator.rb +1 -1
- data/lib/mdm/host/operating_system_normalization.rb +0 -10
- data/lib/metasploit_data_models/version.rb +2 -2
- data/metasploit_data_models.gemspec +1 -1
- data/spec/app/models/mdm/api_key_spec.rb +1 -3
- data/spec/app/models/mdm/client_spec.rb +9 -11
- data/spec/app/models/mdm/cred_spec.rb +42 -54
- data/spec/app/models/mdm/event_spec.rb +21 -23
- data/spec/app/models/mdm/exploit_attempt_spec.rb +19 -21
- data/spec/app/models/mdm/exploited_host_spec.rb +11 -13
- data/spec/app/models/mdm/host_detail_spec.rb +15 -17
- data/spec/app/models/mdm/host_spec.rb +261 -260
- data/spec/app/models/mdm/host_tag_spec.rb +6 -8
- data/spec/app/models/mdm/listener_spec.rb +30 -32
- data/spec/app/models/mdm/loot_spec.rb +21 -23
- data/spec/app/models/mdm/macro_spec.rb +1 -3
- data/spec/app/models/mdm/mod_ref_spec.rb +1 -3
- data/spec/app/models/mdm/module/action_spec.rb +10 -12
- data/spec/app/models/mdm/module/arch_spec.rb +10 -12
- data/spec/app/models/mdm/module/author_spec.rb +22 -17
- data/spec/app/models/mdm/module/detail_spec.rb +184 -75
- data/spec/app/models/mdm/module/mixin_spec.rb +10 -12
- data/spec/app/models/mdm/module/platform_spec.rb +10 -12
- data/spec/app/models/mdm/module/ref_spec.rb +10 -12
- data/spec/app/models/mdm/module/target_spec.rb +13 -15
- data/spec/app/models/mdm/nexpose_console_spec.rb +35 -37
- data/spec/app/models/mdm/note_spec.rb +23 -25
- data/spec/app/models/mdm/profile_spec.rb +1 -3
- data/spec/app/models/mdm/ref_spec.rb +10 -12
- data/spec/app/models/mdm/route_spec.rb +6 -8
- data/spec/app/models/mdm/service_spec.rb +38 -40
- data/spec/app/models/mdm/session_event_spec.rb +10 -12
- data/spec/app/models/mdm/session_spec.rb +13 -15
- data/spec/app/models/mdm/tag_spec.rb +29 -29
- data/spec/app/models/mdm/task_cred_spec.rb +9 -11
- data/spec/app/models/mdm/task_host_spec.rb +9 -11
- data/spec/app/models/mdm/task_service_spec.rb +9 -11
- data/spec/app/models/mdm/task_session_spec.rb +7 -9
- data/spec/app/models/mdm/task_spec.rb +27 -29
- data/spec/app/models/mdm/user_spec.rb +17 -19
- data/spec/app/models/mdm/vuln_attempt_spec.rb +14 -16
- data/spec/app/models/mdm/vuln_detail_spec.rb +26 -28
- data/spec/app/models/mdm/vuln_ref_spec.rb +8 -10
- data/spec/app/models/mdm/vuln_spec.rb +24 -26
- data/spec/app/models/mdm/web_form_spec.rb +11 -13
- data/spec/app/models/mdm/web_page_spec.rb +19 -21
- data/spec/app/models/mdm/web_site_spec.rb +21 -23
- data/spec/app/models/mdm/web_vuln_spec.rb +63 -65
- data/spec/app/models/mdm/wmap_request_spec.rb +1 -3
- data/spec/app/models/mdm/wmap_target_spec.rb +1 -3
- data/spec/app/models/mdm/workspace_spec.rb +97 -100
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_result_spec.rb +3 -5
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_set_spec.rb +13 -15
- data/spec/app/models/metasploit_data_models/automatic_exploitation/match_spec.rb +1 -3
- data/spec/app/models/metasploit_data_models/automatic_exploitation/run_spec.rb +1 -3
- data/spec/app/models/metasploit_data_models/ip_address/v4/cidr_spec.rb +10 -12
- data/spec/app/models/metasploit_data_models/ip_address/v4/nmap_spec.rb +4 -6
- data/spec/app/models/metasploit_data_models/ip_address/v4/range_spec.rb +21 -23
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/list_spec.rb +9 -11
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/nmap/range_spec.rb +21 -23
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/segmented_spec.rb +4 -6
- data/spec/app/models/metasploit_data_models/ip_address/v4/segment/single_spec.rb +22 -15
- data/spec/app/models/metasploit_data_models/ip_address/v4/single_spec.rb +4 -6
- data/spec/app/models/metasploit_data_models/module_run_spec.rb +1 -3
- data/spec/app/models/metasploit_data_models/search/operation/ip_address_spec.rb +18 -20
- data/spec/app/models/metasploit_data_models/search/operation/port/number_spec.rb +6 -8
- data/spec/app/models/metasploit_data_models/search/operation/port/range_spec.rb +8 -10
- data/spec/app/models/metasploit_data_models/search/operation/range_spec.rb +8 -10
- data/spec/app/models/metasploit_data_models/search/operator/ip_address_spec.rb +2 -4
- data/spec/app/models/metasploit_data_models/search/operator/multitext_spec.rb +8 -10
- data/spec/app/models/metasploit_data_models/search/operator/port/list_spec.rb +6 -8
- data/spec/app/models/metasploit_data_models/search/visitor/attribute_spec.rb +9 -11
- data/spec/app/models/metasploit_data_models/search/visitor/includes_spec.rb +5 -7
- data/spec/app/models/metasploit_data_models/search/visitor/joins_spec.rb +17 -19
- data/spec/app/models/metasploit_data_models/search/visitor/method_spec.rb +5 -7
- data/spec/app/models/metasploit_data_models/search/visitor/relation_spec.rb +61 -23
- data/spec/app/models/metasploit_data_models/search/visitor/where_spec.rb +8 -10
- data/spec/app/validators/parameters_validator_spec.rb +29 -29
- data/spec/app/validators/password_is_strong_validator_spec.rb +54 -46
- data/spec/dummy/db/structure.sql +1 -0
- data/spec/lib/base64_serializer_spec.rb +19 -19
- data/spec/lib/metasploit_data_models/ip_address/cidr_spec.rb +18 -12
- data/spec/lib/metasploit_data_models/ip_address/range_spec.rb +4 -6
- data/spec/lib/metasploit_data_models/match/child_spec.rb +2 -4
- data/spec/lib/metasploit_data_models/match/parent_spec.rb +4 -6
- data/spec/lib/metasploit_data_models/version_spec.rb +3 -5
- data/spec/spec_helper.rb +72 -6
- data/spec/support/shared/examples/mdm/module/detail/does_not_support_stance_with_mtype.rb +2 -2
- data/spec/support/shared/examples/mdm/module/detail/supports_stance_with_mtype.rb +4 -4
- data/spec/support/shared/examples/metasploit_data_models/search/operation/ipaddress/match.rb +2 -2
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_children.rb +5 -5
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/includes/visit/with_metasploit_model_search_operation_base.rb +5 -5
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_equality.rb +3 -3
- data/spec/support/shared/examples/metasploit_data_models/search/visitor/where/visit/with_metasploit_model_search_group_base.rb +7 -6
- metadata +6 -6
@@ -1,21 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe Mdm::Module::Mixin do
|
1
|
+
RSpec.describe Mdm::Module::Mixin, type: :model do
|
4
2
|
|
5
3
|
it_should_behave_like 'Metasploit::Concern.run'
|
6
4
|
|
7
5
|
context 'associations' do
|
8
|
-
it {
|
6
|
+
it { is_expected.to belong_to(:detail).class_name('Mdm::Module::Detail') }
|
9
7
|
end
|
10
8
|
|
11
9
|
context 'database' do
|
12
10
|
context 'columns' do
|
13
|
-
it {
|
14
|
-
it {
|
11
|
+
it { is_expected.to have_db_column(:detail_id).of_type(:integer) }
|
12
|
+
it { is_expected.to have_db_column(:name).of_type(:text) }
|
15
13
|
end
|
16
14
|
|
17
15
|
context 'indices' do
|
18
|
-
it {
|
16
|
+
it { is_expected.to have_db_index(:detail_id) }
|
19
17
|
end
|
20
18
|
end
|
21
19
|
|
@@ -25,17 +23,17 @@ describe Mdm::Module::Mixin do
|
|
25
23
|
FactoryGirl.build :mdm_module_mixin
|
26
24
|
end
|
27
25
|
|
28
|
-
it {
|
26
|
+
it { is_expected.to be_valid }
|
29
27
|
end
|
30
28
|
end
|
31
29
|
|
32
30
|
context 'mass assignment security' do
|
33
|
-
it {
|
34
|
-
it {
|
31
|
+
it { is_expected.not_to allow_mass_assignment_of(:detail_id) }
|
32
|
+
it { is_expected.to allow_mass_assignment_of(:name) }
|
35
33
|
end
|
36
34
|
|
37
35
|
context 'validations' do
|
38
|
-
it {
|
39
|
-
it {
|
36
|
+
it { is_expected.to validate_presence_of(:detail) }
|
37
|
+
it { is_expected.to validate_presence_of(:name) }
|
40
38
|
end
|
41
39
|
end
|
@@ -1,21 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe Mdm::Module::Platform do
|
1
|
+
RSpec.describe Mdm::Module::Platform, type: :model do
|
4
2
|
|
5
3
|
it_should_behave_like 'Metasploit::Concern.run'
|
6
4
|
|
7
5
|
context 'associations' do
|
8
|
-
it {
|
6
|
+
it { is_expected.to belong_to(:detail).class_name('Mdm::Module::Detail') }
|
9
7
|
end
|
10
8
|
|
11
9
|
context 'database' do
|
12
10
|
context 'columns' do
|
13
|
-
it {
|
14
|
-
it {
|
11
|
+
it { is_expected.to have_db_column(:detail_id).of_type(:integer) }
|
12
|
+
it { is_expected.to have_db_column(:name).of_type(:text) }
|
15
13
|
end
|
16
14
|
|
17
15
|
context 'indices' do
|
18
|
-
it {
|
16
|
+
it { is_expected.to have_db_index(:detail_id) }
|
19
17
|
end
|
20
18
|
end
|
21
19
|
|
@@ -25,17 +23,17 @@ describe Mdm::Module::Platform do
|
|
25
23
|
FactoryGirl.build :mdm_module_platform
|
26
24
|
end
|
27
25
|
|
28
|
-
it {
|
26
|
+
it { is_expected.to be_valid }
|
29
27
|
end
|
30
28
|
end
|
31
29
|
|
32
30
|
context 'mass assignment security' do
|
33
|
-
it {
|
34
|
-
it {
|
31
|
+
it { is_expected.not_to allow_mass_assignment_of(:detail_id) }
|
32
|
+
it { is_expected.to allow_mass_assignment_of(:name) }
|
35
33
|
end
|
36
34
|
|
37
35
|
context 'validations' do
|
38
|
-
it {
|
39
|
-
it {
|
36
|
+
it { is_expected.to validate_presence_of :detail }
|
37
|
+
it { is_expected.to validate_presence_of :name }
|
40
38
|
end
|
41
39
|
end
|
@@ -1,11 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe Mdm::Module::Ref do
|
1
|
+
RSpec.describe Mdm::Module::Ref, type: :model do
|
4
2
|
|
5
3
|
it_should_behave_like 'Metasploit::Concern.run'
|
6
4
|
|
7
5
|
context 'associations' do
|
8
|
-
it {
|
6
|
+
it { is_expected.to belong_to(:detail).class_name('Mdm::Module::Detail') }
|
9
7
|
|
10
8
|
# shoulda matchers don't have support for :primary_key option, so need
|
11
9
|
# to test this association manually
|
@@ -34,12 +32,12 @@ describe Mdm::Module::Ref do
|
|
34
32
|
|
35
33
|
context 'database' do
|
36
34
|
context 'columns' do
|
37
|
-
it {
|
38
|
-
it {
|
35
|
+
it { is_expected.to have_db_column(:detail_id).of_type(:integer) }
|
36
|
+
it { is_expected.to have_db_column(:name) }
|
39
37
|
end
|
40
38
|
|
41
39
|
context 'indices' do
|
42
|
-
it {
|
40
|
+
it { is_expected.to have_db_column(:detail_id) }
|
43
41
|
end
|
44
42
|
end
|
45
43
|
|
@@ -49,17 +47,17 @@ describe Mdm::Module::Ref do
|
|
49
47
|
FactoryGirl.build :mdm_module_ref
|
50
48
|
end
|
51
49
|
|
52
|
-
it {
|
50
|
+
it { is_expected.to be_valid }
|
53
51
|
end
|
54
52
|
end
|
55
53
|
|
56
54
|
context 'mass assignment security' do
|
57
|
-
it {
|
58
|
-
it {
|
55
|
+
it { is_expected.not_to allow_mass_assignment_of(:detail_id) }
|
56
|
+
it { is_expected.to allow_mass_assignment_of(:name) }
|
59
57
|
end
|
60
58
|
|
61
59
|
context 'validations' do
|
62
|
-
it {
|
63
|
-
it {
|
60
|
+
it { is_expected.to validate_presence_of(:detail) }
|
61
|
+
it { is_expected.to validate_presence_of(:name) }
|
64
62
|
end
|
65
63
|
end
|
@@ -1,22 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe Mdm::Module::Target do
|
1
|
+
RSpec.describe Mdm::Module::Target, type: :model do
|
4
2
|
|
5
3
|
it_should_behave_like 'Metasploit::Concern.run'
|
6
4
|
|
7
5
|
context 'associations' do
|
8
|
-
it {
|
6
|
+
it { is_expected.to belong_to(:detail).class_name('Mdm::Module::Detail') }
|
9
7
|
end
|
10
8
|
|
11
9
|
context 'database' do
|
12
10
|
context 'columns' do
|
13
|
-
it {
|
14
|
-
it {
|
15
|
-
it {
|
11
|
+
it { is_expected.to have_db_column(:detail_id).of_type(:integer) }
|
12
|
+
it { is_expected.to have_db_column(:index).of_type(:integer) }
|
13
|
+
it { is_expected.to have_db_column(:name).of_type(:text) }
|
16
14
|
end
|
17
15
|
|
18
16
|
context 'indices' do
|
19
|
-
it {
|
17
|
+
it { is_expected.to have_db_index(:detail_id) }
|
20
18
|
end
|
21
19
|
end
|
22
20
|
|
@@ -26,19 +24,19 @@ describe Mdm::Module::Target do
|
|
26
24
|
FactoryGirl.build :mdm_module_target
|
27
25
|
end
|
28
26
|
|
29
|
-
it {
|
27
|
+
it { is_expected.to be_valid }
|
30
28
|
end
|
31
29
|
end
|
32
30
|
|
33
31
|
context 'mass assignment security' do
|
34
|
-
it {
|
35
|
-
it {
|
36
|
-
it {
|
32
|
+
it { is_expected.not_to allow_mass_assignment_of(:detail_id) }
|
33
|
+
it { is_expected.to allow_mass_assignment_of(:index) }
|
34
|
+
it { is_expected.to allow_mass_assignment_of(:name) }
|
37
35
|
end
|
38
36
|
|
39
37
|
context 'validations' do
|
40
|
-
it {
|
41
|
-
it {
|
42
|
-
it {
|
38
|
+
it { is_expected.to validate_presence_of(:detail) }
|
39
|
+
it { is_expected.to validate_presence_of(:index) }
|
40
|
+
it { is_expected.to validate_presence_of(:name) }
|
43
41
|
end
|
44
42
|
end
|
@@ -1,34 +1,32 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe Mdm::NexposeConsole do
|
1
|
+
RSpec.describe Mdm::NexposeConsole, type: :model do
|
4
2
|
it_should_behave_like 'Metasploit::Concern.run'
|
5
3
|
|
6
4
|
context 'factory' do
|
7
5
|
it 'should be valid' do
|
8
6
|
nexpose_console = FactoryGirl.build(:mdm_nexpose_console)
|
9
|
-
nexpose_console.
|
7
|
+
expect(nexpose_console).to be_valid
|
10
8
|
end
|
11
9
|
end
|
12
10
|
|
13
11
|
context 'database' do
|
14
12
|
|
15
13
|
context 'timestamps'do
|
16
|
-
it {
|
17
|
-
it {
|
14
|
+
it { is_expected.to have_db_column(:created_at).of_type(:datetime).with_options(:null => false) }
|
15
|
+
it { is_expected.to have_db_column(:updated_at).of_type(:datetime).with_options(:null => false) }
|
18
16
|
end
|
19
17
|
|
20
18
|
context 'columns' do
|
21
|
-
it {
|
22
|
-
it {
|
23
|
-
it {
|
24
|
-
it {
|
25
|
-
it {
|
26
|
-
it {
|
27
|
-
it {
|
28
|
-
it {
|
29
|
-
it {
|
30
|
-
it {
|
31
|
-
it {
|
19
|
+
it { is_expected.to have_db_column(:enabled).of_type(:boolean).with_options(:default => true) }
|
20
|
+
it { is_expected.to have_db_column(:owner).of_type(:text) }
|
21
|
+
it { is_expected.to have_db_column(:address).of_type(:text) }
|
22
|
+
it { is_expected.to have_db_column(:port).of_type(:integer).with_options(:default => 3780) }
|
23
|
+
it { is_expected.to have_db_column(:username).of_type(:text) }
|
24
|
+
it { is_expected.to have_db_column(:password).of_type(:text) }
|
25
|
+
it { is_expected.to have_db_column(:status).of_type(:text) }
|
26
|
+
it { is_expected.to have_db_column(:version).of_type(:text) }
|
27
|
+
it { is_expected.to have_db_column(:cert).of_type(:text) }
|
28
|
+
it { is_expected.to have_db_column(:cached_sites).of_type(:binary) }
|
29
|
+
it { is_expected.to have_db_column(:name).of_type(:text) }
|
32
30
|
end
|
33
31
|
end
|
34
32
|
|
@@ -48,74 +46,74 @@ describe Mdm::NexposeConsole do
|
|
48
46
|
context 'address' do
|
49
47
|
it 'should require an address' do
|
50
48
|
addressless_nexpose_console = FactoryGirl.build(:mdm_nexpose_console, :address => nil)
|
51
|
-
addressless_nexpose_console.
|
52
|
-
addressless_nexpose_console.errors[:address].
|
49
|
+
expect(addressless_nexpose_console).not_to be_valid
|
50
|
+
expect(addressless_nexpose_console.errors[:address]).to include("can't be blank")
|
53
51
|
end
|
54
52
|
|
55
53
|
it 'should be valid for IPv4 format' do
|
56
54
|
ipv4_nexpose_console = FactoryGirl.build(:mdm_nexpose_console, :address => '192.168.1.120')
|
57
|
-
ipv4_nexpose_console.
|
55
|
+
expect(ipv4_nexpose_console).to be_valid
|
58
56
|
end
|
59
57
|
|
60
58
|
it 'should be valid for IPv6 format' do
|
61
59
|
ipv6_nexpose_console = FactoryGirl.build(:mdm_nexpose_console, :address => '2001:0db8:85a3:0000:0000:8a2e:0370:7334')
|
62
|
-
ipv6_nexpose_console.
|
60
|
+
expect(ipv6_nexpose_console).to be_valid
|
63
61
|
end
|
64
62
|
end
|
65
63
|
|
66
64
|
context 'port' do
|
67
65
|
it 'should require a port' do
|
68
66
|
portless_nexpose_console = FactoryGirl.build(:mdm_nexpose_console, :port => nil)
|
69
|
-
portless_nexpose_console.
|
70
|
-
portless_nexpose_console.errors[:port].
|
67
|
+
expect(portless_nexpose_console).not_to be_valid
|
68
|
+
expect(portless_nexpose_console.errors[:port]).to include("is not included in the list")
|
71
69
|
end
|
72
70
|
|
73
71
|
it 'should not be valid for out-of-range numbers' do
|
74
72
|
out_of_range = FactoryGirl.build(:mdm_nexpose_console, :port => 70000)
|
75
|
-
out_of_range.
|
76
|
-
out_of_range.errors[:port].
|
73
|
+
expect(out_of_range).not_to be_valid
|
74
|
+
expect(out_of_range.errors[:port]).to include("is not included in the list")
|
77
75
|
end
|
78
76
|
|
79
77
|
it 'should not be valid for port 0' do
|
80
78
|
out_of_range = FactoryGirl.build(:mdm_nexpose_console, :port => 0)
|
81
|
-
out_of_range.
|
82
|
-
out_of_range.errors[:port].
|
79
|
+
expect(out_of_range).not_to be_valid
|
80
|
+
expect(out_of_range.errors[:port]).to include("is not included in the list")
|
83
81
|
end
|
84
82
|
|
85
83
|
it 'should not be valid for decimal numbers' do
|
86
84
|
out_of_range = FactoryGirl.build(:mdm_nexpose_console, :port => 5.67)
|
87
|
-
out_of_range.
|
88
|
-
out_of_range.errors[:port].
|
85
|
+
expect(out_of_range).not_to be_valid
|
86
|
+
expect(out_of_range.errors[:port]).to include("must be an integer")
|
89
87
|
end
|
90
88
|
|
91
89
|
it 'should not be valid for a negative number' do
|
92
90
|
out_of_range = FactoryGirl.build(:mdm_nexpose_console, :port => -8)
|
93
|
-
out_of_range.
|
94
|
-
out_of_range.errors[:port].
|
91
|
+
expect(out_of_range).not_to be_valid
|
92
|
+
expect(out_of_range.errors[:port]).to include("is not included in the list")
|
95
93
|
end
|
96
94
|
end
|
97
95
|
|
98
96
|
context 'name' do
|
99
97
|
it 'should require a name' do
|
100
98
|
unnamed_console = FactoryGirl.build(:mdm_nexpose_console, :name => nil)
|
101
|
-
unnamed_console.
|
102
|
-
unnamed_console.errors[:name].
|
99
|
+
expect(unnamed_console).not_to be_valid
|
100
|
+
expect(unnamed_console.errors[:name]).to include("can't be blank")
|
103
101
|
end
|
104
102
|
end
|
105
103
|
|
106
104
|
context 'username' do
|
107
105
|
it 'should require a name' do
|
108
106
|
console = FactoryGirl.build(:mdm_nexpose_console, :username => nil)
|
109
|
-
console.
|
110
|
-
console.errors[:username].
|
107
|
+
expect(console).not_to be_valid
|
108
|
+
expect(console.errors[:username]).to include("can't be blank")
|
111
109
|
end
|
112
110
|
end
|
113
111
|
|
114
112
|
context 'password' do
|
115
113
|
it 'should require a password' do
|
116
114
|
console = FactoryGirl.build(:mdm_nexpose_console, :password => nil)
|
117
|
-
console.
|
118
|
-
console.errors[:password].
|
115
|
+
expect(console).not_to be_valid
|
116
|
+
expect(console.errors[:password]).to include("can't be blank")
|
119
117
|
end
|
120
118
|
end
|
121
119
|
|
@@ -1,31 +1,29 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe Mdm::Note do
|
1
|
+
RSpec.describe Mdm::Note, type: :model do
|
4
2
|
it_should_behave_like 'Metasploit::Concern.run'
|
5
3
|
|
6
4
|
context 'factory' do
|
7
5
|
it 'should be valid' do
|
8
6
|
note = FactoryGirl.build(:mdm_note)
|
9
|
-
note.
|
7
|
+
expect(note).to be_valid
|
10
8
|
end
|
11
9
|
end
|
12
10
|
|
13
11
|
context 'database' do
|
14
12
|
|
15
13
|
context 'timestamps'do
|
16
|
-
it {
|
17
|
-
it {
|
14
|
+
it { is_expected.to have_db_column(:created_at).of_type(:datetime) }
|
15
|
+
it { is_expected.to have_db_column(:updated_at).of_type(:datetime) }
|
18
16
|
end
|
19
17
|
|
20
18
|
context 'columns' do
|
21
|
-
it {
|
22
|
-
it {
|
23
|
-
it {
|
24
|
-
it {
|
25
|
-
it {
|
26
|
-
it {
|
27
|
-
it {
|
28
|
-
it {
|
19
|
+
it { is_expected.to have_db_column(:workspace_id).of_type(:integer).with_options(:null => false, :default =>1) }
|
20
|
+
it { is_expected.to have_db_column(:host_id).of_type(:integer) }
|
21
|
+
it { is_expected.to have_db_column(:service_id).of_type(:integer) }
|
22
|
+
it { is_expected.to have_db_column(:vuln_id).of_type(:integer) }
|
23
|
+
it { is_expected.to have_db_column(:ntype).of_type(:string) }
|
24
|
+
it { is_expected.to have_db_column(:critical).of_type(:boolean) }
|
25
|
+
it { is_expected.to have_db_column(:seen).of_type(:boolean) }
|
26
|
+
it { is_expected.to have_db_column(:data).of_type(:text) }
|
29
27
|
end
|
30
28
|
end
|
31
29
|
|
@@ -42,10 +40,10 @@ describe Mdm::Note do
|
|
42
40
|
end
|
43
41
|
|
44
42
|
context 'associations' do
|
45
|
-
it {
|
46
|
-
it {
|
47
|
-
it {
|
48
|
-
it {
|
43
|
+
it { is_expected.to belong_to(:workspace).class_name('Mdm::Workspace') }
|
44
|
+
it { is_expected.to belong_to(:host).class_name('Mdm::Host') }
|
45
|
+
it { is_expected.to belong_to(:service).class_name('Mdm::Service') }
|
46
|
+
it { is_expected.to belong_to(:vuln).class_name('Mdm::Vuln') }
|
49
47
|
end
|
50
48
|
|
51
49
|
context 'scopes' do
|
@@ -54,16 +52,16 @@ describe Mdm::Note do
|
|
54
52
|
flagged_note = FactoryGirl.create(:mdm_note, :critical => true, :seen => false)
|
55
53
|
non_critical_note = FactoryGirl.create(:mdm_note, :critical => false, :seen => false)
|
56
54
|
flagged_set = Mdm::Note.flagged
|
57
|
-
flagged_set.
|
58
|
-
flagged_set.
|
55
|
+
expect(flagged_set).to include(flagged_note)
|
56
|
+
expect(flagged_set).not_to include(non_critical_note)
|
59
57
|
end
|
60
58
|
|
61
59
|
it 'should exclude seen notes' do
|
62
60
|
flagged_note = FactoryGirl.create(:mdm_note, :critical => true, :seen => false)
|
63
61
|
non_critical_note = FactoryGirl.create(:mdm_note, :critical => false, :seen => true)
|
64
62
|
flagged_set = Mdm::Note.flagged
|
65
|
-
flagged_set.
|
66
|
-
flagged_set.
|
63
|
+
expect(flagged_set).to include(flagged_note)
|
64
|
+
expect(flagged_set).not_to include(non_critical_note)
|
67
65
|
end
|
68
66
|
end
|
69
67
|
|
@@ -72,15 +70,15 @@ describe Mdm::Note do
|
|
72
70
|
flagged_note = FactoryGirl.create(:mdm_note, :ntype => 'flag.me', :critical => true, :seen => false)
|
73
71
|
webform_note = FactoryGirl.create(:mdm_note, :ntype => 'web.form', :critical => true, :seen => false)
|
74
72
|
visible_set = Mdm::Note.visible
|
75
|
-
visible_set.
|
76
|
-
visible_set.
|
73
|
+
expect(visible_set).to include(flagged_note)
|
74
|
+
expect(visible_set).not_to include(webform_note)
|
77
75
|
end
|
78
76
|
end
|
79
77
|
|
80
78
|
context 'search' do
|
81
79
|
it 'should match on ntype' do
|
82
80
|
flagged_note = FactoryGirl.create(:mdm_note, :ntype => 'flag.me', :critical => true, :seen => false)
|
83
|
-
Mdm::Note.search('flag.me').
|
81
|
+
expect(Mdm::Note.search('flag.me')).to include(flagged_note)
|
84
82
|
end
|
85
83
|
end
|
86
84
|
end
|