Added keyword to get the rloc object pointed to by hop_index.
[integration/test.git] / csit / libraries / LISPFlowMapping.robot
index b721f956bfcc8ff0af02859f4b54095c6a0db4f9..79571cc7d713a78778b5f9bc7885ed3c7637ce0a 100644 (file)
@@ -5,31 +5,52 @@ Documentation     This resource file defines keywords that are used in more
 ...               variables are coming from.
 
 *** Variables ***
-${ODL_VERSION}    Be
+${JSON_DIR}       ${CURDIR}/../variables/lispflowmapping/Be
 
 *** Keywords ***
-Check Mapping Removal
-    [Arguments]    ${json}
-    Run Keyword If    "${ODL_VERSION}" == "Li"    Check Mapping Removal Lithium    ${json}    ELSE    Post Log Check    ${LFM_RPC_API}:get-mapping
-    ...    ${json}    404
+Authentication Key Should Be
+    [Arguments]    ${resp}    ${password}
+    [Documentation]    Check if the authentication key in the ${resp} is ${password}
+    ${authkey}=    Get Authentication Key    ${resp}
+    Should Be Equal As Strings    ${authkey}    ${password}
 
-Check Mapping Removal Lithium
-    [Arguments]    ${json}
-    ${resp}=    Post Log Check    ${LFM_RPC_API}:get-mapping    ${json}
+Get Authentication Key
+    [Arguments]    ${resp}
+    ${output}=    Get From Dictionary    ${resp.json()}    output
+    ${mapping_authkey}=    Get From Dictionary    ${output}    mapping-authkey
+    ${authkey}=    Get From Dictionary    ${mapping_authkey}    key-string
+    [Return]    ${authkey}
+
+Ipv4 Rloc Should Be
+    [Arguments]    ${resp}    ${address}
+    [Documentation]    Check if the RLOC in the ${resp} is ${address}
+    ${eid_record}=    Get Eid Record    ${resp}
+    ${loc_record}=    Get From Dictionary    ${eid_record}    LocatorRecord
+    ${loc_record_0}=    Get From List    ${loc_record}    0
+    ${ipv4}=    Get Ipv4 Rloc    ${loc_record_0}
+    Should Be Equal As Strings    ${ipv4}    ${address}
+
+Get Eid Record
+    [Arguments]    ${resp}
     ${output}=    Get From Dictionary    ${resp.json()}    output
-    ${eid_record}=    Get From Dictionary    ${output}    eidToLocatorRecord
-    ${eid_record_0}=    Get From List    ${eid_record}    0
-    ${action}=    Get From Dictionary    ${eid_record_0}    action
-    Should Be Equal As Strings    ${action}    NativelyForward
-
-Post Log Check
-    [Arguments]    ${uri}    ${body}    ${status_code}=200
-    [Documentation]    Post body to uri, log response content, and check status
-    ${resp}=    RequestsLibrary.Post    session    ${uri}    ${body}
-    Log    ${resp.content}
-    Should Be Equal As Strings    ${resp.status_code}    ${status_code}
-    [Return]    ${resp}
-
-Create Session And Set External Variables
-    Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
-    Run Keyword If    "${ODL_VERSION}" == "Li"    Set Suite Variable    ${LFM_RPC_API}    ${LFM_RPC_API_LI}
+    ${eid_record}=    Get From Dictionary    ${output}    mapping-record
+    [Return]    ${eid_record}
+
+Get Ipv4 Rloc
+    [Arguments]    ${loc_record}
+    ${loc}=    Get From Dictionary    ${loc_record}    rloc
+    ${ipv4}=    Get From Dictionary    ${loc}    ipv4
+    [Return]    ${ipv4}
+
+Get Elp Hop
+    [Arguments]    ${loc_record}    ${hop_index}
+    [Documentation]    Returns the Rloc object pointed to by ${hop_index}
+    ${rloc}=    Get From Dictionary    ${loc_record}    rloc
+    ${exp_loc_path}=    Get From Dictionary    ${rloc}    explicit-locator-path
+    ${actual_hop_index}=    Evaluate    ${hop_index} - 1
+    ${hop}=    Get From List    ${exp_loc_path}     ${actual_hop_index}
+    [Return]    ${hop}
+
+Check Mapping Removal
+    [Arguments]    ${json}
+    Post Log Check    ${LFM_RPC_API}:get-mapping    ${json}    404