WPScan files
This commit is contained in:
5
spec/lib/updater/git_updater_spec.rb
Normal file
5
spec/lib/updater/git_updater_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
||||
|
||||
describe GitUpdater do
|
||||
|
||||
end
|
||||
78
spec/lib/updater/svn_updater_spec.rb
Normal file
78
spec/lib/updater/svn_updater_spec.rb
Normal file
@@ -0,0 +1,78 @@
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
||||
|
||||
describe SvnUpdater do
|
||||
|
||||
before :each do
|
||||
@svn_updater = SvnUpdater.new
|
||||
end
|
||||
|
||||
describe "#is_installed?" do
|
||||
after :each do
|
||||
stub_system_command(@svn_updater, /^svn info/, @stub_value)
|
||||
@svn_updater.is_installed?.should === @expected
|
||||
end
|
||||
|
||||
it "should return false if the svn command is not found" do
|
||||
@stub_value = "svn: command not found"
|
||||
@expected = false
|
||||
end
|
||||
|
||||
it "should return false if the repository is not manage by svn" do
|
||||
@stub_value = "svn: '.' is not a working copy"
|
||||
@expected = false
|
||||
end
|
||||
|
||||
it "should return true" do
|
||||
@stub_value = '<?xml version="1.0"?>
|
||||
<info>
|
||||
<entry kind="dir" path="." revision="362">
|
||||
<url>https://wpscan.googlecode.com/svn/trunk</url>
|
||||
<repository>
|
||||
<root>https://wpscan.googlecode.com/svn</root>
|
||||
<uuid>0b0242d5-46e6-2201-410d-bc09fd35266c</uuid>
|
||||
</repository>
|
||||
<wc-info>
|
||||
<schedule>normal</schedule>
|
||||
<depth>infinity</depth>
|
||||
</wc-info>
|
||||
<commit revision="362">
|
||||
<author>author@mail.tld</author>
|
||||
<date>2012-06-02T06:26:25.309806Z</date>
|
||||
</commit>
|
||||
</entry>
|
||||
</info>'
|
||||
@expected = true
|
||||
end
|
||||
end
|
||||
|
||||
describe "#local_revision_number" do
|
||||
after :each do
|
||||
stub_system_command(@svn_updater, /^svn info/, @stub_value)
|
||||
@svn_updater.local_revision_number.should === @expected
|
||||
end
|
||||
|
||||
it "should return 399" do
|
||||
@stub_value = '<?xml version="1.0"?>
|
||||
<info>
|
||||
<entry kind="dir" path="." revision="362">
|
||||
<url>https://wpscan.googlecode.com/svn/trunk</url>
|
||||
<repository>
|
||||
<root>https://wpscan.googlecode.com/svn</root>
|
||||
<uuid>0b0242d5-46e6-2201-410d-bc09fd35266c</uuid>
|
||||
</repository>
|
||||
<wc-info>
|
||||
<schedule>normal</schedule>
|
||||
<depth>infinity</depth>
|
||||
</wc-info>
|
||||
<commit revision="362">
|
||||
<author>author@mail.tld</author>
|
||||
<date>2012-06-02T06:26:25.309806Z</date>
|
||||
</commit>
|
||||
</entry>
|
||||
</info>'
|
||||
@expected = "362"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
27
spec/lib/updater/updater_factory_spec.rb
Normal file
27
spec/lib/updater/updater_factory_spec.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
||||
|
||||
describe UpdaterFactory do
|
||||
|
||||
describe "#available_updaters_classes" do
|
||||
after :each do
|
||||
UpdaterFactory.available_updaters_classes.sort.should === @expected.sort
|
||||
end
|
||||
|
||||
it "should return [:GitUpdater, :SvnUpdater]" do
|
||||
@expected = [:GitUpdater, :SvnUpdater]
|
||||
end
|
||||
|
||||
it "should return [:TestUpdater, :GitUpdater, :SvnUpdater]" do
|
||||
class TestUpdater < Updater
|
||||
end
|
||||
|
||||
@expected = [:GitUpdater, :SvnUpdater, :TestUpdater]
|
||||
end
|
||||
end
|
||||
|
||||
# TODO : Find a way to test that
|
||||
describe "#get_updater" do
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
25
spec/lib/updater/updater_spec.rb
Normal file
25
spec/lib/updater/updater_spec.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
||||
|
||||
describe Updater do
|
||||
|
||||
before :all do
|
||||
class TestUpdater < Updater
|
||||
end
|
||||
end
|
||||
|
||||
after :all do
|
||||
Object.send(:remove_const, :TestUpdater)
|
||||
end
|
||||
|
||||
describe "non implementation of #is_installed?, #has_update? and #update" do
|
||||
it "should raise errors" do
|
||||
test_updater = TestUpdater.new
|
||||
methods_to_call = [:is_installed?, :update, :local_revision_number]
|
||||
|
||||
methods_to_call.each do |method_to_call|
|
||||
expect { test_updater.send(method_to_call) }.to raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user