Sha256: f0737fe78d70c335340ba0d771d8583ff500c11ef4b1d47a3863c22686dd7cc8

Contents?: true

Size: 1.97 KB

Versions: 20

Compression:

Stored size: 1.97 KB

Contents

require 'spec_helper'

describe 'wpscan upload plugin' do
  describe "Importer" do

    before(:each) do
      # Stub template service
      templates_dir = File.expand_path('../../templates', __FILE__)
      expect_any_instance_of(Dradis::Plugins::TemplateService)
      .to receive(:default_templates_dir).and_return(templates_dir)

      # Init services
      plugin = Dradis::Plugins::Wpscan

      @content_service = Dradis::Plugins::ContentService::Base.new(plugin: plugin)

      @importer = plugin::Importer.new(
        content_service: @content_service
      )
    end

    it 'raises an error note when the json is not valid' do
      expect(@content_service).to receive(:create_note) do |args|
        expect(args[:text]).to include("ERROR: No 'target_url' field present in the provided JSON data")
        OpenStruct.new(args)
      end.once

      @importer.import(file: 'spec/fixtures/files/invalid.json')
    end

    it "creates nodes, issues, notes and an evidences as needed" do
      expect(@content_service).to receive(:create_node) do |args|
        # puts "create_node: #{ args.inspect }"
        expect(args[:label]).to eq('http://www.redacted.com/')
        expect(args[:type]).to eq(:host)
        OpenStruct.new(args)
      end.once
      expect(@content_service).to receive(:create_note) do |args|
        # puts "create_note: #{ args.inspect }"
        expect(args[:text]).to include("#[Title]#\nWPScan Scan Information")
        expect(args[:node].label).to eq('http://www.redacted.com/')
        OpenStruct.new(args)
      end.once
      expect(@content_service).to receive(:create_issue) do |args|
        # puts "create_issue: #{ args.inspect }"
        OpenStruct.new(args)
      end.exactly(10).times
      expect(@content_service).to receive(:create_evidence) do |args|
        # puts "create_evidence: #{ args.inspect }"
        OpenStruct.new(args)
      end.exactly(5).times

      # Run the import
      @importer.import(file: 'spec/fixtures/files/sample.json')
    end

  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
dradis-wpscan-4.14.0 spec/wpscan_upload_spec.rb
dradis-wpscan-4.13.0 spec/wpscan_upload_spec.rb
dradis-wpscan-4.11.0 spec/wpscan_upload_spec.rb
dradis-wpscan-4.10.0 spec/wpscan_upload_spec.rb
dradis-wpscan-4.9.0 spec/wpscan_upload_spec.rb
dradis-wpscan-4.8.0 spec/wpscan_upload_spec.rb
dradis-wpscan-4.7.0 spec/wpscan_upload_spec.rb
dradis-wpscan-4.6.0 spec/wpscan_upload_spec.rb
dradis-wpscan-4.5.0 spec/wpscan_upload_spec.rb
dradis-wpscan-4.4.0 spec/wpscan_upload_spec.rb
dradis-wpscan-4.3.0 spec/wpscan_upload_spec.rb
dradis-wpscan-4.2.0 spec/wpscan_upload_spec.rb
dradis-wpscan-4.1.0 spec/wpscan_upload_spec.rb
dradis-wpscan-4.0.0 spec/wpscan_upload_spec.rb
dradis-wpscan-3.22.0 spec/wpscan_upload_spec.rb
dradis-wpscan-3.21.0 spec/wpscan_upload_spec.rb
dradis-wpscan-3.20.0 spec/wpscan_upload_spec.rb
dradis-wpscan-3.19.0 spec/wpscan_upload_spec.rb
dradis-wpscan-3.18.0 spec/wpscan_upload_spec.rb
dradis-wpscan-3.17.0 spec/wpscan_upload_spec.rb