Add GRA CSIT tests
[sdnc/oam.git] / csit / tests / sdnc / resources / sdnc-keywords.robot
index 7a3df83..76d1140 100644 (file)
@@ -5,6 +5,7 @@ Resource          ./sdnc-properties.robot
 Library           Collections
 Library           RequestsLibrary
 Library           OperatingSystem
+Library           HttpLibrary.HTTP
 
 
 *** Keywords ***
@@ -14,46 +15,50 @@ Create SDNC RESTCONF Session
     ${auth}=  Create List  ${ODL_USER}  ${ODL_PASSWORD}
     Create Session  sdnc_restconf  ${SDNC_RESTCONF_URL}  auth=${auth}
 
-Send Post Request And Validate Response
-    [Documentation]    Send POST request to passed URL and validate received response
-    [Arguments]  ${path}  ${body}  ${resp_code}
+Send Post File And Validate Response
+    [Documentation]    POST file contents to OpenDaylight controller
+    [Arguments]  ${url}  ${path}  ${resp_code}
     Create SDNC RESTCONF Session
+    ${body}=      Get File     ${path}
     &{headers}=  Create Dictionary    Authorization=Basic YWRtaW46S3A4Yko0U1hzek0wV1hsaGFrM2VIbGNzZTJnQXc4NHZhb0dHbUp2VXkyVQ==    Content-Type=application/json    Accept=application/json
-    ${resp}=  POST On Session  sdnc_restconf  ${path}  headers=${headers}  json=${body}  expected_status=${resp_code}
+    ${resp}=  POST On Session  sdnc_restconf  ${url}  headers=${headers}  data=${body}  expected_status=200
+    ${respjson}=    Parse Json    ${resp.content}
+    Should Be Equal As Strings    ${respjson['output']['response-code']}        ${resp_code}
+
 
 Send Empty Post Request And Validate Response
-    [Documentation]    Send POST request to passed URL and validate received response
-    [Arguments]  ${path}   ${resp_code}
+    [Documentation]    POST with no content to OpenDaylight controller
+    [Arguments]  ${url}   ${resp_code}
     Create SDNC RESTCONF Session
     &{headers}=  Create Dictionary    Content-Type=application/json    Content-Length=0  Accept=application/json
-    ${resp}=  POST On Session  sdnc_restconf  ${path}  headers=${headers}  expected_status=${resp_code}
+    ${resp}=  POST On Session  sdnc_restconf  ${url}  headers=${headers}  expected_status=${resp_code}
     
 Send Get Request And Validate Response Sdnc
-    [Documentation]   Send request to passed url and validate received response
-    [Arguments]   ${path}  ${resp_code}
+    [Documentation]   GET from Opendaylight controller and validate received response
+    [Arguments]   ${url}  ${resp_code}
     CREATE SDNC RESTCONF Session
     &{headers}=  Create Dictionary    Content-Type=application/json    Accept=application/json
-    ${resp}=     GET On Session    sdnc_restconf    ${path}    headers=${headers}  expected_status=${resp_code}
+    ${resp}=     GET On Session    sdnc_restconf    ${url}    headers=${headers}  expected_status=${resp_code}
 
 Send Get Request And Validate TLS Connection Response
-    [Documentation]   Send request to passed url and validate received response
-    [Arguments]   ${path}  ${resp_code}
+    [Documentation]   Create NETCONF mount and validate TLS connection
+    [Arguments]   ${url}  ${resp_code}
     Create SDNC RESTCONF Session
     ${mount}=    Get File    ${REQUEST_DATA_PATH}${/}mount.xml
     &{headers}=  Create Dictionary   Content-Type=application/xml    Accept=application/xml
-    ${resp}=    PUT On Session    sdnc_restconf    ${path}    data=${mount}    headers=${headers}  expected_status=201
+    ${resp}=    PUT On Session    sdnc_restconf    ${url}    data=${mount}    headers=${headers}  expected_status=201
     Sleep  30
     &{headers1}=  Create Dictionary  Content-Type=application/json    Accept=application/json
     ${resp1}=    GET On Session    sdnc_restconf    ${PNFSIM_MOUNT_PATH}    headers=${headers1}  expected_status=${resp_code}
 
 
 Send Delete Request And Validate PNF Mount Deleted
-    [Documentation]   Send request to passed url and validate received response
-    [Arguments]   ${path}  ${resp_code}
+    [Documentation]   Disconnect NETCONT mount and validate
+    [Arguments]   ${url}  ${resp_code}
     Create SDNC RESTCONF Session
     ${mount}=    Get File   ${REQUEST_DATA_PATH}${/}mount.xml
     &{headers}=  Create Dictionary    Content-Type=application/json    Accept=application/json
-    ${deleteresponse}=    DELETE On Session    sdnc_restconf    ${path}    data=${mount}    headers=${headers}  expected_status=${resp_code}
+    ${deleteresponse}=    DELETE On Session    sdnc_restconf    ${url}    data=${mount}    headers=${headers}  expected_status=${resp_code}
     Sleep  30
     ${del_topology}=    DELETE On Session    sdnc_restconf    ${SDNC_NETWORK_TOPOLOGY}  expected_status=${resp_code}
     ${del_keystore}=    DELETE On Session    sdnc_restconf    ${SDNC_KEYSTORE_CONFIG_PATH}