1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-10-29 18:07:27 +01:00

Update msftidy spec to be more easily added to

This commit is contained in:
Jon Hart 2015-12-24 10:55:13 -08:00
parent f029cd0c9a
commit be84ed13a2
No known key found for this signature in database
GPG Key ID: 2FA9F0A3AFA8E9D3
2 changed files with 28 additions and 10 deletions

View File

@ -7,6 +7,8 @@ require 'msf/core'
# XXX: invalid super class for an auxiliary module # XXX: invalid super class for an auxiliary module
class Metasploit4 < Msf::Exploit class Metasploit4 < Msf::Exploit
# XXX: auxiliary modules don't use Rank
Rank = LowRanking
def initialize(info = {}) def initialize(info = {})
super( super(
update_info( update_info(

View File

@ -1,32 +1,48 @@
RSpec.describe 'msftidy utility' do require 'spec_helper'
let(:msftidy) { File.expand_path('tools/dev/msftidy.rb') }
it "shows Usage if invalid arguments are provided" do load Metasploit::Framework.root.join('tools/dev/msftidy.rb').to_path
expect { system(msftidy) }.to output(/Usage/).to_stderr_from_any_process
end
RSpec.describe Msftidy do
context "with a tidy auxiliary module" do context "with a tidy auxiliary module" do
let(:auxiliary_tidy) { File.expand_path('modules/auxiliary/auxiliary_tidy.rb', FILE_FIXTURES_PATH) } let(:auxiliary_tidy) { File.expand_path('modules/auxiliary/auxiliary_tidy.rb', FILE_FIXTURES_PATH) }
let(:msftidy) { Msftidy.new(auxiliary_tidy) }
before(:each) do
@msftidy_stdout = get_stdout { msftidy.run_checks }
end
it "outputs nothing" do it "outputs nothing" do
expect { system("#{msftidy} #{auxiliary_tidy}") }.to_not output.to_stdout_from_any_process expect(@msftidy_stdout).to be_empty
end end
end end
context "with an untidy auxiliary module" do context "with an untidy auxiliary module" do
let(:auxiliary_untidy) { File.expand_path('modules/auxiliary/auxiliary_untidy.rb', FILE_FIXTURES_PATH) } let(:auxiliary_untidy) { File.expand_path('modules/auxiliary/auxiliary_untidy.rb', FILE_FIXTURES_PATH) }
let(:msftidy) { Msftidy.new(auxiliary_untidy) }
it "outputs expected errors and warnings" do before(:each) do
expect { system("#{msftidy} #{auxiliary_untidy}") }.to \ @msftidy_stdout = get_stdout { msftidy.run_checks }
output(/ERROR.*Invalid super class for auxiliary module/).to_stdout_from_any_process end
it "ERRORs when invalid superclass" do
expect(@msftidy_stdout).to match(/ERROR.*Invalid super class for auxiliary module/)
end
it "WARNINGs when specifying Rank" do
expect(@msftidy_stdout).to match(/WARNING.*Rank/)
end end
end end
context "with a tidy payload module" do context "with a tidy payload module" do
let(:payload_tidy) { File.expand_path('modules/payloads/payload_tidy.rb', FILE_FIXTURES_PATH) } let(:payload_tidy) { File.expand_path('modules/payloads/payload_tidy.rb', FILE_FIXTURES_PATH) }
let(:msftidy) { Msftidy.new(payload_tidy) }
before(:each) do
@msftidy_stdout = get_stdout { msftidy.run_checks }
end
it "outputs nothing" do it "outputs nothing" do
expect { system("#{msftidy} #{payload_tidy}") }.to_not output.to_stdout_from_any_process expect(@msftidy_stdout).to be_empty
end end
end end
end end