aboutsummaryrefslogtreecommitdiffstats
path: root/tests/vnfsdk-ice/ice-server/validation_test.robot
blob: 1a134b017b98878771fe51be5606b0bff92b0f0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
*** settings ***
Library           OperatingSystem
Library           Process
Library           String
Library           Collections
Library           RequestsLibrary
Library           json


*** Variables ***
${valid_heat_zip}   ${SCRIPTS}/../tests/vnfsdk-ice/ice-server/heat_template_ok.zip
${empty_heat_zip}   ${SCRIPTS}/../tests/vnfsdk-ice/ice-server/heat_template_empty.zip
${ice_uri}           /onapapi/ice/v1/

*** Test Cases ***

ICE health Check
    [Documentation]  Validate that ICE is up
    Create Session   ice_session  http://${ICE_IP}:5000
    &{headers}=  Create Dictionary      Content-Type=application/json

    ${resp}=    Get Request    ice_session   ${ice_uri}   headers=${headers}

    Should Be Equal As Strings  ${resp.status_code}     200

Check status code for valid HEAT based VNF package
    [Documentation]    Post a valid VNF package and expect 200 Response
    ${fileData}=  Get Binary File  ${valid_heat_zip}
    ${fileDir}  ${fileName}=  Split Path  ${valid_heat_zip}
    ${partData}=  Create List  ${fileName}  ${fileData}  application/octet-stream
    &{fileParts}=  Create Dictionary
    Set To Dictionary  ${fileParts}  file=${partData}

    ${resp}=  Post Request  ice_session  ${ice_uri}  files=${fileParts}

    Log    Receive HTTP Status code ${resp.status_code}
    Should Be Equal As Strings  ${resp.status_code}     200
    ${json} =  Set Variable  ${resp.json()}
    ${message} =  Get From Dictionary  ${json}  message
    Should Be Equal  ${message}  OK

Check status code for empty VNF package
    [Documentation]    Post an empty VNF package and expect 422 Response
    ${fileData}=  Get Binary File  ${empty_heat_zip}
    ${fileDir}  ${fileName}=  Split Path  ${empty_heat_zip}
    ${partData}=  Create List  ${fileName}  ${fileData}  application/octet-stream
    &{fileParts}=  Create Dictionary
    Set To Dictionary  ${fileParts}  file=${partData}

    ${resp}=  Post Request  ice_session  ${ice_uri}  files=${fileParts}

    Log    Receive HTTP Status code ${resp.status_code}
    Should Be Equal As Strings  ${resp.status_code}     422
    ${json} =  Set Variable  ${resp.json()}
    ${message} =  Get From Dictionary  ${json}  message
    Should Be Equal  ${message}  Tests failed

Check status code for invalid request
    [Documentation]    Post an invalid request and expect 400 Response
    ${fileData}=  Get Binary File  ${empty_heat_zip}
    ${fileDir}  ${fileName}=  Split Path  ${empty_heat_zip}
    ${partData}=  Create List  ${fileName}  ${fileData}  application/octet-stream
    &{fileParts}=  Create Dictionary
    Set To Dictionary  ${fileParts}  foo=${partData}

    ${resp}=  Post Request  ice_session  ${ice_uri}  files=${fileParts}

    Log    Receive HTTP Status code ${resp.status_code}
    Should Be Equal As Strings  ${resp.status_code}     400