Use explicit RequestsLibrary.Create_Session reference
[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 Library             JsonGenerator.py
8
9
10 *** Variables ***
11 ${JSON_DIR}     ${CURDIR}/../variables/lispflowmapping/Be
12
13
14 *** Keywords ***
15 Authentication Key Should Be
16     [Documentation]    Check if the authentication key in the ${resp} is ${password}
17     [Arguments]    ${resp}    ${password}
18     ${authkey}=    Get Authentication Key    ${resp}
19     Should Be Equal As Strings    ${authkey}    ${password}
20
21 Get Authentication Key
22     [Arguments]    ${resp}
23     ${output}=    Get From Dictionary    ${resp.json()}    output
24     ${mapping_authkey}=    Get From Dictionary    ${output}    mapping-authkey
25     ${authkey}=    Get From Dictionary    ${mapping_authkey}    key-string
26     RETURN    ${authkey}
27
28 Ipv4 Rloc Should Be
29     [Documentation]    Check if the RLOC in the ${resp} is ${address}
30     [Arguments]    ${resp}    ${address}
31     ${eid_record}=    Get Eid Record    ${resp}
32     ${loc_record}=    Get From Dictionary    ${eid_record}    LocatorRecord
33     ${loc_record_0}=    Get From List    ${loc_record}    0
34     ${ipv4}=    Get Ipv4 Rloc    ${loc_record_0}
35     Should Be Equal As Strings    ${ipv4}    ${address}
36
37 Get Eid Record
38     [Arguments]    ${resp}
39     ${output}=    Get From Dictionary    ${resp.json()}    output
40     ${eid_record}=    Get From Dictionary    ${output}    mapping-record
41     RETURN    ${eid_record}
42
43 Get Ipv4 Rloc
44     [Arguments]    ${loc_record}
45     ${loc}=    Get From Dictionary    ${loc_record}    rloc
46     ${ipv4}=    Get From Dictionary    ${loc}    ipv4
47     RETURN    ${ipv4}
48
49 Get Elp Hop
50     [Documentation]    Returns the Rloc object pointed to by ${hop_index}
51     [Arguments]    ${loc_record}    ${hop_index}
52     ${rloc}=    Get From Dictionary    ${loc_record}    rloc
53     ${exp_loc_path}=    Get From Dictionary    ${rloc}    explicit-locator-path
54     ${actual_hop_index}=    Evaluate    ${hop_index} - 1
55     ${hop}=    Get From List    ${exp_loc_path}    ${actual_hop_index}
56     RETURN    ${hop}
57
58 Check Key Removal
59     [Arguments]    ${json}
60     Post Log Check    ${LFM_RPC_API}:get-key    ${json}    status_codes=${DELETED_STATUS_CODES}
61
62 Check Mapping Removal
63     [Arguments]    ${json}
64     Post Log Check    ${LFM_RPC_API}:get-mapping    ${json}    status_codes=${DELETED_STATUS_CODES}
65
66 Get Mapping JSON
67     [Documentation]    Returns mapping record JSON dict
68     [Arguments]    ${eid}    ${rloc}
69     ${loc_record}=    Get LocatorRecord Object    ${rloc}
70     ${lisp_address}=    Get LispAddress Object    ${eid}
71     ${loc_record_list}=    Create List    ${loc_record}
72     ${mapping_record_json}=    Get MappingRecord JSON    ${lisp_address}    ${loc_record_list}
73     ${mapping}=    Wrap input    ${mapping_record_json}
74     RETURN    ${mapping}
75
76 Post Log Check Authkey
77     [Documentation]    Extend the 'Post Log Check' keyword to check for the correct authentication key
78     [Arguments]    ${json}    ${password}
79     ${resp}=    Post Log Check    ${LFM_RPC_API}:get-key    ${json}
80     Authentication Key Should Be    ${resp}    ${password}
81
82 Post Log Check Ipv4 Rloc
83     [Documentation]    Extend the 'Post Log Check' keyword to check for the correct IPv4 RLOC
84     [Arguments]    ${json}    ${rloc}
85     ${resp}=    Post Log Check    ${LFM_RPC_API}:get-mapping    ${json}
86     Ipv4 Rloc Should Be    ${resp}    ${rloc}
87
88 Post Log Check LocatorRecord
89     [Documentation]    Extend the 'Post Log Check' keyword to check for the existence of a LocatorRecord
90     [Arguments]    ${json}
91     ${resp}=    Post Log Check    ${LFM_RPC_API}:get-mapping    ${json}
92     ${eid_record}=    Get Eid Record    ${resp}
93     Dictionary Should Contain Key    ${eid_record}    LocatorRecord