Gary Wu | 9abb61c | 2018-09-27 10:38:50 -0700 | [diff] [blame] | 1 | *** settings *** |
| 2 | Library OperatingSystem |
| 3 | Library Process |
| 4 | Library String |
| 5 | Library Collections |
| 6 | Library RequestsLibrary |
| 7 | Library json |
| 8 | |
| 9 | |
| 10 | *** Variables *** |
| 11 | ${valid_heat_zip} ${SCRIPTS}/../tests/vnfsdk-ice/ice-server/heat_template_ok.zip |
| 12 | ${empty_heat_zip} ${SCRIPTS}/../tests/vnfsdk-ice/ice-server/heat_template_empty.zip |
| 13 | ${ice_uri} /onapapi/ice/v1/ |
| 14 | |
| 15 | *** Test Cases *** |
| 16 | |
| 17 | ICE health Check |
| 18 | [Documentation] Validate that ICE is up |
| 19 | Create Session ice_session http://${ICE_IP}:5000 |
| 20 | &{headers}= Create Dictionary Content-Type=application/json |
| 21 | |
| 22 | ${resp}= Get Request ice_session ${ice_uri} headers=${headers} |
| 23 | |
| 24 | Should Be Equal As Strings ${resp.status_code} 200 |
| 25 | |
| 26 | Check status code for valid HEAT based VNF package |
| 27 | [Documentation] Post a valid VNF package and expect 200 Response |
| 28 | ${fileData}= Get Binary File ${valid_heat_zip} |
| 29 | ${fileDir} ${fileName}= Split Path ${valid_heat_zip} |
| 30 | ${partData}= Create List ${fileName} ${fileData} application/octet-stream |
| 31 | &{fileParts}= Create Dictionary |
| 32 | Set To Dictionary ${fileParts} file=${partData} |
| 33 | |
| 34 | ${resp}= Post Request ice_session ${ice_uri} files=${fileParts} |
| 35 | |
| 36 | Log Receive HTTP Status code ${resp.status_code} |
| 37 | Should Be Equal As Strings ${resp.status_code} 200 |
| 38 | ${json} = Set Variable ${resp.json()} |
| 39 | ${message} = Get From Dictionary ${json} message |
| 40 | Should Be Equal ${message} OK |
| 41 | |
| 42 | Check status code for empty VNF package |
| 43 | [Documentation] Post an empty VNF package and expect 422 Response |
| 44 | ${fileData}= Get Binary File ${empty_heat_zip} |
| 45 | ${fileDir} ${fileName}= Split Path ${empty_heat_zip} |
| 46 | ${partData}= Create List ${fileName} ${fileData} application/octet-stream |
| 47 | &{fileParts}= Create Dictionary |
| 48 | Set To Dictionary ${fileParts} file=${partData} |
| 49 | |
| 50 | ${resp}= Post Request ice_session ${ice_uri} files=${fileParts} |
| 51 | |
| 52 | Log Receive HTTP Status code ${resp.status_code} |
| 53 | Should Be Equal As Strings ${resp.status_code} 422 |
| 54 | ${json} = Set Variable ${resp.json()} |
| 55 | ${message} = Get From Dictionary ${json} message |
| 56 | Should Be Equal ${message} Tests failed |
| 57 | |
| 58 | Check status code for invalid request |
| 59 | [Documentation] Post an invalid request and expect 400 Response |
| 60 | ${fileData}= Get Binary File ${empty_heat_zip} |
| 61 | ${fileDir} ${fileName}= Split Path ${empty_heat_zip} |
| 62 | ${partData}= Create List ${fileName} ${fileData} application/octet-stream |
| 63 | &{fileParts}= Create Dictionary |
| 64 | Set To Dictionary ${fileParts} foo=${partData} |
| 65 | |
| 66 | ${resp}= Post Request ice_session ${ice_uri} files=${fileParts} |
| 67 | |
| 68 | Log Receive HTTP Status code ${resp.status_code} |
| 69 | Should Be Equal As Strings ${resp.status_code} 400 |