Included broken DNS unit tests so others can help debug.
Temporary 'dns' and 'dns_rest' Rake tasks make it easier to run tests.
This commit is contained in:
16
Rakefile
16
Rakefile
@@ -32,6 +32,22 @@ task :integration => ["install"] do
|
||||
Rake::Task['beef_stop'].invoke
|
||||
end
|
||||
|
||||
# TODO: Remove task before comitting
|
||||
desc "Run DNS integration tests"
|
||||
task :dns_rest do
|
||||
Rake::Task['beef_start'].invoke
|
||||
sh "cd test/integration; ruby -W0 ts_dns_rest.rb"
|
||||
Rake::Task['beef_stop'].invoke
|
||||
end
|
||||
|
||||
# TODO: Remove task before comitting
|
||||
desc "Run DNS unit tests"
|
||||
task :dns do
|
||||
Rake::Task['beef_start'].invoke
|
||||
sh "cd test/unit; ruby -W0 ts_unit_dns.rb"
|
||||
Rake::Task['beef_stop'].invoke
|
||||
end
|
||||
|
||||
desc "Run integration unit tests"
|
||||
task :unit => ["install"] do
|
||||
sh "cd test/unit;ruby -W0 ts_unit.rb"
|
||||
|
||||
20
test/integration/ts_dns_rest.rb
Normal file
20
test/integration/ts_dns_rest.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# Copyright (c) 2006-2013 Wade Alcorn - wade@bindshell.net
|
||||
# Browser Exploitation Framework (BeEF) - http://beefproject.com
|
||||
# See the file 'doc/COPYING' for copying permission
|
||||
#
|
||||
require '../common/ts_common'
|
||||
require './tc_dns_rest'
|
||||
|
||||
class TS_DnsIntegrationTests
|
||||
|
||||
def self.suite
|
||||
suite = Test::Unit::TestSuite.new(name="BeEF DNS Integration Test Suite")
|
||||
suite << TC_DnsRest.suite
|
||||
|
||||
return suite
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Test::Unit::UI::Console::TestRunner.run(TS_DnsIntegrationTests)
|
||||
@@ -4,16 +4,39 @@
|
||||
# See the file 'doc/COPYING' for copying permission
|
||||
#
|
||||
require 'test/unit'
|
||||
require 'resolv'
|
||||
|
||||
class TC_Dns < Test::Unit::TestCase
|
||||
|
||||
def setup
|
||||
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '.'))
|
||||
$root_dir = File.expand_path('../../../../', __FILE__)
|
||||
class << self
|
||||
|
||||
def startup
|
||||
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '../../../'))
|
||||
|
||||
require 'core/loader'
|
||||
require 'extensions/dns/extension'
|
||||
|
||||
config = BeEF::Core::Configuration.instance
|
||||
|
||||
@@address = config.get('beef.extension.dns.address')
|
||||
@@port = config.get('beef.extension.dns.port')
|
||||
|
||||
Thread.new do
|
||||
dns = BeEF::Extension::Dns::Server.instance
|
||||
dns.run_server(@@address, @@port)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def test_dns
|
||||
assert(true)
|
||||
def test_add_rule
|
||||
dns = BeEF::Extension::Dns::Server.instance
|
||||
|
||||
id = dns.add_rule('foo.bar', Resolv::DNS::Resource::IN::A) do |transaction|
|
||||
transaction.respond!('1.2.3.4')
|
||||
end
|
||||
|
||||
assert_not_nil(id)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
20
test/unit/ts_unit_dns.rb
Normal file
20
test/unit/ts_unit_dns.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# Copyright (c) 2006-2013 Wade Alcorn - wade@bindshell.net
|
||||
# Browser Exploitation Framework (BeEF) - http://beefproject.com
|
||||
# See the file 'doc/COPYING' for copying permission
|
||||
#
|
||||
require '../common/ts_common'
|
||||
require './extensions/tc_dns'
|
||||
|
||||
class TS_BeefDnsTests
|
||||
|
||||
def self.suite
|
||||
suite = Test::Unit::TestSuite.new(name="BeEF DNS Unit Tests")
|
||||
suite << TC_Dns.suite
|
||||
|
||||
return suite
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Test::Unit::UI::Console::TestRunner.run(TS_BeefDnsTests)
|
||||
Reference in New Issue
Block a user