Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/spec/msf/core/exception_spec.rb
Views: 11779
require 'rspec'12RSpec.describe 'Metasploit Exceptions' do3describe Msf::OptionValidateError do4describe '#new' do5it 'supports no options being provided' do6subject = described_class.new7expect(subject.options).to eq([])8expect(subject.reasons).to eq({})9end1011it 'supports a custom message' do12subject = described_class.new(message: 'custom message')13expect(subject.options).to eq([])14expect(subject.reasons).to eq({})15expect(subject.message).to eq 'custom message'16end1718it 'supports a default message' do19subject = described_class.new(['OptionName'])20expect(subject.options).to eq(['OptionName'])21expect(subject.reasons).to eq({})22expect(subject.message).to eq 'The following options failed to validate: OptionName.'23end2425it 'supports only options being provided' do26subject = described_class.new(['RHOSTS'])27expect(subject.options).to eq(['RHOSTS'])28expect(subject.reasons).to eq({})29end3031it 'supports a hash of options being provided, with associated string error reasons' do32subject = described_class.new(33{34'RHOSTS' => 'Human readable description'35}36)37expect(subject.options).to eq(['RHOSTS'])38expect(subject.reasons).to eq(39{40'RHOSTS' => ['Human readable description']41}42)43end4445it 'supports a hash of options being provided, with an array of string error reasons' do46subject = described_class.new(47{48'RHOSTS' => [49'Human readable description 1',50'Human readable description 2',51]52}53)54expect(subject.options).to eq(['RHOSTS'])55expect(subject.reasons).to eq(56{57'RHOSTS' => [58'Human readable description 1',59'Human readable description 2',60]61}62)63end6465it 'supports both options and error reasons being provided' do66subject = described_class.new(67[68'RHOSTS',69'RPORT'70],71reasons: {72'RHOSTS' => 'Human readable description'73}74)75expect(subject.options).to eq(['RHOSTS', 'RPORT'])76expect(subject.reasons).to eq(77{78'RHOSTS' => ['Human readable description']79}80)81end82end83end84end858687