Add GRA CSIT tests
[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 Library           HttpLibrary.HTTP
9
10
11 *** Keywords ***
12
13 Create SDNC RESTCONF Session
14     [Documentation]    Create session to OpenDaylight controller
15     ${auth}=  Create List  ${ODL_USER}  ${ODL_PASSWORD}
16     Create Session  sdnc_restconf  ${SDNC_RESTCONF_URL}  auth=${auth}
17
18 Send Post File And Validate Response
19     [Documentation]    POST file contents to OpenDaylight controller
20     [Arguments]  ${url}  ${path}  ${resp_code}
21     Create SDNC RESTCONF Session
22     ${body}=      Get File     ${path}
23     &{headers}=  Create Dictionary    Authorization=Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==    Content-Type=application/json    Accept=application/json
24     ${resp}=  POST On Session  sdnc_restconf  ${url}  headers=${headers}  data=${body}  expected_status=200
25     ${respjson}=    Parse Json    ${resp.content}
26     Should Be Equal As Strings    ${respjson['output']['response-code']}        ${resp_code}
27
28
29 Send Empty Post Request And Validate Response
30     [Documentation]    POST with no content to OpenDaylight controller
31     [Arguments]  ${url}   ${resp_code}
32     Create SDNC RESTCONF Session
33     &{headers}=  Create Dictionary    Content-Type=application/json    Content-Length=0  Accept=application/json
34     ${resp}=  POST On Session  sdnc_restconf  ${url}  headers=${headers}  expected_status=${resp_code}
35     
36 Send Get Request And Validate Response Sdnc
37     [Documentation]   GET from Opendaylight controller and validate received response
38     [Arguments]   ${url}  ${resp_code}
39     CREATE SDNC RESTCONF Session
40     &{headers}=  Create Dictionary    Content-Type=application/json    Accept=application/json
41     ${resp}=     GET On Session    sdnc_restconf    ${url}    headers=${headers}  expected_status=${resp_code}
42
43 Send Get Request And Validate TLS Connection Response
44     [Documentation]   Create NETCONF mount and validate TLS connection
45     [Arguments]   ${url}  ${resp_code}
46     Create SDNC RESTCONF Session
47     ${mount}=    Get File    ${REQUEST_DATA_PATH}${/}mount.xml
48     &{headers}=  Create Dictionary   Content-Type=application/xml    Accept=application/xml
49     ${resp}=    PUT On Session    sdnc_restconf    ${url}    data=${mount}    headers=${headers}  expected_status=201
50     Sleep  30
51     &{headers1}=  Create Dictionary  Content-Type=application/json    Accept=application/json
52     ${resp1}=    GET On Session    sdnc_restconf    ${PNFSIM_MOUNT_PATH}    headers=${headers1}  expected_status=${resp_code}
53
54
55 Send Delete Request And Validate PNF Mount Deleted
56     [Documentation]   Disconnect NETCONT mount and validate
57     [Arguments]   ${url}  ${resp_code}
58     Create SDNC RESTCONF Session
59     ${mount}=    Get File   ${REQUEST_DATA_PATH}${/}mount.xml
60     &{headers}=  Create Dictionary    Content-Type=application/json    Accept=application/json
61     ${deleteresponse}=    DELETE On Session    sdnc_restconf    ${url}    data=${mount}    headers=${headers}  expected_status=${resp_code}
62     Sleep  30
63     ${del_topology}=    DELETE On Session    sdnc_restconf    ${SDNC_NETWORK_TOPOLOGY}  expected_status=${resp_code}
64     ${del_keystore}=    DELETE On Session    sdnc_restconf    ${SDNC_KEYSTORE_CONFIG_PATH}
65
66