.should == -> expect().to eq

MSP-13484
bug/bundler_fix
Luke Imhoff 2015-10-20 11:30:38 -05:00 committed by Brent Cook
parent 3fff6cabce
commit 6f29e9a4cf
47 changed files with 414 additions and 414 deletions

View File

@ -166,18 +166,18 @@ RSpec.describe ActiveRecord::ConnectionAdapters::ConnectionPool do
child_count = reserved_connection_count
count_change = child_count - before_count
count_change.should == 1
expect(count_change).to eq 1
connection_pool.with_connection do
grandchild_count = reserved_connection_count
grandchild_count.should == child_count
expect(grandchild_count).to eq child_count
end
end
after_count = reserved_connection_count
after_count.should == before_count
expect(after_count).to eq before_count
end
end
@ -197,7 +197,7 @@ RSpec.describe ActiveRecord::ConnectionAdapters::ConnectionPool do
connection_pool.with_connection do
inside = reserved_connection_count
inside.should == outside
expect(inside).to eq outside
end
end
end

View File

@ -31,7 +31,7 @@ RSpec.describe Metasploit::Framework::JtR::InvalidWordlist do
end
it 'should be the passed in model' do
error_model.should == model
expect(error_model).to eq model
end
end

View File

@ -31,7 +31,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::Invalid do
end
it 'should be the passed in model' do
error_model.should == model
expect(error_model).to eq model
end
end

View File

@ -5,29 +5,29 @@ require 'msf/core/data_store'
RSpec.shared_examples "datastore" do
it "should have options" do
subject["foo"].should == "bar"
subject["fizz"].should == "buzz"
expect(subject["foo"]).to eq "bar"
expect(subject["fizz"]).to eq "buzz"
end
it "should have case-insensitive keys" do
# Sorted by gray code, just for fun
subject["foo"].should == "bar"
subject["Foo"].should == "bar"
subject["FOo"].should == "bar"
subject["fOo"].should == "bar"
subject["fOO"].should == "bar"
subject["FOO"].should == "bar"
subject["FoO"].should == "bar"
subject["foO"].should == "bar"
expect(subject["foo"]).to eq "bar"
expect(subject["Foo"]).to eq "bar"
expect(subject["FOo"]).to eq "bar"
expect(subject["fOo"]).to eq "bar"
expect(subject["fOO"]).to eq "bar"
expect(subject["FOO"]).to eq "bar"
expect(subject["FoO"]).to eq "bar"
expect(subject["foO"]).to eq "bar"
end
context "#to_h" do
it "should return a Hash with correct values" do
subject.to_h.should == { "foo" => "bar", "fizz" => "buzz" }
expect(subject.to_h).to eq({ "foo" => "bar", "fizz" => "buzz" })
end
end
context "#delete" do
it "should delete the specified case-insensitive key" do
subject.delete("foo").should == "bar"
subject.delete("Fizz").should == "buzz"
expect(subject.delete("foo")).to eq "bar"
expect(subject.delete("Fizz")).to eq "buzz"
end
end
end

View File

@ -19,14 +19,14 @@ RSpec.describe Msf::Exe::SegmentAppender do
it { should respond_to :buffer_register }
it 'should return the correct processor for the arch' do
injector.processor.class.should == Metasm::Ia32
expect(injector.processor.class).to eq Metasm::Ia32
injector.arch = :x64
injector.processor.class.should == Metasm::X86_64
expect(injector.processor.class).to eq Metasm::X86_64
end
context '#create_thread_stub' do
it 'should use edx as a default buffer register' do
injector.buffer_register.should == 'edx'
expect(injector.buffer_register).to eq 'edx'
end
context 'when given a non-default buffer register' do
@ -39,14 +39,14 @@ RSpec.describe Msf::Exe::SegmentAppender do
}
end
it 'should use the correct buffer register' do
injector.buffer_register.should == 'eax'
expect(injector.buffer_register).to eq 'eax'
end
end
end
describe '#generate_pe' do
it 'should return a string' do
injector.generate_pe.kind_of?(String).should == true
expect(injector.generate_pe.kind_of?(String)).to eq true
end
it 'should produce a valid PE exe' do
@ -56,25 +56,25 @@ RSpec.describe Msf::Exe::SegmentAppender do
context 'the generated exe' do
let(:exe) { Metasm::PE.decode(injector.generate_pe) }
it 'should be the propper arch' do
exe.bitsize.should == 32
expect(exe.bitsize).to eq 32
end
it 'should have 5 sections' do
exe.sections.count.should == 5
expect(exe.sections.count).to eq 5
end
it 'should have all the right original section names' do
s_names = []
exe.sections.collect {|s| s_names << s.name}
s_names[0,4].should == [".text", ".rdata", ".data", ".rsrc"]
expect(s_names[0,4]).to eq [".text", ".rdata", ".data", ".rsrc"]
end
it 'should have the last section set to RWX' do
exe.sections.last.characteristics.should == ["CONTAINS_CODE", "MEM_EXECUTE", "MEM_READ", "MEM_WRITE"]
expect(exe.sections.last.characteristics).to eq ["CONTAINS_CODE", "MEM_EXECUTE", "MEM_READ", "MEM_WRITE"]
end
it 'should have an entrypoint that points to the last section' do
exe.optheader.entrypoint.should == exe.sections.last.virtaddr
expect(exe.optheader.entrypoint).to eq exe.sections.last.virtaddr
end
end
end

View File

@ -19,14 +19,14 @@ RSpec.describe Msf::Exe::SegmentInjector do
it { should respond_to :buffer_register }
it 'should return the correct processor for the arch' do
injector.processor.class.should == Metasm::Ia32
expect(injector.processor.class).to eq Metasm::Ia32
injector.arch = :x64
injector.processor.class.should == Metasm::X86_64
expect(injector.processor.class).to eq Metasm::X86_64
end
context '#create_thread_stub' do
it 'should use edx as a default buffer register' do
injector.buffer_register.should == 'edx'
expect(injector.buffer_register).to eq 'edx'
end
context 'when given a non-default buffer register' do
@ -39,7 +39,7 @@ RSpec.describe Msf::Exe::SegmentInjector do
}
end
it 'should use the correct buffer register' do
injector.buffer_register.should == 'eax'
expect(injector.buffer_register).to eq 'eax'
end
end
@ -50,7 +50,7 @@ RSpec.describe Msf::Exe::SegmentInjector do
describe '#generate_pe' do
it 'should return a string' do
injector.generate_pe.kind_of?(String).should == true
expect(injector.generate_pe.kind_of?(String)).to eq true
end
it 'should produce a valid PE exe' do
@ -60,25 +60,25 @@ RSpec.describe Msf::Exe::SegmentInjector do
context 'the generated exe' do
let(:exe) { Metasm::PE.decode(injector.generate_pe) }
it 'should be the propper arch' do
exe.bitsize.should == 32
expect(exe.bitsize).to eq 32
end
it 'should have 5 sections' do
exe.sections.count.should == 5
expect(exe.sections.count).to eq 5
end
it 'should have all the right section names' do
s_names = []
exe.sections.collect {|s| s_names << s.name}
s_names.should == [".text", ".rdata", ".data", ".rsrc", ".text"]
expect(s_names).to eq [".text", ".rdata", ".data", ".rsrc", ".text"]
end
it 'should have the last section set to RWX' do
exe.sections.last.characteristics.should == ["CONTAINS_CODE", "MEM_EXECUTE", "MEM_READ", "MEM_WRITE"]
expect(exe.sections.last.characteristics).to eq ["CONTAINS_CODE", "MEM_EXECUTE", "MEM_READ", "MEM_WRITE"]
end
it 'should have an entrypoint that points to the last section' do
exe.optheader.entrypoint.should == exe.sections.last.virtaddr
expect(exe.optheader.entrypoint).to eq exe.sections.last.virtaddr
end
end
end

View File

@ -27,8 +27,8 @@ RSpec.describe Msf::Exploit::Capture do
it 'should return the correct number of bytes if the destination MAC can be determined, regardless of broadcast' do
allow(subject).to receive(:lookup_eth).and_return(%w(de:ad:be:ef:ca:fe 01:02:03:04:05:06))
allow(subject).to receive(:inject_eth).and_return(payload.size)
subject.capture_sendto(payload, '127.0.0.1', false).should == payload.size
subject.capture_sendto(payload, '127.0.0.1', true).should == payload.size
expect(subject.capture_sendto(payload, '127.0.0.1', false)).to eq payload.size
expect(subject.capture_sendto(payload, '127.0.0.1', true)).to eq payload.size
end
it 'should return false if the destination MAC cannot be determined and broadcast is not desired' do
@ -40,7 +40,7 @@ RSpec.describe Msf::Exploit::Capture do
it 'should return the correct number of bytes if the destination MAC cannot be determined and broadcast is desired' do
allow(subject).to receive(:lookup_eth).and_return(nil)
allow(subject).to receive(:inject_eth).and_return(payload.size)
subject.capture_sendto(payload, '127.0.0.1', true).should == payload.size
expect(subject.capture_sendto(payload, '127.0.0.1', true)).to eq payload.size
end
end
@ -48,15 +48,15 @@ RSpec.describe Msf::Exploit::Capture do
context '#stats_*' do
it 'should show received packets' do
subject.stats_recv.should == 0
expect(subject.stats_recv).to eq 0
end
it 'should show dropped packets' do
subject.stats_drop.should == 0
expect(subject.stats_drop).to eq 0
end
it 'should show interface-dropped packets' do
subject.stats_ifdrop.should == 0
expect(subject.stats_ifdrop).to eq 0
end
end

View File

@ -28,7 +28,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do
subject
end
it "should return the set vhost" do
cli_vhost.vhost.should == vhost
expect(cli_vhost.vhost).to eq vhost
end
end
@ -39,7 +39,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do
end
it "should return the rhost as the vhost" do
cli_rhost.datastore['VHOST'].should be_nil
cli_rhost.vhost.should == rhost
expect(cli_rhost.vhost).to eq rhost
end
end
@ -60,11 +60,11 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do
end
it "should be '/'" do
unnormalized_uri.should == '/'
expect(unnormalized_uri).to eq '/'
end
it "should return '/'" do
normalized_uri.should == '/'
expect(normalized_uri).to eq '/'
end
end
@ -74,11 +74,11 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do
end
it "should start with '/'" do
unnormalized_uri[0, 1].should == '/'
expect(unnormalized_uri[0, 1]).to eq '/'
end
it "should not add another starting '/'" do
normalized_uri.should == expected_normalized_uri
expect(normalized_uri).to eq expected_normalized_uri
end
context "with multiple internal '/'" do
@ -87,7 +87,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do
end
it "should remove doubled internal '/'" do
normalized_uri.should == expected_normalized_uri
expect(normalized_uri).to eq expected_normalized_uri
end
end
@ -97,11 +97,11 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do
end
it "should have at least 2 starting '/'" do
unnormalized_uri[0, 2].should == '//'
expect(unnormalized_uri[0, 2]).to eq '//'
end
it "should return with one starting '/'" do
normalized_uri.should == expected_normalized_uri
expect(normalized_uri).to eq expected_normalized_uri
end
end
@ -115,7 +115,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do
end
it "should end with '/'" do
normalized_uri[-1, 1].should == '/'
expect(normalized_uri[-1, 1]).to eq '/'
end
context "with multiple trailing '/'" do
@ -124,11 +124,11 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do
end
it "should have multiple trailing '/'" do
unnormalized_uri[-2,2].should == '//'
expect(unnormalized_uri[-2,2]).to eq '//'
end
it "should return only one trailing '/'" do
normalized_uri.should == expected_normalized_uri
expect(normalized_uri).to eq expected_normalized_uri
end
end
end
@ -143,7 +143,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do
end
it "should return original string" do
normalized_uri.should == expected_normalized_uri
expect(normalized_uri).to eq expected_normalized_uri
end
end
end
@ -158,19 +158,19 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do
end
it "should have trailing '/'" do
unnormalized_uri[-1, 1].should == '/'
expect(unnormalized_uri[-1, 1]).to eq '/'
end
it "should add starting '/'" do
normalized_uri[0, 1].should == '/'
expect(normalized_uri[0, 1]).to eq '/'
end
it "should not remove trailing '/'" do
normalized_uri[-1, 1].should == '/'
expect(normalized_uri[-1, 1]).to eq '/'
end
it 'should normalize the uri' do
normalized_uri.should == "#{expected_normalized_uri}"
expect(normalized_uri).to eq "#{expected_normalized_uri}"
end
context "with multiple internal '/'" do
@ -179,7 +179,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do
end
it "should remove doubled internal '/'" do
normalized_uri.should == expected_normalized_uri
expect(normalized_uri).to eq expected_normalized_uri
end
end
end
@ -194,7 +194,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do
end
it "should add starting '/'" do
normalized_uri[0, 1].should == '/'
expect(normalized_uri[0, 1]).to eq '/'
end
it "should add trailing '/'" do
@ -213,7 +213,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do
end
it "should return '/'" do
normalized_uri.should == '/'
expect(normalized_uri).to eq '/'
end
end
@ -227,7 +227,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do
end
it "should return '/" do
normalized_uri.should == '/'
expect(normalized_uri).to eq '/'
end
end
end

View File

@ -22,24 +22,24 @@ RSpec.describe Msf::Framework do
end
it "should return the Version constant" do
described_class.const_get(:Version).should == framework.version
expect(described_class.const_get(:Version)).to eq framework.version
end
it "should return the concatenation of Major.Minor.Point-Release" do
major,minor,point,release = framework.version.split(/[.-]/)
major.to_i.should == described_class::Major
minor.to_i.should == described_class::Minor
point.to_i.should == described_class::Point
"-#{release}".should == described_class::Release
expect(major.to_i).to eq described_class::Major
expect(minor.to_i).to eq described_class::Minor
expect(point.to_i).to eq described_class::Point
expect("-#{release}").to eq described_class::Release
end
skip "conform to SemVer 2.0 syntax: http://semver.org/" do
it "should have constants that correspond to SemVer standards" do
major,minor,patch,label = framework.version.split(/[.-]/)
major.to_i.should == described_class::VERSION::MAJOR
minor.to_i.should == described_class::VERSION::MINOR
point.to_i.should == described_class::VERSION::POINT
label.to_s.should == described_class::VERSION::LABEL
expect(major.to_i).to eq described_class::VERSION::MAJOR
expect(minor.to_i).to eq described_class::VERSION::MINOR
expect(point.to_i).to eq described_class::VERSION::POINT
expect(label.to_s).to eq described_class::VERSION::LABEL
end
end

View File

@ -12,7 +12,7 @@ RSpec.describe Msf::Modules::Error do
end
it 'should include causal_message in error' do
subject.to_s.should == "Failed to load module due to #{causal_message}"
expect(subject.to_s).to eq "Failed to load module due to #{causal_message}"
end
end
@ -25,7 +25,7 @@ RSpec.describe Msf::Modules::Error do
end
it 'should include causal_message and module_path in error' do
subject.to_s.should == "Failed to load module (from #{module_path}) due to #{causal_message}"
expect(subject.to_s).to eq "Failed to load module (from #{module_path}) due to #{causal_message}"
end
end
@ -38,7 +38,7 @@ RSpec.describe Msf::Modules::Error do
end
it 'should include causal_message and module_reference_name in error' do
subject.to_s.should == "Failed to load module (#{module_reference_name}) due to #{causal_message}"
expect(subject.to_s).to eq "Failed to load module (#{module_reference_name}) due to #{causal_message}"
end
end
@ -52,7 +52,7 @@ RSpec.describe Msf::Modules::Error do
end
it 'should include causal_message, module_path, and module_reference_name in error' do
subject.to_s.should == "Failed to load module (#{module_reference_name} from #{module_path}) due to #{causal_message}"
expect(subject.to_s).to eq "Failed to load module (#{module_reference_name} from #{module_path}) due to #{causal_message}"
end
end
@ -62,11 +62,11 @@ RSpec.describe Msf::Modules::Error do
end
it 'should use :module_path for module_path' do
subject.module_path.should == module_path
expect(subject.module_path).to eq module_path
end
it 'should include module_path in error' do
subject.to_s.should == "Failed to load module (from #{module_path})"
expect(subject.to_s).to eq "Failed to load module (from #{module_path})"
end
end
@ -79,7 +79,7 @@ RSpec.describe Msf::Modules::Error do
end
it 'should include module_path and module_reference_name in error' do
subject.to_s.should == "Failed to load module (#{module_reference_name} from #{module_path})"
expect(subject.to_s).to eq "Failed to load module (#{module_reference_name} from #{module_path})"
end
end
@ -89,11 +89,11 @@ RSpec.describe Msf::Modules::Error do
end
it 'should use :module_reference_name for module_reference_name' do
subject.module_reference_name.should == module_reference_name
expect(subject.module_reference_name).to eq module_reference_name
end
it 'should include module_reference_name in error' do
subject.to_s.should == "Failed to load module (#{module_reference_name})"
expect(subject.to_s).to eq "Failed to load module (#{module_reference_name})"
end
end

View File

@ -56,27 +56,27 @@ RSpec.describe Msf::Modules::Loader::Base do
end
it 'should map Msf::MODULE_AUX to auxiliary' do
directory_by_type[Msf::MODULE_AUX].should == 'auxiliary'
expect(directory_by_type[Msf::MODULE_AUX]).to eq 'auxiliary'
end
it 'should map Msf::MODULE_ENCODER to encoders' do
directory_by_type[Msf::MODULE_ENCODER].should == 'encoders'
expect(directory_by_type[Msf::MODULE_ENCODER]).to eq 'encoders'
end
it 'should map Msf::MODULE_EXPLOIT to exploits' do
directory_by_type[Msf::MODULE_EXPLOIT].should == 'exploits'
expect(directory_by_type[Msf::MODULE_EXPLOIT]).to eq 'exploits'
end
it 'should map Msf::MODULE_NOP to nops' do
directory_by_type[Msf::MODULE_NOP].should == 'nops'
expect(directory_by_type[Msf::MODULE_NOP]).to eq 'nops'
end
it 'should map Msf::MODULE_PAYLOAD to payloads' do
directory_by_type[Msf::MODULE_PAYLOAD].should == 'payloads'
expect(directory_by_type[Msf::MODULE_PAYLOAD]).to eq 'payloads'
end
it 'should map Msf::MODULE_POST to post' do
directory_by_type[Msf::MODULE_POST].should == 'post'
expect(directory_by_type[Msf::MODULE_POST]).to eq 'post'
end
end
@ -94,7 +94,7 @@ RSpec.describe Msf::Modules::Loader::Base do
constant_lines = described_class::NAMESPACE_MODULE_CONTENT.lines.to_a
constant_line = constant_lines.first
file_line.should == constant_line
expect(file_line).to eq constant_line
end
end
@ -127,7 +127,7 @@ RSpec.describe Msf::Modules::Loader::Base do
loader = double('Loader')
namespace_module.loader = loader
namespace_module.loader.should == loader
expect(namespace_module.loader).to eq loader
end
end
@ -160,7 +160,7 @@ RSpec.describe Msf::Modules::Loader::Base do
parent_path = double('Parent Path')
namespace_module.parent_path = parent_path
namespace_module.parent_path.should == parent_path
expect(namespace_module.parent_path).to eq parent_path
end
end
end
@ -168,14 +168,14 @@ RSpec.describe Msf::Modules::Loader::Base do
context 'MODULE_EXTENSION' do
it 'should only support ruby source modules' do
described_class::MODULE_EXTENSION.should == '.rb'
expect(described_class::MODULE_EXTENSION).to eq '.rb'
end
end
context 'MODULE_SEPARATOR' do
it 'should make valid module names' do
name = ['Msf', 'Modules'].join(described_class::MODULE_SEPARATOR)
name.constantize.should == Msf::Modules
expect(name.constantize).to eq Msf::Modules
end
end
@ -208,7 +208,7 @@ RSpec.describe Msf::Modules::Loader::Base do
it 'should have MODULE_EXTENSION for the extension name' do
typed_path = described_class.typed_path(Msf::MODULE_AUX, module_reference_name)
File.extname(typed_path).should == described_class::MODULE_EXTENSION
expect(File.extname(typed_path)).to eq described_class::MODULE_EXTENSION
end
# Don't iterate over a Hash here as that would too closely mirror the actual implementation and not test anything
@ -233,7 +233,7 @@ RSpec.describe Msf::Modules::Loader::Base do
context '#initialize' do
it 'should set @module_manager' do
loader = described_class.new(module_manager)
loader.instance_variable_get(:@module_manager).should == module_manager
expect(loader.instance_variable_get(:@module_manager)).to eq module_manager
end
end
@ -340,7 +340,7 @@ RSpec.describe Msf::Modules::Loader::Base do
subject.stub(:read_module_content => module_content)
subject.load_module(parent_path, type, module_reference_name).should be_truthy
namespace_module.parent_path.should == parent_path
expect(namespace_module.parent_path).to eq parent_path
end
it 'should call #read_module_content to get the module content so that #read_module_content can be overridden to change loading behavior' do
@ -572,7 +572,7 @@ RSpec.describe Msf::Modules::Loader::Base do
it 'should restore the old namespace module' do
subject.load_module(parent_path, type, module_reference_name).should be_falsey
Msf::Modules.const_defined?(relative_name).should be_truthy
Msf::Modules.const_get(relative_name).should == @original_namespace_module
expect(Msf::Modules.const_get(relative_name)).to eq @original_namespace_module
end
end
@ -607,7 +607,7 @@ RSpec.describe Msf::Modules::Loader::Base do
it 'should restore the old namespace module' do
subject.load_module(parent_path, type, module_reference_name).should be_falsey
Msf::Modules.const_defined?(relative_name).should be_truthy
Msf::Modules.const_get(relative_name).should == @original_namespace_module
expect(Msf::Modules.const_get(relative_name)).to eq @original_namespace_module
end
end
@ -626,7 +626,7 @@ RSpec.describe Msf::Modules::Loader::Base do
original_load_error = "Back in my day this module didn't load"
module_manager.module_load_error_by_path[module_path] = original_load_error
module_manager.module_load_error_by_path[module_path].should == original_load_error
expect(module_manager.module_load_error_by_path[module_path]).to eq original_load_error
subject.load_module(parent_path, type, module_reference_name).should be_truthy
module_manager.module_load_error_by_path[module_path].should be_nil
end
@ -665,7 +665,7 @@ RSpec.describe Msf::Modules::Loader::Base do
module_reference_name,
:count_by_type => count_by_type
).should be_truthy
count_by_type[type].should == 1
expect(count_by_type[type]).to eq 1
end
it 'should increment the count if it does exist' do
@ -682,7 +682,7 @@ RSpec.describe Msf::Modules::Loader::Base do
).should be_truthy
incremented_count = original_count + 1
count_by_type[type].should == incremented_count
expect(count_by_type[type]).to eq incremented_count
end
end
end
@ -822,7 +822,7 @@ RSpec.describe Msf::Modules::Loader::Base do
end
end
subject.send(:current_module, module_names).should == Msf::Modules::Mod0
expect(subject.send(:current_module, module_names)).to eq Msf::Modules::Mod0
end
end
@ -881,7 +881,7 @@ RSpec.describe Msf::Modules::Loader::Base do
path_without_extension = "a#{described_class::MODULE_EXTENSION}.dir/a"
path = "#{path_without_extension}#{described_class::MODULE_EXTENSION}"
subject.send(:module_reference_name_from_path, path).should == path_without_extension
expect(subject.send(:module_reference_name_from_path, path)).to eq path_without_extension
end
end
@ -901,7 +901,7 @@ RSpec.describe Msf::Modules::Loader::Base do
namespace_module_name = subject.send(:namespace_module_name, module_full_name)
unpacked_name = namespace_module_name.gsub(/^.*::Mod/, '')
[unpacked_name].pack('H*').should == module_full_name
expect([unpacked_name].pack('H*')).to eq module_full_name
end
end
@ -921,7 +921,7 @@ RSpec.describe Msf::Modules::Loader::Base do
relative_name = namespace_module_names.last
unpacked_name = relative_name.gsub(/^Mod/, '')
[unpacked_name].pack('H*').should == module_full_name
expect([unpacked_name].pack('H*')).to eq module_full_name
end
end
@ -988,13 +988,13 @@ RSpec.describe Msf::Modules::Loader::Base do
end
it 'should restore the previous namespace module' do
Msf::Modules.const_get(relative_name).should == @existent_namespace_module
expect(Msf::Modules.const_get(relative_name)).to eq @existent_namespace_module
begin
subject.send(:namespace_module_transaction, module_full_name) do |namespace_module|
current_constant = Msf::Modules.const_get(relative_name)
current_constant.should == namespace_module
expect(current_constant).to eq namespace_module
expect(current_constant).not_to eq @existent_namespace_module
raise error_class, error_message
@ -1002,7 +1002,7 @@ RSpec.describe Msf::Modules::Loader::Base do
rescue error_class => error
end
Msf::Modules.const_get(relative_name).should == @existent_namespace_module
expect(Msf::Modules.const_get(relative_name)).to eq @existent_namespace_module
end
it 'should re-raise the error' do
@ -1016,18 +1016,18 @@ RSpec.describe Msf::Modules::Loader::Base do
context 'with the block returning false' do
it 'should restore the previous namespace module' do
Msf::Modules.const_get(relative_name).should == @existent_namespace_module
expect(Msf::Modules.const_get(relative_name)).to eq @existent_namespace_module
subject.send(:namespace_module_transaction, module_full_name) do |namespace_module|
current_constant = Msf::Modules.const_get(relative_name)
current_constant.should == namespace_module
expect(current_constant).to eq namespace_module
expect(current_constant).not_to eq @existent_namespace_module
false
end
Msf::Modules.const_get(relative_name).should == @existent_namespace_module
expect(Msf::Modules.const_get(relative_name)).to eq @existent_namespace_module
end
it 'should return false' do
@ -1039,7 +1039,7 @@ RSpec.describe Msf::Modules::Loader::Base do
context 'with the block returning true' do
it 'should not restore the previous namespace module' do
Msf::Modules.const_get(relative_name).should == @existent_namespace_module
expect(Msf::Modules.const_get(relative_name)).to eq @existent_namespace_module
subject.send(:namespace_module_transaction, module_full_name) do |namespace_module|
true
@ -1074,7 +1074,7 @@ RSpec.describe Msf::Modules::Loader::Base do
}.to raise_error(NameError)
subject.send(:namespace_module_transaction, module_full_name) do |namespace_module|
Msf::Modules.const_get(relative_name).should == namespace_module
expect(Msf::Modules.const_get(relative_name)).to eq namespace_module
end
end
@ -1146,7 +1146,7 @@ RSpec.describe Msf::Modules::Loader::Base do
end
Msf::Modules.const_defined?(relative_name).should be_truthy
Msf::Modules.const_get(relative_name).should == created_namespace_module
expect(Msf::Modules.const_get(relative_name)).to eq created_namespace_module
end
it 'should return true' do
@ -1258,14 +1258,14 @@ RSpec.describe Msf::Modules::Loader::Base do
parent_module.const_defined?(relative_name).should be_truthy
current_module = parent_module.const_get(relative_name)
current_module.should == @current_namespace_module
expect(current_module).to eq @current_namespace_module
subject.send(:restore_namespace_module, parent_module, relative_name, @current_namespace_module)
parent_module.const_defined?(relative_name).should be_truthy
restored_module = parent_module.const_get(relative_name)
restored_module.should == current_module
restored_module.should == @current_namespace_module
expect(restored_module).to eq current_module
expect(restored_module).to eq @current_namespace_module
end
it 'should not remove the constant and then set it' do
@ -1296,7 +1296,7 @@ RSpec.describe Msf::Modules::Loader::Base do
subject.send(:restore_namespace_module, parent_module, relative_name, @original_namespace_module)
parent_module.const_get(relative_name).should == @original_namespace_module
expect(parent_module.const_get(relative_name)).to eq @original_namespace_module
end
end
end
@ -1310,7 +1310,7 @@ RSpec.describe Msf::Modules::Loader::Base do
subject.send(:restore_namespace_module, parent_module, relative_name, @original_namespace_module)
parent_module.const_defined?(relative_name).should be_truthy
parent_module.const_get(relative_name).should == @original_namespace_module
expect(parent_module.const_get(relative_name)).to eq @original_namespace_module
end
end
end
@ -1341,7 +1341,7 @@ RSpec.describe Msf::Modules::Loader::Base do
usability = 'maybe'
metasploit_class = double('Metasploit Class', :is_usable => usability)
subject.send(:usable?, metasploit_class).should == usability
expect(subject.send(:usable?, metasploit_class)).to eq usability
end
context 'with error from metasploit_class.is_usable' do

View File

@ -57,7 +57,7 @@ RSpec.describe Msf::Modules::Loader::Directory do
created_module = module_manager.create(module_full_name)
created_module.name.should == 'MS08-067 Microsoft Server Service Relative Path Stack Corruption'
expect(created_module.name).to eq 'MS08-067 Microsoft Server Service Relative Path Stack Corruption'
end
context 'with module previously loaded' do
@ -152,13 +152,13 @@ RSpec.describe Msf::Modules::Loader::Directory do
end
it 'should return an empty string' do
subject.send(:read_module_content, parent_path, type, module_reference_name).should == ''
expect(subject.send(:read_module_content, parent_path, type, module_reference_name)).to eq ''
end
it 'should record the load error' do
subject.should_receive(:load_error).with(module_path, kind_of(Errno::ENOENT))
subject.send(:read_module_content, parent_path, type, module_reference_name).should == ''
expect(subject.send(:read_module_content, parent_path, type, module_reference_name)).to eq ''
end
end
end

View File

@ -133,7 +133,7 @@ RSpec.describe Msf::Modules::Namespace do
end
it 'should return the metasploit_class' do
subject.metasploit_class!(module_path, module_reference_name).should == metasploit_class
expect(subject.metasploit_class!(module_path, module_reference_name)).to eq metasploit_class
end
end

View File

@ -23,7 +23,7 @@ RSpec.describe Msf::Modules::VersionCompatibilityError do
end
it 'should set minimum_api_version' do
subject.minimum_api_version.should == minimum_api_version
expect(subject.minimum_api_version).to eq minimum_api_version
end
it 'should include minimum_api_version in error' do
@ -52,7 +52,7 @@ RSpec.describe Msf::Modules::VersionCompatibilityError do
end
it 'should set minimum_core_version' do
subject.minimum_core_version.should == minimum_core_version
expect(subject.minimum_core_version).to eq minimum_core_version
end
it 'should include minimum_core_version in error' do

View File

@ -45,11 +45,11 @@ RSpec.describe Msf::OptAddressRange do
context 'the normalizer' do
it 'should handle a call for random IPs' do
random_addresses = required_opt.normalize('rand:5')
random_addresses.kind_of?(String).should == true
expect(random_addresses.kind_of?(String)).to eq true
ips = random_addresses.split(' ')
ips.count.should == 5
expect(ips.count).to eq 5
ips.each do |ip|
(ip =~ Rex::Socket::MATCH_IPV4).should == 0
expect(ip).to match Rex::Socket::MATCH_IPV4
end
end
end

View File

@ -13,11 +13,11 @@ RSpec.describe Msf::OptEnum do
context 'the validator' do
it 'should return false for a value not in the list' do
subject.valid?('Snap').should == false
expect(subject.valid?('Snap')).to eq false
end
it 'should return true for a value in the list' do
subject.valid?('Bar').should == true
expect(subject.valid?('Bar')).to eq true
end
end
end

View File

@ -18,7 +18,7 @@ RSpec.describe Msf::OptionContainer do
subject = described_class.new({
'thing' => [ foo_class, true, nil, false ]
})
subject["thing"].should == foo_inst
expect(subject["thing"]).to eq foo_inst
end

View File

@ -49,7 +49,7 @@ RSpec.describe Msf::Post::Windows::Priv do
it "should produce expected plaintext" do
decrypted = subject.decrypt_lsa_data(ciphertext, lsa_key)
decrypted.should == plaintext
expect(decrypted).to eq plaintext
end
end
@ -67,7 +67,7 @@ RSpec.describe Msf::Post::Windows::Priv do
end
it "should produce expected plaintext" do
subject.decrypt_secret_data(ciphertext, boot_key).should == plaintext
expect(subject.decrypt_secret_data(ciphertext, boot_key)).to eq plaintext
end
end

View File

@ -57,7 +57,7 @@ RSpec.describe Msf::DBManager::Export do
it 'should have module_detail tag for each Mdm::Module::Detail' do
nodes = root.xpath('module_detail')
nodes.length.should == module_detail_count
expect(nodes.length).to eq module_detail_count
end
context 'module_detail' do
@ -79,7 +79,7 @@ RSpec.describe Msf::DBManager::Export do
it 'should have Mdm::Module::Detail#disclosure_date from disclosure-date content' do
node = module_detail_node.at_xpath('disclosure-date')
DateTime.parse(node.content).should == module_detail.disclosure_date
expect(DateTime.parse(node.content)).to eq module_detail.disclosure_date
end
end

View File

@ -39,14 +39,14 @@ RSpec.describe Rex::Parser::NmapXMLStreamParser do
host["addrs"].should be_a(Hash)
end
it "should find the address" do
host["addrs"].keys.length.should == 1
expect(host["addrs"].keys.length).to eq 1
host["addrs"].should have_key("ipv4")
host["addrs"]["ipv4"].should == "192.168.0.1"
expect(host["addrs"]["ipv4"]).to eq "192.168.0.1"
end
}
REXML::Document.parse_stream(StringIO.new(xml), parser)
it "should have found exactly one host" do
total_hosts.should == 1
expect(total_hosts).to eq 1
end
end

View File

@ -19,9 +19,9 @@ RSpec.describe Rex::Post::Meterpreter::PacketParser do
end
it "should initialise with expected defaults" do
parser.send(:raw).should == ""
parser.send(:hdr_length_left).should == 8
parser.send(:payload_length_left).should == 0
expect(parser.send(:raw)).to eq ""
expect(parser.send(:hdr_length_left)).to eq 8
expect(parser.send(:payload_length_left)).to eq 0
end
it "should parse valid raw data into a packet object" do
@ -29,8 +29,8 @@ RSpec.describe Rex::Post::Meterpreter::PacketParser do
parsed_packet = parser.recv(@sock)
end
parsed_packet.should be_a Rex::Post::Meterpreter::Packet
parsed_packet.type.should == Rex::Post::Meterpreter::PACKET_TYPE_REQUEST
parsed_packet.method?("test_method").should == true
expect(parsed_packet.type).to eq Rex::Post::Meterpreter::PACKET_TYPE_REQUEST
expect(parsed_packet.method?("test_method")).to eq true
end
end

View File

@ -47,51 +47,51 @@ RSpec.describe Rex::Post::Meterpreter::Tlv do
context "A String TLV" do
it "should return the correct TLV type" do
tlv.type.should == Rex::Post::Meterpreter::TLV_TYPE_STRING
expect(tlv.type).to eq Rex::Post::Meterpreter::TLV_TYPE_STRING
end
it "should return the correct value" do
tlv.value.should == "test"
expect(tlv.value).to eq "test"
end
context "#type?" do
it "should return true for STRING" do
tlv.type?(Rex::Post::Meterpreter::TLV_TYPE_STRING).should == true
expect(tlv.type?(Rex::Post::Meterpreter::TLV_TYPE_STRING)).to eq true
end
it "should return false for UINT" do
tlv.type?(Rex::Post::Meterpreter::TLV_TYPE_UINT).should == false
expect(tlv.type?(Rex::Post::Meterpreter::TLV_TYPE_UINT)).to eq false
end
end
context "#value?" do
it "should return true for the correct value" do
tlv.value?("test").should == true
expect(tlv.value?("test")).to eq true
end
it "should return false for an incorrect value" do
tlv.value?("fake").should == false
expect(tlv.value?("fake")).to eq false
end
end
context "#inspect" do
it "should return a string representation of the TLV" do
tlv_to_s = "#<Rex::Post::Meterpreter::Tlv type=STRING meta=STRING value=\"test\">"
tlv.inspect.should == tlv_to_s
expect(tlv.inspect).to eq tlv_to_s
end
end
context "#to_r" do
it "should return the raw bytes of the TLV to send over the wire" do
tlv_bytes = "\x00\x00\x00\r\x00\x01\x00\ntest\x00"
tlv.to_r.should == tlv_bytes
expect(tlv.to_r).to eq tlv_bytes
end
end
context "#from_r" do
it "should adjust the tlv attributes from the given raw bytes" do
tlv.from_r("\x00\x00\x00\r\x00\x01\x00\ntes2\x00")
tlv.value.should == "tes2"
expect(tlv.value).to eq "tes2"
end
end
end
@ -104,12 +104,12 @@ RSpec.describe Rex::Post::Meterpreter::Tlv do
)
}
it "should have a meta type of String" do
tlv.meta_type?(Rex::Post::Meterpreter::TLV_META_TYPE_STRING).should == true
expect(tlv.meta_type?(Rex::Post::Meterpreter::TLV_META_TYPE_STRING)).to eq true
end
it "should show the correct type and meta type in inspect" do
tlv_to_s = "#<Rex::Post::Meterpreter::Tlv type=METHOD meta=STRING value=\"test\">"
tlv.inspect.should == tlv_to_s
expect(tlv.inspect).to eq tlv_to_s
end
end
@ -118,7 +118,7 @@ RSpec.describe Rex::Post::Meterpreter::Tlv do
Rex::Post::Meterpreter::Tlv.new(Rex::Post::Meterpreter::TLV_TYPE_STRING,5)
}
it "should return the string version of the number" do
tlv.value.should == "5"
expect(tlv.value).to eq "5"
end
end
@ -192,28 +192,28 @@ RSpec.describe Rex::Post::Meterpreter::GroupTlv do
end
it "should return an empty array for tlvs by default" do
group_tlv.tlvs.should == []
expect(group_tlv.tlvs).to eq []
end
context "#add_tlv" do
it "should add to the tlvs array when given basic tlv paramaters" do
group_tlv.add_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,"test")
group_tlv.tlvs.first.type.should == Rex::Post::Meterpreter::TLV_TYPE_STRING
group_tlv.tlvs.first.value.should == "test"
expect(group_tlv.tlvs.first.type).to eq Rex::Post::Meterpreter::TLV_TYPE_STRING
expect(group_tlv.tlvs.first.value).to eq "test"
end
it "should replace any existing TLV of the same type when the replace flag is set to true" do
group_tlv.add_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,"test")
group_tlv.add_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,"test2", true)
group_tlv.tlvs.count.should == 1
group_tlv.tlvs.first.value.should == "test2"
expect(group_tlv.tlvs.count).to eq 1
expect(group_tlv.tlvs.first.value).to eq "test2"
end
it "should add both if replace is set to false" do
group_tlv.add_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,"test")
group_tlv.add_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,"test2", false)
group_tlv.tlvs.first.value.should == "test"
group_tlv.tlvs.last.value.should == "test2"
expect(group_tlv.tlvs.first.value).to eq "test"
expect(group_tlv.tlvs.last.value).to eq "test2"
end
end
@ -224,9 +224,9 @@ RSpec.describe Rex::Post::Meterpreter::GroupTlv do
{'type' => Rex::Post::Meterpreter::TLV_TYPE_STRING, 'value' => "test2"}
]
group_tlv.add_tlvs(tlv_array)
group_tlv.tlvs.count.should == 2
group_tlv.tlvs.first.value.should == "test"
group_tlv.tlvs.last.value.should == "test2"
expect(group_tlv.tlvs.count).to eq 2
expect(group_tlv.tlvs.first.value).to eq "test"
expect(group_tlv.tlvs.last.value).to eq "test2"
end
it "should raise an error when given something other than nil or an array" do
@ -263,11 +263,11 @@ RSpec.describe Rex::Post::Meterpreter::GroupTlv do
it "should empty the array of TLV when reset is called" do
group_tlv.reset
group_tlv.tlvs.should == []
expect(group_tlv.tlvs).to eq []
end
it "should convert to raw bytes when to_r is called" do
group_tlv.to_r.should == @raw_group
expect(group_tlv.to_r).to eq @raw_group
end
@ -275,9 +275,9 @@ RSpec.describe Rex::Post::Meterpreter::GroupTlv do
it "should build the TLV group when given the propper raw bytes" do
group_tlv.reset
group_tlv.from_r( @raw_group)
group_tlv.tlvs[0].inspect.should == "#<Rex::Post::Meterpreter::Tlv type=STRING meta=STRING value=\"test\">"
group_tlv.tlvs[1].inspect.should == "#<Rex::Post::Meterpreter::Tlv type=STRING meta=STRING value=\"test2\">"
group_tlv.tlvs[2].inspect.should == "#<Rex::Post::Meterpreter::Tlv type=UINT meta=INT value=5>"
expect(group_tlv.tlvs[0].inspect).to eq "#<Rex::Post::Meterpreter::Tlv type=STRING meta=STRING value=\"test\">"
expect(group_tlv.tlvs[1].inspect).to eq "#<Rex::Post::Meterpreter::Tlv type=STRING meta=STRING value=\"test2\">"
expect(group_tlv.tlvs[2].inspect).to eq "#<Rex::Post::Meterpreter::Tlv type=UINT meta=INT value=5>"
end
end
@ -285,79 +285,79 @@ RSpec.describe Rex::Post::Meterpreter::GroupTlv do
context "#get_tlvs" do
it "should return all TLVs of the supplied type" do
tlvs = group_tlv.get_tlvs(Rex::Post::Meterpreter::TLV_TYPE_STRING)
tlvs.count.should == 2
tlvs.first.value.should == "test"
tlvs.last.value.should == "test2"
expect(tlvs.count).to eq 2
expect(tlvs.first.value).to eq "test"
expect(tlvs.last.value).to eq "test2"
end
it "should return all TLVs when supplied the ANY TLV type" do
tlvs = group_tlv.get_tlvs(Rex::Post::Meterpreter::TLV_TYPE_ANY)
tlvs.count.should == group_tlv.tlvs.count
expect(tlvs.count).to eq group_tlv.tlvs.count
end
it "should return an empty array for a TLV type that isn't present" do
group_tlv.get_tlvs(Rex::Post::Meterpreter::TLV_TYPE_BOOL).should == []
expect(group_tlv.get_tlvs(Rex::Post::Meterpreter::TLV_TYPE_BOOL)).to eq []
end
it "should return an empty array for a nonexistant TLV type" do
group_tlv.get_tlvs(55555555).should == []
expect(group_tlv.get_tlvs(55555555)).to eq []
end
end
context "#get_tlv" do
it "should return the first TLV of the specified type by default" do
group_tlv.get_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING).should == group_tlv.tlvs.first
group_tlv.get_tlv(Rex::Post::Meterpreter::TLV_TYPE_UINT).should == group_tlv.tlvs.last
expect(group_tlv.get_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING)).to eq group_tlv.tlvs.first
expect(group_tlv.get_tlv(Rex::Post::Meterpreter::TLV_TYPE_UINT)).to eq group_tlv.tlvs.last
end
it "should return the correct TLV of the specified type for the given index" do
group_tlv.get_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,1).should == group_tlv.tlvs[1]
expect(group_tlv.get_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,1)).to eq group_tlv.tlvs[1]
end
it "should return nil if given an out of bounds index" do
group_tlv.get_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,5).should == nil
expect(group_tlv.get_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,5)).to eq nil
end
it "should return nil if given a non-present TLV type" do
group_tlv.get_tlv(Rex::Post::Meterpreter::TLV_TYPE_BOOL).should == nil
expect(group_tlv.get_tlv(Rex::Post::Meterpreter::TLV_TYPE_BOOL)).to eq nil
end
end
context "#get_tlv_value" do
it "should return the value of the first TLV with the given type" do
group_tlv.get_tlv_value(Rex::Post::Meterpreter::TLV_TYPE_STRING).should == group_tlv.tlvs.first.value
expect(group_tlv.get_tlv_value(Rex::Post::Meterpreter::TLV_TYPE_STRING)).to eq group_tlv.tlvs.first.value
end
it "should return the correct TLV value of the specified type for the given index" do
group_tlv.get_tlv_value(Rex::Post::Meterpreter::TLV_TYPE_STRING,1).should == group_tlv.tlvs[1].value
expect(group_tlv.get_tlv_value(Rex::Post::Meterpreter::TLV_TYPE_STRING,1)).to eq group_tlv.tlvs[1].value
end
it "should return nil if given an out of bounds index" do
group_tlv.get_tlv_value(Rex::Post::Meterpreter::TLV_TYPE_STRING,5).should == nil
expect(group_tlv.get_tlv_value(Rex::Post::Meterpreter::TLV_TYPE_STRING,5)).to eq nil
end
it "should return nil if given a non-present TLV type" do
group_tlv.get_tlv_value(Rex::Post::Meterpreter::TLV_TYPE_BOOL).should == nil
expect(group_tlv.get_tlv_value(Rex::Post::Meterpreter::TLV_TYPE_BOOL)).to eq nil
end
end
context "#get_tlv_values" do
it "should return an array of values for the designated TLV types" do
group_tlv.get_tlv_values(Rex::Post::Meterpreter::TLV_TYPE_STRING).should == ["test", "test2"]
expect(group_tlv.get_tlv_values(Rex::Post::Meterpreter::TLV_TYPE_STRING)).to eq ["test", "test2"]
end
it "should return an empty array for a non-present TLV type" do
group_tlv.get_tlv_values(Rex::Post::Meterpreter::TLV_TYPE_BOOL).should == []
expect(group_tlv.get_tlv_values(Rex::Post::Meterpreter::TLV_TYPE_BOOL)).to eq []
end
end
context "#has_tlv?" do
it "should return true if the TLV Type is present" do
group_tlv.has_tlv?(Rex::Post::Meterpreter::TLV_TYPE_STRING).should == true
expect(group_tlv.has_tlv?(Rex::Post::Meterpreter::TLV_TYPE_STRING)).to eq true
end
it "should return false if the TLV type is not present" do
group_tlv.has_tlv?(Rex::Post::Meterpreter::TLV_TYPE_BOOL).should == false
expect(group_tlv.has_tlv?(Rex::Post::Meterpreter::TLV_TYPE_BOOL)).to eq false
end
end
end
@ -405,25 +405,25 @@ RSpec.describe Rex::Post::Meterpreter::Packet do
end
it "should return false for response?" do
packet.response?.should == false
expect(packet.response?).to eq false
end
it "should evaluate the method correctly" do
packet.method?("test_method").should == true
packet.method?("blah").should == false
expect(packet.method?("test_method")).to eq true
expect(packet.method?("blah")).to eq false
end
it "should accept new methods" do
packet.method= "test_method2"
packet.method?("test_method2").should == true
expect(packet.method?("test_method2")).to eq true
end
it "should return the correct method" do
packet.method.should == "test_method"
expect(packet.method).to eq "test_method"
end
it "should not have a result" do
packet.result.should == nil
expect(packet.result).to eq nil
end
it "should return a valid request id" do
@ -432,9 +432,9 @@ RSpec.describe Rex::Post::Meterpreter::Packet do
it "should be created when Packet.create_request is called" do
req = Rex::Post::Meterpreter::Packet.create_request("test_method")
req.class.should == Rex::Post::Meterpreter::Packet
req.response?.should == false
req.method?("test_method").should == true
expect(req.class).to eq Rex::Post::Meterpreter::Packet
expect(req.response?).to eq false
expect(req.method?("test_method")).to eq true
end
it "should return the correct raw byte form of the packet" do
@ -442,8 +442,8 @@ RSpec.describe Rex::Post::Meterpreter::Packet do
meth = packet.method
raw = packet.to_r
packet.from_r(raw)
packet.rid.should == rid
packet.method.should == meth
expect(packet.rid).to eq rid
expect(packet.method).to eq meth
end
end
@ -459,23 +459,23 @@ RSpec.describe Rex::Post::Meterpreter::Packet do
end
it "should return the correct result" do
packet.result.should == "a-ok"
expect(packet.result).to eq "a-ok"
end
it "should evaluate result correctly" do
packet.result?("a-ok").should == true
packet.result?("5by5").should == false
expect(packet.result?("a-ok")).to eq true
expect(packet.result?("5by5")).to eq false
end
it "should accept a new result" do
packet.result = "test2"
packet.result.should == "test2"
expect(packet.result).to eq "test2"
end
it "should be created when Packet.create_response is called" do
resp = Rex::Post::Meterpreter::Packet.create_response
resp.class.should == Rex::Post::Meterpreter::Packet
resp.response?.should == true
expect(resp.class).to eq Rex::Post::Meterpreter::Packet
expect(resp.response?).to eq true
end
end

View File

@ -12,7 +12,7 @@ RSpec.shared_context "with no evasions" do
end
it "should return the unmodified uri" do
client_request.send(:set_uri).should == "/"
expect(client_request.send(:set_uri)).to eq "/"
end
end
@ -161,7 +161,7 @@ RSpec.describe Rex::Proto::Http::ClientRequest do
result = things[:result]
describe "##{meth}" do
it "should return #{result.inspect}" do
client_request.send(meth, *args).should == result
expect(client_request.send(meth, *args)).to eq result
end
end
end
@ -202,10 +202,10 @@ RSpec.describe Rex::Proto::Http::ClientRequest do
client_request.opts['pad_get_params'] = true
client_request.opts['pad_get_params_count'] = 0
client_request.to_s.split("&").length.should == vars_get.length
expect(client_request.to_s.split("&").length).to eq vars_get.length
client_request.opts['pad_get_params_count'] = 10
client_request.to_s.split("&").length.should == vars_get.length + 10
expect(client_request.to_s.split("&").length).to eq vars_get.length + 10
client_request.opts['pad_get_params'] = old
end
@ -262,7 +262,7 @@ RSpec.describe Rex::Proto::Http::ClientRequest do
describe "#to_s" do
it "should produce same values if called multiple times with same options" do
client_request.to_s.should == client_request.to_s
expect(client_request.to_s).to eq client_request.to_s
end
end

View File

@ -38,7 +38,7 @@ RSpec.describe Rex::Proto::Http::Client do
describe "#set_config" do
it "should respond to #set_config" do
cli.set_config.should == {}
expect(cli.set_config).to eq {}
end
end
@ -48,9 +48,9 @@ RSpec.describe Rex::Proto::Http::Client do
end
it "should have a set of default instance variables" do
cli.instance_variable_get(:@hostname).should == ip
cli.instance_variable_get(:@port).should == 80
cli.instance_variable_get(:@context).should == {}
expect(cli.instance_variable_get(:@hostname)).to eq ip
expect(cli.instance_variable_get(:@port)).to eq 80
expect(cli.instance_variable_get(:@context)).to eq {}
cli.instance_variable_get(:@ssl).should be_falsey
cli.instance_variable_get(:@proxies).should be_nil
cli.instance_variable_get(:@username).should be_empty
@ -85,14 +85,14 @@ RSpec.describe Rex::Proto::Http::Client do
req = cli.request_cgi
match = req.to_s.match("Authorization: Basic")
match.should be
match.length.should == 1
expect(match.length).to eq 1
end
it "should prefer the value in the header" do
req = cli.request_cgi
match = req.to_s.match(/Authorization: Basic (.*)$/)
match.should be
match.captures.length.should == 1
match.captures[0].chomp.should == base64
expect(match.captures.length).to eq 1
expect(match.captures[0].chomp).to eq base64
end
end
end
@ -142,7 +142,7 @@ RSpec.describe Rex::Proto::Http::Client do
cli.send_recv(req)
# Make sure it didn't modify the argument
opts.should == { "username" => user, "password" => pass}
expect(opts).to eq({ "username" => user, "password" => pass})
end
end
@ -182,7 +182,7 @@ RSpec.describe Rex::Proto::Http::Client do
u = "user1"
p = "pass1"
b64 = ["#{u}:#{p}"].pack("m*").strip
cli.basic_auth_header("user1","pass1").should == "Basic #{b64}"
expect(cli.basic_auth_header("user1","pass1")).to eq "Basic #{b64}"
end
it "should perform digest authentication", :skip => excuse_needs_auth do

View File

@ -25,10 +25,10 @@ RSpec.describe Rex::Proto::Http::Packet do
end
it "should have correct headers" do
subject["foo"].should == "Bar"
subject["Content-Length"].should == body.length.to_s
subject.cmd_string.should == "GET / HTTP/1.0\r\n"
subject.body.should == body
expect(subject["foo"]).to eq "Bar"
expect(subject["Content-Length"]).to eq body.length.to_s
expect(subject.cmd_string).to eq "GET / HTTP/1.0\r\n"
expect(subject.body).to eq body
end
end
@ -42,10 +42,10 @@ RSpec.describe Rex::Proto::Http::Packet do
end
it "should have correct headers" do
subject["foo"].should == "Bar"
subject["Content-Length"].should == body.length.to_s
subject.cmd_string.should == "HTTP/1.0 200 OK\r\n"
subject.body.should == body
expect(subject["foo"]).to eq "Bar"
expect(subject["Content-Length"]).to eq body.length.to_s
expect(subject.cmd_string).to eq "HTTP/1.0 200 OK\r\n"
expect(subject.body).to eq body
end
end

View File

@ -24,12 +24,12 @@ RSpec.describe "Rex::Proto::NTP mode message handling" do
end
it 'Generates control NTP messages correctly' do
@control_raw.should == @control.to_s
expect(@control_raw).to eq @control.to_s
end
it 'Parses control NTP messages correctly' do
parsed_raw = Rex::Proto::NTP::NTPControl.new(@control_raw)
@control.should == parsed_raw
expect(@control).to eq parsed_raw
end
end
@ -47,12 +47,12 @@ RSpec.describe "Rex::Proto::NTP mode message handling" do
end
it 'Generates generic NTP messages correctly' do
@generic_raw.should == @generic.to_s
expect(@generic_raw).to eq @generic.to_s
end
it 'Parses generic NTP messages correctly' do
parsed_raw = Rex::Proto::NTP::NTPGeneric.new(@generic_raw)
@generic.should == parsed_raw
expect(@generic).to eq parsed_raw
end
end
@ -72,12 +72,12 @@ RSpec.describe "Rex::Proto::NTP mode message handling" do
end
it 'Generates private NTP messages correctly' do
@private_raw.should == @private.to_s
expect(@private_raw).to eq @private.to_s
end
it 'Parses private NTP messages correctly' do
parsed_raw = Rex::Proto::NTP::NTPPrivate.new(@private_raw)
@private.should == parsed_raw
expect(@private).to eq parsed_raw
end
end
end

View File

@ -44,7 +44,7 @@ RSpec.describe Rex::RandomIdentifierGenerator do
{ :min_length=>3, :max_length=>3 }
end
it "should return the same thing for subsequent calls" do
rig.get(:rspec).should == rig.get(:rspec)
expect(rig.get(:rspec)).to eq rig.get(:rspec)
end
it "should not return the same for different names" do
# Statistically...
@ -53,7 +53,7 @@ RSpec.describe Rex::RandomIdentifierGenerator do
count.times do |n|
a.add rig.get(n)
end
a.size.should == count
expect(a.size).to eq count
end
context "with an exhausted set" do
@ -87,30 +87,30 @@ RSpec.describe Rex::RandomIdentifierGenerator do
it "should allow smaller than minimum length" do
value = "a"*(options[:min_length]-1)
rig.store(:spec, value)
rig.get(:spec).should == value
expect(rig.get(:spec)).to eq value
end
it "should allow bigger than maximum length" do
value = "a"*(options[:max_length]+1)
rig.store(:spec, value)
rig.get(:spec).should == value
expect(rig.get(:spec)).to eq value
end
it "should raise if value is not unique" do
value = "a"*(options[:max_length]+1)
rig.store(:spec0, value)
rig.get(:spec0).should == value
expect(rig.get(:spec0)).to eq value
expect { rig.store(:spec1, value) }.to raise_error
end
it "should overwrite a previously stored value" do
orig_value = "a"*(options[:max_length])
rig.store(:spec, orig_value)
rig.get(:spec).should == orig_value
expect(rig.get(:spec)).to eq orig_value
new_value = "b"*(options[:max_length])
rig.store(:spec, new_value)
rig.get(:spec).should == new_value
expect(rig.get(:spec)).to eq new_value
end
it "should overwrite a previously generated value" do
@ -118,7 +118,7 @@ RSpec.describe Rex::RandomIdentifierGenerator do
new_value = "a"*(options[:max_length])
rig.store(:spec, new_value)
rig.get(:spec).should == new_value
expect(rig.get(:spec)).to eq new_value
end
end

View File

@ -42,14 +42,14 @@ RSpec.describe Rex::Socket::RangeWalker do
it "should handle single ipv6 addresses" do
walker = Rex::Socket::RangeWalker.new("::1")
walker.should be_valid
walker.length.should == 1
expect(walker.length).to eq 1
end
it "should handle longform ranges" do
walker = Rex::Socket::RangeWalker.new("10.1.1.1-10.1.1.2")
walker.should be_valid
walker.length.should == 2
walker.next.should == "10.1.1.1"
expect(walker.length).to eq 2
expect(walker.next).to eq "10.1.1.1"
end
context "with mulitple ranges" do
@ -62,14 +62,14 @@ RSpec.describe Rex::Socket::RangeWalker do
it "should handle ranges" do
walker = Rex::Socket::RangeWalker.new("10.1.1.1-2")
walker.should be_valid
walker.length.should == 2
walker.next.should == "10.1.1.1"
expect(walker.length).to eq 2
expect(walker.next).to eq "10.1.1.1"
walker = Rex::Socket::RangeWalker.new("10.1-2.1.1-2")
walker.should be_valid
walker.length.should == 4
expect(walker.length).to eq 4
walker = Rex::Socket::RangeWalker.new("10.1-2.3-4.5-6")
walker.should be_valid
walker.length.should == 8
expect(walker.length).to eq 8
walker.should include("10.1.3.5")
end
@ -86,28 +86,28 @@ RSpec.describe Rex::Socket::RangeWalker do
it "should default the lower bound of a range to 0" do
walker = Rex::Socket::RangeWalker.new("10.1.3.-17")
walker.should be_valid
walker.length.should == 18
expect(walker.length).to eq 18
walker = Rex::Socket::RangeWalker.new("10.1.3.-255")
walker.should be_valid
walker.length.should == 256
expect(walker.length).to eq 256
end
it "should default the upper bound of a range to 255" do
walker = Rex::Socket::RangeWalker.new("10.1.3.254-")
walker.should be_valid
walker.length.should == 2
expect(walker.length).to eq 2
end
it "should take * to mean 0-255" do
walker = Rex::Socket::RangeWalker.new("10.1.3.*")
walker.should be_valid
walker.length.should == 256
walker.next.should == "10.1.3.0"
expect(walker.length).to eq 256
expect(walker.next).to eq "10.1.3.0"
walker.should include("10.1.3.255")
walker = Rex::Socket::RangeWalker.new("10.1.*.3")
walker.should be_valid
walker.length.should == 256
walker.next.should == "10.1.0.3"
expect(walker.length).to eq 256
expect(walker.next).to eq "10.1.0.3"
walker.should include("10.1.255.3")
end
@ -117,10 +117,10 @@ RSpec.describe Rex::Socket::RangeWalker do
#walker.length.should == 2
walker = Rex::Socket::RangeWalker.new("10.1.1.1")
walker.should be_valid
walker.length.should == 1
expect(walker.length).to eq 1
walker = Rex::Socket::RangeWalker.new("10.1.1.1,3")
walker.should be_valid
walker.length.should == 2
expect(walker.length).to eq 2
walker.should_not include("10.1.1.2")
end
@ -133,19 +133,19 @@ RSpec.describe Rex::Socket::RangeWalker do
it "should handle ranges and lists together" do
walker = Rex::Socket::RangeWalker.new("10.1.1.1-2,3")
walker.should be_valid
walker.length.should == 3
expect(walker.length).to eq 3
walker = Rex::Socket::RangeWalker.new("10.1-2.1.1,2")
walker.should be_valid
walker.length.should == 4
expect(walker.length).to eq 4
walker = Rex::Socket::RangeWalker.new("10.1,2.3,4.5,6")
walker.length.should == 8
expect(walker.length).to eq 8
end
it "should handle cidr" do
31.downto 16 do |bits|
walker = Rex::Socket::RangeWalker.new("10.1.1.1/#{bits}")
walker.should be_valid
walker.length.should == (2**(32-bits))
expect(walker.length).to eq (2**(32-bits))
end
end
end
@ -158,7 +158,7 @@ RSpec.describe Rex::Socket::RangeWalker do
walker.each { |ip|
got.push ip
}
got.should == ["10.1.1.1", "10.1.1.2", "10.1.1.3", "10.2.2.2"]
expect(got).to eq ["10.1.1.1", "10.1.1.2", "10.1.1.3", "10.2.2.2"]
end
end
@ -180,7 +180,7 @@ RSpec.describe Rex::Socket::RangeWalker do
while ip = walker.next
all << ip
end
all.should == [ "10.1.1.1", "10.1.1.2", "10.1.1.3", "10.1.1.4", "10.1.1.5", ]
expect(all).to eq [ "10.1.1.1", "10.1.1.2", "10.1.1.3", "10.1.1.4", "10.1.1.5", ]
end
it "should not raise if called again after empty" do

View File

@ -8,25 +8,25 @@ RSpec.describe Rex::Socket do
context 'with explicit v6' do
it "should convert a number to a human-readable IPv6 address" do
described_class.addr_itoa(1, true).should == "::1"
expect(described_class.addr_itoa(1, true)).to eq "::1"
end
end
context 'with explicit v4' do
it "should convert a number to a human-readable IPv4 address" do
described_class.addr_itoa(1, false).should == "0.0.0.1"
expect(described_class.addr_itoa(1, false)).to eq "0.0.0.1"
end
end
context 'without explicit version' do
it "should convert a number within the range of possible v4 addresses to a human-readable IPv4 address" do
described_class.addr_itoa(0).should == "0.0.0.0"
described_class.addr_itoa(1).should == "0.0.0.1"
described_class.addr_itoa(0xffff_ffff).should == "255.255.255.255"
expect(described_class.addr_itoa(0)).to eq "0.0.0.0"
expect(described_class.addr_itoa(1)).to eq "0.0.0.1"
expect(described_class.addr_itoa(0xffff_ffff)).to eq "255.255.255.255"
end
it "should convert a number larger than possible v4 addresses to a human-readable IPv6 address" do
described_class.addr_itoa(0xfe80_0000_0000_0000_0000_0000_0000_0001).should == "fe80::1"
described_class.addr_itoa(0x1_0000_0001).should == "::1:0:1"
expect(described_class.addr_itoa(0xfe80_0000_0000_0000_0000_0000_0000_0001)).to eq "fe80::1"
expect(described_class.addr_itoa(0x1_0000_0001)).to eq "::1:0:1"
end
end
@ -42,7 +42,7 @@ RSpec.describe Rex::Socket do
it { is_expected.to be_an(String) }
it { expect(subject.bytes.count).to eq(16) }
it "should be in the right order" do
nbo.should == "\xfe\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"
expect(nbo).to eq "\xfe\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"
end
end
@ -51,7 +51,7 @@ RSpec.describe Rex::Socket do
it { is_expected.to be_an(String) }
it { expect(subject.bytes.count).to eq(4) }
it "should be in the right order" do
nbo.should == "\x7f\x00\x00\x01"
expect(nbo).to eq "\x7f\x00\x00\x01"
end
end
@ -59,7 +59,7 @@ RSpec.describe Rex::Socket do
let(:try) { "localhost" }
it "should resolve" do
nbo.should be_a(String)
nbo.encoding.should == Encoding.find('binary')
expect(nbo.encoding).to eq Encoding.find('binary')
[ 4, 16 ].should include(nbo.length)
end
end
@ -93,7 +93,7 @@ RSpec.describe Rex::Socket do
it { should be_a(String) }
it "should return the first ASCII address" do
subject.should == "1.1.1.1"
expect(subject).to eq "1.1.1.1"
end
end
@ -103,7 +103,7 @@ RSpec.describe Rex::Socket do
it { should be_a(String) }
it "should return the first ASCII address" do
subject.should == "fe80::1"
expect(subject).to eq "fe80::1"
end
end
@ -113,7 +113,7 @@ RSpec.describe Rex::Socket do
it { should be_a(String) }
it "should return the first ASCII address" do
subject.should == "1.1.1.1"
expect(subject).to eq "1.1.1.1"
end
end

View File

@ -23,7 +23,7 @@ RSpec.describe Rex::SSLScan::Result do
context "with no values set" do
it "should return nil for the cert" do
subject.cert.should == nil
expect(subject.cert).to eq nil
end
it "should return an empty set for ciphers" do
@ -31,68 +31,68 @@ RSpec.describe Rex::SSLScan::Result do
end
it "should return an empty array for accepted" do
subject.accepted.should == []
expect(subject.accepted).to eq []
end
it "should return an empty array for rejected" do
subject.rejected.should == []
expect(subject.rejected).to eq []
end
it "should return an empty array for #sslv2" do
subject.sslv2.should == []
expect(subject.sslv2).to eq []
end
it "should return an empty array for #sslv3" do
subject.sslv3.should == []
expect(subject.sslv3).to eq []
end
it "should return an empty array for #tlsv1" do
subject.tlsv1.should == []
expect(subject.tlsv1).to eq []
end
it "should return an empty array for #weak_ciphers" do
subject.weak_ciphers.should == []
expect(subject.weak_ciphers).to eq []
end
it "should return an empty array for #strong_ciphers" do
subject.strong_ciphers.should == []
expect(subject.strong_ciphers).to eq []
end
it "should return false for #supports_ssl?" do
subject.supports_ssl?.should == false
expect(subject.supports_ssl?).to eq false
end
it "should return false for #supports_ssl?v2" do
subject.supports_sslv2?.should == false
expect(subject.supports_sslv2?).to eq false
end
it "should return false for #supports_sslv3?" do
subject.supports_sslv3?.should == false
expect(subject.supports_sslv3?).to eq false
end
it "should return false for #supports_tlsv1?" do
subject.supports_tlsv1?.should == false
expect(subject.supports_tlsv1?).to eq false
end
it "should return false for #supports_weak_ciphers?" do
subject.supports_weak_ciphers?.should == false
expect(subject.supports_weak_ciphers?).to eq false
end
it "should return true for #standards_compliant?" do
subject.standards_compliant?.should == true
expect(subject.standards_compliant?).to eq true
end
end
context "setting the cert" do
it "should accept nil" do
subject.cert = nil
subject.cert.should == nil
expect(subject.cert).to eq nil
end
it "should accept an X509 cert" do
cert = OpenSSL::X509::Certificate.new
subject.cert = cert
subject.cert.should == cert
expect(subject.cert).to eq cert
end
it "should raise an exception for anything else" do
@ -145,7 +145,7 @@ RSpec.describe Rex::SSLScan::Result do
:weak=> false,
:status => :accepted})
rescue ArgumentError => e
e.message.should == "unknown SSL method `SSLv2'."
expect(e.message).to eq "unknown SSL method `SSLv2'."
end
end
@ -189,7 +189,7 @@ RSpec.describe Rex::SSLScan::Result do
it "should not add duplicate entries" do
subject.add_cipher(:SSLv3, "AES128-SHA", 128, :accepted)
subject.add_cipher(:SSLv3, "AES128-SHA", 128, :accepted)
subject.accepted(:SSLv3).count.should == 1
expect(subject.accepted(:SSLv3).count).to eq 1
end
end
context "that was rejected" do
@ -203,7 +203,7 @@ RSpec.describe Rex::SSLScan::Result do
:weak=> false,
:status => :rejected})
rescue ArgumentError => e
e.message.should == "unknown SSL method `SSLv2'."
expect(e.message).to eq "unknown SSL method `SSLv2'."
end
end
@ -247,7 +247,7 @@ RSpec.describe Rex::SSLScan::Result do
it "should not add duplicate entries" do
subject.add_cipher(:SSLv3, "AES128-SHA", 128, :rejected)
subject.add_cipher(:SSLv3, "AES128-SHA", 128, :rejected)
subject.rejected(:SSLv3).count.should == 1
expect(subject.rejected(:SSLv3).count).to eq 1
end
end
end
@ -271,7 +271,7 @@ RSpec.describe Rex::SSLScan::Result do
subject.each_accepted do |cipher_details|
count = count+1
end
count.should == 3
expect(count).to eq 3
end
end
@ -286,7 +286,7 @@ RSpec.describe Rex::SSLScan::Result do
it "should return only ciphers matching the version" do
subject.each_accepted(:SSLv3) do |cipher_details|
cipher_details[:version].should == :SSLv3
expect(cipher_details[:version]).to eq :SSLv3
end
end
end
@ -297,7 +297,7 @@ RSpec.describe Rex::SSLScan::Result do
subject.each_accepted([:TLSv3, :TLSv4]) do |cipher_details|
count = count+1
end
count.should == 3
expect(count).to eq 3
end
it "should return only the ciphers for the specified version" do
@ -327,7 +327,7 @@ RSpec.describe Rex::SSLScan::Result do
subject.each_rejected do |cipher_details|
count = count+1
end
count.should == 3
expect(count).to eq 3
end
end
@ -342,7 +342,7 @@ RSpec.describe Rex::SSLScan::Result do
it "should return only ciphers matching the version" do
subject.each_rejected(:SSLv3) do |cipher_details|
cipher_details[:version].should == :SSLv3
expect(cipher_details[:version]).to eq :SSLv3
end
end
end
@ -353,7 +353,7 @@ RSpec.describe Rex::SSLScan::Result do
subject.each_rejected([:TLSv3, :TLSv4]) do |cipher_details|
count = count+1
end
count.should == 3
expect(count).to eq 3
end
it "should return only the ciphers for the specified version" do
@ -367,42 +367,42 @@ RSpec.describe Rex::SSLScan::Result do
context "checking SSL support" do
context "for SSLv2" do
it "should return false if there are no accepted ciphers" do
subject.supports_sslv2?.should == false
expect(subject.supports_sslv2?).to eq false
end
it "should return true if there are accepted ciphers or raise an SSLv2 exception" do
begin
subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :accepted)
subject.supports_sslv2?.should == true
expect(subject.supports_sslv2?).to eq true
rescue ArgumentError => e
e.message.should == "unknown SSL method `SSLv2'."
expect(e.message).to eq "unknown SSL method `SSLv2'."
end
end
end
context "for SSLv3" do
it "should return false if there are no accepted ciphers" do
subject.supports_sslv3?.should == false
expect(subject.supports_sslv3?).to eq false
end
it "should return true if there are accepted ciphers" do
subject.add_cipher(:SSLv3, "AES256-SHA", 256, :accepted)
subject.supports_sslv3?.should == true
expect(subject.supports_sslv3?).to eq true
end
end
context "for TLSv1" do
it "should return false if there are no accepted ciphers" do
subject.supports_tlsv1?.should == false
expect(subject.supports_tlsv1?).to eq false
end
it "should return true if there are accepted ciphers" do
subject.add_cipher(:TLSv1, "AES256-SHA", 256, :accepted)
subject.supports_tlsv1?.should == true
expect(subject.supports_tlsv1?).to eq true
end
end
context "for SSL at large" do
it "should return false if there are no accepted ciphers" do
subject.supports_ssl?.should == false
expect(subject.supports_ssl?).to eq false
end
it "should return true if there are accepted ciphers" do
subject.add_cipher(:TLSv1, "AES256-SHA", 256, :accepted)
subject.supports_ssl?.should == true
expect(subject.supports_ssl?).to eq true
end
end
end
@ -415,15 +415,15 @@ RSpec.describe Rex::SSLScan::Result do
end
it "should return an array of weak ciphers from #weak_ciphers" do
weak = subject.weak_ciphers
weak.class.should == Array
expect(weak.class).to eq Array
weak.each do |cipher|
cipher[:weak].should == true
expect(cipher[:weak]).to eq true
end
weak.count.should == 2
expect(weak.count).to eq 2
end
it "should return true from #supports_weak_ciphers" do
subject.supports_weak_ciphers?.should == true
expect(subject.supports_weak_ciphers?).to eq true
end
end
@ -434,39 +434,39 @@ RSpec.describe Rex::SSLScan::Result do
subject.add_cipher(:SSLv3, "AES128-SHA", 128, :accepted)
end
it "should return an empty array from #weak_ciphers" do
subject.weak_ciphers.should == []
expect(subject.weak_ciphers).to eq []
end
it "should return false from #supports_weak_ciphers" do
subject.supports_weak_ciphers?.should == false
expect(subject.supports_weak_ciphers?).to eq false
end
end
end
context "checking for standards compliance" do
it "should return true if there is no SSL support" do
subject.standards_compliant?.should == true
expect(subject.standards_compliant?).to eq true
end
it "should return false if SSLv2 is supported or raise an SSLv2 exception" do
begin
subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :accepted)
subject.standards_compliant?.should == false
expect(subject.standards_compliant?).to eq false
rescue ArgumentError => e
e.message.should == "unknown SSL method `SSLv2'."
expect(e.message).to eq "unknown SSL method `SSLv2'."
end
end
it "should return false if weak ciphers are supported" do
subject.add_cipher(:SSLv3, "EXP-RC2-CBC-MD5", 40, :accepted)
subject.standards_compliant?.should == false
expect(subject.standards_compliant?).to eq false
end
it "should return true if SSLv2 and Weak Ciphers are disabled" do
subject.add_cipher(:SSLv3, "AES256-SHA", 256, :accepted)
subject.add_cipher(:TLSv1, "AES256-SHA", 256, :accepted)
subject.add_cipher(:SSLv3, "AES128-SHA", 128, :accepted)
subject.standards_compliant?.should == true
expect(subject.standards_compliant?).to eq true
end
end
@ -518,7 +518,7 @@ RSpec.describe Rex::SSLScan::Result do
it "should return an appropriate message when SSL is not supported" do
subject.stub(:supports_ssl?).and_return(false)
subject.to_s.should == "Server does not appear to support SSL on this port!"
expect(subject.to_s).to eq "Server does not appear to support SSL on this port!"
end

View File

@ -15,22 +15,22 @@ RSpec.describe Rex::SSLScan::Scanner do
context "when validating the scanner config" do
it "should return true when given a valid config" do
subject.valid?.should == true
expect(subject.valid?).to eq true
end
it "should return false if given an invalid host" do
subject.host = nil
subject.valid?.should == false
expect(subject.valid?).to eq false
end
it "should return false if given an invalid port" do
subject.port = nil
subject.valid?.should == false
expect(subject.valid?).to eq false
end
it "should return false if given an invalid timeout" do
subject.timeout = nil
subject.valid?.should == false
expect(subject.valid?).to eq false
end
end
@ -56,24 +56,24 @@ RSpec.describe Rex::SSLScan::Scanner do
context ":rejected should be returned if" do
it "scans a server that doesn't support the supplied SSL version" do
subject.test_cipher(:SSLv3, "DES-CBC-SHA").should == :rejected
expect(subject.test_cipher(:SSLv3, "DES-CBC-SHA")).to eq :rejected
end
it "scans a server that doesn't support the cipher" do
subject.test_cipher(:SSLv3, "DHE-DSS-AES256-SHA").should == :rejected
expect(subject.test_cipher(:SSLv3, "DHE-DSS-AES256-SHA")).to eq :rejected
end
end
context ":accepted should be returned if" do
it "scans a server that accepts the given cipher" do
subject.test_cipher(:SSLv3, "AES256-SHA").should == :accepted
expect(subject.test_cipher(:SSLv3, "AES256-SHA")).to eq :accepted
end
end
end
context "when retrieving the cert" do
it "should return nil if it can't connect" do
subject.get_cert(:SSLv3, "DES-CBC-SHA").should == nil
expect(subject.get_cert(:SSLv3, "DES-CBC-SHA")).to eq nil
end
it "should return an X509 cert if it can connect" do
@ -94,12 +94,12 @@ RSpec.describe Rex::SSLScan::Scanner do
end
it "should mark SSLv2 as unsupported" do
subject.supported_versions.should_not include :SSLv2
subject.sslv2.should == false
expect(subject.sslv2).to eq false
end
it "should not test any SSLv2 ciphers" do
res = subject.scan
res.sslv2.should == []
expect(res.sslv2).to eq []
end
end
end

View File

@ -59,7 +59,7 @@ RSpec.describe Msfupdate do
ARGV.clear
ARGV << 'foo'
subject.parse_args(['x', 'y'])
ARGV.should == ['foo']
expect(ARGV).to eq ['foo']
end
context "with --help" do
@ -84,7 +84,7 @@ RSpec.describe Msfupdate do
it "sets @git_branch" do
subject.parse_args(args)
subject.instance_variable_get(:@git_branch).should == git_branch
expect(subject.instance_variable_get(:@git_branch)).to eq git_branch
end
context "without a space" do
@ -92,7 +92,7 @@ RSpec.describe Msfupdate do
it "sets @git_branch" do
subject.parse_args(args)
subject.instance_variable_get(:@git_branch).should == git_branch
expect(subject.instance_variable_get(:@git_branch)).to eq git_branch
end
end
end
@ -103,7 +103,7 @@ RSpec.describe Msfupdate do
it "sets @git_remote" do
subject.parse_args(args)
subject.instance_variable_get(:@git_remote).should == git_remote
expect(subject.instance_variable_get(:@git_remote)).to eq git_remote
end
context "without a space" do
@ -111,7 +111,7 @@ RSpec.describe Msfupdate do
it "sets @git_remote" do
subject.parse_args(args)
subject.instance_variable_get(:@git_remote).should == git_remote
expect(subject.instance_variable_get(:@git_remote)).to eq git_remote
end
end
end
@ -128,7 +128,7 @@ RSpec.describe Msfupdate do
context "with relative path" do
it "transforms argument into an absolute path" do
subject.parse_args(args)
subject.instance_variable_get(:@offline_file).should == File.join(Dir.pwd, offline_file)
expect(subject.instance_variable_get(:@offline_file)).to eq File.join(Dir.pwd, offline_file)
end
end
@ -136,7 +136,7 @@ RSpec.describe Msfupdate do
let(:offline_file) { '/tmp/foo' }
it "accepts an absolute path" do
subject.parse_args(args)
subject.instance_variable_get(:@offline_file).should == offline_file
expect(subject.instance_variable_get(:@offline_file)).to eq offline_file
end
end
@ -154,7 +154,7 @@ RSpec.describe Msfupdate do
let(:args) { ['wait'] }
it "sets @actually_wait" do
subject.parse_args(args)
subject.instance_variable_get(:@actually_wait).should == true
expect(subject.instance_variable_get(:@actually_wait)).to eq true
end
end
@ -162,7 +162,7 @@ RSpec.describe Msfupdate do
let(:args) { ['nowait'] }
it "sets @actually_wait" do
subject.parse_args(args)
subject.instance_variable_get(:@actually_wait).should == false
expect(subject.instance_variable_get(:@actually_wait)).to eq false
end
end
end

View File

@ -9,18 +9,18 @@ shared_examples_for "an option" do |valid_values, invalid_values, type|
let(:optional) { described_class.new('name', [false, 'A description here'])}
it "should return a type of #{type}" do
subject.type.should == type
expect(subject.type).to eq type
end
context 'when required' do
it 'should not be valid for nil' do
required.valid?(nil).should == false
expect(required.valid?(nil)).to eq false
end
end
context 'when not required' do
it 'it should be valid for nil' do
optional.valid?(nil).should == true
expect(optional.valid?(nil)).to eq true
end
end
@ -31,7 +31,7 @@ shared_examples_for "an option" do |valid_values, invalid_values, type|
it "should be valid and normalize appropriately: #{valid_value}" do
block = Proc.new {
subject.normalize(valid_value).should == normalized_value
expect(subject.normalize(valid_value)).to eq normalized_value
subject.valid?(valid_value).should be_truthy
}
if vhash[:skip]

View File

@ -3,19 +3,19 @@ shared_examples_for "hash with insensitive keys" do
subject["asdf"] = "foo"
subject["ASDF"] = "bar"
subject["asdf"].should == "bar"
subject["ASDF"].should == "bar"
expect(subject["asdf"]).to eq "bar"
expect(subject["ASDF"]).to eq "bar"
end
it "should fetch with insensitive key" do
subject["foo"] = "bar"
subject["foo"].should == "bar"
subject["Foo"].should == "bar"
subject["FOo"].should == "bar"
subject["FOO"].should == "bar"
subject["fOO"].should == "bar"
subject["fOo"].should == "bar"
subject["FOo"].should == "bar"
subject["Foo"].should == "bar"
expect(subject["foo"]).to eq "bar"
expect(subject["Foo"]).to eq "bar"
expect(subject["FOo"]).to eq "bar"
expect(subject["FOO"]).to eq "bar"
expect(subject["fOO"]).to eq "bar"
expect(subject["fOo"]).to eq "bar"
expect(subject["FOo"]).to eq "bar"
expect(subject["Foo"]).to eq "bar"
end
end

View File

@ -17,7 +17,7 @@ shared_examples_for 'Msf::DBManager::Export#extract_module_detail_info module_de
if attribute == false
child_node.content.should be_blank
else
child_node.content.should == attribute.to_s
expect(child_node.content).to eq attribute.to_s
end
end
end

View File

@ -209,7 +209,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do
end
it 'should strip text' do
info[:child].should == stripped
expect(info[:child]).to eq stripped
end
end
@ -232,7 +232,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do
end
it 'should have text for child name in info' do
info[child_sym].should == text
expect(info[child_sym]).to eq text
end
end
end
@ -245,7 +245,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do
end
it 'should return an empty Hash' do
info.should == {}
expect(info).to eq {}
end
end
end
@ -491,7 +491,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do
returned_hash
end
actual_args.should == [element, options]
expect(actual_args).to eq [element, options]
end
it 'should pass return Hash to report_web_<:type>' do
@ -528,13 +528,13 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do
it 'should call :notifier with event and path' do
import_msf_web_element
successive_args.length.should == 1
expect(successive_args.length).to eq 1
args = successive_args[0]
args.length.should == 2
args[0].should == event
args[1].should == web_vuln.path
expect(args.length).to eq 2
expect(args[0]).to eq event
expect(args[1]).to eq web_vuln.path
end
end
@ -605,13 +605,13 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do
it 'should include :method' do
with_info do |info|
info[:method].should == web_form_attributes[:method]
expect(info[:method]).to eq web_form_attributes[:method]
end
end
it 'should include :params' do
with_info do |info|
info[:params].should == web_form_attributes[:params]
expect(info[:params]).to eq web_form_attributes[:params]
end
end
end
@ -724,49 +724,49 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do
it 'should include :auth' do
with_info do |info|
info[:auth].should == web_page_attributes.fetch(:auth)
expect(info[:auth]).to eq web_page_attributes.fetch(:auth)
end
end
it 'should include :body' do
with_info do |info|
info[:body].should == web_page_attributes.fetch(:body)
expect(info[:body]).to eq web_page_attributes.fetch(:body)
end
end
it 'should include :code' do
with_info do |info|
info[:code].should == web_page_attributes.fetch(:code)
expect(info[:code]).to eq web_page_attributes.fetch(:code)
end
end
it 'should include :cookie' do
with_info do |info|
info[:cookie].should == web_page_attributes.fetch(:cookie)
expect(info[:cookie]).to eq web_page_attributes.fetch(:cookie)
end
end
it 'should include :ctype' do
with_info do |info|
info[:ctype].should == web_page_attributes.fetch(:ctype)
expect(info[:ctype]).to eq web_page_attributes.fetch(:ctype)
end
end
it 'should include :headers' do
with_info do |info|
info[:headers].should == web_page_attributes.fetch(:headers)
expect(info[:headers]).to eq web_page_attributes.fetch(:headers)
end
end
it 'should include :location' do
with_info do |info|
info[:location].should == web_page_attributes.fetch(:location)
expect(info[:location]).to eq web_page_attributes.fetch(:location)
end
end
it 'should include :mtime' do
with_info do |info|
info[:mtime].should == web_page_attributes.fetch(:mtime)
expect(info[:mtime]).to eq web_page_attributes.fetch(:mtime)
end
end
end
@ -893,55 +893,55 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do
it 'should include :blame' do
with_info do |info|
info[:blame].should == web_vuln_attributes.fetch(:blame)
expect(info[:blame]).to eq web_vuln_attributes.fetch(:blame)
end
end
it 'should include :category' do
with_info do |info|
info[:category].should == web_vuln_attributes.fetch(:category)
expect(info[:category]).to eq web_vuln_attributes.fetch(:category)
end
end
it 'should include :confidence' do
with_info do |info|
info[:confidence].should == web_vuln_attributes.fetch(:confidence)
expect(info[:confidence]).to eq web_vuln_attributes.fetch(:confidence)
end
end
it 'should include :description' do
with_info do |info|
info[:description].should == web_vuln_attributes.fetch(:description)
expect(info[:description]).to eq web_vuln_attributes.fetch(:description)
end
end
it 'should include :method' do
with_info do |info|
info[:method].should == web_vuln_attributes.fetch(:method)
expect(info[:method]).to eq web_vuln_attributes.fetch(:method)
end
end
it 'should include :name' do
with_info do |info|
info[:name].should == web_vuln_attributes.fetch(:name)
expect(info[:name]).to eq web_vuln_attributes.fetch(:name)
end
end
it 'should include :pname' do
with_info do |info|
info[:pname].should == web_vuln_attributes.fetch(:pname)
expect(info[:pname]).to eq web_vuln_attributes.fetch(:pname)
end
end
it 'should include :proof' do
with_info do |info|
info[:proof].should == web_vuln_attributes.fetch(:proof)
expect(info[:proof]).to eq web_vuln_attributes.fetch(:proof)
end
end
it 'should include :risk' do
with_info do |info|
info[:risk].should == web_vuln_attributes.fetch(:risk)
expect(info[:risk]).to eq web_vuln_attributes.fetch(:risk)
end
end
end

View File

@ -19,7 +19,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML#check_msf_
end
it "should have #{root_tag} as root tag" do
metadata[:root_tag].should == root_tag
expect(metadata[:root_tag]).to eq root_tag
end
end
end

View File

@ -16,7 +16,7 @@ shared_examples_for 'Msf::DBManager::Migration' do
ActiveRecord::Migrator.migrations_paths.length
}
ActiveRecord::Migrator.migrations_paths.uniq.should == ActiveRecord::Migrator.migrations_paths
expect(ActiveRecord::Migrator.migrations_paths.uniq).to eq ActiveRecord::Migrator.migrations_paths
end
end
@ -37,7 +37,7 @@ shared_examples_for 'Msf::DBManager::Migration' do
migrations = [double('Migration 1')]
ActiveRecord::Migrator.stub(:migrate => migrations)
migrate.should == migrations
expect(migrate).to eq migrations
end
it 'should reset the column information' do
@ -62,7 +62,7 @@ shared_examples_for 'Msf::DBManager::Migration' do
it 'should set Msf::DBManager#error' do
migrate
db_manager.error.should == error
expect(db_manager.error).to eq error
end
it 'should log error message at error level' do

View File

@ -325,7 +325,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do
context 'without Mdm::Module::Ref#name' do
it 'should not match Mdm::Module::Ref#name' do
module_details.count.should == 0
expect(module_details.count).to eq 0
end
end
end
@ -363,7 +363,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do
context 'without Mdm::Module::Detail#mtype' do
it 'should not match Mdm::Module::Detail#mtype' do
module_details.count.should == 0
expect(module_details.count).to eq 0
end
end
end
@ -445,7 +445,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do
end
it 'should match Mdm::Module::Detail#description' do
module_details.count.should == 1
expect(module_details.count).to eq 1
module_details.all? { |module_detail|
module_detail.description == target_module_detail.description
@ -459,7 +459,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do
end
it 'should match Mdm::Module::Detail#fullname' do
module_details.count.should == 1
expect(module_details.count).to eq 1
module_details.all? { |module_detail|
module_detail.fullname == search_string
@ -474,7 +474,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do
end
it 'should match Mdm::Module::Detail#name' do
module_details.count.should == 1
expect(module_details.count).to eq 1
module_details.all? { |module_detail|
module_detail.name == target_module_detail.name

View File

@ -37,7 +37,7 @@ shared_examples_for 'Msf::DBManager#search_modules Mdm::Module::Ref#name keyword
context "without #{context_suffix}" do
it 'should not match Mdm::Module::Ref#name' do
module_details.count.should == 0
expect(module_details.count).to eq 0
end
end
end

View File

@ -229,7 +229,7 @@ shared_examples_for 'Msf::DBManager::Session' do
it 'should set session.db_record to created Mdm::Session' do
mdm_session = report_session
session.db_record.should == mdm_session
expect(session.db_record).to eq mdm_session
end
context 'with session.via_exploit' do
@ -432,7 +432,7 @@ shared_examples_for 'Msf::DBManager::Session' do
context "with session.via_exploit 'exploit/multi/handler'" do
it "should have session.via_exploit of 'exploit/multi/handler'" do
session.via_exploit.should == 'exploit/multi/handler'
expect(session.via_exploit).to eq 'exploit/multi/handler'
end
context "with session.exploit_datastore['ParentModule']" do
@ -572,7 +572,7 @@ shared_examples_for 'Msf::DBManager::Session' do
it 'should set session.db_record to created Mdm::Session' do
mdm_session = report_session
session.db_record.should == mdm_session
expect(session.db_record).to eq mdm_session
end
context 'with session.via_exploit' do
@ -775,7 +775,7 @@ shared_examples_for 'Msf::DBManager::Session' do
context "with session.via_exploit 'exploit/multi/handler'" do
it "should have session.via_exploit of 'exploit/multi/handler'" do
session.via_exploit.should == 'exploit/multi/handler'
expect(session.via_exploit).to eq 'exploit/multi/handler'
end
context "with session.exploit_datastore['ParentModule']" do

View File

@ -32,8 +32,8 @@ shared_examples_for 'Msf::DBManager#update_all_module_details refresh' do
it 'should call update_module_details to create a new Mdm::Module::Detail from the module instance returned by create' do
db_manager.should_receive(:update_module_details) do |module_instance|
module_instance.should be_a Msf::Module
module_instance.type.should == module_detail.mtype
module_instance.refname.should == module_detail.refname
expect(module_instance.type).to eq module_detail.mtype
expect(module_instance.refname).to eq module_detail.refname
end
update_all_module_details

View File

@ -14,7 +14,7 @@ shared_examples_for 'Msf::DBManager#update_module_details with module' do |optio
end
it "should use module_instance with #{type.inspect} type" do
module_instance.type.should == type
expect(module_instance.type).to eq type
end
it 'should not raise error' do

View File

@ -106,19 +106,19 @@ shared_examples_for 'Msf::ModuleManager::Cache' do
end
it 'should have modification time of :path option for :modification_time' do
value[:modification_time].should == pathname_modification_time
expect(value[:modification_time]).to eq pathname_modification_time
end
it 'should have parent path from namespace module for :parent_path' do
value[:parent_path].should == namespace_module.parent_path
expect(value[:parent_path]).to eq namespace_module.parent_path
end
it 'should use :reference_name option' do
value[:reference_name].should == reference_name
expect(value[:reference_name]).to eq reference_name
end
it 'should use :type option' do
value[:type].should == type
expect(value[:type]).to eq type
end
end
end
@ -440,7 +440,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do
# have to use fetch because [] will trigger de-symbolization and
# instantiation.
typed_module_set.fetch(reference_name).should == Msf::SymbolicModule
expect(typed_module_set.fetch(reference_name)).to eq Msf::SymbolicModule
end
end
end

View File

@ -70,7 +70,7 @@ shared_examples_for 'Msf::ModuleManager::Loading' do
:modification_time => cached_modification_time
}
cached_modification_time.should == modification_time
expect(cached_modification_time).to eq modification_time
subject.file_changed?(module_path).should be_falsey
end
end

View File

@ -16,11 +16,11 @@ shared_examples_for 'Msf::Modules::Error subclass #initialize' do
end
it 'should set module_path' do
subject.module_path.should == module_path
expect(subject.module_path).to eq module_path
end
it 'should set module_reference_name' do
subject.module_reference_name.should == module_reference_name
expect(subject.module_reference_name).to eq module_reference_name
end
end
end

View File

@ -23,7 +23,7 @@ shared_examples_for 'typed_path' do |map|
typed_path = described_class.typed_path(type_constant, module_reference_name)
first_directory = typed_path.split(File::SEPARATOR).first
first_directory.should == directory
expect(first_directory).to eq directory
end
end
end