Sha256: d5d57e51e79cc791b4cb6ec70e38ef61d8b31cefb371e803385fc813929c8a81

Contents?: true

Size: 1.68 KB

Versions: 27

Compression:

Stored size: 1.68 KB

Contents

require 'webrick'
require File.dirname(__FILE__) + '/../lib/yawast'
require File.dirname(__FILE__) + '/base'

class TestDirectorySearch < Minitest::Test
  include TestBase

  def test_directory_search_recurs
    port = rand(60000) + 1024 # pick a random port number
    server = run_server port

    override_stdout
    uri = Yawast::Commands::Utils.extract_uri(["http://localhost:#{port}"])

    Yawast::Shared::Http.setup nil, nil
    Yawast::Scanner::Plugins::Http::DirectorySearch.search uri, true, true, %w(test data)

    assert stdout_value.include?('Recursively searching for common directories'), 'Output not found'

    server.exit
    restore_stdout
  end

  def test_directory_search
    port = rand(60000) + 1024 # pick a random port number
    server = run_server port

    override_stdout
    uri = Yawast::Commands::Utils.extract_uri(["http://localhost:#{port}"])

    Yawast::Shared::Http.setup nil, nil
    Yawast::Scanner::Plugins::Http::DirectorySearch.search uri, false, true, %w(test data)

    assert stdout_value.include?('Searching for common directories'), 'Output not found'

    server.exit
    restore_stdout
  end

  def run_server(port)
    Thread.new {
      sockets = WEBrick::Utils.create_listeners nil, port

      server = WEBrick::HTTPServer.new :Port => port,
                                       :BindAddress => 'localhost',
                                       :AccessLog => [],
                                       :Logger => WEBrick::Log.new('/dev/null'),
                                       :DocumentRoot => File.dirname(__FILE__),
                                       :DoNotListen => true
      server.listeners.replace sockets
      server.start
    }
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
yawast-0.7.2 test/test_directory_search.rb
yawast-0.7.1 test/test_directory_search.rb
yawast-0.7.0 test/test_directory_search.rb
yawast-0.7.0.beta3 test/test_directory_search.rb
yawast-0.7.0.beta2 test/test_directory_search.rb
yawast-0.7.0.beta1 test/test_directory_search.rb
yawast-0.6.0 test/test_directory_search.rb
yawast-0.6.0.beta6 test/test_directory_search.rb
yawast-0.6.0.beta5 test/test_directory_search.rb
yawast-0.6.0.beta4 test/test_directory_search.rb
yawast-0.6.0.beta3 test/test_directory_search.rb
yawast-0.6.0.beta2 test/test_directory_search.rb
yawast-0.6.0.beta1 test/test_directory_search.rb
yawast-0.5.2 test/test_directory_search.rb
yawast-0.5.1 test/test_directory_search.rb
yawast-0.5.1.beta1 test/test_directory_search.rb
yawast-0.5.0 test/test_directory_search.rb
yawast-0.5.0.beta8 test/test_directory_search.rb
yawast-0.5.0.beta7 test/test_directory_search.rb
yawast-0.5.0.beta6 test/test_directory_search.rb