Began first integration tests for DNS RESTful API interface.

First test is for POST /api/dns/rule handler.
This commit is contained in:
soh_cah_toa
2013-06-06 23:16:40 -04:00
parent 6901581ae7
commit 1f37ceec9f
3 changed files with 53 additions and 1 deletions

View File

@@ -19,4 +19,5 @@ BEEF_PASSWD = "beef"
RESTAPI_HOOKS = "http://" + ATTACK_DOMAIN + ":3000/api/hooks"
RESTAPI_LOGS = "http://" + ATTACK_DOMAIN + ":3000/api/logs"
RESTAPI_MODULES = "http://" + ATTACK_DOMAIN + ":3000/api/modules"
RESTAPI_ADMIN = "http://" + ATTACK_DOMAIN + ":3000/api/admin"
RESTAPI_DNS = "http://" + ATTACK_DOMAIN + ":3000/api/dns"
RESTAPI_ADMIN = "http://" + ATTACK_DOMAIN + ":3000/api/admin"

View File

@@ -0,0 +1,49 @@
#
# 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 'test/unit'
require 'rest_client'
require 'json'
require '../common/test_constants'
class TC_DnsRest < Test::Unit::TestCase
class << self
def startup
json = {:username => BEEF_USER, :password => BEEF_PASSWD}.to_json
@@headers = {:content_type => :json, :accept => :json}
response = RestClient.post("#{RESTAPI_ADMIN}/login",
json,
@@headers)
result = JSON.parse(response.body)
@@token = result['token']
end
end
def test_1_add_rule
pattern = 'foo.bar'
type = 'A'
dns_response = ['1.2.3.4']
json = {:pattern => pattern, :type => type, :response => dns_response}.to_json
rest_response = RestClient.post("#{RESTAPI_DNS}/rule?token=#{@@token}",
json,
@@headers)
assert_not_nil(rest_response.body)
assert_equal(200, rest_response.code)
result = JSON.parse(rest_response.body)
assert(result['success'])
assert(result['id'])
end
end

View File

@@ -16,6 +16,7 @@ require './check_environment' # Basic log in and log out tests
require './tc_debug_modules' # RESTful API tests (as well as debug modules)
require './tc_login' # Basic log in and log out tests
require './tc_jools' # Basic tests for jools
require './tc_dns_rest' # Basic tests for DNS RESTful API interface
class TS_BeefIntegrationTests
def self.suite
@@ -25,6 +26,7 @@ class TS_BeefIntegrationTests
suite << TC_login.suite
suite << TC_DebugModules.suite
suite << TC_Jools.suite
suite << TC_DnsRest.suite
return suite
end