def testTransformWithoutFilters(self): filter = TrapFilter() filter._filtersDefined = False event = { "snmpVersion": "1", "snmpV1GenericTrapType": 6, "snmpV1Enterprise": "1.2.3", "snmpV1SpecificTrap": 59 } self.assertEquals(TRANSFORM_CONTINUE, filter.transform(event)) event = { "snmpVersion": "2", "oid": "1.2.3", } self.assertEquals(TRANSFORM_CONTINUE, filter.transform(event))
def testTransformWithoutFilters(self): filter = TrapFilter() filter._filtersDefined = False event = { "snmpVersion": "1", "snmpV1GenericTrapType": 6, "snmpV1Enterprise": "1.2.3", "snmpV1SpecificTrap": 59 } self.assertEquals(TRANSFORM_CONTINUE, filter.transform(event)) event = { "snmpVersion": "2", "oid": "1.2.3", } self.assertEquals(TRANSFORM_CONTINUE, filter.transform(event))
def testTransformDropsV2Event(self): filterDef = V2FilterDefinition(99, "exclude", "1.2.3") filtersByLevel = {filterDef.oid: filterDef} filter = TrapFilter() filter._v2Filters[3] = filtersByLevel filter._filtersDefined = True event = { "snmpVersion": "2", "oid": filterDef.oid, } self.assertEquals(TRANSFORM_DROP, filter.transform(event))
def testTransformDropsV2Event(self): filterDef = V2FilterDefinition(99, "exclude", "1.2.3") filtersByLevel = {filterDef.oid: filterDef} filter = TrapFilter() filter._v2Filters[3] = filtersByLevel filter._filtersDefined = True event = { "snmpVersion": "2", "oid": filterDef.oid, } self.assertEquals(TRANSFORM_DROP, filter.transform(event))
def testTransformDropsV1Event(self): filterDef = V1FilterDefinition(99, "exclude", "1.2.3") filterDef.specificTrap = "59" filtersByLevel = {"1.2.3-59": filterDef} filter = TrapFilter() filter._v1Filters[3] = filtersByLevel filter._filtersDefined = True event = { "snmpVersion": "1", "snmpV1GenericTrapType": 6, "snmpV1Enterprise": filterDef.oid, "snmpV1SpecificTrap": filterDef.specificTrap } self.assertEquals(TRANSFORM_DROP, filter.transform(event))
def testTransformDropsV1Event(self): filterDef = V1FilterDefinition(99, "exclude", "1.2.3") filterDef.specificTrap = "59" filtersByLevel = {"1.2.3-59": filterDef} filter = TrapFilter() filter._v1Filters[3] = filtersByLevel filter._filtersDefined = True event = { "snmpVersion": "1", "snmpV1GenericTrapType": 6, "snmpV1Enterprise": filterDef.oid, "snmpV1SpecificTrap": filterDef.specificTrap } self.assertEquals(TRANSFORM_DROP, filter.transform(event))