Sha256: bccec0d1ce49b40b18b84c21d125b79e8558bd613bbe9ba73d44686619ca8d83

Contents?: true

Size: 1.29 KB

Versions: 5

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe CMSScanner::Finders::InterestingFile::SearchReplaceDB2 do

  subject(:finder) { described_class.new(target) }
  let(:target)     { CMSScanner::Target.new(url) }
  let(:url)        { 'http://example.com/' }
  let(:file)       { url + 'searchreplacedb2.php' }
  let(:fixtures)   { File.join(FIXTURES, 'interesting_files', 'search_replace_db_2') }

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

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

      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' do
        let(:body) { File.new(File.join(fixtures, 'searchreplacedb2.php')).read }

        it 'returns the InterestingFile result' do
          @expected = CMSScanner::InterestingFile.new(
            file,
            confidence: 100,
            found_by: 'SearchReplaceDB2 (aggressive detection)'
          )
        end
      end
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cms_scanner-0.0.6 spec/app/finders/interesting_files/search_replace_db_2_spec.rb
cms_scanner-0.0.5 spec/app/finders/interesting_files/search_replace_db_2_spec.rb
cms_scanner-0.0.4 spec/app/finders/interesting_files/search_replace_db_2_spec.rb
cms_scanner-0.0.3 spec/app/finders/interesting_files/search_replace_db_2_spec.rb
cms_scanner-0.0.2 spec/app/finders/interesting_files/search_replace_db_2_spec.rb