StatsPlugin spec fixes

This commit is contained in:
erwanlr
2013-03-29 23:15:29 +01:00
parent 09c9554e4b
commit f26ece827c
3 changed files with 27 additions and 21 deletions

View File

@@ -20,49 +20,45 @@
require File.expand_path(File.dirname(__FILE__) + '/../../wpstools_helper') require File.expand_path(File.dirname(__FILE__) + '/../../wpstools_helper')
describe 'StatsPlugin' do describe 'StatsPlugin' do
before :each do subject(:stats) { StatsPlugin.new }
@stats = StatsPlugin.new() let(:plugins_vulns) { MODELS_FIXTURES + '/wp_plugin/vulnerable/plugins_vulns.xml' }
end let(:themes_vulns) { MODELS_FIXTURES + '/wp_theme/vulnerable/themes_vulns.xml' }
let(:plugins_file) { COLLECTIONS_FIXTURES + '/wp_plugins/detectable/targets.txt' }
let(:themes_file) { COLLECTIONS_FIXTURES + '/wp_themes/detectable/targets.txt'}
describe '#vuln_plugin_count' do describe '#vuln_plugin_count' do
it 'should return the correct number' do it 'returns the correct number' do
xml = "#{SPEC_FIXTURES_WPSCAN_WP_PLUGIN_DIR}/vulnerabilities/plugin_vulns.xml" stats.vuln_plugin_count(plugins_vulns).should == 2
@stats.vuln_plugin_count(xml).should == 2
end end
end end
describe '#vuln_theme_count' do describe '#vuln_theme_count' do
it 'should return the correct number' do it 'returns the correct number' do
xml = "#{SPEC_FIXTURES_WPSCAN_WP_THEME_DIR}/vulnerabilities/theme_vulns.xml" stats.vuln_theme_count(themes_vulns).should == 2
@stats.vuln_theme_count(xml).should == 2
end end
end end
describe '#plugin_vulns_count' do describe '#plugin_vulns_count' do
it 'should return the correct number' do it 'returns the correct number' do
xml = "#{SPEC_FIXTURES_WPSCAN_WP_PLUGIN_DIR}/vulnerabilities/plugin_vulns.xml" stats.plugin_vulns_count(plugins_vulns).should == 3
@stats.plugin_vulns_count(xml).should == 3
end end
end end
describe '#theme_vulns_count' do describe '#theme_vulns_count' do
it 'should return the correct number' do it 'returns the correct number' do
xml = "#{SPEC_FIXTURES_WPSCAN_WP_THEME_DIR}/vulnerabilities/theme_vulns.xml" stats.theme_vulns_count(themes_vulns).should == 3
@stats.theme_vulns_count(xml).should == 3
end end
end end
describe '#total_plugins' do describe '#total_plugins' do
it 'should return the correct numer' do it 'returns the correct numer' do
file = "#{SPEC_FIXTURES_WPSCAN_WP_PLUGIN_DIR}/plugins.txt" stats.total_plugins(plugins_file).should == 3
@stats.total_plugins(file).should == 4
end end
end end
describe '#total_themes' do describe '#total_themes' do
it 'should return the correct numer' do it 'returns the correct numer' do
file = "#{SPEC_FIXTURES_WPSCAN_WP_THEME_DIR}/themes.txt" stats.total_themes(themes_file).should == 3
@stats.total_themes(file).should == 5
end end
end end
end end

View File

@@ -7,6 +7,11 @@
<reference>http://ref1.com</reference> <reference>http://ref1.com</reference>
<type>RCE</type> <type>RCE</type>
</vulnerability> </vulnerability>
<vulnerability>
<title>Neither do I</title>
<reference>http://ref3.com</reference>
<type>FPD</type>
</vulnerability>
</plugin> </plugin>
<plugin name="white-rabbit"> <plugin name="white-rabbit">

View File

@@ -7,6 +7,11 @@
<reference>http://some-ref.com</reference> <reference>http://some-ref.com</reference>
<type>SQLI</type> <type>SQLI</type>
</vulnerability> </vulnerability>
<vulnerability>
<title>Neither do I</title>
<reference>http://some-other-ref.com</reference>
<type>XSS</type>
</vulnerability>
</theme> </theme>
<theme name="the-oracle"> <theme name="the-oracle">