Parent

Class/Module Index [+]

Quicksearch

Rex::Socket::Comm::Local::UnitTest

Public Instance Methods

test_create_invalid() click to toggle source
# File lib/rex/socket/comm/local.rb.ut.rb, line 66
def test_create_invalid
        assert_raise(Rex::UnsupportedProtocol, "invalid protocol check failed") {
                Rex::Socket::Comm::Local.create(
                        Rex::Socket::Parameters.from_hash(
                                'Proto' => 'invalid'))
        }
end
test_create_tcp() click to toggle source
# File lib/rex/socket/comm/local.rb.ut.rb, line 11
def test_create_tcp
        test_port   = 64432
        test_server = TCPServer.new('127.0.0.1', test_port)

        # Create a stream connection to the stub listener
        stream = nil

        assert_nothing_raised {
                stream = Rex::Socket::Comm::Local.create(
                        Rex::Socket::Parameters.from_hash(
                                'PeerHost' => '127.0.0.1',
                                'PeerPort' => test_port,
                                'Proto'    => 'tcp'))
        }

        assert_kind_of(Rex::IO::Stream, stream, "valid Stream instance")
        assert_kind_of(Rex::Socket::Tcp, stream, "valid Tcp instance")
        stream.close

        # Now create a bare connection to the listener
        stream = nil

        assert_nothing_raised {
                stream = Rex::Socket::Comm::Local.create(
                        Rex::Socket::Parameters.from_hash(
                                'PeerHost' => '127.0.0.1',
                                'PeerPort' => test_port,
                                'Proto'    => 'tcp',
                                'Bare'     => true))
        }

        assert_kind_of(Socket, stream, "valid Socket instance")

        assert_raise(Rex::ConnectionRefused, "connection refused failed") {
                Rex::Socket::Comm::Local.create(
                        Rex::Socket::Parameters.from_hash(
                                'PeerHost' => '127.0.0.1',
                                'PeerPort' => 1,
                                'Proto'    => 'tcp',
                                'Bare'     => true))
        }

        stream.close

        test_server.close
end
test_create_tcp_server() click to toggle source
# File lib/rex/socket/comm/local.rb.ut.rb, line 58
def test_create_tcp_server
        # TODO
end
test_create_udp() click to toggle source
# File lib/rex/socket/comm/local.rb.ut.rb, line 62
def test_create_udp
        # TODO
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.