Exemplo n.º 1
0
    def test_init(self):
        new_netflow = _New_Netflow_v9(self.sample, self.count)
        eq_(new_netflow.data, self.sample)
        eq_(new_netflow.count, self.count)
        eq_(new_netflow._raw_data, '')
        eq_(new_netflow.length, list())
        eq_(new_netflow.flowset_id, list())  #lsit of flowset id
        eq_(new_netflow.template_header_list,
            list())  #contains flowset_id and length
        eq_(new_netflow.flow_data_list, list())  #contains raw data
        eq_(new_netflow.template_template_list,
            list())  #contains template_id and field count
        eq_(new_netflow.data_header_list,
            list())  #contains template_id and length of the data
        eq_(new_netflow.template_data_dict,
            dict())  #contains templateflow data as template_id:data
        eq_(new_netflow.data_data_dict,
            list())  #contains dataflow data as template_id:data
        eq_(new_netflow.unparsed_raw_data, list())
        eq_(new_netflow.now, int(time.time()))

        assert_not_equal(new_netflow.data, sample_v5)
        assert_not_equal(new_netflow.count, 1)
        assert_not_equal(new_netflow.unparsed_raw_data, sample_v9)
        assert_not_equal(new_netflow.now, int(time.time()) - 1)
Exemplo n.º 2
0
    def test_get_flowset_id_length_data(self):
        new_netflow = _New_Netflow_v9(self.sample, self.count)
        eq_(new_netflow.get_flowset_id_length_data(self.sample, self.count),
            None, "test get flowset id")
        eq_(new_netflow.length, [[80, 56]])
        eq_(new_netflow.flowset_id, [0, 300], "test get flowset id")
        eq_(new_netflow.template_header_list, [(0, 80), (300, 56)])
        eq_(new_netflow.flow_data_list, [
            '\x00\x00\x00P\x01,\x00\x12\x00\x08\x00\x04\x00\x0c\x00\x04\x00\x0f\x00\x04\x00\n\x00\x04\x00\x0e\x00\x04\x00\x02\x00\x04\x00\x01\x00\x04\x00\x07\x00\x02\x00\x0b\x00\x02\x00\x06\x00\x01\x00\x04\x00\x01\x00\x05\x00\x01\x00\x11\x00\x02\x00\x10\x00\x02\x00\t\x00\x01\x00\r\x00\x01\x00\x15\x00\x04\x00\x16\x00\x04',
            '\x01,\x008\n\x00\x00\x02\n\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x05\x00\x00\x00\x01\x00\x00\x00@\x10\x92\x00P\x00\x11\x01\x00\x03\x00\x02 \x1f\x01\xbc\x90G\x01\xbb\xa5\xe7\x00\x00\x00'
        ])

        assert_not_equal(new_netflow.length, list())
        assert_not_equal(new_netflow.flowset_id, list())
Exemplo n.º 3
0
    def test_clean_unparsed_raw_data(self):
        new_netflow = _New_Netflow_v9(self.sample, self.count)
        eq_(new_netflow.get_flowset_id_length_data(self.sample, self.count),
            None, "test get flowset id")
        eq_(
            new_netflow.get_raw_template_dict_raw_data_dict(
                sid, netflow_out, device_name, col_type, ip, collected_at),
            None, "test update template data list")
        eq_(new_netflow.update_template_data_list_dict(), None,
            "test update template data list")

        eq_(new_netflow.unparsed_raw_data, list())

        assert_not_equal(new_netflow.flowset_id, list(self.sample))
        assert_not_equal(new_netflow.flowset_id, dict())
Exemplo n.º 4
0
    def test_get_raw_template_dict_raw_data_dict(self):
        new_netflow = _New_Netflow_v9(self.sample, self.count)
        eq_(new_netflow.get_flowset_id_length_data(self.sample, self.count),
            None, "test get flowset id")
        eq_(
            new_netflow.get_raw_template_dict_raw_data_dict(
                sid, netflow_out, device_name, col_type, ip, collected_at),
            None, "get_raw_data")
        eq_(new_netflow.template_template_list, [(300, 18)])

        expected_data_header_list = [(
            300, 56,
            '\n\x00\x00\x02\n\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x05\x00\x00\x00\x01\x00\x00\x00@\x10\x92\x00P\x00\x11\x01\x00\x03\x00\x02 \x1f\x01\xbc\x90G\x01\xbb\xa5\xe7\x00\x00\x00'
        )]
        eq_(new_netflow.data_header_list, expected_data_header_list)

        assert_not_equal(new_netflow.template_template_list, dict())
        assert_not_equal(new_netflow.template_template_list, list())
        assert_not_equal(new_netflow.template_template_list, list((300, 0)))