Class: Rex::Post::Meterpreter::Extensions::Stdapi::Railgun::DLLWrapper::UnitTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
MockMagic
Defined in:
lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_wrapper.rb.ut.rb

Constant Summary

Constants included from MockMagic

MockMagic::TLV_TYPE_NAMES

Instance Method Summary collapse

Methods included from MockMagic

#make_mock_client, #mock_function_descriptions

Instance Method Details

#test_functionsObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_wrapper.rb.ut.rb', line 21

def test_functions
	mock_function_descriptions.each do |func|
		client = make_mock_client(func[:platform], func[:request_to_client], func[:response_from_client])
		dll = DLL.new(func[:dll_name], client)

		dll_wrapper = DLLWrapper.new(dll, client)

		# This represents how people check if a function doesn't exist
		assert(!dll_wrapper.functions[func[:name]], 'Function non-existence can be chucked via .functions')

		dll.add_function(func[:name], func[:return_type], func[:params])

		# This represents how people check if a function exist
		assert(dll_wrapper.functions[func[:name]], 'Function existence can be chucked via .functions')

		actual_returned_hash = dll_wrapper.send(:method_missing, func[:name].to_sym, *func[:ruby_args])

		assert_equal(func[:returned_hash], actual_returned_hash,
			"method_missing should result in a successful call to specified function")
	end
end

#test_method_missingObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/dll_wrapper.rb.ut.rb', line 43

def test_method_missing
	mock_function_descriptions.each do |func|
		client = make_mock_client(func[:platform], func[:request_to_client], func[:response_from_client])
		dll = DLL.new(func[:dll_name], client)

		dll.add_function(func[:name], func[:return_type], func[:params])

		dll_wrapper = DLLWrapper.new(dll, client)

		actual_returned_hash = dll_wrapper.send(:method_missing, func[:name].to_sym, *func[:ruby_args])

		assert_equal(func[:returned_hash], actual_returned_hash,
			"method_missing should result in a successful call to specified function")
	end
end