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:
soh_cah_toa
2013-06-08 23:25:23 -04:00
parent 9e1ec69e40
commit d2ac9e0f7a
4 changed files with 84 additions and 5 deletions

View File

@@ -32,6 +32,22 @@ task :integration => ["install"] do
Rake::Task['beef_stop'].invoke Rake::Task['beef_stop'].invoke
end 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" desc "Run integration unit tests"
task :unit => ["install"] do task :unit => ["install"] do
sh "cd test/unit;ruby -W0 ts_unit.rb" sh "cd test/unit;ruby -W0 ts_unit.rb"

View 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)

View File

@@ -4,16 +4,39 @@
# See the file 'doc/COPYING' for copying permission # See the file 'doc/COPYING' for copying permission
# #
require 'test/unit' require 'test/unit'
require 'resolv'
class TC_Dns < Test::Unit::TestCase class TC_Dns < Test::Unit::TestCase
def setup class << self
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '.'))
$root_dir = File.expand_path('../../../../', __FILE__) 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 end
def test_dns def test_add_rule
assert(true) 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
end end

20
test/unit/ts_unit_dns.rb Normal file
View 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)