blob: 3552e5bb4a03c14cd9ea9efc855d25383a01b73f [file] [log] [blame]
Olivia.Zhan1de6ffb2019-07-16 10:40:16 +08001*** Settings ***
2Resource ../../common.robot
3Library Collections
4Library RequestsLibrary
5Library OperatingSystem
6Library json
7Library HttpLibrary.HTTP
8
9*** Variables ***
10${catalog_port} 8806
11${pnf_descriptors_url} /api/nsd/v1/pnf_descriptors
12
13#json files
14${request_json} ${SCRIPTS}/../tests/vfc/nfvo-catalog/jsons/CreatePnfdInfoRequest.json
15${request_csar} ${SCRIPTS}/../tests/vfc/nfvo-catalog/files/ran-du.csar
16
17#global variables
18${pnfdId}
19
20*** Test Cases ***
21Create new PNF Descriptor Resource for pre-condition
22 Log Create new PNF Descriptor Resource for pre-condition
23 ${json_value}= json_from_file ${request_json}
24 ${json_string}= string_from_json ${json_value}
25 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
26 Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers}
27 Set Request Body ${json_string}
28 ${resp}= Post Request web_session ${pnf_descriptors_url} ${json_string}
29 Should Be Equal As Strings 201 ${resp.status_code}
30 ${response_json} json.loads ${resp.content}
31 Should Be Equal As Strings CREATED ${response_json['pnfdOnboardingState']}
32 ${pnfdId}= Convert To String ${response_json['id']}
33 Set Global Variable ${pnfdId}
34
35Upload PNFD Content
36 Log Upload PNFD Content
37 [Documentation] The objective is to test the upload of a PNFD Content
38 Create Session web_session http://${CATALOG_IP}:${catalog_port}
39 ${headers} Create Dictionary Accept=application/json
40 &{fileParts}= Create Dictionary
41 Create Multi Part ${fileParts} file ${request_csar}
42 Log ${fileParts}
43 ${resp}= Put Request web_session ${pnf_descriptors_url}/${pnfdId}/pnfd_content files=${fileParts} headers=${headers}
44 Log ${resp.status_code}
45 Should Be Equal As Strings 204 ${resp.status_code}
46 Log Received 204 Accepted as expected
47
48Get PNFD Content
49 Log Get PNFD Content
50 [Documentation] The objective is to test the retrieval of the PNFD Content
51 ${headers} Create Dictionary Content-Type=application/json
52 Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers}
53 ${resp}= Get Request web_session ${pnf_descriptors_url}/${pnfdId}/pnfd_content
54 Should Be Equal As Strings 200 ${resp.status_code}
55
56Check Postcondition
57 Log Check Postcondition
58 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
59 Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers}
60 ${resp}= Get Request web_session ${pnf_descriptors_url}/${pnfdId}
61 Should Be Equal As Strings 200 ${resp.status_code}
62 ${response_json} json.loads ${resp.content}
63 Should Be Equal As Strings ONBOARDED ${response_json['pnfdOnboardingState']}
64
65POST PNFD Content - Method not implemented
66 Log POST PNFD Content - Method not implemented
67 [Documentation] The objective is to test that POST method is not allowed to create new PNF Descriptor content
68 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
69 Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers}
70 ${resp}= Post Request web_session ${pnf_descriptors_url}/${pnfdId}/pnfd_content
71 Should Be Equal As Strings 405 ${resp.status_code}
72
73PATCH PNFD Content - Method not implemented
74 Log PATCH PNFD Content - Method not implemented
75 [Documentation] The objective is to test that PATCH method is not allowed to update a PNF Descriptor content
76 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
77 Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers}
78 ${resp}= Patch Request web_session ${pnf_descriptors_url}/${pnfdId}/pnfd_content
79 Should Be Equal As Strings 405 ${resp.status_code}
80
81DELETE PNFD Content - Method not implemented
82 Log DELETE PNFD Content - Method not implemented
83 [Documentation] The objective is to test that DELETE method is not allowed to delete a PNF Descriptor content
84 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
85 Create Session web_session http://${CATALOG_IP}:${catalog_port} headers=${headers}
86 ${resp}= Delete Request web_session ${pnf_descriptors_url}/${pnfdId}/pnfd_content
87 Should Be Equal As Strings 405 ${resp.status_code}
88
89*** Keywords ***
90Create Multi Part
91 [Arguments] ${addTo} ${partName} ${filePath} ${contentType}=${None} ${content}=${None}
92 ${fileData}= Run Keyword If '''${content}''' != '''${None}''' Set Variable ${content}
93 ... ELSE Get Binary File ${filePath}
94 ${fileDir} ${fileName}= Split Path ${filePath}
95 ${partData}= Create List ${fileName} ${fileData} ${contentType}
96 Set To Dictionary ${addTo} ${partName}=${partData}