Use RFC8040 URL for JSON-RPC tests
[integration/test.git] / csit / libraries / LISPFlowMapping.robot
index 6ee0ab481267064e2e92db592327156419d34d21..1eee8412b95350b8c14c0ca0a917dbf00b15f21b 100644 (file)
@@ -3,9 +3,10 @@ Documentation     This resource file defines keywords that are used in more
 ...               than one lispflowmapping test suite. Those suites include
 ...               ../variables/Variables.py, which is where some of the
 ...               variables are coming from.
+Library           JsonGenerator.py
 
 *** Variables ***
-${ODL_VERSION}    Be
+${JSON_DIR}       ${CURDIR}/../variables/lispflowmapping/Be
 
 *** Keywords ***
 Authentication Key Should Be
@@ -17,21 +18,10 @@ Authentication Key Should Be
 Get Authentication Key
     [Arguments]    ${resp}
     ${output}=    Get From Dictionary    ${resp.json()}    output
-    ${authkey}=    Run Keyword If    "${ODL_VERSION}" == "Li"    Get Authentication Key Lithium    ${output}
-    ...    ELSE    Get Authentication Key Beryllium    ${output}
-    [Return]    ${authkey}
-
-Get Authentication Key Beryllium
-    [Arguments]    ${output}
     ${mapping_authkey}=    Get From Dictionary    ${output}    mapping-authkey
     ${authkey}=    Get From Dictionary    ${mapping_authkey}    key-string
     [Return]    ${authkey}
 
-Get Authentication Key Lithium
-    [Arguments]    ${output}
-    ${authkey}=    Get From Dictionary    ${output}    authkey
-    [Return]    ${authkey}
-
 Ipv4 Rloc Should Be
     [Arguments]    ${resp}    ${address}
     [Documentation]    Check if the RLOC in the ${resp} is ${address}
@@ -44,62 +34,57 @@ Ipv4 Rloc Should Be
 Get Eid Record
     [Arguments]    ${resp}
     ${output}=    Get From Dictionary    ${resp.json()}    output
-    ${eid_record}=    Run Keyword If    "${ODL_VERSION}" == "Li"    Get Eid Record Lithium    ${output}
-    ...    ELSE    Get Eid Record Beryllium    ${output}
-    [Return]    ${eid_record}
-
-Get Eid Record Beryllium
-    [Arguments]    ${output}
     ${eid_record}=    Get From Dictionary    ${output}    mapping-record
     [Return]    ${eid_record}
 
-Get Eid Record Lithium
-    [Arguments]    ${output}
-    ${eid_record}=    Get From Dictionary    ${output}    eidToLocatorRecord
-    ${eid_record}=    Get From List    ${eid_record}    0
-    [Return]    ${eid_record}
-
 Get Ipv4 Rloc
-    [Arguments]    ${loc_record}
-    ${ipv4}=    Run Keyword If    "${ODL_VERSION}" == "Li"    Get Ipv4 Rloc Lithium    ${loc_record}
-    ...    ELSE    Get Ipv4 Rloc Beryllium    ${loc_record}
-    [Return]    ${ipv4}
-
-Get Ipv4 Rloc Beryllium
     [Arguments]    ${loc_record}
     ${loc}=    Get From Dictionary    ${loc_record}    rloc
     ${ipv4}=    Get From Dictionary    ${loc}    ipv4
     [Return]    ${ipv4}
 
-Get Ipv4 Rloc Lithium
-    [Arguments]    ${loc_record}
-    ${loc}=    Get From Dictionary    ${loc_record}    LispAddressContainer
-    ${address}=    Get From Dictionary    ${loc}    Ipv4Address
-    ${ipv4}=    Get From Dictionary    ${address}    Ipv4Address
-    [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
+Check Key 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
+    Post Log Check    ${LFM_RPC_API}:get-key    ${json}    status_codes=${DELETED_STATUS_CODES}
 
-Check Mapping Removal Lithium
+Check Mapping Removal
     [Arguments]    ${json}
+    Post Log Check    ${LFM_RPC_API}:get-mapping    ${json}    status_codes=${DELETED_STATUS_CODES}
+
+Get Mapping JSON
+    [Arguments]    ${eid}    ${rloc}
+    [Documentation]    Returns mapping record JSON dict
+    ${loc_record}=    Get LocatorRecord Object    ${rloc}
+    ${lisp_address}=    Get LispAddress Object    ${eid}
+    ${loc_record_list}=    Create List    ${loc_record}
+    ${mapping_record_json}=    Get MappingRecord JSON    ${lisp_address}    ${loc_record_list}
+    ${mapping}=    Wrap input    ${mapping_record_json}
+    [Return]    ${mapping}
+
+Post Log Check Authkey
+    [Arguments]    ${json}    ${password}
+    [Documentation]    Extend the 'Post Log Check' keyword to check for the correct authentication key
+    ${resp}=    Post Log Check    ${LFM_RPC_API}:get-key    ${json}
+    Authentication Key Should Be    ${resp}    ${password}
+
+Post Log Check Ipv4 Rloc
+    [Arguments]    ${json}    ${rloc}
+    [Documentation]    Extend the 'Post Log Check' keyword to check for the correct IPv4 RLOC
     ${resp}=    Post Log Check    ${LFM_RPC_API}:get-mapping    ${json}
-    ${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}
+    Ipv4 Rloc Should Be    ${resp}    ${rloc}
 
-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}
+Post Log Check LocatorRecord
+    [Arguments]    ${json}
+    [Documentation]    Extend the 'Post Log Check' keyword to check for the existence of a LocatorRecord
+    ${resp}=    Post Log Check    ${LFM_RPC_API}:get-mapping    ${json}
+    ${eid_record}=    Get Eid Record    ${resp}
+    Dictionary Should Contain Key    ${eid_record}    LocatorRecord