metasploit_data_models 0.6.13
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +24 -0
- data/.rspec +3 -0
- data/.simplecov +38 -0
- data/.yardopts +4 -0
- data/Gemfile +27 -0
- data/LICENSE +27 -0
- data/README.md +72 -0
- data/Rakefile +53 -0
- data/app/models/mdm/api_key.rb +20 -0
- data/app/models/mdm/client.rb +9 -0
- data/app/models/mdm/cred.rb +80 -0
- data/app/models/mdm/event.rb +30 -0
- data/app/models/mdm/exploit_attempt.rb +14 -0
- data/app/models/mdm/exploited_host.rb +11 -0
- data/app/models/mdm/host.rb +134 -0
- data/app/models/mdm/host_detail.rb +15 -0
- data/app/models/mdm/host_tag.rb +13 -0
- data/app/models/mdm/imported_cred.rb +10 -0
- data/app/models/mdm/listener.rb +24 -0
- data/app/models/mdm/loot.rb +63 -0
- data/app/models/mdm/macro.rb +20 -0
- data/app/models/mdm/mod_ref.rb +3 -0
- data/app/models/mdm/module_action.rb +24 -0
- data/app/models/mdm/module_arch.rb +24 -0
- data/app/models/mdm/module_author.rb +25 -0
- data/app/models/mdm/module_detail.rb +59 -0
- data/app/models/mdm/module_mixin.rb +24 -0
- data/app/models/mdm/module_platform.rb +24 -0
- data/app/models/mdm/module_ref.rb +24 -0
- data/app/models/mdm/module_target.rb +26 -0
- data/app/models/mdm/nexpose_console.rb +20 -0
- data/app/models/mdm/note.rb +49 -0
- data/app/models/mdm/profile.rb +9 -0
- data/app/models/mdm/ref.rb +14 -0
- data/app/models/mdm/report.rb +50 -0
- data/app/models/mdm/report_template.rb +27 -0
- data/app/models/mdm/route.rb +9 -0
- data/app/models/mdm/service.rb +56 -0
- data/app/models/mdm/session.rb +48 -0
- data/app/models/mdm/session_event.rb +9 -0
- data/app/models/mdm/tag.rb +46 -0
- data/app/models/mdm/task.rb +41 -0
- data/app/models/mdm/user.rb +25 -0
- data/app/models/mdm/vuln.rb +60 -0
- data/app/models/mdm/vuln_attempt.rb +15 -0
- data/app/models/mdm/vuln_detail.rb +14 -0
- data/app/models/mdm/vuln_ref.rb +13 -0
- data/app/models/mdm/web_form.rb +16 -0
- data/app/models/mdm/web_page.rb +16 -0
- data/app/models/mdm/web_site.rb +47 -0
- data/app/models/mdm/web_vuln.rb +190 -0
- data/app/models/mdm/wmap_request.rb +3 -0
- data/app/models/mdm/wmap_target.rb +3 -0
- data/app/models/mdm/workspace.rb +196 -0
- data/bin/mdm_console +68 -0
- data/console_db.yml +9 -0
- data/db/migrate/000_create_tables.rb +79 -0
- data/db/migrate/001_add_wmap_tables.rb +35 -0
- data/db/migrate/002_add_workspaces.rb +36 -0
- data/db/migrate/003_move_notes.rb +20 -0
- data/db/migrate/004_add_events_table.rb +16 -0
- data/db/migrate/005_expand_info.rb +58 -0
- data/db/migrate/006_add_timestamps.rb +26 -0
- data/db/migrate/007_add_loots.rb +20 -0
- data/db/migrate/008_create_users.rb +16 -0
- data/db/migrate/009_add_loots_ctype.rb +10 -0
- data/db/migrate/010_add_alert_fields.rb +16 -0
- data/db/migrate/011_add_reports.rb +19 -0
- data/db/migrate/012_add_tasks.rb +24 -0
- data/db/migrate/013_add_tasks_result.rb +10 -0
- data/db/migrate/014_add_loots_fields.rb +12 -0
- data/db/migrate/015_rename_user.rb +16 -0
- data/db/migrate/016_add_host_purpose.rb +10 -0
- data/db/migrate/017_expand_info2.rb +58 -0
- data/db/migrate/018_add_workspace_user_info.rb +29 -0
- data/db/migrate/019_add_workspace_desc.rb +23 -0
- data/db/migrate/020_add_user_preferences.rb +11 -0
- data/db/migrate/021_standardize_info_and_data.rb +18 -0
- data/db/migrate/022_enlarge_event_info.rb +10 -0
- data/db/migrate/023_add_report_downloaded_at.rb +10 -0
- data/db/migrate/024_convert_service_info_to_text.rb +12 -0
- data/db/migrate/025_add_user_admin.rb +19 -0
- data/db/migrate/026_add_creds_table.rb +19 -0
- data/db/migrate/20100819123300_migrate_cred_data.rb +154 -0
- data/db/migrate/20100824151500_add_exploited_table.rb +16 -0
- data/db/migrate/20100908001428_add_owner_to_workspaces.rb +9 -0
- data/db/migrate/20100911122000_add_report_templates.rb +18 -0
- data/db/migrate/20100916151530_require_admin_flag.rb +15 -0
- data/db/migrate/20100916175000_add_campaigns_and_templates.rb +61 -0
- data/db/migrate/20100920012100_add_generate_exe_column.rb +8 -0
- data/db/migrate/20100926214000_add_template_prefs.rb +11 -0
- data/db/migrate/20101001000000_add_web_tables.rb +57 -0
- data/db/migrate/20101002000000_add_query.rb +10 -0
- data/db/migrate/20101007000000_add_vuln_info.rb +15 -0
- data/db/migrate/20101008111800_add_clients_to_campaigns.rb +10 -0
- data/db/migrate/20101009023300_add_campaign_attachments.rb +15 -0
- data/db/migrate/20101104135100_add_imported_creds.rb +17 -0
- data/db/migrate/20101203000000_fix_web_tables.rb +34 -0
- data/db/migrate/20101203000001_expand_host_comment.rb +12 -0
- data/db/migrate/20101206212033_add_limit_to_network_to_workspaces.rb +9 -0
- data/db/migrate/20110112154300_add_module_uuid_to_tasks.rb +9 -0
- data/db/migrate/20110204112800_add_host_tags.rb +28 -0
- data/db/migrate/20110317144932_add_session_table.rb +110 -0
- data/db/migrate/20110414180600_add_local_id_to_session_table.rb +11 -0
- data/db/migrate/20110415175705_add_routes_table.rb +18 -0
- data/db/migrate/20110422000000_convert_binary.rb +72 -0
- data/db/migrate/20110425095900_add_last_seen_to_sessions.rb +8 -0
- data/db/migrate/20110513143900_track_successful_exploits.rb +31 -0
- data/db/migrate/20110517160800_rename_and_prune_nessus_vulns.rb +26 -0
- data/db/migrate/20110527000000_add_task_id_to_reports_table.rb +11 -0
- data/db/migrate/20110527000001_add_api_keys_table.rb +12 -0
- data/db/migrate/20110606000001_add_macros_table.rb +16 -0
- data/db/migrate/20110622000000_add_settings_to_tasks_table.rb +12 -0
- data/db/migrate/20110624000001_add_listeners_table.rb +19 -0
- data/db/migrate/20110625000001_add_macro_to_listeners_table.rb +12 -0
- data/db/migrate/20110630000001_add_nexpose_consoles_table.rb +21 -0
- data/db/migrate/20110630000002_add_name_to_nexpose_consoles_table.rb +12 -0
- data/db/migrate/20110717000001_add_profiles_table.rb +15 -0
- data/db/migrate/20110727163801_expand_cred_ptype_column.rb +9 -0
- data/db/migrate/20110730000001_add_initial_indexes.rb +85 -0
- data/db/migrate/20110812000001_prune_indexes.rb +23 -0
- data/db/migrate/20110922000000_expand_notes.rb +9 -0
- data/db/migrate/20110928101300_add_mod_ref_table.rb +17 -0
- data/db/migrate/20111011110000_add_display_name_to_reports_table.rb +24 -0
- data/db/migrate/20111203000000_inet_columns.rb +13 -0
- data/db/migrate/20111204000000_more_inet_columns.rb +17 -0
- data/db/migrate/20111210000000_add_scope_to_hosts.rb +9 -0
- data/db/migrate/20120126110000_add_virtual_host_to_hosts.rb +9 -0
- data/db/migrate/20120411173220_rename_workspace_members.rb +9 -0
- data/db/migrate/20120601152442_add_counter_caches_to_hosts.rb +21 -0
- data/db/migrate/20120625000000_add_vuln_details.rb +34 -0
- data/db/migrate/20120625000001_add_host_details.rb +16 -0
- data/db/migrate/20120625000002_expand_details.rb +16 -0
- data/db/migrate/20120625000003_expand_details2.rb +24 -0
- data/db/migrate/20120625000004_add_vuln_attempts.rb +19 -0
- data/db/migrate/20120625000005_add_vuln_and_host_counter_caches.rb +14 -0
- data/db/migrate/20120625000006_add_module_details.rb +118 -0
- data/db/migrate/20120625000007_add_exploit_attempts.rb +26 -0
- data/db/migrate/20120625000008_add_fail_message.rb +12 -0
- data/db/migrate/20120718202805_add_owner_and_payload_to_web_vulns.rb +13 -0
- data/db/migrate/20130228214900_change_required_columns_to_null_false_in_web_vulns.rb +35 -0
- data/lib/mdm.rb +12 -0
- data/lib/mdm/host/operating_system_normalization.rb +984 -0
- data/lib/metasploit_data_models.rb +60 -0
- data/lib/metasploit_data_models/base64_serializer.rb +103 -0
- data/lib/metasploit_data_models/engine.rb +23 -0
- data/lib/metasploit_data_models/serialized_prefs.rb +23 -0
- data/lib/metasploit_data_models/validators/ip_format_validator.rb +13 -0
- data/lib/metasploit_data_models/validators/password_is_strong_validator.rb +70 -0
- data/lib/metasploit_data_models/version.rb +8 -0
- data/lib/tasks/yard.rake +26 -0
- data/metasploit_data_models.gemspec +31 -0
- data/script/rails +8 -0
- data/spec/app/models/mdm/module_action_spec.rb +38 -0
- data/spec/app/models/mdm/module_arch_spec.rb +38 -0
- data/spec/app/models/mdm/module_author_spec.rb +50 -0
- data/spec/app/models/mdm/module_detail_spec.rb +291 -0
- data/spec/app/models/mdm/module_mixin_spec.rb +38 -0
- data/spec/app/models/mdm/module_platform_spec.rb +38 -0
- data/spec/app/models/mdm/module_ref_spec.rb +38 -0
- data/spec/app/models/mdm/module_target_spec.rb +41 -0
- data/spec/app/models/mdm/web_vuln_spec.rb +126 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +61 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml.example +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/routes.rb +2 -0
- data/spec/dummy/db/schema.rb +638 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/mdm/addresses.rb +7 -0
- data/spec/factories/mdm/hosts.rb +18 -0
- data/spec/factories/mdm/module_actions.rb +14 -0
- data/spec/factories/mdm/module_archs.rb +14 -0
- data/spec/factories/mdm/module_authors.rb +22 -0
- data/spec/factories/mdm/module_details.rb +9 -0
- data/spec/factories/mdm/module_mixins.rb +14 -0
- data/spec/factories/mdm/module_platforms.rb +14 -0
- data/spec/factories/mdm/module_refs.rb +14 -0
- data/spec/factories/mdm/module_targets.rb +19 -0
- data/spec/factories/mdm/services.rb +35 -0
- data/spec/factories/mdm/users.rb +22 -0
- data/spec/factories/mdm/web_sites.rb +8 -0
- data/spec/factories/mdm/web_vulns.rb +64 -0
- data/spec/factories/mdm/workspaces.rb +23 -0
- data/spec/lib/base64_serializer_spec.rb +174 -0
- data/spec/spec_helper.rb +36 -0
- metadata +433 -0
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mdm::ModuleAuthor do
|
4
|
+
context 'associations' do
|
5
|
+
it { should belong_to(:module_detail).class_name('Mdm::ModuleDetail') }
|
6
|
+
end
|
7
|
+
|
8
|
+
context 'database' do
|
9
|
+
context 'columns' do
|
10
|
+
it { should have_db_column(:module_detail_id).of_type(:integer) }
|
11
|
+
it { should have_db_column(:name).of_type(:text) }
|
12
|
+
it { should have_db_column(:email).of_type(:text) }
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'indices' do
|
16
|
+
it { should have_db_index(:module_detail_id) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'factories' do
|
21
|
+
context 'full_mdm_module_author' do
|
22
|
+
subject(:full_mdm_module_author) do
|
23
|
+
FactoryGirl.build :full_mdm_module_author
|
24
|
+
end
|
25
|
+
|
26
|
+
it { should be_valid }
|
27
|
+
its(:email) { should_not be_nil }
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'mdm_module_author' do
|
31
|
+
subject(:mdm_module_author) do
|
32
|
+
FactoryGirl.build :mdm_module_author
|
33
|
+
end
|
34
|
+
|
35
|
+
it { should be_valid }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'mass assignment security' do
|
40
|
+
it { should_not allow_mass_assignment_of(:module_detail_id) }
|
41
|
+
it { should allow_mass_assignment_of(:email) }
|
42
|
+
it { should allow_mass_assignment_of(:name) }
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'validations' do
|
46
|
+
it { should_not validate_presence_of(:email) }
|
47
|
+
it { should validate_presence_of(:module_detail) }
|
48
|
+
it { should validate_presence_of(:name) }
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,291 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mdm::ModuleDetail do
|
4
|
+
subject(:module_detail) do
|
5
|
+
FactoryGirl.build(:mdm_module_detail)
|
6
|
+
end
|
7
|
+
|
8
|
+
context 'associations' do
|
9
|
+
it { should have_many(:actions).class_name('Mdm::ModuleAction').dependent(:destroy) }
|
10
|
+
it { should have_many(:archs).class_name('Mdm::ModuleArch').dependent(:destroy) }
|
11
|
+
it { should have_many(:authors).class_name('Mdm::ModuleAuthor').dependent(:destroy) }
|
12
|
+
it { should have_many(:mixins).class_name('Mdm::ModuleMixin').dependent(:destroy) }
|
13
|
+
it { should have_many(:platforms).class_name('Mdm::ModulePlatform').dependent(:destroy) }
|
14
|
+
it { should have_many(:refs).class_name('Mdm::ModuleRef').dependent(:destroy) }
|
15
|
+
it { should have_many(:targets).class_name('Mdm::ModuleTarget').dependent(:destroy) }
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'database' do
|
19
|
+
context 'columns' do
|
20
|
+
it { should have_db_column(:default_target).of_type(:integer) }
|
21
|
+
it { should have_db_column(:description).of_type(:text) }
|
22
|
+
it { should have_db_column(:disclosure_date).of_type(:datetime)}
|
23
|
+
it { should have_db_column(:file).of_type(:text) }
|
24
|
+
it { should have_db_column(:fullname).of_type(:text) }
|
25
|
+
it { should have_db_column(:license).of_type(:string) }
|
26
|
+
it { should have_db_column(:mtime).of_type(:datetime) }
|
27
|
+
it { should have_db_column(:mtype).of_type(:string) }
|
28
|
+
it { should have_db_column(:name).of_type(:text) }
|
29
|
+
it { should have_db_column(:privileged).of_type(:boolean) }
|
30
|
+
it { should have_db_column(:rank).of_type(:integer) }
|
31
|
+
it { should have_db_column(:ready).of_type(:boolean) }
|
32
|
+
it { should have_db_column(:refname).of_type(:text) }
|
33
|
+
it { should have_db_column(:stance).of_type(:string) }
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'indices' do
|
37
|
+
it { should have_db_index(:description) }
|
38
|
+
it { should have_db_index(:mtype) }
|
39
|
+
it { should have_db_index(:name) }
|
40
|
+
it { should have_db_index(:refname) }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'factories' do
|
45
|
+
context 'mdm_module_detail' do
|
46
|
+
subject(:mdm_module_detail) do
|
47
|
+
FactoryGirl.build(:mdm_module_detail)
|
48
|
+
end
|
49
|
+
|
50
|
+
it { should be_valid }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'validations' do
|
55
|
+
it { should validate_presence_of(:refname) }
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'with saved' do
|
59
|
+
before(:each) do
|
60
|
+
module_detail.save!
|
61
|
+
end
|
62
|
+
|
63
|
+
context '#add_action' do
|
64
|
+
def add_action
|
65
|
+
module_detail.add_action(name)
|
66
|
+
end
|
67
|
+
|
68
|
+
let(:name) do
|
69
|
+
FactoryGirl.generate :mdm_module_action_name
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'should add an Mdm::ModuleAction under the Mdm::ModuleDetail' do
|
73
|
+
expect {
|
74
|
+
add_action
|
75
|
+
}.to change(module_detail.actions, :length).by(1)
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'new Mdm::ModuleAction' do
|
79
|
+
subject(:module_action) do
|
80
|
+
add_action
|
81
|
+
|
82
|
+
module_detail.actions.last
|
83
|
+
end
|
84
|
+
|
85
|
+
it { should be_valid }
|
86
|
+
|
87
|
+
its(:name) { should == name }
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context '#add_arch' do
|
92
|
+
def add_arch
|
93
|
+
module_detail.add_arch(name)
|
94
|
+
end
|
95
|
+
|
96
|
+
let(:name) do
|
97
|
+
FactoryGirl.generate :mdm_module_arch_name
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should add an Mdm::ModuleArch under the Mdm::ModuleDetail' do
|
101
|
+
expect {
|
102
|
+
add_arch
|
103
|
+
}.to change(module_detail.archs, :length).by(1)
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'new Mdm::ModuleArch' do
|
107
|
+
subject(:module_arch) do
|
108
|
+
add_arch
|
109
|
+
|
110
|
+
module_detail.archs.last
|
111
|
+
end
|
112
|
+
|
113
|
+
it { should be_valid }
|
114
|
+
|
115
|
+
its(:name) { should == name }
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context '#add_author' do
|
120
|
+
let(:name) do
|
121
|
+
FactoryGirl.generate :mdm_module_author_name
|
122
|
+
end
|
123
|
+
|
124
|
+
context 'with email' do
|
125
|
+
def add_author
|
126
|
+
module_detail.add_author(name, email)
|
127
|
+
end
|
128
|
+
|
129
|
+
let(:email) do
|
130
|
+
FactoryGirl.generate :mdm_module_author_email
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'should add an Mdm::ModuleAuthor under the Mdm::ModuleDetail' do
|
134
|
+
expect {
|
135
|
+
add_author
|
136
|
+
}.to change(module_detail.authors, :length).by(1)
|
137
|
+
end
|
138
|
+
|
139
|
+
context 'new Mdm::ModuleAuthor' do
|
140
|
+
subject(:module_author) do
|
141
|
+
add_author
|
142
|
+
|
143
|
+
module_detail.authors.last
|
144
|
+
end
|
145
|
+
|
146
|
+
it { should be_valid }
|
147
|
+
|
148
|
+
its(:email) { should == email }
|
149
|
+
its(:name) { should == name }
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
context 'without email' do
|
154
|
+
def add_author
|
155
|
+
module_detail.add_author(name)
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'should add an Mdm::ModuleAuthor under the Mdm::ModuleDetail' do
|
159
|
+
expect {
|
160
|
+
add_author
|
161
|
+
}.to change(module_detail.authors, :length).by(1)
|
162
|
+
end
|
163
|
+
|
164
|
+
context 'new Mdm::ModuleAuthor' do
|
165
|
+
subject(:module_author) do
|
166
|
+
add_author
|
167
|
+
|
168
|
+
module_detail.authors.last
|
169
|
+
end
|
170
|
+
|
171
|
+
it { should be_valid }
|
172
|
+
|
173
|
+
its(:email) { should be_nil }
|
174
|
+
its(:name) { should == name }
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
context '#add_mixin' do
|
180
|
+
def add_mixin
|
181
|
+
module_detail.add_mixin(name)
|
182
|
+
end
|
183
|
+
|
184
|
+
let(:name) do
|
185
|
+
FactoryGirl.generate :mdm_module_mixin_name
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'should add an Mdm::ModuleMixin under the Mdm::ModuleDetail' do
|
189
|
+
expect {
|
190
|
+
add_mixin
|
191
|
+
}.to change(module_detail.mixins, :length).by(1)
|
192
|
+
end
|
193
|
+
|
194
|
+
context 'new Mdm::ModuleMixin' do
|
195
|
+
subject do
|
196
|
+
add_mixin
|
197
|
+
|
198
|
+
module_detail.mixins.last
|
199
|
+
end
|
200
|
+
|
201
|
+
it { should be_valid }
|
202
|
+
its(:name) { should == name }
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
context '#add_platform' do
|
207
|
+
def add_platform
|
208
|
+
module_detail.add_platform(name)
|
209
|
+
end
|
210
|
+
|
211
|
+
let(:name) do
|
212
|
+
FactoryGirl.generate :mdm_module_platform_name
|
213
|
+
end
|
214
|
+
|
215
|
+
it 'should add an Mdm::ModulePlatform under the Mdm::ModuleDetail' do
|
216
|
+
expect {
|
217
|
+
add_platform
|
218
|
+
}.to change(module_detail.platforms, :length).by(1)
|
219
|
+
end
|
220
|
+
|
221
|
+
context 'new Mdm::ModulePlatform' do
|
222
|
+
subject(:module_platform) do
|
223
|
+
add_platform
|
224
|
+
|
225
|
+
module_detail.platforms.last
|
226
|
+
end
|
227
|
+
|
228
|
+
it { should be_valid }
|
229
|
+
its(:name) { should == name }
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
context '#add_ref' do
|
234
|
+
def add_ref
|
235
|
+
module_detail.add_ref(name)
|
236
|
+
end
|
237
|
+
|
238
|
+
let(:name) do
|
239
|
+
FactoryGirl.generate :mdm_module_ref_name
|
240
|
+
end
|
241
|
+
|
242
|
+
it 'should add an Mdm::ModuleRef under the Mdm::ModuleDetail' do
|
243
|
+
expect {
|
244
|
+
add_ref
|
245
|
+
}.to change(module_detail.refs, :length).by(1)
|
246
|
+
end
|
247
|
+
|
248
|
+
context 'new Mdm::ModuleRef' do
|
249
|
+
subject(:module_ref) do
|
250
|
+
add_ref
|
251
|
+
|
252
|
+
module_detail.refs.last
|
253
|
+
end
|
254
|
+
|
255
|
+
it { should be_valid }
|
256
|
+
its(:name) { should == name }
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
context '#add_target' do
|
261
|
+
def add_target
|
262
|
+
module_detail.add_target(index, name)
|
263
|
+
end
|
264
|
+
|
265
|
+
let(:index) do
|
266
|
+
FactoryGirl.generate :mdm_module_target_index
|
267
|
+
end
|
268
|
+
|
269
|
+
let(:name) do
|
270
|
+
FactoryGirl.generate :mdm_module_target_name
|
271
|
+
end
|
272
|
+
|
273
|
+
it 'should add an Mdm::ModuleTarget under the Mdm::ModuleDetail' do
|
274
|
+
expect {
|
275
|
+
add_target
|
276
|
+
}.to change(module_detail.targets, :length).by(1)
|
277
|
+
end
|
278
|
+
|
279
|
+
context 'new Mdm::ModuleTarget' do
|
280
|
+
subject(:module_target) do
|
281
|
+
add_target
|
282
|
+
|
283
|
+
module_detail.targets.last
|
284
|
+
end
|
285
|
+
|
286
|
+
it { should be_valid }
|
287
|
+
its(:name) { should == name }
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mdm::ModuleMixin do
|
4
|
+
context 'associations' do
|
5
|
+
it { should belong_to(:module_detail).class_name('Mdm::ModuleDetail') }
|
6
|
+
end
|
7
|
+
|
8
|
+
context 'database' do
|
9
|
+
context 'columns' do
|
10
|
+
it { should have_db_column(:module_detail_id).of_type(:integer) }
|
11
|
+
it { should have_db_column(:name).of_type(:text) }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'indices' do
|
15
|
+
it { should have_db_index(:module_detail_id) }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'factories' do
|
20
|
+
context 'mdm_module_mixin' do
|
21
|
+
subject(:mdm_module_mixin) do
|
22
|
+
FactoryGirl.build :mdm_module_mixin
|
23
|
+
end
|
24
|
+
|
25
|
+
it { should be_valid }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'mass assignment security' do
|
30
|
+
it { should_not allow_mass_assignment_of(:module_detail_id) }
|
31
|
+
it { should allow_mass_assignment_of(:name) }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'validations' do
|
35
|
+
it { should validate_presence_of(:module_detail) }
|
36
|
+
it { should validate_presence_of(:name) }
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mdm::ModulePlatform do
|
4
|
+
context 'associations' do
|
5
|
+
it { should belong_to(:module_detail).class_name('Mdm::ModuleDetail') }
|
6
|
+
end
|
7
|
+
|
8
|
+
context 'database' do
|
9
|
+
context 'columns' do
|
10
|
+
it { should have_db_column(:module_detail_id).of_type(:integer) }
|
11
|
+
it { should have_db_column(:name).of_type(:text) }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'indices' do
|
15
|
+
it { should have_db_index(:module_detail_id) }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'factories' do
|
20
|
+
context 'mdm_module_platform' do
|
21
|
+
subject(:mdm_module_platform) do
|
22
|
+
FactoryGirl.build :mdm_module_platform
|
23
|
+
end
|
24
|
+
|
25
|
+
it { should be_valid }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'mass assignment security' do
|
30
|
+
it { should_not allow_mass_assignment_of(:module_detail_id) }
|
31
|
+
it { should allow_mass_assignment_of(:name) }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'validations' do
|
35
|
+
it { should validate_presence_of :module_detail }
|
36
|
+
it { should validate_presence_of :name }
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mdm::ModuleRef do
|
4
|
+
context 'associations' do
|
5
|
+
it { should belong_to(:module_detail) }
|
6
|
+
end
|
7
|
+
|
8
|
+
context 'database' do
|
9
|
+
context 'columns' do
|
10
|
+
it { should have_db_column(:module_detail_id).of_type(:integer) }
|
11
|
+
it { should have_db_column(:name) }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'indices' do
|
15
|
+
it { should have_db_column(:module_detail_id) }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'factories' do
|
20
|
+
context 'mdm_module_ref' do
|
21
|
+
subject(:mdm_module_ref) do
|
22
|
+
FactoryGirl.build :mdm_module_ref
|
23
|
+
end
|
24
|
+
|
25
|
+
it { should be_valid }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'mass assignment security' do
|
30
|
+
it { should_not allow_mass_assignment_of(:module_detail_id) }
|
31
|
+
it { should allow_mass_assignment_of(:name) }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'validations' do
|
35
|
+
it { should validate_presence_of(:module_detail) }
|
36
|
+
it { should validate_presence_of(:name) }
|
37
|
+
end
|
38
|
+
end
|