[ 
https://issues.apache.org/jira/browse/NIFI-12406?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Giuseppe Gerla updated NIFI-12406:
----------------------------------
    Summary: SNMP processors shall manage INFORM message as traps  (was: SNMP 
processors doesn't manage INFORM message as traps)

> SNMP processors shall manage INFORM message as traps
> ----------------------------------------------------
>
>                 Key: NIFI-12406
>                 URL: https://issues.apache.org/jira/browse/NIFI-12406
>             Project: Apache NiFi
>          Issue Type: Improvement
>          Components: Extensions
>    Affects Versions: 1.16.3
>            Reporter: Giuseppe Gerla
>            Priority: Major
>              Labels: SNMP
>
> Traps and informs are mainly the same; notifications sent from a SNMP agent 
> to a SNMP manager. The only difference is that an inform requests a response 
> from the manager.
>  
> They are “unacknowledged notification-type PDU” and “acknowledged 
> notification-type PDUs” respectively.
> ([https://www.ietf.org/rfc/rfc3413.txt])
> ([https://www.ietf.org/rfc/rfc3412.txt])
>  
> So the isValidTrapPdu should be
>  
> private boolean isValidTrapPdu{*}({*}final PDU pdu{*}){*} *{*
>         *return* pdu *!=* *null* *&&* {*}({*}pdu{*}.{*}getType{*}(){*} *==* 
> PDU{*}.{*}V1TRAP *||* pdu{*}.{*}getType{*}(){*} *==* PDU{*}.{*}TRAP *||* 
> {*}pdu{*}{*}.{*}{*}getType{*}{*}(){*} * ** == ** 
> PDU{*}{{*}}.{*}{{*}}INFORM{*}{{*}});\{*}
>     *}*
>  
> and to test it
>  
> @Test
>     void testTrapReceiverCreatesInforPduV2FlowFile{*}(){*} *{*
>         final CommandResponderEvent mockEvent *=* 
> mock{*}({*}CommandResponderEvent{*}.{*}class{*});{*}
>  
>         
> when{*}({*}mockPdu{*}.{*}getType{*}()).{*}thenReturn{*}({*}PDU{*}.{*}INFORM{*});{*}
>         
> when{*}({*}mockPdu{*}.{*}getErrorIndex{*}()).{*}thenReturn{*}({*}123{*});{*}
>         
> when{*}({*}mockPdu{*}.{*}getErrorStatusText{*}()).{*}thenReturn{*}({*}"test 
> error status text"{*});{*}
>         final Vector{*}<{*}VariableBinding{*}>{*} vbs *=* *new* 
> Vector{*}<>();{*}
>         
> doReturn{*}({*}vbs{*}).{*}when{*}({*}mockPdu{*}).{*}getVariableBindings{*}();{*}
>         
> when{*}({*}mockEvent{*}.{*}getPDU{*}()).{*}thenReturn{*}({*}mockPdu{*});{*}
>         
> when{*}({*}mockProcessSessionFactory{*}.{*}createSession{*}()).{*}thenReturn{*}({*}mockProcessSession{*});{*}
>  
>         snmpTrapReceiver{*}.{*}processPdu{*}({*}mockEvent{*});{*}
>  
>         final List{*}<{*}MockFlowFile{*}>{*} flowFiles *=* 
> mockProcessSession{*}.{*}getFlowFilesForRelationship{*}({*}AmsSnmpTrapListener{*}.{*}REL_SUCCESS{*});{*}
>         final FlowFile flowFile *=* flowFiles{*}.{*}get{*}({*}0{*});{*}
>  
>         assertEquals{*}({*}String{*}.{*}valueOf{*}({*}123{*}),{*} 
> flowFile{*}.{*}getAttribute{*}({*}"snmp$errorIndex"{*}));{*}
>         assertEquals{*}({*}"test error status text"{*},{*} 
> flowFile{*}.{*}getAttribute{*}({*}"snmp$errorStatusText"{*}));{*}
>     *}*



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to