7a3df839c649cdb709065ec371f3e3dd88fb066b
[sdnc/oam.git] / csit / tests / sdnc / resources / sdnc-keywords.robot
1 *** Settings ***
2
3 Resource          ./sdnc-properties.robot
4
5 Library           Collections
6 Library           RequestsLibrary
7 Library           OperatingSystem
8
9
10 *** Keywords ***
11
12 Create SDNC RESTCONF Session
13     [Documentation]    Create session to OpenDaylight controller
14     ${auth}=  Create List  ${ODL_USER}  ${ODL_PASSWORD}
15     Create Session  sdnc_restconf  ${SDNC_RESTCONF_URL}  auth=${auth}
16
17 Send Post Request And Validate Response
18     [Documentation]    Send POST request to passed URL and validate received response
19     [Arguments]  ${path}  ${body}  ${resp_code}
20     Create SDNC RESTCONF Session
21     &{headers}=  Create Dictionary    Authorization=Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==    Content-Type=application/json    Accept=application/json
22     ${resp}=  POST On Session  sdnc_restconf  ${path}  headers=${headers}  json=${body}  expected_status=${resp_code}
23
24 Send Empty Post Request And Validate Response
25     [Documentation]    Send POST request to passed URL and validate received response
26     [Arguments]  ${path}   ${resp_code}
27     Create SDNC RESTCONF Session
28     &{headers}=  Create Dictionary    Content-Type=application/json    Content-Length=0  Accept=application/json
29     ${resp}=  POST On Session  sdnc_restconf  ${path}  headers=${headers}  expected_status=${resp_code}
30     
31 Send Get Request And Validate Response Sdnc
32     [Documentation]   Send request to passed url and validate received response
33     [Arguments]   ${path}  ${resp_code}
34     CREATE SDNC RESTCONF Session
35     &{headers}=  Create Dictionary    Content-Type=application/json    Accept=application/json
36     ${resp}=     GET On Session    sdnc_restconf    ${path}    headers=${headers}  expected_status=${resp_code}
37
38 Send Get Request And Validate TLS Connection Response
39     [Documentation]   Send request to passed url and validate received response
40     [Arguments]   ${path}  ${resp_code}
41     Create SDNC RESTCONF Session
42     ${mount}=    Get File    ${REQUEST_DATA_PATH}${/}mount.xml
43     &{headers}=  Create Dictionary   Content-Type=application/xml    Accept=application/xml
44     ${resp}=    PUT On Session    sdnc_restconf    ${path}    data=${mount}    headers=${headers}  expected_status=201
45     Sleep  30
46     &{headers1}=  Create Dictionary  Content-Type=application/json    Accept=application/json
47     ${resp1}=    GET On Session    sdnc_restconf    ${PNFSIM_MOUNT_PATH}    headers=${headers1}  expected_status=${resp_code}
48
49
50 Send Delete Request And Validate PNF Mount Deleted
51     [Documentation]   Send request to passed url and validate received response
52     [Arguments]   ${path}  ${resp_code}
53     Create SDNC RESTCONF Session
54     ${mount}=    Get File   ${REQUEST_DATA_PATH}${/}mount.xml
55     &{headers}=  Create Dictionary    Content-Type=application/json    Accept=application/json
56     ${deleteresponse}=    DELETE On Session    sdnc_restconf    ${path}    data=${mount}    headers=${headers}  expected_status=${resp_code}
57     Sleep  30
58     ${del_topology}=    DELETE On Session    sdnc_restconf    ${SDNC_NETWORK_TOPOLOGY}  expected_status=${resp_code}
59     ${del_keystore}=    DELETE On Session    sdnc_restconf    ${SDNC_KEYSTORE_CONFIG_PATH}
60
61