Files
beef/test/unit/core/tc_modules.rb
Wade Alcorn 9ee9bf6c2b Fixed typo
2012-01-20 21:13:07 +10:00

62 lines
2.2 KiB
Ruby

#
# Copyright 2012 Wade Alcorn wade@bindshell.net
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
require 'test/unit'
class TC_Modules < Test::Unit::TestCase
def setup
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '.'))
$root_dir = File.expand_path('../../../../', __FILE__)
end
#
# Test that modules are loading properly
#
def test_modules
assert_nothing_raised do
BeEF::Modules.load
end
BeEF::Core::Configuration.instance.get('beef.module').select {|k,v| v['enable'] == true and v['category'] != nil }.each { |k,v|
assert((BeEF::Module.is_present(k)),"#{k} is not present in config - buh?")
}
BeEF::Core::Configuration.instance.get('beef.module').select {|k,v| v['enable'] == true and v['category'] != nil }.each { |k,v|
assert((BeEF::Module.is_enabled(k)),"#{k} is not enabled in config - ruhhh?")
}
assert_nothing_raised do
BeEF::Core::Configuration.instance.get('beef.module').select {|k,v| v['enable'] == true and v['category'] != nil }.each { |k,v|
BeEF::Module.hard_load(k)
}
end
BeEF::Core::Configuration.instance.get('beef.module').select {|k,v| v['enable'] == true and v['category'] != nil }.each { |k,v|
assert((BeEF::Module.is_loaded(k)), "#{k} is not loaded - even though it should be - rut roh?")
}
BeEF::Core::Configuration.instance.get('beef.module').select {|k,v| v['enable'] == true and v['category'] != nil }.each { |k,v|
BeEF::Core::Configuration.instance.get('beef.module.'+k+'.target').each { |t,tt|
if tt.class == Array
assert_not_equal(tt.length,0,"#{k} does not have valid TARGET configuration")
end
}
}
end
end