From 3ef47151b57d1b7f0f332bcfca4a0ffc37444972 Mon Sep 17 00:00:00 2001 From: Brendan Coles Date: Wed, 9 Sep 2015 18:50:50 +0000 Subject: [PATCH] Add XssRays unit test stub - Fix #578 --- test/unit/extensions/tc_xssrays.rb | 44 ++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/test/unit/extensions/tc_xssrays.rb b/test/unit/extensions/tc_xssrays.rb index 1cc134059e..0e88524026 100644 --- a/test/unit/extensions/tc_xssrays.rb +++ b/test/unit/extensions/tc_xssrays.rb @@ -7,13 +7,47 @@ class TC_XssRays < Test::Unit::TestCase - def setup - $:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '.')) - $root_dir = File.expand_path('../../../../', __FILE__) + class << self + + def startup + $root_dir = '../../' + $:.unshift(File.expand_path($root_dir)) + + # load extension + require 'extensions/xssrays/extension' + + # load config + BeEF::Core::Configuration.new(File.join($root_dir, 'config.yaml')) + config = BeEF::Core::Configuration.instance + config.load_extensions_config + @@xssrays_config = config.get('beef.extension.xssrays') + end + + def shutdown + $root_dir = nil + end + + end + + # Connects to in-memory database (does not test anything) + def test_01_database + DataMapper.setup(:default, 'sqlite3::memory:') + DataMapper.auto_migrate! + end + + # Checks for required settings in config file + def test_02_config + assert(@@xssrays_config.has_key?('enable')) + assert(@@xssrays_config.has_key?('clean_timeout')) + assert(@@xssrays_config.has_key?('cross_domain')) + assert(@@xssrays_config.has_key?('js_console_logs')) end - def test_xssrays - assert(true) + # Verifies public interface + def test_03_interface + @@xssrays = BeEF::Extension::Xssrays::API::Scan.new + assert_respond_to(@@xssrays, :start_scan) + assert_respond_to(@@xssrays, :add_to_body) end end