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

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
MockMagic
Defined in:
lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.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_add_functionObject



20
21
22
23
24
25
26
27
28
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.rb.ut.rb', line 20

def test_add_function
  mock_function_descriptions.each do |func|
    dll = DLL.new(func[:dll_name], nil)
    dll.add_function(func[:name], func[:return_type], func[:params])

    assert(dll.functions.has_key?(func[:name]),
      "add_function should expand the list of available functions")
  end
end

#test_call_functionObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/dll.rb.ut.rb', line 30

def test_call_function
  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], nil)

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

    actual_returned_hash = dll.call_function(func[:name].to_sym, func[:ruby_args], client)

    assert(func[:returned_hash].has_key?('GetLastError'),
      "process_function_call should add the result of GetLastError to the key GetLastError")

    assert_equal(func[:returned_hash], actual_returned_hash,
      "process_function_call convert function result to a ruby hash")
  end
end