Sha256: 5f0bf9092d54e0de7e649172156cff094755bcfecd683f3cc95025270cdca932

Contents?: true

Size: 1.51 KB

Versions: 43

Compression:

Stored size: 1.51 KB

Contents

#!/usr/bin/env ruby

$:.unshift(File.join(File.dirname(__FILE__), '..', '..'))

require 'test/unit'
require 'rex/socket/parameters'

class Rex::Socket::Parameters::UnitTest < Test::Unit::TestCase

	def test_parameters
		h = { 
				'PeerHost'  => 'phost',
				'PeerPort'  => 12,
				'LocalHost' => 'lhost',
				'LocalPort' => 47,
				'Bare'      => true,
				'Server'    => true,
				'Comm'      => 'nothing',
				'Proto'     => 'tcp',
				'SSL'       => true
		    }

		p = Rex::Socket::Parameters.from_hash(h)

		assert_equal('phost', p.peerhost, "peerhost")
		assert_equal('phost', p.peeraddr, "peeraddr")
		assert_equal(12, p.peerport, "peerport")
		assert_equal('lhost', p.localhost, "localhost")
		assert_equal('lhost', p.localaddr, "localaddr")
		assert_equal(47, p.localport, "localport")
		assert_equal(true, p.bare?, "bare")
		assert_equal(true, p.server?, "server")
		assert_equal(false, p.client?, "client")
		assert_equal('nothing', p.comm, "comm")
		assert_equal(true, p.tcp?, "proto tcp")
		assert_equal(false, p.udp?, "proto udp")
		assert_equal(true, p.ssl, "ssl")

		p = Rex::Socket::Parameters.from_hash({})

		assert_equal(nil, p.peerhost, "null peerhost")
		assert_equal('0.0.0.0', p.localhost, "default localhost")
		assert_equal(0, p.peerport, "0 peerport")
		assert_equal(0, p.localport, "0 localport")
		assert_equal(false, p.bare, "default false bare")
		assert_equal('tcp', p.proto, "default tcp proto")
		assert_equal(false, p.server, "default false server")
		assert_equal(false, p.ssl, "default false ssl")
	end

end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
librex-0.0.65 lib/rex/socket/parameters.rb.ut.rb
librex-0.0.63 lib/rex/socket/parameters.rb.ut.rb
librex-0.0.54 lib/rex/socket/parameters.rb.ut.rb
librex-0.0.53 lib/rex/socket/parameters.rb.ut.rb
librex-0.0.52 lib/rex/socket/parameters.rb.ut.rb
librex-0.0.51 lib/rex/socket/parameters.rb.ut.rb
librex-0.0.50 lib/rex/socket/parameters.rb.ut.rb
librex-0.0.49 lib/rex/socket/parameters.rb.ut.rb
librex-0.0.48 lib/rex/socket/parameters.rb.ut.rb
librex-0.0.47 lib/rex/socket/parameters.rb.ut.rb
librex-0.0.46 lib/rex/socket/parameters.rb.ut.rb
librex-0.0.44 lib/rex/socket/parameters.rb.ut.rb
librex-0.0.43 lib/rex/socket/parameters.rb.ut.rb
librex-0.0.42 lib/rex/socket/parameters.rb.ut.rb
librex-0.0.41 lib/rex/socket/parameters.rb.ut.rb
librex-0.0.40 lib/rex/socket/parameters.rb.ut.rb
librex-0.0.39 lib/rex/socket/parameters.rb.ut.rb
librex-0.0.38 lib/rex/socket/parameters.rb.ut.rb
librex-0.0.37 lib/rex/socket/parameters.rb.ut.rb
librex-0.0.36 lib/rex/socket/parameters.rb.ut.rb