Sha256: 1605f24223e1b85b87439367a40eadc32de48f2e569f7e93c3ead8bf7c35bd33
Contents?: true
Size: 1.71 KB
Versions: 2
Compression:
Stored size: 1.71 KB
Contents
#!/usr/bin/env ruby # -*- coding: binary -*- $:.unshift(File.join(File.dirname(__FILE__), '..', '..', '..')) require 'test/unit' require 'rex/exceptions' require 'rex/socket/parameters' require 'rex/socket/comm/local' class Rex::Socket::Comm::Local::UnitTest < Test::Unit::TestCase 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 def test_create_tcp_server # TODO end def test_create_udp # TODO end 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 end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
librex-0.0.68 | lib/rex/socket/comm/local.rb.ut.rb |
librex-0.0.66 | lib/rex/socket/comm/local.rb.ut.rb |