Rspec 3.0 support
This commit is contained in:
@@ -15,8 +15,8 @@ shared_examples 'Browser::Actions' do
|
||||
#body: { login: 'master', password: 'hello' } # It's should be this line, but it fails
|
||||
)
|
||||
|
||||
response.should be_a Typhoeus::Response
|
||||
response.body.should == 'Welcome Master'
|
||||
expect(response).to be_a Typhoeus::Response
|
||||
expect(response.body).to eq 'Welcome Master'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -29,8 +29,8 @@ shared_examples 'Browser::Actions' do
|
||||
|
||||
response = Browser.get(url)
|
||||
|
||||
response.should be_a Typhoeus::Response
|
||||
response.body.should == 'Hello World !'
|
||||
expect(response).to be_a Typhoeus::Response
|
||||
expect(response.body).to eq 'Hello World !'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ shared_examples 'Browser::Options' do
|
||||
after do
|
||||
if @expected
|
||||
browser.basic_auth = @auth
|
||||
browser.basic_auth.should == @expected
|
||||
expect(browser.basic_auth).to eq @expected
|
||||
else
|
||||
expect { browser.basic_auth = @auth }.to raise_error(exception)
|
||||
end
|
||||
@@ -47,7 +47,7 @@ shared_examples 'Browser::Options' do
|
||||
after do
|
||||
if @expected
|
||||
browser.max_threads = @max_threads
|
||||
browser.max_threads.should == @expected
|
||||
expect(browser.max_threads).to eq @expected
|
||||
else
|
||||
expect { browser.max_threads = @max_threads }.to raise_error(exception)
|
||||
end
|
||||
@@ -77,7 +77,7 @@ shared_examples 'Browser::Options' do
|
||||
after do
|
||||
if @expected
|
||||
browser.proxy = @proxy
|
||||
browser.proxy.should == @expected
|
||||
expect(browser.proxy).to eq @expected
|
||||
else
|
||||
expect { browser.proxy = @proxy }.to raise_error(exception)
|
||||
end
|
||||
@@ -101,7 +101,7 @@ shared_examples 'Browser::Options' do
|
||||
after :each do
|
||||
if @expected
|
||||
browser.proxy_auth = @proxy_auth
|
||||
browser.proxy_auth.should === @expected
|
||||
expect(browser.proxy_auth).to be === @expected
|
||||
else
|
||||
expect { browser.proxy_auth = @proxy_auth }.to raise_error
|
||||
end
|
||||
@@ -163,7 +163,7 @@ shared_examples 'Browser::Options' do
|
||||
let(:override_options) { { max_threads: nil } }
|
||||
|
||||
it 'does not set it' do
|
||||
browser.should_not_receive(:max_threads=)
|
||||
expect(browser).not_to receive(:max_threads=)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -171,7 +171,7 @@ shared_examples 'Browser::Options' do
|
||||
let(:override_options) { { not_allowed: 'owned' } }
|
||||
|
||||
it 'does not set it' do
|
||||
browser.should_not_receive(:not_allowed=)
|
||||
expect(browser).not_to receive(:not_allowed=)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -179,7 +179,7 @@ shared_examples 'Browser::Options' do
|
||||
let(:override_options) { { max_threads: 30 } }
|
||||
|
||||
it 'sets it' do
|
||||
browser.should_receive(:max_threads=).with(30)
|
||||
expect(browser).to receive(:max_threads=).with(30)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -189,9 +189,9 @@ shared_examples 'Browser::Options' do
|
||||
}
|
||||
|
||||
it 'sets @max_threads, @proxy' do
|
||||
browser.should_not_receive(:not_allowed=)
|
||||
browser.should_receive(:max_threads=).with(10)
|
||||
browser.should_receive(:proxy=).with('host:port')
|
||||
expect(browser).not_to receive(:not_allowed=)
|
||||
expect(browser).to receive(:max_threads=).with(10)
|
||||
expect(browser).to receive(:proxy=).with('host:port')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,26 +9,26 @@ shared_examples 'WebSite::InterestingHeaders' do
|
||||
it 'returns MyTestHeader' do
|
||||
stub_request(:head, web_site.url).
|
||||
to_return(status: 200, headers: { 'Mytestheader' => 'Mytestheadervalue' })
|
||||
web_site.interesting_headers.should =~ [ [ 'MYTESTHEADER', 'Mytestheadervalue' ] ]
|
||||
expect(web_site.interesting_headers).to match_array [ [ 'MYTESTHEADER', 'Mytestheadervalue' ] ]
|
||||
end
|
||||
|
||||
it 'removes known headers' do
|
||||
stub_request(:head, web_site.url).
|
||||
to_return(status: 200, headers: { 'Location' => 'a', 'Connection' => 'Close' })
|
||||
web_site.interesting_headers.should be_empty
|
||||
expect(web_site.interesting_headers).to be_empty
|
||||
end
|
||||
|
||||
it 'returns nothing' do
|
||||
stub_request(:head, web_site.url).
|
||||
to_return(status: 200, headers: { })
|
||||
web_site.interesting_headers.should be_empty
|
||||
expect(web_site.interesting_headers).to be_empty
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe '#known_headers' do
|
||||
it 'does not contain duplicates' do
|
||||
known_headers.flatten.uniq.length.should == known_headers.length
|
||||
expect(known_headers.flatten.uniq.length).to eq known_headers.length
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -5,19 +5,19 @@ shared_examples 'WebSite::RobotsTxt' do
|
||||
|
||||
describe '#robots_url' do
|
||||
it 'returns the correct url' do
|
||||
web_site.robots_url.should === 'http://example.localhost/robots.txt'
|
||||
expect(web_site.robots_url).to be === 'http://example.localhost/robots.txt'
|
||||
end
|
||||
end
|
||||
|
||||
describe '#has_robots?' do
|
||||
it 'returns true' do
|
||||
stub_request(:get, web_site.robots_url).to_return(status: 200)
|
||||
web_site.has_robots?.should be_true
|
||||
expect(web_site.has_robots?).to be_truthy
|
||||
end
|
||||
|
||||
it 'returns false' do
|
||||
stub_request(:get, web_site.robots_url).to_return(status: 404)
|
||||
web_site.has_robots?.should be_false
|
||||
expect(web_site.has_robots?).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
@@ -27,7 +27,7 @@ shared_examples 'WebSite::RobotsTxt' do
|
||||
after :each do
|
||||
stub_request_to_fixture(url: web_site.robots_url, fixture: @fixture)
|
||||
robots = web_site.parse_robots_txt
|
||||
robots.should =~ @expected
|
||||
expect(robots).to match_array @expected
|
||||
end
|
||||
|
||||
it 'returns an empty Array (empty robots.txt)' do
|
||||
@@ -74,14 +74,14 @@ shared_examples 'WebSite::RobotsTxt' do
|
||||
)
|
||||
stub_request_to_fixture(url: web_site_sub.robots_url, fixture: fixture)
|
||||
robots = web_site_sub.parse_robots_txt
|
||||
robots.should =~ expected
|
||||
expect(robots).to match_array expected
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#known_dirs' do
|
||||
it 'does not contain duplicates' do
|
||||
known_dirs.flatten.uniq.length.should == known_dirs.length
|
||||
expect(known_dirs.flatten.uniq.length).to eq known_dirs.length
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -8,19 +8,19 @@ shared_examples 'WpItem::Existable' do
|
||||
let(:response) { Typhoeus::Response.new }
|
||||
|
||||
it 'does not create a request' do
|
||||
Browser.should_not_receive(:get)
|
||||
subject.stub(:exists_from_response?).and_return(true)
|
||||
expect(Browser).not_to receive(:get)
|
||||
allow(subject).to receive(:exists_from_response?).and_return(true)
|
||||
|
||||
subject.exists?({}, response).should be_true
|
||||
expect(subject.exists?({}, response)).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the response is not supplied' do
|
||||
it 'creates a request' do
|
||||
Browser.should_receive(:get)
|
||||
subject.stub(:exists_from_response?).and_return(false)
|
||||
expect(Browser).to receive(:get)
|
||||
allow(subject).to receive(:exists_from_response?).and_return(false)
|
||||
|
||||
subject.exists?.should be_false
|
||||
expect(subject.exists?).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -31,7 +31,7 @@ shared_examples 'WpItem::Existable' do
|
||||
|
||||
after do
|
||||
response = Typhoeus::Response.new(@resp_opt)
|
||||
subject.send(:exists_from_response?, response, exists_options).should == @expected
|
||||
expect(subject.send(:exists_from_response?, response, exists_options)).to eq @expected
|
||||
end
|
||||
|
||||
context 'when invalid response.code' do
|
||||
|
||||
@@ -5,7 +5,7 @@ shared_examples 'WpItem::Findable#Found_From=' do
|
||||
describe '#found_from=' do
|
||||
after do
|
||||
subject.found_from = @method
|
||||
subject.found_from.should == @expected
|
||||
expect(subject.found_from).to eq @expected
|
||||
end
|
||||
context 'when the pattern is not found' do
|
||||
it 'returns nil' do
|
||||
|
||||
@@ -8,7 +8,7 @@ shared_examples 'WpItem::Infos' do
|
||||
# let(:error_log_url) { }
|
||||
|
||||
describe '#readme_url' do
|
||||
after { subject.readme_url.should === @expected }
|
||||
after { expect(subject.readme_url).to be === @expected }
|
||||
|
||||
it 'returns nil' do
|
||||
stub_request(:get, /.*/).to_return(status: 404)
|
||||
@@ -30,8 +30,8 @@ shared_examples 'WpItem::Infos' do
|
||||
|
||||
describe '#has_readme?' do
|
||||
after do
|
||||
subject.stub(readme_url: @stub)
|
||||
subject.has_readme?.should === @expected
|
||||
allow(subject).to receive_messages(readme_url: @stub)
|
||||
expect(subject.has_readme?).to be === @expected
|
||||
end
|
||||
|
||||
context 'when readme_url is nil'
|
||||
@@ -49,14 +49,14 @@ shared_examples 'WpItem::Infos' do
|
||||
|
||||
describe '#changelog_url' do
|
||||
it 'returns the correct url' do
|
||||
subject.changelog_url.should == changelog_url
|
||||
expect(subject.changelog_url).to eq changelog_url
|
||||
end
|
||||
end
|
||||
|
||||
describe '#has_changelog?' do
|
||||
after :each do
|
||||
stub_request(:get, subject.changelog_url).to_return(status: @status)
|
||||
subject.has_changelog?.should === @expected
|
||||
expect(subject.has_changelog?).to be === @expected
|
||||
end
|
||||
|
||||
it 'returns true on a 200' do
|
||||
@@ -73,7 +73,7 @@ shared_examples 'WpItem::Infos' do
|
||||
describe '#has_directory_listing?' do
|
||||
after do
|
||||
stub_request(:get, subject.uri.to_s).to_return(@stub_return)
|
||||
subject.has_directory_listing?.should === @expected
|
||||
expect(subject.has_directory_listing?).to be === @expected
|
||||
end
|
||||
|
||||
context 'when the body contains <title>Index of' do
|
||||
@@ -96,14 +96,14 @@ shared_examples 'WpItem::Infos' do
|
||||
|
||||
describe '#error_log_url' do
|
||||
it 'returns the correct url' do
|
||||
subject.error_log_url.should == error_log_url
|
||||
expect(subject.error_log_url).to eq error_log_url
|
||||
end
|
||||
end
|
||||
|
||||
describe '#has_error_log?' do
|
||||
after do
|
||||
stub_request(:get, subject.error_log_url).to_return(@stub_return)
|
||||
subject.has_error_log?.should === @expected
|
||||
expect(subject.has_error_log?).to be === @expected
|
||||
end
|
||||
|
||||
it 'returns true if the pattern is detected' do
|
||||
|
||||
@@ -9,14 +9,14 @@ shared_examples 'WpItem::Versionable' do
|
||||
context 'when the version is already set' do
|
||||
it 'returns it' do
|
||||
subject.version = '1.2'
|
||||
subject.version.should == '1.2'
|
||||
expect(subject.version).to eq '1.2'
|
||||
end
|
||||
end
|
||||
|
||||
context 'otherwise' do
|
||||
after do
|
||||
stub_request_to_fixture(url: readme_url, fixture: fixtures_dir + @file)
|
||||
subject.version.should == @expected
|
||||
expect(subject.version).to eq @expected
|
||||
end
|
||||
|
||||
context 'when version is "trunk"' do
|
||||
@@ -37,10 +37,10 @@ shared_examples 'WpItem::Versionable' do
|
||||
|
||||
describe '#to_s' do
|
||||
after do
|
||||
subject.stub(:version).and_return(@version)
|
||||
allow(subject).to receive(:version).and_return(@version)
|
||||
subject.name = 'some-name'
|
||||
|
||||
subject.to_s.should == @expected
|
||||
expect(subject.to_s).to eq @expected
|
||||
end
|
||||
|
||||
context 'when the version does not exist' do
|
||||
|
||||
@@ -22,8 +22,8 @@ shared_examples 'WpItem::Vulnerable' do
|
||||
subject.vulns_xpath = vulns_xpath if defined?(vulns_xpath)
|
||||
|
||||
result = subject.vulnerabilities
|
||||
result.should be_a Vulnerabilities
|
||||
result.should == @expected
|
||||
expect(result).to be_a Vulnerabilities
|
||||
expect(result).to eq @expected
|
||||
end
|
||||
|
||||
context 'when the vulns_file is empty' do
|
||||
@@ -41,8 +41,8 @@ shared_examples 'WpItem::Vulnerable' do
|
||||
|
||||
describe '#vulnerable?' do
|
||||
after do
|
||||
subject.stub(:vulnerabilities).and_return(@stub)
|
||||
subject.vulnerable?.should == @expected
|
||||
allow(subject).to receive(:vulnerabilities).and_return(@stub)
|
||||
expect(subject.vulnerable?).to eq @expected
|
||||
end
|
||||
|
||||
it 'returns false when no vulnerabilities' do
|
||||
@@ -72,23 +72,23 @@ shared_examples 'WpItem::Vulnerable' do
|
||||
|
||||
context 'check basic version comparing' do
|
||||
it 'returns true because checked version is newer' do
|
||||
subject.version.should == version_orig
|
||||
subject.vulnerable_to?(newer).should be_true
|
||||
expect(subject.version).to eq version_orig
|
||||
expect(subject.vulnerable_to?(newer)).to be_truthy
|
||||
end
|
||||
|
||||
it 'returns false because checked version is older' do
|
||||
subject.version.should == version_orig
|
||||
subject.vulnerable_to?(older).should be_false
|
||||
expect(subject.version).to eq version_orig
|
||||
expect(subject.vulnerable_to?(older)).to be_falsey
|
||||
end
|
||||
|
||||
it 'returns false because checked version is the fixed version' do
|
||||
subject.version.should == version_orig
|
||||
subject.vulnerable_to?(same).should be_false
|
||||
expect(subject.version).to eq version_orig
|
||||
expect(subject.vulnerable_to?(same)).to be_falsey
|
||||
end
|
||||
|
||||
it 'returns true because no fixed_in version is provided' do
|
||||
subject.version.should == version_orig
|
||||
subject.vulnerable_to?(no_fixed_info).should be_true
|
||||
expect(subject.version).to eq version_orig
|
||||
expect(subject.vulnerable_to?(no_fixed_info)).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
@@ -99,9 +99,9 @@ shared_examples 'WpItem::Vulnerable' do
|
||||
end
|
||||
|
||||
it 'returns true because no version can be detected' do
|
||||
subject.vulnerable_to?(newer).should be_true
|
||||
subject.vulnerable_to?(older).should be_true
|
||||
subject.vulnerable_to?(same).should be_true
|
||||
expect(subject.vulnerable_to?(newer)).to be_truthy
|
||||
expect(subject.vulnerable_to?(older)).to be_truthy
|
||||
expect(subject.vulnerable_to?(same)).to be_truthy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,19 +14,19 @@ shared_examples 'WpItems::Detectable' do
|
||||
|
||||
before do
|
||||
if class_vulns_file = subject.vulns_file
|
||||
class_vulns_file.should == expected[:vulns_file]
|
||||
expect(class_vulns_file).to eq expected[:vulns_file]
|
||||
end
|
||||
|
||||
subject.stub(:vulns_file).and_return(vulns_file)
|
||||
allow(subject).to receive(:vulns_file).and_return(vulns_file)
|
||||
|
||||
unless subject.item_xpath
|
||||
subject.stub(:item_xpath).and_return('//item')
|
||||
allow(subject).to receive(:item_xpath).and_return('//item')
|
||||
end
|
||||
end
|
||||
|
||||
describe '::request_params' do
|
||||
it 'returns the default params' do
|
||||
subject.send(:request_params).should == expected[:request_params]
|
||||
expect(subject.send(:request_params)).to eq expected[:request_params]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,8 +34,8 @@ shared_examples 'WpItems::Detectable' do
|
||||
it 'returns the correct item class' do
|
||||
klass = subject.send(:item_class)
|
||||
|
||||
klass.should be_a Class
|
||||
klass.should == item_class
|
||||
expect(klass).to be_a Class
|
||||
expect(klass).to eq item_class
|
||||
end
|
||||
end
|
||||
|
||||
@@ -43,11 +43,11 @@ shared_examples 'WpItems::Detectable' do
|
||||
after do
|
||||
results = subject.send(:targets_items_from_file, file, wp_target, item_class, vulns_file)
|
||||
|
||||
results.map { |i| i.name }.should == @expected.map { |i| i.name }
|
||||
expect(results.map { |i| i.name }).to eq @expected.map { |i| i.name }
|
||||
|
||||
unless results.empty?
|
||||
results.each do |item|
|
||||
item.should be_a item_class
|
||||
expect(item).to be_a item_class
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -73,11 +73,11 @@ shared_examples 'WpItems::Detectable' do
|
||||
after do
|
||||
results = subject.send(:vulnerable_targets_items, wp_target, item_class, vulns_file)
|
||||
|
||||
results.map { |i| i.name }.should == @expected.map { |i| i.name }
|
||||
expect(results.map { |i| i.name }).to eq @expected.map { |i| i.name }
|
||||
|
||||
unless results.empty?
|
||||
results.each do |item|
|
||||
item.should be_a item_class
|
||||
expect(item).to be_a item_class
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -104,7 +104,7 @@ shared_examples 'WpItems::Detectable' do
|
||||
if @expected
|
||||
results = subject.send(:targets_items, wp_target, options)
|
||||
|
||||
results.sort.map { |i| i.name }.should == @expected.sort.map { |i| i.name }
|
||||
expect(results.sort.map { |i| i.name }).to eq @expected.sort.map { |i| i.name }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -139,8 +139,8 @@ shared_examples 'WpItems::Detectable' do
|
||||
|
||||
results = subject.passive_detection(wp_target)
|
||||
|
||||
results.should be_a subject
|
||||
results.map { |i| i.name }.should == @expected.sort.map { |i| i.name }
|
||||
expect(results).to be_a subject
|
||||
expect(results.map { |i| i.name }).to eq @expected.sort.map { |i| i.name }
|
||||
end
|
||||
|
||||
context 'when the page is empty' do
|
||||
@@ -160,7 +160,7 @@ shared_examples 'WpItems::Detectable' do
|
||||
|
||||
describe '::aggressive_detection' do
|
||||
def stub_targets_dont_exist(targets)
|
||||
targets.each { |t| t.stub(:exists?).and_return(false) }
|
||||
targets.each { |t| allow(t).to receive(:exists?).and_return(false) }
|
||||
end
|
||||
|
||||
let(:options) { {} }
|
||||
@@ -170,8 +170,8 @@ shared_examples 'WpItems::Detectable' do
|
||||
|
||||
result = subject.aggressive_detection(wp_target, options)
|
||||
|
||||
result.should be_a subject
|
||||
result.sort.map { |i| i.name }.should == @expected.sort.map { |i| i.name }
|
||||
expect(result).to be_a subject
|
||||
expect(result.sort.map { |i| i.name }).to eq @expected.sort.map { |i| i.name }
|
||||
end
|
||||
|
||||
context 'when :only_vulnerable' do
|
||||
@@ -185,21 +185,21 @@ shared_examples 'WpItems::Detectable' do
|
||||
|
||||
stub_targets_dont_exist(targets)
|
||||
|
||||
vulnerable_target.stub(:exists?).and_return(true)
|
||||
vulnerable_target.stub(:vulnerable?).and_return(true)
|
||||
allow(vulnerable_target).to receive(:exists?).and_return(true)
|
||||
allow(vulnerable_target).to receive(:vulnerable?).and_return(true)
|
||||
|
||||
fixed_target.stub(:exists?).and_return(true)
|
||||
fixed_target.stub(:vulnerable?).and_return(false)
|
||||
allow(fixed_target).to receive(:exists?).and_return(true)
|
||||
allow(fixed_target).to receive(:vulnerable?).and_return(false)
|
||||
|
||||
@expected = subject.new << vulnerable_target
|
||||
|
||||
subject.should_receive(:targets_items).and_return(targets)
|
||||
expect(subject).to receive(:targets_items).and_return(targets)
|
||||
end
|
||||
|
||||
context 'when all targets dont exist' do
|
||||
it 'returns an empty WpItems' do
|
||||
stub_targets_dont_exist(targets)
|
||||
subject.should_receive(:targets_items).and_return(targets)
|
||||
expect(subject).to receive(:targets_items).and_return(targets)
|
||||
@expected = subject.new
|
||||
end
|
||||
end
|
||||
@@ -213,10 +213,10 @@ shared_examples 'WpItems::Detectable' do
|
||||
@expected = expected[:passive_detection] << target
|
||||
|
||||
stub_targets_dont_exist(targets)
|
||||
target.stub(:exists?).and_return(true)
|
||||
allow(target).to receive(:exists?).and_return(true)
|
||||
|
||||
subject.should_receive(:targets_items).and_return(targets)
|
||||
subject.should_receive(:passive_detection).and_return(expected[:passive_detection])
|
||||
expect(subject).to receive(:targets_items).and_return(targets)
|
||||
expect(subject).to receive(:passive_detection).and_return(expected[:passive_detection])
|
||||
end
|
||||
|
||||
context 'when all targets dont exist' do
|
||||
@@ -224,8 +224,8 @@ shared_examples 'WpItems::Detectable' do
|
||||
@expected = expected[:passive_detection]
|
||||
|
||||
stub_targets_dont_exist(targets)
|
||||
subject.should_receive(:targets_items).and_return(targets)
|
||||
subject.should_receive(:passive_detection).and_return(@expected)
|
||||
expect(subject).to receive(:targets_items).and_return(targets)
|
||||
expect(subject).to receive(:passive_detection).and_return(@expected)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
shared_examples 'WpPlugin::Vulnerable' do
|
||||
|
||||
describe '#vulns_file' do
|
||||
after { subject.vulns_file.should == @expected }
|
||||
after { expect(subject.vulns_file).to eq @expected }
|
||||
|
||||
context 'when :vulns_file is no set' do
|
||||
it 'returns the default one' do
|
||||
@@ -20,7 +20,7 @@ shared_examples 'WpPlugin::Vulnerable' do
|
||||
end
|
||||
|
||||
describe '#vulns_xpath' do
|
||||
its(:vulns_xpath) { should == "//plugin[@name='plugin-name']/vulnerability" }
|
||||
its(:vulns_xpath) { is_expected.to eq "//plugin[@name='plugin-name']/vulnerability" }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ shared_examples 'WpTarget::Malwares' do
|
||||
|
||||
describe '#malwares_file' do
|
||||
it "returns the correct file path" do
|
||||
WpTarget::Malwares.malwares_file(malwares_file).should === malwares_file
|
||||
expect(WpTarget::Malwares.malwares_file(malwares_file)).to be === malwares_file
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,8 +19,8 @@ shared_examples 'WpTarget::Malwares' do
|
||||
|
||||
malwares = wp_target.malwares(@malwares_file_path)
|
||||
|
||||
malwares.sort.should === @expected.sort
|
||||
wp_target.has_malwares?.should === (@expected.empty? ? false : true)
|
||||
expect(malwares.sort).to be === @expected.sort
|
||||
expect(wp_target.has_malwares?).to be === (@expected.empty? ? false : true)
|
||||
end
|
||||
|
||||
it 'returns an empty array on a 404' do
|
||||
|
||||
@@ -17,7 +17,7 @@ shared_examples 'WpTarget::WpConfigBackup' do
|
||||
end
|
||||
|
||||
it 'shoud return an empty array if no config backup is present' do
|
||||
wp_target.config_backup.should be_empty
|
||||
expect(wp_target.config_backup).to be_empty
|
||||
end
|
||||
|
||||
it 'returns an array with 1 backup file' do
|
||||
@@ -31,8 +31,8 @@ shared_examples 'WpTarget::WpConfigBackup' do
|
||||
end
|
||||
|
||||
wp_config_backup = wp_target.config_backup
|
||||
wp_config_backup.should_not be_empty
|
||||
wp_config_backup.should === expected
|
||||
expect(wp_config_backup).not_to be_empty
|
||||
expect(wp_config_backup).to be === expected
|
||||
end
|
||||
|
||||
# Is there a way to factorise that one with the previous test ?
|
||||
@@ -47,14 +47,14 @@ shared_examples 'WpTarget::WpConfigBackup' do
|
||||
end
|
||||
|
||||
wp_config_backup = wp_target.config_backup
|
||||
wp_config_backup.should_not be_empty
|
||||
wp_config_backup.sort.should === expected.sort
|
||||
expect(wp_config_backup).not_to be_empty
|
||||
expect(wp_config_backup.sort).to be === expected.sort
|
||||
end
|
||||
end
|
||||
|
||||
describe '#config_backup_files' do
|
||||
it 'does not contain duplicates' do
|
||||
config_backup_files.flatten.uniq.length.should == config_backup_files.length
|
||||
expect(config_backup_files.flatten.uniq.length).to eq config_backup_files.length
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ shared_examples 'WpTarget::WpCustomDirectories' do
|
||||
stub_request(:get, /.*\/wp-content\/?$/).to_return(:status => 200, :body => '') # default dir request
|
||||
stub_request(:get, /.*\.html$/).to_return(:status => 200, :body => '') # 404 hash request
|
||||
|
||||
@wp_target.wp_content_dir.should === @expected
|
||||
expect(@wp_target.wp_content_dir).to be === @expected
|
||||
end
|
||||
|
||||
it 'returns the string set in the initialize method' do
|
||||
@@ -80,7 +80,7 @@ shared_examples 'WpTarget::WpCustomDirectories' do
|
||||
@wp_target = WpTarget.new('http://lamp.localhost/')
|
||||
stub_request(:get, @wp_target.url).to_return(:status => 200, :body => 'homepage') # homepage request
|
||||
|
||||
@wp_target.default_wp_content_dir_exists?.should === @expected
|
||||
expect(@wp_target.default_wp_content_dir_exists?).to be === @expected
|
||||
end
|
||||
|
||||
it 'returns false if wp-content returns an invalid response code' do
|
||||
@@ -110,7 +110,7 @@ shared_examples 'WpTarget::WpCustomDirectories' do
|
||||
|
||||
describe '#wp_plugins_dir' do
|
||||
after :each do
|
||||
@wp_target.wp_plugins_dir.should === @expected
|
||||
expect(@wp_target.wp_plugins_dir).to be === @expected
|
||||
end
|
||||
|
||||
it 'returns the string set in the initialize method' do
|
||||
@@ -131,12 +131,12 @@ shared_examples 'WpTarget::WpCustomDirectories' do
|
||||
|
||||
it 'returns true' do
|
||||
stub_request(:get, url).to_return(status: 200)
|
||||
wp_target.wp_plugins_dir_exists?.should == true
|
||||
expect(wp_target.wp_plugins_dir_exists?).to eq true
|
||||
end
|
||||
|
||||
it 'returns false' do
|
||||
stub_request(:get, url).to_return(status: 404)
|
||||
wp_target.wp_plugins_dir_exists?.should == false
|
||||
expect(wp_target.wp_plugins_dir_exists?).to eq false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ shared_examples 'WpTarget::WpFullPathDisclosure' do
|
||||
|
||||
describe '#full_path_disclosure_url' do
|
||||
it 'returns http://example.localhost/wp-includes/rss-functions.php' do
|
||||
wp_target.full_path_disclosure_url.should === 'http://example.localhost/wp-includes/rss-functions.php'
|
||||
expect(wp_target.full_path_disclosure_url).to be === 'http://example.localhost/wp-includes/rss-functions.php'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ shared_examples 'WpTarget::WpFullPathDisclosure' do
|
||||
stub_request(:get, wp_target.full_path_disclosure_url).
|
||||
to_return(@stub)
|
||||
|
||||
wp_target.has_full_path_disclosure?.should === @expected
|
||||
expect(wp_target.has_full_path_disclosure?).to be === @expected
|
||||
end
|
||||
|
||||
it 'returns false on a 404' do
|
||||
|
||||
@@ -4,7 +4,7 @@ shared_examples 'WpTarget::WpLoginProtection' do
|
||||
|
||||
let(:fixtures_dir) { SPEC_FIXTURES_WPSCAN_WP_TARGET_DIR + '/wp_login_protection' }
|
||||
|
||||
before { wp_target.stub(:wp_plugins_dir).and_return('wp-content/plugins') }
|
||||
before { allow(wp_target).to receive(:wp_plugins_dir).and_return('wp-content/plugins') }
|
||||
|
||||
# It will test all protected methods has_.*_protection with each fixtures to be sure that
|
||||
# there is not false positive : for example the login-lock must not be detected as login-lockdown
|
||||
@@ -33,7 +33,7 @@ shared_examples 'WpTarget::WpLoginProtection' do
|
||||
stub_request(:get, wp_target.send(special_plugin_call_url_symbol).to_s).to_return(status: status_code)
|
||||
end
|
||||
|
||||
wp_target.send(@symbol_to_call).should === @expected
|
||||
expect(wp_target.send(@symbol_to_call)).to be === @expected
|
||||
end
|
||||
|
||||
self.protected_instance_methods.grep(pattern).each do |symbol_to_call|
|
||||
@@ -63,8 +63,8 @@ shared_examples 'WpTarget::WpLoginProtection' do
|
||||
stub_request(:get, wp_target.send(:limit_login_attempts_url).to_s).to_return(status: 404)
|
||||
stub_request(:get, wp_target.send(:bluetrait_event_viewer_url).to_s).to_return(status: 404)
|
||||
|
||||
wp_target.login_protection_plugin().should == @plugin_expected
|
||||
wp_target.has_login_protection?.should === @has_protection_expected
|
||||
expect(wp_target.login_protection_plugin()).to eq @plugin_expected
|
||||
expect(wp_target.has_login_protection?).to be === @has_protection_expected
|
||||
end
|
||||
|
||||
it 'returns nil if no protection is present' do
|
||||
|
||||
@@ -6,7 +6,7 @@ shared_examples 'WpTarget::WpReadme' do
|
||||
|
||||
describe '#readme_url' do
|
||||
it 'returns http://example.localhost/readme.html' do
|
||||
wp_target.readme_url.should === "#{wp_target.uri}readme.html"
|
||||
expect(wp_target.readme_url).to be === "#{wp_target.uri}readme.html"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ shared_examples 'WpTarget::WpReadme' do
|
||||
after do
|
||||
stub_request(:get, wp_target.readme_url).to_return(@stub)
|
||||
|
||||
wp_target.has_readme?.should === @expected
|
||||
expect(wp_target.has_readme?).to be === @expected
|
||||
end
|
||||
|
||||
it 'returns false on a 404' do
|
||||
|
||||
@@ -5,11 +5,11 @@ shared_examples 'WpTarget::WpRegistrable' do
|
||||
let(:signup_url) { wp_target.uri.merge('wp-signup.php').to_s }
|
||||
|
||||
describe '#registration_url' do
|
||||
after { wp_target.registration_url.should === @expected }
|
||||
after { expect(wp_target.registration_url).to be === @expected }
|
||||
|
||||
context 'when multisite' do
|
||||
it 'returns the signup url' do
|
||||
wp_target.stub(:multisite?).and_return(true)
|
||||
allow(wp_target).to receive(:multisite?).and_return(true)
|
||||
|
||||
@expected = signup_url
|
||||
end
|
||||
@@ -17,7 +17,7 @@ shared_examples 'WpTarget::WpRegistrable' do
|
||||
|
||||
context 'when not multisite' do
|
||||
it 'returns the login url with ?action=register' do
|
||||
wp_target.stub(:multisite?).and_return(false)
|
||||
allow(wp_target).to receive(:multisite?).and_return(false)
|
||||
|
||||
@expected = login_url + '?action=register'
|
||||
end
|
||||
@@ -26,10 +26,10 @@ shared_examples 'WpTarget::WpRegistrable' do
|
||||
|
||||
describe '#registration_enabled?' do
|
||||
after do
|
||||
wp_target.stub(:multisite?).and_return(multisite)
|
||||
allow(wp_target).to receive(:multisite?).and_return(multisite)
|
||||
stub_request(:get, wp_target.registration_url).to_return(@stub)
|
||||
|
||||
wp_target.registration_enabled?.should === @expected
|
||||
expect(wp_target.registration_enabled?).to be === @expected
|
||||
end
|
||||
|
||||
context 'when multisite' do
|
||||
@@ -69,7 +69,7 @@ shared_examples 'WpTarget::WpRegistrable' do
|
||||
after do
|
||||
stub_request(:get, signup_url).to_return(@stub)
|
||||
|
||||
wp_target.multisite?.should === @expected
|
||||
expect(wp_target.multisite?).to be === @expected
|
||||
end
|
||||
|
||||
it 'returns false' do
|
||||
|
||||
@@ -10,7 +10,7 @@ shared_examples 'WpTheme::Versionable' do
|
||||
stub_request(:get, subject.style_url).to_return(status: 200, body: body)
|
||||
end
|
||||
|
||||
subject.version.should == @expected
|
||||
expect(subject.version).to eq @expected
|
||||
end
|
||||
|
||||
context 'the version is already set' do
|
||||
@@ -35,7 +35,7 @@ shared_examples 'WpTheme::Versionable' do
|
||||
|
||||
context 'from both style & readme' do
|
||||
it 'returns nil' do
|
||||
subject.stub(readme_url: readme_url)
|
||||
allow(subject).to receive_messages(readme_url: readme_url)
|
||||
stub_request(:get, readme_url).to_return(status: 404)
|
||||
|
||||
@file = file
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
shared_examples 'WpTheme::Vulnerable' do
|
||||
|
||||
describe '#vulns_file' do
|
||||
after { subject.vulns_file.should == @expected }
|
||||
after { expect(subject.vulns_file).to eq @expected }
|
||||
|
||||
context 'when :vulns_file is not set' do
|
||||
it 'returns the default one' do
|
||||
@@ -20,7 +20,7 @@ shared_examples 'WpTheme::Vulnerable' do
|
||||
end
|
||||
|
||||
describe '#vulns_xpath' do
|
||||
its(:vulns_xpath) { should == "//theme[@name='theme-name']/vulnerability" }
|
||||
its(:vulns_xpath) { is_expected.to eq "//theme[@name='theme-name']/vulnerability" }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ shared_examples 'WpTimthumb::Existable' do
|
||||
describe 'exists_from_response?' do
|
||||
after do
|
||||
response = Typhoeus::Response.new(@resp_opt)
|
||||
subject.send(:exists_from_response?, response).should == @expected
|
||||
expect(subject.send(:exists_from_response?, response)).to eq @expected
|
||||
end
|
||||
|
||||
context 'when the status is not a 400' do
|
||||
|
||||
@@ -6,7 +6,7 @@ shared_examples 'WpTimthumb::Versionable' do
|
||||
after do
|
||||
stub_request(:get, subject.url).to_return(status: 200, body: @body)
|
||||
|
||||
subject.version.should === @expected
|
||||
expect(subject.version).to be === @expected
|
||||
end
|
||||
|
||||
context 'when a version is already set' do
|
||||
@@ -32,7 +32,7 @@ shared_examples 'WpTimthumb::Versionable' do
|
||||
end
|
||||
|
||||
describe '#to_s' do
|
||||
after { subject.to_s.should == @expected }
|
||||
after { expect(subject.to_s).to eq @expected }
|
||||
|
||||
context 'when there is a version' do
|
||||
it 'returns it with the url' do
|
||||
@@ -43,7 +43,7 @@ shared_examples 'WpTimthumb::Versionable' do
|
||||
|
||||
context 'when there is not a version' do
|
||||
it 'returns only the url' do
|
||||
subject.stub(:version).and_return(nil)
|
||||
allow(subject).to receive(:version).and_return(nil)
|
||||
@expected = uri.merge(options[:path]).to_s
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ shared_examples 'WpUser::BruteForcable' do
|
||||
let(:resp_options) { {} }
|
||||
|
||||
after do
|
||||
wp_user.valid_password?(response, 'password', redirect_url).should == @expected
|
||||
expect(wp_user.valid_password?(response, 'password', redirect_url)).to eq @expected
|
||||
end
|
||||
|
||||
context 'when 302 and valid return_to parameter' do
|
||||
@@ -73,7 +73,7 @@ shared_examples 'WpUser::BruteForcable' do
|
||||
[wordlist_utf8, wordlist_iso].each do |wordlist|
|
||||
wp_user.login = login
|
||||
wp_user.brute_force(wordlist, {}, redirect_url)
|
||||
wp_user.password.should == @expected
|
||||
expect(wp_user.password).to eq @expected
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ shared_examples 'WpUser::Existable' do
|
||||
|
||||
describe '::login_from_author_pattern' do
|
||||
after do
|
||||
mod.login_from_author_pattern(@text).should == @expected
|
||||
expect(mod.login_from_author_pattern(@text)).to eq @expected
|
||||
end
|
||||
|
||||
context 'when no trailing slash' do
|
||||
@@ -32,13 +32,13 @@ shared_examples 'WpUser::Existable' do
|
||||
end
|
||||
|
||||
describe '::login_from_body' do
|
||||
after { mod.login_from_body(body).should == @expected }
|
||||
after { expect(mod.login_from_body(body)).to eq @expected }
|
||||
|
||||
context 'when the author pattern is in the body' do
|
||||
let(:body) { '/author/admin' }
|
||||
|
||||
it 'returns it' do
|
||||
mod.stub(:login_from_body).with(body).and_return('admin')
|
||||
allow(mod).to receive(:login_from_body).with(body).and_return('admin')
|
||||
@expected = 'admin'
|
||||
end
|
||||
end
|
||||
@@ -53,7 +53,7 @@ shared_examples 'WpUser::Existable' do
|
||||
end
|
||||
|
||||
describe '::display_name_from_body' do
|
||||
after { mod.display_name_from_body(@body).should == @expected }
|
||||
after { expect(mod.display_name_from_body(@body)).to eq @expected }
|
||||
|
||||
context 'when pattern not found' do
|
||||
it 'returns nil' do
|
||||
@@ -110,8 +110,8 @@ shared_examples 'WpUser::Existable' do
|
||||
response = Typhoeus::Response.new(@resp_opt || resp_opt)
|
||||
subject.send(:load_from_response, response)
|
||||
|
||||
subject.login.should == @login
|
||||
subject.display_name.should == @display_name
|
||||
expect(subject.login).to eq @login
|
||||
expect(subject.display_name).to eq @display_name
|
||||
end
|
||||
|
||||
context 'with a 301' do
|
||||
@@ -147,7 +147,7 @@ shared_examples 'WpUser::Existable' do
|
||||
describe '#exists_from_response?' do
|
||||
after do
|
||||
response = Typhoeus::Response.new(@resp_opt || resp_opt)
|
||||
subject.exists_from_response?(response).should == @expected
|
||||
expect(subject.exists_from_response?(response)).to eq @expected
|
||||
end
|
||||
|
||||
context 'login not found' do
|
||||
|
||||
@@ -10,7 +10,7 @@ shared_examples 'WpUsers::BruteForcable' do
|
||||
it 'calls #brute_force on each wp_user' do
|
||||
range.each do |id|
|
||||
wp_user = WpUser.new(uri, id: id)
|
||||
wp_user.should_receive(:brute_force).with(wordlist, brute_force_opt)
|
||||
expect(wp_user).to receive(:brute_force).with(wordlist, brute_force_opt)
|
||||
|
||||
wp_users << wp_user
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
shared_examples 'WpVersion::Vulnerable' do
|
||||
|
||||
describe '#vulns_file' do
|
||||
after { subject.vulns_file.should == @expected }
|
||||
after { expect(subject.vulns_file).to eq @expected }
|
||||
|
||||
context 'when :vulns_file is no set' do
|
||||
it 'returns the default one' do
|
||||
@@ -20,7 +20,7 @@ shared_examples 'WpVersion::Vulnerable' do
|
||||
end
|
||||
|
||||
describe '#vulns_xpath' do
|
||||
its(:vulns_xpath) { should == "//wordpress[@version='1.2']/vulnerability" }
|
||||
its(:vulns_xpath) { is_expected.to eq "//wordpress[@version='1.2']/vulnerability" }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user