aboutsummaryrefslogtreecommitdiffstats
path: root/tests/vfc/nfvo-catalog/PNFDContent.robot
blob: 3552e5bb4a03c14cd9ea9efc855d25383a01b73f (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
*** Settings ***
Resource    ../../common.robot
Library     Collections
Library     RequestsLibrary
Library     OperatingSystem
Library     json
Library     HttpLibrary.HTTP

*** Variables ***
${catalog_port}            8806
${pnf_descriptors_url}         /api/nsd/v1/pnf_descriptors

#json files
${request_json}    ${SCRIPTS}/../tests/vfc/nfvo-catalog/jsons/CreatePnfdInfoRequest.json
${request_csar}    ${SCRIPTS}/../tests/vfc/nfvo-catalog/files/ran-du.csar

#global variables
${pnfdId}

*** Test Cases ***
Create new PNF Descriptor Resource for pre-condition
    Log    Create new PNF Descriptor Resource for pre-condition
    ${json_value}=     json_from_file      ${request_json}
    ${json_string}=     string_from_json   ${json_value}
    ${headers}    Create Dictionary    Content-Type=application/json    Accept=application/json
    Create Session    web_session    http://${CATALOG_IP}:${catalog_port}    headers=${headers}
    Set Request Body    ${json_string}
    ${resp}=    Post Request    web_session     ${pnf_descriptors_url}    ${json_string}
    Should Be Equal As Strings    201   ${resp.status_code}
    ${response_json}    json.loads    ${resp.content}
    Should Be Equal As Strings    CREATED    ${response_json['pnfdOnboardingState']}
    ${pnfdId}=    Convert To String      ${response_json['id']}
    Set Global Variable     ${pnfdId}

Upload PNFD Content
    Log   Upload PNFD Content
    [Documentation]    The objective is to test the upload of a PNFD Content
    Create Session    web_session    http://${CATALOG_IP}:${catalog_port}
    ${headers}    Create Dictionary    Accept=application/json
    &{fileParts}=    Create Dictionary
    Create Multi Part   ${fileParts}  file  ${request_csar}
    Log  ${fileParts}
    ${resp}=  Put Request  web_session  ${pnf_descriptors_url}/${pnfdId}/pnfd_content  files=${fileParts}  headers=${headers}
    Log  ${resp.status_code}    
    Should Be Equal As Strings    204    ${resp.status_code}
    Log    Received 204 Accepted as expected
  
Get PNFD Content
    Log    Get PNFD Content
    [Documentation]    The objective is to test the retrieval of the PNFD Content
    ${headers}            Create Dictionary    Content-Type=application/json
    Create Session        web_session          http://${CATALOG_IP}:${catalog_port}      headers=${headers}
    ${resp}=              Get Request          web_session     ${pnf_descriptors_url}/${pnfdId}/pnfd_content
    Should Be Equal As Strings    200    ${resp.status_code}

Check Postcondition
    Log    Check Postcondition
    ${headers}            Create Dictionary    Content-Type=application/json    Accept=application/json
    Create Session        web_session          http://${CATALOG_IP}:${catalog_port}      headers=${headers}
    ${resp}=              Get Request          web_session     ${pnf_descriptors_url}/${pnfdId}
    Should Be Equal As Strings    200    ${resp.status_code}
    ${response_json}    json.loads    ${resp.content}
    Should Be Equal As Strings    ONBOARDED    ${response_json['pnfdOnboardingState']}
  
POST PNFD Content - Method not implemented
    Log    POST PNFD Content - Method not implemented
    [Documentation]    The objective is to test that POST method is not allowed to create new PNF Descriptor content
    ${headers}            Create Dictionary    Content-Type=application/json    Accept=application/json
    Create Session        web_session          http://${CATALOG_IP}:${catalog_port}      headers=${headers}
    ${resp}=              Post Request          web_session     ${pnf_descriptors_url}/${pnfdId}/pnfd_content
    Should Be Equal As Strings    405    ${resp.status_code}

PATCH PNFD Content - Method not implemented
    Log    PATCH PNFD Content - Method not implemented
    [Documentation]    The objective is to test that PATCH  method is not allowed to update a PNF Descriptor content
    ${headers}            Create Dictionary    Content-Type=application/json    Accept=application/json
    Create Session        web_session          http://${CATALOG_IP}:${catalog_port}      headers=${headers}
    ${resp}=              Patch Request          web_session     ${pnf_descriptors_url}/${pnfdId}/pnfd_content
    Should Be Equal As Strings    405    ${resp.status_code}

DELETE PNFD Content - Method not implemented
    Log    DELETE PNFD Content - Method not implemented
    [Documentation]    The objective is to test that DELETE  method is not allowed to delete a PNF Descriptor content
    ${headers}            Create Dictionary    Content-Type=application/json    Accept=application/json
    Create Session        web_session          http://${CATALOG_IP}:${catalog_port}      headers=${headers}
    ${resp}=              Delete Request          web_session     ${pnf_descriptors_url}/${pnfdId}/pnfd_content
    Should Be Equal As Strings    405    ${resp.status_code}

*** Keywords ***
Create Multi Part
    [Arguments]  ${addTo}  ${partName}  ${filePath}  ${contentType}=${None}  ${content}=${None}
    ${fileData}=  Run Keyword If  '''${content}''' != '''${None}'''  Set Variable  ${content}
    ...            ELSE  Get Binary File  ${filePath}
    ${fileDir}  ${fileName}=  Split Path  ${filePath}
    ${partData}=  Create List  ${fileName}  ${fileData}  ${contentType}
    Set To Dictionary  ${addTo}  ${partName}=${partData}