WpUsers::Detectable specs
This commit is contained in:
@@ -3,10 +3,23 @@
|
|||||||
class WpUsers < WpItems
|
class WpUsers < WpItems
|
||||||
module Detectable
|
module Detectable
|
||||||
|
|
||||||
|
# @return [ Hash ]
|
||||||
def request_params; {} end
|
def request_params; {} end
|
||||||
|
|
||||||
# options:
|
# No passive detection
|
||||||
# :range - default 1..10
|
#
|
||||||
|
# @return [ WpUsers ]
|
||||||
|
def passive_detection(wp_target, options = {})
|
||||||
|
new
|
||||||
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
# @param [ WpTarget ] wp_target
|
||||||
|
# @param [ Hash ] options
|
||||||
|
# @option options [ Range ] :range ((1..10))
|
||||||
|
#
|
||||||
|
# @return [ Array<WpUser> ]
|
||||||
def targets_items(wp_target, options = {})
|
def targets_items(wp_target, options = {})
|
||||||
range = options[:range] || (1..10)
|
range = options[:range] || (1..10)
|
||||||
targets = []
|
targets = []
|
||||||
@@ -17,11 +30,5 @@ class WpUsers < WpItems
|
|||||||
targets
|
targets
|
||||||
end
|
end
|
||||||
|
|
||||||
# No passive detection
|
|
||||||
# @return [ WpUsers ]
|
|
||||||
def passive_detection(wp_target, options = {})
|
|
||||||
new
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,6 +18,14 @@ class WpUser < WpItem
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @return [ String ]
|
||||||
|
def to_s
|
||||||
|
s = "#{id}"
|
||||||
|
s += " | #{login}" if login
|
||||||
|
s += " | #{display_name}" if display_name
|
||||||
|
s
|
||||||
|
end
|
||||||
|
|
||||||
# @param [ WpUser ] other
|
# @param [ WpUser ] other
|
||||||
def <=>(other)
|
def <=>(other)
|
||||||
id <=> other.id
|
id <=> other.id
|
||||||
|
|||||||
59
spec/lib/common/collections/wp_users/detectable_spec.rb
Normal file
59
spec/lib/common/collections/wp_users/detectable_spec.rb
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
# encoding: UTF-8
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
require WPSCAN_LIB_DIR + '/wp_target'
|
||||||
|
|
||||||
|
describe 'WpUsers::Detectable' do
|
||||||
|
subject(:wp_users) { WpUsers }
|
||||||
|
let(:wp_content_dir) { 'wp-content' }
|
||||||
|
let(:wp_plugins_dir) { wp_content_dir + '/plugins' }
|
||||||
|
let(:wp_target) { WpTarget.new(url, wp_content_dir: wp_content_dir, wp_plugins_dir: wp_plugins_dir) }
|
||||||
|
let(:url) { 'http://example.com/' }
|
||||||
|
let(:uri) { URI.parse(url) }
|
||||||
|
|
||||||
|
def create_from_range(range)
|
||||||
|
result = []
|
||||||
|
|
||||||
|
range.each do |current_id|
|
||||||
|
result << WpUser.new(uri, id: current_id)
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '::request_params' do
|
||||||
|
it 'return an empty Hash' do
|
||||||
|
subject.request_params.should === {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '::passive_detection' do
|
||||||
|
it 'return an empty WpUsers' do
|
||||||
|
subject.passive_detection(wp_target).should == subject.new
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '::targets_items' do
|
||||||
|
after do
|
||||||
|
targets = subject.send(:targets_items, wp_target, options)
|
||||||
|
|
||||||
|
targets.should == @expected
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when no :range' do
|
||||||
|
let(:options) { {} }
|
||||||
|
|
||||||
|
it 'returns Array<WpUser> with id from 1 to 10' do
|
||||||
|
@expected = create_from_range((1..10))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when :range' do
|
||||||
|
let(:options) { { range: (1..2) } }
|
||||||
|
|
||||||
|
it 'returns Array<WpUser> with id from 1 to 2' do
|
||||||
|
@expected = create_from_range((1..2))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user