Files
metasploit-gs/spec/plugins/capture_spec.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

78 lines
2.1 KiB
Ruby
Raw Normal View History

2023-06-28 16:52:07 +02:00
require 'spec_helper'
require Metasploit::Framework.root.join('plugins/capture.rb').to_path
RSpec.describe Msf::Plugin::Capture::ConsoleCommandDispatcher do
2023-07-06 15:57:42 +02:00
include_context 'Msf::UIDriver'
let(:framework) { instance_double(Msf::Framework) }
2023-06-28 16:52:07 +02:00
2023-07-06 15:57:42 +02:00
describe '#cmd_captureg' do
2023-06-28 16:52:07 +02:00
subject { described_class.new(driver) }
2023-07-06 15:57:42 +02:00
context 'when called without args' do
2023-06-28 16:52:07 +02:00
it 'returns generic help text' do
expect(subject.cmd_captureg).to eql subject.help
end
end
2023-07-06 15:57:42 +02:00
context 'when there is a single arg matching the HELP regex' do
2023-06-28 16:52:07 +02:00
it 'returns generic help text' do
expect(subject.cmd_captureg('--help')).to eql subject.help
end
end
2023-07-06 15:57:42 +02:00
context 'when there are two args with first one matching the HELP regex' do
2023-06-28 16:52:07 +02:00
it 'calls `help` with second arg' do
expect(subject.cmd_captureg('--help', 'start')).to eql subject.help('start')
end
end
end
end
RSpec.describe Msf::Plugin::Capture::ConsoleCommandDispatcher::CaptureJobListener do
2023-07-06 15:57:42 +02:00
include_context 'Msf::UIDriver'
let(:dispatcher) { instance_double(Msf::Plugin::Capture::ConsoleCommandDispatcher) }
let(:done_event) { instance_double(Rex::Sync::Event, set: nil) }
let(:name) { 'my-little-module' }
subject { described_class.new(name, done_event, dispatcher) }
2023-07-06 15:57:42 +02:00
before(:each) do
capture_logging(dispatcher)
end
describe '#waiting' do
it 'sets the `succeeded` flag' do
subject.waiting('ignored')
expect(subject.succeeded).to eql true
end
it 'outputs a message via the dispatcher' do
subject.waiting('ignored')
2023-07-06 15:57:42 +02:00
expect(@output).to include("#{name} started")
end
it 'sets the done event' do
expect(done_event).to receive(:set)
subject.waiting('ignored')
end
end
describe '#failed' do
it 'outputs a message via the dispatcher' do
subject.failed('ignored', 'ignored', 'ignored')
2023-07-06 15:57:42 +02:00
expect(@error).to include("#{name} failed to start")
end
it 'sets the done event' do
expect(done_event).to receive(:set)
subject.failed('ignored', 'ignored', 'ignored')
end
end
end