Path: blob/master/spec/app/finders/users/rss_generator_spec.rb
1483 views
# frozen_string_literal: true12describe WPScan::Finders::Users::RSSGenerator do3subject(:finder) { described_class.new(target) }4let(:target) { WPScan::Target.new(url) }5let(:url) { 'http://ex.lo/' }6let(:fixtures) { FINDERS_FIXTURES.join('users', 'rss_generator') }7let(:rss_fixture) { File.read(fixtures.join('feed.xml')) }89describe '#passive, #aggressive' do10before do11allow(target).to receive(:sub_dir).and_return(false)1213stub_request(:get, target.url).to_return(body: File.read(homepage_fixture))14end1516context 'when no RSS link in homepage' do17let(:homepage_fixture) { fixtures.join('homepage_no_links.html') }1819its(:passive) { should eql [] }2021it 'returns the expected from #aggressive' do22stub_request(:get, target.url('feed/')).to_return(body: rss_fixture)23stub_request(:get, target.url('comments/feed/'))24stub_request(:get, target.url('feed/rss/'))25stub_request(:get, target.url('feed/rss2/'))2627expect(finder.aggressive).to eql [28WPScan::Model::User.new(29'admin',30confidence: 50,31found_by: 'Rss Generator (Aggressive Detection)'32),33WPScan::Model::User.new(34'Aa Dias-Gildes',35confidence: 50,36found_by: 'Rss Generator (Aggressive Detection)'37)38]39end40end4142context 'when RSS link in homepage' do43let(:homepage_fixture) { fixtures.join('homepage_links.html') }4445it 'returns the expected from #passive' do46stub_request(:get, target.url('feed/')).to_return(body: rss_fixture)4748expect(finder.passive).to eql [49WPScan::Model::User.new(50'admin',51confidence: 50,52found_by: 'Rss Generator (Passive Detection)'53),54WPScan::Model::User.new(55'Aa Dias-Gildes',56confidence: 50,57found_by: 'Rss Generator (Passive Detection)'58)59]60end6162context 'when :mixed mode' do63it 'avoids checking existing URL/s from #passive' do64stub_request(:get, target.url('comments/feed/')).to_return(body: rss_fixture)6566expect(finder.aggressive(mode: :mixed)).to eql [67WPScan::Model::User.new(68'admin',69confidence: 50,70found_by: 'Rss Generator (Aggressive Detection)'71),72WPScan::Model::User.new(73'Aa Dias-Gildes',74confidence: 50,75found_by: 'Rss Generator (Aggressive Detection)'76)77]78end79end8081context 'when no mode' do82it 'checks the first URL detected from the URLs' do83stub_request(:get, target.url('feed/')).to_return(body: rss_fixture)8485expect(finder.aggressive).to eql [86WPScan::Model::User.new(87'admin',88confidence: 50,89found_by: 'Rss Generator (Aggressive Detection)'90),91WPScan::Model::User.new(92'Aa Dias-Gildes',93confidence: 50,94found_by: 'Rss Generator (Aggressive Detection)'95)96]97end98end99end100end101end102103104