Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wpscanteam
GitHub Repository: wpscanteam/wpscan
Path: blob/master/spec/lib/finders/dynamic_finder/version/config_parser_spec.rb
1469 views
1
# frozen_string_literal: true
2
3
describe WPScan::Finders::DynamicFinder::Version::ConfigParser do
4
module WPScan
5
module Finders
6
module Version
7
# Needed to be able to test the below
8
module Rspec
9
end
10
end
11
end
12
end
13
14
let(:finder_module) { WPScan::Finders::Version::Rspec }
15
let(:finder_class) { WPScan::Finders::Version::Rspec::ConfigParser }
16
let(:finder_config) { { 'key' => 'some-key', 'path' => 'file.json' } }
17
let(:default) { { 'pattern' => /(?<v>\d+\.[.\d]+)/, 'confidence' => 70 } }
18
19
before { described_class.create_child_class(finder_module, :ConfigParser, finder_config) }
20
after { finder_module.send(:remove_const, :ConfigParser) }
21
22
describe '.create_child_class' do
23
context 'when CONFIDENCE' do
24
let(:finder_config) { super().merge('confidence' => 30) }
25
26
it 'contains the expected constants' do
27
expect(finder_class::KEY).to eql finder_config['key']
28
expect(finder_class::CONFIDENCE).to eql finder_config['confidence']
29
expect(finder_class::PATH).to eql finder_config['path']
30
31
expect(finder_class::PATTERN).to eql default['pattern']
32
end
33
end
34
35
context 'when PATTERN' do
36
let(:finder_config) { super().merge('pattern' => /another pattern/i) }
37
38
it 'contains the expected constants' do
39
expect(finder_class::KEY).to eql finder_config['key']
40
expect(finder_class::PATTERN).to eql finder_config['pattern']
41
expect(finder_class::PATH).to eql finder_config['path']
42
43
expect(finder_class::CONFIDENCE).to eql default['confidence']
44
end
45
end
46
end
47
48
describe '#passive, #aggressive' do
49
# Handled in spec/lib/finders/dynamic_finder/plugin_version_spec
50
end
51
end
52
53