Path: blob/master/spec/app/finders/users/author_posts_spec.rb
1483 views
# frozen_string_literal: true12describe WPScan::Finders::Users::AuthorPosts do3subject(:finder) { described_class.new(target) }4let(:target) { WPScan::Target.new(url) }5let(:url) { 'http://wp.lab/' }6let(:fixtures) { FINDERS_FIXTURES.join('users', 'author_posts') }78describe '#passive' do9xit10end1112describe '#potential_usernames' do13it 'returns the expected usernames' do14res = Typhoeus::Response.new(body: File.read(fixtures.join('potential_usernames.html')))1516results = finder.potential_usernames(res)1718expect(results).to eql [19['admin', 'Author Pattern', 100],20['admin display_name', 'Display Name', 30],21['editor', 'Author Pattern', 100],22['editor', 'Display Name', 30]23]24end2526context 'when a lot of unrelated uris' do27it 'should not take a while to process the page' do28body = Array.new(300) { |i| "<a href='#{url}#{i}.html'>Some Link</a>" }.join("\n")29body << "<a href='#{url}author/admin/'>Other Link</a>"30body << "<a href='#{url}?author=2'>user display name</a>"3132time_start = Time.now33results = finder.potential_usernames(Typhoeus::Response.new(body: body))34time_end = Time.now3536expect(results).to eql [37['admin', 'Author Pattern', 100],38['user display name', 'Display Name', 30]39]4041expect(time_end - time_start).to be < 142end43end44end45end464748