Sha256: ffe091889b77a281f6bdac0f5fdfd21bc5ea1bb01a76dc1997bdf06bcd4d5d4c

Contents?: true

Size: 1.74 KB

Versions: 8

Compression:

Stored size: 1.74 KB

Contents

require 'spec_helper'

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

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

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

      result = finder.aggressive

      expect(result).to be_a CMSScanner::FantasticoFileslist if @expected
      expect(result).to eql @expected
    end

    let(:body)    { '' }
    let(:headers) { { 'Content-Type' => 'text/html ' } }

    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 not a text/plain Content-Type' do
        let(:body) { 'not an empty body' }

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

      context 'when the body matches and Content-Type = text/plain' do
        let(:body)    { File.new(File.join(fixtures, 'fantastico_fileslist.txt')).read }
        let(:headers) { { 'Content-Type' => 'text/plain' } }

        it 'returns the InterestingFile result' do
          @expected = CMSScanner::FantasticoFileslist.new(
            file,
            confidence: 100,
            found_by: 'Fantastico Fileslist (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/fantastico_fileslist_spec.rb
cms_scanner-0.0.15 spec/app/finders/interesting_files/fantastico_fileslist_spec.rb
cms_scanner-0.0.14 spec/app/finders/interesting_files/fantastico_fileslist_spec.rb
cms_scanner-0.0.13 spec/app/finders/interesting_files/fantastico_fileslist_spec.rb
cms_scanner-0.0.12 spec/app/finders/interesting_files/fantastico_fileslist_spec.rb
cms_scanner-0.0.11 spec/app/finders/interesting_files/fantastico_fileslist_spec.rb
cms_scanner-0.0.10 spec/app/finders/interesting_files/fantastico_fileslist_spec.rb
cms_scanner-0.0.9 spec/app/finders/interesting_files/fantastico_fileslist_spec.rb