Sha256: 1b3ad7f1dbda119a5a8fb2f4635413c8fb1f384b74c46665ddfd421d6e2ebc16
Contents?: true
Size: 1.99 KB
Versions: 2
Compression:
Stored size: 1.99 KB
Contents
require 'spec_helper' require 'ronin/exploits/params/base_url' require 'ronin/exploits/exploit' describe Ronin::Exploits::Params::BaseURL do module TestBaseURLParam class TestExploit < Ronin::Exploits::Exploit include Ronin::Exploits::Params::BaseURL end end describe ".included" do subject { TestBaseURLParam::TestExploit } it "must add a required 'base_url' param to the exploit class" do expect(subject.params[:base_url]).to_not be_nil expect(subject.params[:base_url].type).to be_kind_of(Ronin::Core::Params::Types::URI) expect(subject.params[:base_url].required?).to be(true) expect(subject.params[:base_url].desc).to eq("The base URL of the target") end end let(:base_url) { URI('https://example.com:8080/') } subject { TestBaseURLParam::TestExploit.new(params: {base_url: base_url}) } describe "#host" do it "must return the host value of the base URL" do expect(subject.host).to eq(base_url.host) end end describe "#port" do it "must return the port value of the base URL" do expect(subject.port).to eq(base_url.port) end end describe "#url_for" do context "when given an absolute path" do let(:path) { '/foo' } it "must return a URI::HTTP object" do expect(subject.url_for(path)).to be_kind_of(URI::HTTP) end it "must override the path of the params[:base_url]" do expect(subject.url_for(path).path).to eq(path) end end context "when given a relative path" do let(:path) { 'foo' } it "must return a URI::HTTP object" do expect(subject.url_for(path)).to be_kind_of(URI::HTTP) end it "must convert the path into an absolute path" do expect(subject.url_for(path).path).to eq("/#{path}") end end context "when given a fully qualified URL" do let(:url) { "https://www.other.com/foo" } it "must return the URL" do expect(subject.url_for(url).to_s).to eq(url) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ronin-exploits-1.0.0.beta2 | spec/params/base_url_spec.rb |
ronin-exploits-1.0.0.beta1 | spec/params/base_url_spec.rb |