File tree Expand file tree Collapse file tree 4 files changed +72
-4
lines changed
Expand file tree Collapse file tree 4 files changed +72
-4
lines changed Original file line number Diff line number Diff line change 11class AddSessionTable < ActiveRecord ::Migration [ 4.2 ]
22
33 class Event < ApplicationRecord
4- serialize :info
4+ if ActiveRecord ::VERSION ::MAJOR >= 7 && ActiveRecord ::VERSION ::MINOR >= 1
5+ serialize :info , coder : YAML
6+ else
7+ serialize :info , YAML
8+ end
59 end
610
711 class SessionEvent < ApplicationRecord
@@ -10,7 +14,11 @@ class SessionEvent < ApplicationRecord
1014
1115 class Session < ApplicationRecord
1216 has_many :events , :class_name => 'AddSessionTable::SessionEvent'
13- serialize :datastore
17+ if ActiveRecord ::VERSION ::MAJOR >= 7 && ActiveRecord ::VERSION ::MINOR >= 1
18+ serialize :datastore , coder : YAML
19+ else
20+ serialize :datastore , YAML
21+ end
1422 end
1523
1624 def self . up
Original file line number Diff line number Diff line change @@ -3,11 +3,19 @@ class ConvertBinary < ActiveRecord::Migration[4.2]
33
44
55 class WebPage < ApplicationRecord
6- serialize :headers
6+ if ActiveRecord ::VERSION ::MAJOR >= 7 && ActiveRecord ::VERSION ::MINOR >= 1
7+ serialize :headers , coder : YAML
8+ else
9+ serialize :headers , YAML
10+ end
711 end
812
913 class WebVuln < ApplicationRecord
10- serialize :params
14+ if ActiveRecord ::VERSION ::MAJOR >= 7 && ActiveRecord ::VERSION ::MINOR >= 1
15+ serialize :params , coder : YAML
16+ else
17+ serialize :params , YAML
18+ end
1119 end
1220
1321 def bfilter ( str )
Original file line number Diff line number Diff line change 1+ RSpec . describe Mdm ::Payload , type : :model do
2+ it_should_behave_like 'Metasploit::Concern.run'
3+
4+ context 'factory' do
5+ it 'should be valid' do
6+ mdm_payload = FactoryBot . build ( :mdm_payload )
7+ expect ( mdm_payload ) . to be_valid
8+ end
9+ end
10+
11+ context 'database' do
12+
13+ context 'timestamps' do
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 ) }
16+ end
17+
18+ context 'columns' do
19+ it { is_expected . to have_db_column ( :name ) . of_type ( :string ) }
20+ it { is_expected . to have_db_column ( :uuid ) . of_type ( :string ) }
21+ it { is_expected . to have_db_column ( :uuid_mask ) . of_type ( :integer ) }
22+ it { is_expected . to have_db_column ( :timestamp ) . of_type ( :integer ) }
23+ it { is_expected . to have_db_column ( :arch ) . of_type ( :string ) }
24+ it { is_expected . to have_db_column ( :platform ) . of_type ( :string ) }
25+ it { is_expected . to have_db_column ( :urls ) . of_type ( :string ) }
26+ it { is_expected . to have_db_column ( :description ) . of_type ( :string ) }
27+ it { is_expected . to have_db_column ( :raw_payload ) . of_type ( :string ) }
28+ it { is_expected . to have_db_column ( :raw_payload_hash ) . of_type ( :string ) }
29+ it { is_expected . to have_db_column ( :build_status ) . of_type ( :string ) }
30+ it { is_expected . to have_db_column ( :build_opts ) . of_type ( :string ) }
31+ end
32+ end
33+
34+ context '#destroy' do
35+ it 'should successfully destroy the object' do
36+ payload = FactoryBot . build ( :mdm_payload )
37+ expect {
38+ payload . destroy
39+ } . to_not raise_error
40+ expect {
41+ payload . reload
42+ } . to raise_error ( ActiveRecord ::RecordNotFound )
43+ end
44+ end
45+ end
Original file line number Diff line number Diff line change 1+ FactoryBot . define do
2+ factory :mdm_payload , :aliases => [ :payload ] , :class => Mdm ::Payload do
3+ #
4+ # Associations
5+ #
6+ end
7+ end
You can’t perform that action at this time.
0 commit comments