Skip to content

Commit

Permalink
Adds a test for the new method
Browse files Browse the repository at this point in the history
  • Loading branch information
cgranleese-r7 committed May 13, 2024
1 parent c938b10 commit 7ee36eb
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions spec/lib/msf/debug_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down Expand Up @@ -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:
<details>
<summary>Collapse</summary>
| name | enabled |
|-:|-:|
| filtered_options | false |
| new_search_capabilities | true |
</details>
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,
Expand Down

0 comments on commit 7ee36eb

Please sign in to comment.