Class: Mu::Xtractr::Flow::Test

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/mu/xtractr/test/tc_flow.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#xtractrObject (readonly)

Returns the value of attribute xtractr.



22
23
24
# File 'lib/mu/xtractr/test/tc_flow.rb', line 22

def xtractr
  @xtractr
end

Instance Method Details

#setupObject



24
25
26
# File 'lib/mu/xtractr/test/tc_flow.rb', line 24

def setup
    @xtractr = Xtractr.new
end

#test_attributesObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/mu/xtractr/test/tc_flow.rb', line 32

def test_attributes
    flow = xtractr.flows('flow.service:HTTP').first
    assert_equal(2, flow.id)
    assert_equal(0.264773, flow.time)
    assert_equal(30.2019, flow.duration)
    assert_kind_of(Host, flow.src)
    assert_equal('192.168.1.10', flow.src.address)
    assert_kind_of(Host, flow.dst)
    assert_equal('8.18.65.67', flow.dst.address)
    assert_equal(6, flow.proto)
    assert_equal(49163, flow.sport)
    assert_equal(80, flow.dport)
    assert_kind_of(Service, flow.service)
    assert_equal('HTTP', flow.service.name)
    assert_equal('GET /WebObjects/MZStore.woa/wa/viewGrouping?id=39 HTTP/1.1 ', flow.title)
    assert_equal(28, flow.packets)
    assert_equal(19791, flow.bytes)
    assert_equal(1, flow.cmsgs)
    assert_equal(1, flow.smsgs)
    assert_equal(3, flow.instance_variable_get(:@first_id))
    assert_equal(300, flow.instance_variable_get(:@last_id))
    assert_kind_of(Packet, flow.first)
    assert_equal(3, flow.first.id)
    assert_kind_of(Packet, flow.last)
    assert_equal(300, flow.last.id)
end

#test_contentsObject



67
68
69
70
71
# File 'lib/mu/xtractr/test/tc_flow.rb', line 67

def test_contents
    flow = xtractr.flows('flow.service:HTTP').first
    contents = flow.contents
    assert_equal(1, contents.size)
end

#test_eachObject



59
60
61
62
63
64
65
# File 'lib/mu/xtractr/test/tc_flow.rb', line 59

def test_each
    flow = xtractr.flows('flow.service:HTTP').first
    v = flow.each { |pkt| assert_kind_of(Packet, pkt) }
    assert_equal(flow, v)
    v = flow.each_packet { |pkt| assert_kind_of(Packet, pkt) }
    assert_equal(flow, v)
end

#test_FlowObject



28
29
30
# File 'lib/mu/xtractr/test/tc_flow.rb', line 28

def test_Flow
    assert(Flow.ancestors.include?(Enumerable), "Flow doesn't mixin Enumerable")
end

#test_inspectObject



73
74
75
# File 'lib/mu/xtractr/test/tc_flow.rb', line 73

def test_inspect
    assert_nothing_raised { xtractr.flows.inspect }
end