Add core/extensions test cases

This commit is contained in:
Brendan Coles
2016-04-22 02:51:06 +00:00
parent 0d11678ed0
commit 8139488482
2 changed files with 51 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
#
# Copyright (c) 2006-2016 Wade Alcorn - wade@bindshell.net
# Browser Exploitation Framework (BeEF) - http://beefproject.com
# See the file 'doc/COPYING' for copying permission
#
require 'test/unit'
class TC_Extensions < Test::Unit::TestCase
def setup
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '.'))
$root_dir = File.expand_path('../../../../', __FILE__)
end
#
# Test that extensions are loading properly
#
def test_extensions
assert_nothing_raised do
BeEF::Extensions.load
end
enabled_extensions = BeEF::Core::Configuration.instance.get('beef.extension').select {|k,v|
v['enable'] == true
}
enabled_extensions.each do |k,v|
assert(v.has_key?('name'))
assert(v.has_key?('enable'))
assert(v.has_key?('loaded'))
end
enabled_extensions.each do |k,v|
assert(v['loaded'], 'Extension is enabled but was not loaded')
end
end
def test_safe_client_debug_log
Dir['../../extensions/**/*.js'].each do |path|
next if /extensions\/admin_ui/.match(path) # skip this file
File.open(path) do |f|
f.grep(/\W*console\.log\W*\(/im) do |line|
assert(false, "Function 'console.log' used instead of 'beef.debug' in command module: " + path + ':' + line)
end
end
end
end
end

View File

@@ -16,6 +16,7 @@ require './core/tc_core'
require './core/tc_api'
require './core/tc_bootstrap'
require './core/tc_modules'
require './core/tc_extensions'
require './core/tc_social_engineering'
require './core/tc_autorun'
require './core/tc_obfuscation'
@@ -44,6 +45,7 @@ class TS_BeefTests
suite << TC_Bootstrap.suite
suite << TC_Api.suite
suite << TC_Modules.suite
suite << TC_Extensions.suite
suite << TC_Filesystem.suite
suite << TC_Grep.suite
suite << TC_SocialEngineering.suite