Path: blob/master/spec/app/finders/interesting_findings/readme_spec.rb
1483 views
# frozen_string_literal: true12describe WPScan::Finders::InterestingFindings::Readme do3subject(:finder) { described_class.new(target) }4let(:target) { WPScan::Target.new(url) }5let(:url) { 'http://ex.lo/' }6let(:fixtures) { FINDERS_FIXTURES.join('interesting_findings', 'readme') }78describe '#aggressive' do9before do10expect(target).to receive(:sub_dir).at_least(1).and_return(false)11expect(target).to receive(:head_or_get_params).at_least(1).and_return(method: :head)1213finder.potential_files.each do |file|14stub_request(:head, target.url(file)).to_return(status: 404)15end16end1718context 'when no file present' do19its(:aggressive) { should be_nil }20end2122# TODO: case when multiple files are present ? (should return only the first one found)23context 'when a file exists' do24let(:file) { finder.potential_files.sample }25let(:readme) { File.read(fixtures.join('readme-3.9.2.html')) }2627before do28stub_request(:head, target.url(file))29stub_request(:get, target.url(file)).to_return(body: readme)30end3132it 'returns the expected InterestingFinding' do33expected = WPScan::Model::Readme.new(34target.url(file),35confidence: 100,36found_by: described_class::DIRECT_ACCESS37)3839expect(finder.aggressive).to eql expected40end41end42end4344describe '#potential_files' do45it 'does not contain duplicates' do46expect(finder.potential_files.flatten.uniq.length).to eql finder.potential_files.length47end48end49end505152