Sha256: 8c1eba0a760848abcc82031f6551948458058909ac87e53b2a94943f41b75fd1

Contents?: true

Size: 1.8 KB

Versions: 2

Compression:

Stored size: 1.8 KB

Contents

require 'spec_helper'
require 'ronin/exploits/cli/exploit_command'
require 'ronin/exploits/exploit'

describe Ronin::Exploits::CLI::ExploitCommand do
  module TestExploitCommand
    class TestExploit < Ronin::Exploits::Exploit
      register 'test_exploit_command'
    end

    class TestCommand < Ronin::Exploits::CLI::ExploitCommand
    end
  end

  let(:exploit_class) { TestExploitCommand::TestExploit }
  let(:command_class) { TestExploitCommand::TestCommand }
  subject { command_class.new }

  describe "#load_exploit" do
    let(:id) { exploit_class.id }

    before do
      expect(Ronin::Exploits).to receive(:load_class).with(id).and_return(exploit_class)
    end

    it "must load the exploit class and return the exploit class" do
      expect(subject.load_exploit(id)).to be(exploit_class)
    end

    it "must also set #exploit_class" do
      subject.load_exploit(id)

      expect(subject.exploit_class).to be(exploit_class)
    end
  end

  describe "#load_exploit_from" do
    let(:file) { "path/to/exploit/file.rb" }

    before do
      expect(Ronin::Exploits).to receive(:load_class_from_file).with(file).and_return(exploit_class)
    end

    it "must load the exploit class and return the exploit class" do
      expect(subject.load_exploit_from(file)).to be(exploit_class)
    end

    it "must also set #exploit_class" do
      subject.load_exploit_from(file)

      expect(subject.exploit_class).to be(exploit_class)
    end
 end

  describe "#initialize_exploit" do
    before { subject.load_exploit(exploit_class.id) }

    it "must initialize a new exploit object using #exploit_class" do
      expect(subject.initialize_exploit).to be_kind_of(exploit_class)
    end

    it "must also set #exploit" do
      subject.initialize_exploit

      expect(subject.exploit).to be_kind_of(exploit_class)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ronin-exploits-1.0.0.beta2 spec/cli/exploit_command_spec.rb
ronin-exploits-1.0.0.beta1 spec/cli/exploit_command_spec.rb