Vulnerability::Output specs

This commit is contained in:
erwanlr
2013-03-22 18:25:17 +01:00
parent af4ecc4084
commit d937b20d79
5 changed files with 36 additions and 0 deletions

View File

@@ -15,6 +15,7 @@ class Vulnerability
end
end
# @return [ String ] The url to the metasploit module page
def self.metasploit_module_url(module_path)
# remove leading slash
module_path = module_path.sub(/^\//, '')

View File

@@ -19,6 +19,8 @@ class WpItem
attr_reader :path
attr_accessor :name, :wp_content_dir, :wp_plugins_dir
# @return [ Array ]
# Make it private ?
def allowed_options
[:name, :wp_content_dir, :wp_plugins_dir, :path, :version, :vulns_file]
end

View File

@@ -9,6 +9,7 @@ class WpUser < WpItem
def allowed_options; [:id, :login, :display_name, :password] end
# @return [ URI ] The uri to the auhor page
def uri
if id
return @uri.merge("?author=#{id}")
@@ -17,14 +18,17 @@ class WpUser < WpItem
end
end
# @param [ Wpuser ] other
def <=>(other)
id <=> other.id
end
# @param [ WpUser ] other
def ==(other)
self === other
end
# @param [ WpUser ] other
def ===(other)
id === other.id && login === other.login
end

View File

@@ -13,6 +13,7 @@ class WpVersion < WpItem
# The version number
attr_accessor :number
# @return [ Array ]
def allowed_options; super << :number << :found_from end
end

View File

@@ -0,0 +1,28 @@
# encoding: UTF-8
require 'spec_helper'
describe Vulnerability::Output do
let(:modules_url) { 'http://www.metasploit.com/modules/' }
describe '::metasploit_module_url' do
after :each do
Vulnerability::Output.metasploit_module_url(@module).should == @expected
end
it 'removes the leading slash' do
@module = '/exploit/testing'
@expected = modules_url + 'exploit/testing'
end
it 'returns the correct url' do
@module = 'gathering/yolo'
@expected = modules_url + @module
end
end
describe '#output' do
# How to test it ? oO
end
end