Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wpscanteam
GitHub Repository: wpscanteam/wpscan
Path: blob/master/spec/app/controllers/custom_directories_spec.rb
486 views
1
# frozen_string_literal: true
2
3
describe WPScan::Controller::CustomDirectories do
4
subject(:controller) { described_class.new }
5
let(:target_url) { 'http://ex.lo/' }
6
let(:cli_args) { "--url #{target_url}" }
7
8
before do
9
WPScan::ParsedCli.options = rspec_parsed_options(cli_args)
10
end
11
12
describe '#cli_options' do
13
its(:cli_options) { should_not be_empty }
14
its(:cli_options) { should be_a Array }
15
16
it 'contains to correct options' do
17
expect(controller.cli_options.map(&:to_sym)).to eq %i[wp_content_dir wp_plugins_dir]
18
end
19
end
20
21
describe '#before_scan' do
22
context 'when the content_dir is not found and not supplied' do
23
before { expect(controller.target).to receive(:content_dir).and_return(nil) }
24
25
it 'raises an exception' do
26
expect { controller.before_scan }.to raise_error(WPScan::Error::WpContentDirNotDetected)
27
end
28
end
29
30
context 'when content_dir found/supplied' do
31
let(:cli_args) { "#{super()} --wp-content-dir wp-content" }
32
33
it 'does not raise any error' do
34
expect { controller.before_scan }.to_not raise_error
35
expect(controller.target.content_dir).to eq WPScan::ParsedCli.wp_content_dir
36
end
37
end
38
end
39
end
40
41