Class: Mu::Xtractr::Host::Test
- Inherits:
-
Test::Unit::TestCase
- Object
- Test::Unit::TestCase
- Mu::Xtractr::Host::Test
- Defined in:
- lib/mu/xtractr/test/tc_host.rb
Instance Attribute Summary collapse
-
#xtractr ⇒ Object
readonly
Returns the value of attribute xtractr.
Instance Method Summary collapse
- #setup ⇒ Object
- #test_clients ⇒ Object
- #test_flows ⇒ Object
- #test_inspect ⇒ Object
- #test_packets ⇒ Object
- #test_servers ⇒ Object
- #test_services ⇒ Object
Instance Attribute Details
#xtractr ⇒ Object (readonly)
Returns the value of attribute xtractr.
22 23 24 |
# File 'lib/mu/xtractr/test/tc_host.rb', line 22 def xtractr @xtractr end |
Instance Method Details
#setup ⇒ Object
24 25 26 |
# File 'lib/mu/xtractr/test/tc_host.rb', line 24 def setup @xtractr = Xtractr.new end |
#test_clients ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/mu/xtractr/test/tc_host.rb', line 28 def test_clients host = xtractr.host('192.168.1.10') assert_equal(true, host.clients.empty?) host = xtractr.host('8.18.65.32') assert_equal(1, host.clients.size) assert_equal('192.168.1.10', host.clients[0].value) end |
#test_flows ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/mu/xtractr/test/tc_host.rb', line 76 def test_flows host = xtractr.host('192.168.1.10') flows = host.flows assert_equal("flow.src|flow.dst:\"192.168.1.10\"", flows.q) flows = host.flows :any assert_equal("flow.src|flow.dst:\"192.168.1.10\"", flows.q) flows = host.flows :client assert_equal("flow.src:\"192.168.1.10\"", flows.q) flows = host.flows :server assert_equal("flow.dst:\"192.168.1.10\"", flows.q) assert_raise(ArgumentError) { host.flows :blah } end |
#test_inspect ⇒ Object
110 111 112 |
# File 'lib/mu/xtractr/test/tc_host.rb', line 110 def test_inspect assert_nothing_raised { xtractr.hosts.first.inspect } end |
#test_packets ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/mu/xtractr/test/tc_host.rb', line 93 def test_packets host = xtractr.host('192.168.1.10') packets = host.packets assert_equal("pkt.src|pkt.dst:\"192.168.1.10\"", packets.q) packets = host.packets :any assert_equal("pkt.src|pkt.dst:\"192.168.1.10\"", packets.q) packets = host.packets :client assert_equal("pkt.src:\"192.168.1.10\"", packets.q) packets = host.packets :server assert_equal("pkt.dst:\"192.168.1.10\"", packets.q) assert_raise(ArgumentError) { host.packets :blah } end |
#test_servers ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/mu/xtractr/test/tc_host.rb', line 37 def test_servers host = xtractr.host('8.18.65.32') assert_equal(true, host.servers.empty?) host = xtractr.host('192.168.1.10') assert_equal(11, host.servers.size) assert_equal('4.2.2.1', host.servers[0].value) end |
#test_services ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/mu/xtractr/test/tc_host.rb', line 46 def test_services host = xtractr.host('192.168.1.10') services = host.services assert_equal(3, services.size) assert_equal('HTTP', services[0].value) assert_equal('DNS', services[1].value) assert_equal('MDNS', services[2].value) services = host.services :client assert_equal(3, services.size) assert_equal('HTTP', services[0].value) assert_equal('DNS', services[1].value) assert_equal('MDNS', services[2].value) services = host.services :server assert_equal(true, services.empty?) host = xtractr.host('4.2.2.1') services = host.services assert_equal(1, services.size) assert_equal('DNS', services[0].value) services = host.services :client assert_equal(true, services.empty?) services = host.services :server assert_equal(1, services.size) assert_equal('DNS', services[0].value) end |