From fd5cf4785c8ddc30ba2f39229e12e00d93b232c1 Mon Sep 17 00:00:00 2001 From: Erwan Date: Tue, 23 Oct 2012 12:19:16 +0200 Subject: [PATCH] Rspec fixes --- lib/wpscan/wp_enumerator.rb | 6 +++--- spec/lib/wpscan/wp_target_spec.rb | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/wpscan/wp_enumerator.rb b/lib/wpscan/wp_enumerator.rb index ba4bab5a..8615d546 100644 --- a/lib/wpscan/wp_enumerator.rb +++ b/lib/wpscan/wp_enumerator.rb @@ -56,9 +56,9 @@ class WpEnumerator request_count += 1 request.on_complete do |response| - if options[:show_progress_bar] - print "\rChecking for #{enumerate_size} total #{options[:type]}... #{(request_count * 100) / enumerate_size}% complete." - end + + print "\rChecking for #{enumerate_size} total #{options[:type]}... #{(request_count * 100) / enumerate_size}% complete." if options[:show_progress_bar] + if WpTarget.valid_response_codes.include?(response.code) if Digest::MD5.hexdigest(response.body) != options[:error_404_hash] found << target diff --git a/spec/lib/wpscan/wp_target_spec.rb b/spec/lib/wpscan/wp_target_spec.rb index f049465f..de268b45 100644 --- a/spec/lib/wpscan/wp_target_spec.rb +++ b/spec/lib/wpscan/wp_target_spec.rb @@ -103,7 +103,7 @@ describe WpTarget do end it "should return the string set in the initialize method" do - @wp_target = WpTarget.new("http://example.localhost/", :wp_content_dir => "hello-world") + @wp_target = WpTarget.new("http://example.localhost/", @options.merge(:wp_content_dir => "hello-world")) @expected = "hello-world" end @@ -159,7 +159,7 @@ describe WpTarget do end it "should return the string set in the initialize method" do - @wp_target = WpTarget.new("http://example.localhost/", :wp_content_dir => "asdf", :wp_plugins_dir => "custom-plugins") + @wp_target = WpTarget.new("http://example.localhost/", @options.merge(:wp_content_dir => "asdf", :wp_plugins_dir => "custom-plugins")) @expected = "custom-plugins" end @@ -169,22 +169,22 @@ describe WpTarget do end it "should return 'wp-content/plugins'" do - @stub_value = nil - @expected = "wp-content/plugins" + @wp_target = WpTarget.new("http://example.localhost/", @options.merge(:wp_content_dir => "wp-content", :wp_plugins_dir => nil)) + @expected = "wp-content/plugins" end end describe "#wp_plugins_dir_exists?" do it "should return true" do - target = WpTarget.new("http://example.localhost/", :wp_content_dir => "asdf", :wp_plugins_dir => "custom-plugins") - url = target.uri.merge(target.wp_plugins_dir).to_s + target = WpTarget.new("http://example.localhost/", @options.merge(:wp_content_dir => "asdf", :wp_plugins_dir => "custom-plugins")) + url = target.uri.merge(target.wp_plugins_dir).to_s stub_request(:any, url).to_return(:status => 200) target.wp_plugins_dir_exists?.should == true end it "should return false" do - target = WpTarget.new("http://example.localhost/", :wp_content_dir => "asdf", :wp_plugins_dir => "custom-plugins") - url = target.uri.merge(target.wp_plugins_dir).to_s + target = WpTarget.new("http://example.localhost/", @options.merge(:wp_content_dir => "asdf", :wp_plugins_dir => "custom-plugins")) + url = target.uri.merge(target.wp_plugins_dir).to_s stub_request(:any, url).to_return(:status => 404) target.wp_plugins_dir_exists?.should == false end @@ -217,7 +217,7 @@ describe WpTarget do end it "should also detect it if there are PHP notice" do - @fixture = fixtures_dir + "/debug-notice.log" + @fixture = fixtures_dir + "/debug-notice.log" @expected = true end end