Sha256: f63075d9bfca549f9c50e586d77b96527e7d641b6eb71c0a224b31e5c3f4c4ca

Contents?: true

Size: 1.41 KB

Versions: 8

Compression:

Stored size: 1.41 KB

Contents

require 'spec_helper'

describe CMSScanner::Finders::InterestingFile::RobotsTxt do
  subject(:finder) { described_class.new(target) }
  let(:target)     { CMSScanner::Target.new(url) }
  let(:url)        { 'http://example.com/' }
  let(:robots_txt) { url + 'robots.txt' }
  let(:fixtures)   { File.join(FIXTURES, 'interesting_files', 'robots_txt') }

  describe '#url' do
    its(:url) { should eq robots_txt }
  end

  describe '#aggressive' do
    after do
      stub_request(:get, robots_txt).to_return(status: status, body: body)

      result = finder.aggressive

      expect(result).to be_a CMSScanner::RobotsTxt if @expected
      expect(finder.aggressive).to eql @expected
    end

    let(:body) { '' }

    context 'when 404' do
      let(:status) { 404 }

      it 'returns nil' do
        @expected = nil
      end
    end

    context 'when 200' do
      let(:status) { 200 }

      context 'when the body is empty' do
        it 'returns nil' do
          @expected = nil
        end
      end

      context 'when the body matches a robots.txt' do
        let(:body) { File.new(File.join(fixtures, 'robots.txt')).read }

        it 'returns the InterestingFile result' do
          @expected = CMSScanner::RobotsTxt.new(robots_txt,
                                                confidence: 100,
                                                found_by: 'Robots Txt (Aggressive Detection)')
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cms_scanner-0.0.16 spec/app/finders/interesting_files/robots_txt_spec.rb
cms_scanner-0.0.15 spec/app/finders/interesting_files/robots_txt_spec.rb
cms_scanner-0.0.14 spec/app/finders/interesting_files/robots_txt_spec.rb
cms_scanner-0.0.13 spec/app/finders/interesting_files/robots_txt_spec.rb
cms_scanner-0.0.12 spec/app/finders/interesting_files/robots_txt_spec.rb
cms_scanner-0.0.11 spec/app/finders/interesting_files/robots_txt_spec.rb
cms_scanner-0.0.10 spec/app/finders/interesting_files/robots_txt_spec.rb
cms_scanner-0.0.9 spec/app/finders/interesting_files/robots_txt_spec.rb