Path: blob/master/spec/lib/db/dynamic_finders/plugin_spec.rb
486 views
# frozen_string_literal: true12describe WPScan::DB::DynamicFinders::Plugin do3subject(:dynamic_finders) { described_class }45describe '.finders_configs' do6context 'when the given class is not allowed' do7it 'returns an empty hash' do8expect(subject.finder_configs('aaaa')).to eql({})9end10end1112context 'when the given class is allowed' do13context 'when aggressive argument is false' do14it 'returns only the configs w/o a path parameter' do15configs = subject.finder_configs(:Xpath)1617expect(configs.keys).to include('wordpress-mobile-pack', 'shareaholic')18expect(configs.keys).to_not include('simple-share-button-adder')1920expect(configs['sitepress-multilingual-cms']['MetaGenerator']['pattern']).to be_a Regexp21expect(configs['sitepress-multilingual-cms']['MetaGenerator']['version']).to eql true22end23end2425context 'when aggressive argument is true' do26it 'returns only the configs with a path parameter' do27configs = subject.finder_configs(:Xpath, aggressive: true)2829expect(configs.keys).to include('revslider')30expect(configs.keys).to_not include('shareaholic')31end32end33end34end3536describe '.versions_finders_configs' do37# Just test a sample here38its('versions_finders_configs.keys') { should include('shareaholic') }39its('versions_finders_configs.keys') { should_not include('wordpress-mobile-pack') }40end4142describe '.maybe_create_module' do43xit44end4546describe '.create_versions_finders' do47# handled and tested in spec/lib/finders/dynamic_finders/plugin_version_spec4849context 'When trying to create the finders twice' do50# let's just test one slug, no need to test them all51let(:slug) { '12-step-meeting-list' }5253it 'does not raise an error when the class already exists' do54WPScan::DB::DynamicFinders::Plugin.create_versions_finders(slug)5556expect { WPScan::DB::DynamicFinders::Plugin.create_versions_finders(slug) }.to_not raise_error57end58end5960context 'when the slug contains non alpha-numeric chars' do61let(:slug) { 'test.something' }6263it 'sanitize it and does not raise an error' do64expect { WPScan::DB::DynamicFinders::Plugin.create_versions_finders(slug) }.to_not raise_error65end66end67end6869describe '.version_finder_super_class' do70# handled and tested in spec/lib/finders/dynamic_finders/plugin_version_spec71end7273describe '.method_missing' do74context 'when the method matches a valid call' do75its('passive_comment_finder_configs.keys') { should include('addthis') }76its('passive_comment_finder_configs.keys') { should_not include('shareaholic') }7778its('passive_xpath_finder_configs.keys') { should include('shareaholic') }79its('passive_xpath_finder_configs.keys') { should_not include('simple-share-button-adder') }80its('aggressive_xpath_finder_configs.keys') { should_not include('wordpress-mobile-pack') }81its('aggressive_xpath_finder_configs.keys') { should include('revslider') }82end8384context 'when the method does not match a valid call' do85it 'raises an error' do86expect { subject.aaa }.to raise_error(NoMethodError)87end88end89end90end919293