From 7ee36ebc29ec770146ab10d742579600283b5a74 Mon Sep 17 00:00:00 2001 From: cgranleese-r7 Date: Thu, 9 May 2024 14:05:24 +0100 Subject: [PATCH] Adds a test for the new method --- spec/lib/msf/debug_spec.rb | 47 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/spec/lib/msf/debug_spec.rb b/spec/lib/msf/debug_spec.rb index 3f98b37a29e2..82baa903f8bd 100644 --- a/spec/lib/msf/debug_spec.rb +++ b/spec/lib/msf/debug_spec.rb @@ -2,6 +2,20 @@ RSpec.describe Msf::Ui::Debug do let(:file_fixtures_path) { File.join(Msf::Config.install_root, 'spec', 'file_fixtures') } + let(:features) do + [ + { + name: 'filtered_options', + description: 'Add option filtering functionality to Metasploit', + enabled: false + }, + { + name: 'new_search_capabilities', + description: 'Add new search capabilities to Metasploit', + enabled: true + } + ] + end it 'error parsing correctly parses framework.log and msf-ws.log' do allow(::Msf::Config).to receive(:log_directory).and_return(Pathname.new(file_fixtures_path).join('debug', 'error_logs', 'basic')) @@ -1269,6 +1283,39 @@ expect(subject.logs).to eql(error_log_output) end + it 'correctly retrieves features and outputs them' do + db = instance_double( + Msf::DBManager, + connection_established?: false, + driver: 'driver' + ) + + framework = instance_double( + ::Msf::Framework, + features: instance_double(Msf::FeatureManager, all: features), + db: db + ) + + expected_output = <<~OUTPUT + ## %grnFramework Configuration%clr + + The features are configured as follows: +
+ Collapse + + | name | enabled | + |-:|-:| + | filtered_options | false | + | new_search_capabilities | true | + +
+ + + OUTPUT + + expect(subject.framework_config(framework)).to eql(expected_output) + end + it 'correctly retrieves version information with no connected DB' do db = instance_double( Msf::DBManager,