Migrate LISP tests to new Beryllium API
[integration/test.git] / csit / libraries / LISPFlowMapping.robot
1 *** Settings ***
2 Documentation     This resource file defines keywords that are used in more
3 ...               than one lispflowmapping test suite. Those suites include
4 ...               ../variables/Variables.py, which is where some of the
5 ...               variables are coming from.
6
7 *** Variables ***
8 ${ODL_VERSION}    Be
9
10 *** Keywords ***
11 Authentication Key Should Be
12     [Arguments]    ${resp}    ${password}
13     [Documentation]    Check if the authentication key in the ${resp} is ${password}
14     ${authkey}=    Get Authentication Key    ${resp}
15     Should Be Equal As Strings    ${authkey}    ${password}
16
17 Get Authentication Key
18     [Arguments]    ${resp}
19     ${output}=    Get From Dictionary    ${resp.json()}    output
20     ${authkey}=    Run Keyword If    "${ODL_VERSION}" == "Li"    Get Authentication Key Lithium    ${output}
21     ...    ELSE    Get Authentication Key Beryllium    ${output}
22     [Return]    ${authkey}
23
24 Get Authentication Key Beryllium
25     [Arguments]    ${output}
26     ${mapping_authkey}=    Get From Dictionary    ${output}    mapping-authkey
27     ${authkey}=    Get From Dictionary    ${mapping_authkey}    key-string
28     [Return]    ${authkey}
29
30 Get Authentication Key Lithium
31     [Arguments]    ${output}
32     ${authkey}=    Get From Dictionary    ${output}    authkey
33     [Return]    ${authkey}
34
35 Ipv4 Rloc Should Be
36     [Arguments]    ${resp}    ${address}
37     [Documentation]    Check if the RLOC in the ${resp} is ${address}
38     ${eid_record}=    Get Eid Record    ${resp}
39     ${loc_record}=    Get From Dictionary    ${eid_record}    LocatorRecord
40     ${loc_record_0}=    Get From List    ${loc_record}    0
41     ${ipv4}=    Get Ipv4 Rloc    ${loc_record_0}
42     Should Be Equal As Strings    ${ipv4}    ${address}
43
44 Get Eid Record
45     [Arguments]    ${resp}
46     ${output}=    Get From Dictionary    ${resp.json()}    output
47     ${eid_record}=    Run Keyword If    "${ODL_VERSION}" == "Li"    Get Eid Record Lithium    ${output}
48     ...    ELSE    Get Eid Record Beryllium    ${output}
49     [Return]    ${eid_record}
50
51 Get Eid Record Beryllium
52     [Arguments]    ${output}
53     ${eid_record}=    Get From Dictionary    ${output}    mapping-record
54     [Return]    ${eid_record}
55
56 Get Eid Record Lithium
57     [Arguments]    ${output}
58     ${eid_record}=    Get From Dictionary    ${output}    eidToLocatorRecord
59     ${eid_record}=    Get From List    ${eid_record}    0
60     [Return]    ${eid_record}
61
62 Get Ipv4 Rloc
63     [Arguments]    ${loc_record}
64     ${ipv4}=    Run Keyword If    "${ODL_VERSION}" == "Li"    Get Ipv4 Rloc Lithium    ${loc_record}
65     ...    ELSE    Get Ipv4 Rloc Beryllium    ${loc_record}
66     [Return]    ${ipv4}
67
68 Get Ipv4 Rloc Beryllium
69     [Arguments]    ${loc_record}
70     ${loc}=    Get From Dictionary    ${loc_record}    rloc
71     ${ipv4}=    Get From Dictionary    ${loc}    ipv4
72     [Return]    ${ipv4}
73
74 Get Ipv4 Rloc Lithium
75     [Arguments]    ${loc_record}
76     ${loc}=    Get From Dictionary    ${loc_record}    LispAddressContainer
77     ${address}=    Get From Dictionary    ${loc}    Ipv4Address
78     ${ipv4}=    Get From Dictionary    ${address}    Ipv4Address
79     [Return]    ${ipv4}
80
81 Check Mapping Removal
82     [Arguments]    ${json}
83     Run Keyword If    "${ODL_VERSION}" == "Li"    Check Mapping Removal Lithium    ${json}
84     ...    ELSE    Post Log Check    ${LFM_RPC_API}:get-mapping    ${json}    404
85
86 Check Mapping Removal Lithium
87     [Arguments]    ${json}
88     ${resp}=    Post Log Check    ${LFM_RPC_API}:get-mapping    ${json}
89     ${output}=    Get From Dictionary    ${resp.json()}    output
90     ${eid_record}=    Get From Dictionary    ${output}    eidToLocatorRecord
91     ${eid_record_0}=    Get From List    ${eid_record}    0
92     ${action}=    Get From Dictionary    ${eid_record_0}    action
93     Should Be Equal As Strings    ${action}    NativelyForward
94
95 Post Log Check
96     [Arguments]    ${uri}    ${body}    ${status_code}=200
97     [Documentation]    Post body to uri, log response content, and check status
98     ${resp}=    RequestsLibrary.Post    session    ${uri}    ${body}
99     Log    ${resp.content}
100     Should Be Equal As Strings    ${resp.status_code}    ${status_code}
101     [Return]    ${resp}
102
103 Create Session And Set External Variables
104     Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
105     Run Keyword If    "${ODL_VERSION}" == "Li"    Set Suite Variable    ${LFM_RPC_API}    ${LFM_RPC_API_LI}