3 Library OperatingSystem
4 Library RequestsLibrary
5 Library ONAPLibrary.Utilities
10 ${ASDC_CATALOG_SERVICES_PATH} /sdc2/rest/v1/catalog/services
11 ${ASDC_CATALOG_RESOURCES_PATH} /sdc2/rest/v1/catalog/resources
12 ${ASDC_CATALOG_LIFECYCLE_PATH} /lifecycleState
13 ${ASDC_CATALOG_SERVICE_RESOURCE_INSTANCE_PATH} /resourceInstance
14 ${ASDC_CATALOG_SERVICE_DISTRIBUTION_STATE_PATH} /distribution-state
15 ${ASDC_DISTRIBUTION_STATE_APPROVE_PATH} /approve
17 ${ASDC_CATALOG_RESOURCE_TEMPLATE} ${ASSETS_DIR}component_catalog_resource.template
18 ${ASDC_CATALOG_SERVICE_TEMPLATE} ${ASSETS_DIR}catalog_service.template
19 ${ASDC_ARTIFACT_UPLOAD_TEMPLATE} ${ASSETS_DIR}artifact_upload.template
20 ${ASDC_USER_REMARKS_TEMPLATE} ${ASSETS_DIR}user_remarks.template
21 ${DCAE_VFCMT_TEMPLATE} ${ASSETS_DIR}create_vfcmt.template
22 ${DCAE_COMPOSITION_TEMPLATE} ${ASSETS_DIR}dcae_composition.template
23 ${DCAE_MONITORING_CONFIGURATION_TEMPLATE} ${ASSETS_DIR}dcae_monitoring_configuration.template
24 ${ASDC_RESOURCE_INSTANCE_TEMPLATE} ${ASSETS_DIR}resource_instance.template
26 ${ASDC_BE_ENDPOINT} http://localhost:8080
30 Create Catalog Resource Data
31 [Documentation] Creates and returns data for ASDC Catalog Resource
32 [Arguments] ${resource_name} ${vendor_name}
33 ${map}= Create Dictionary resource_name=${resource_name} vendor_name=${vendor_name}
34 ${data}= json_templater.Fill JSON Template File ${ASDC_CATALOG_RESOURCE_TEMPLATE} ${map}
37 # Based on testsuite/robot/resources/asdc_interface.robot's 'Post ASDC Resource Request' keyword
38 Post ASDC Resource Request Unauthenticated
39 [Documentation] Makes unauthenticated Post request for ASDC Catalog resource and returns its unique id
41 ${resp}= Run ASDC Post Request Unauthenticated ${ASDC_CATALOG_RESOURCES_PATH} ${data} ${ASDC_DESIGNER_USER_ID}
42 Should Be Equal As Strings ${resp.status_code} 201
43 [Return] ${resp.json()['uniqueId']}
45 # Based on testsuite/robot/resources/asdc_interface.robot's 'Run ASDC Post Request' keyword
46 Run ASDC Post Request Unauthenticated
47 [Documentation] Runs an ASDC Post request without authentication and returns the HTTP response
48 [Arguments] ${data_path} ${data} ${user}=${ASDC_DESIGNER_USER_ID} ${MY_ASDC_BE_ENDPOINT}=${ASDC_BE_ENDPOINT}
49 Log Creating session ${MY_ASDC_BE_ENDPOINT}
50 ${session}= Create Session asdc ${MY_ASDC_BE_ENDPOINT}
51 ${uuid}= Generate UUID4
52 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json USER_ID=${user} X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID}
53 ${resp}= Post Request asdc ${data_path} data=${data} headers=${headers}
54 Log Received response from asdc ${resp.text}
57 # Based on testsuite/robot/resources/asdc_interface.robot's 'Run ASDC MD5 Post Request' keyword
58 Run ASDC MD5 Post Request Unauthenticated
59 [Documentation] Runs an ASDC post request with MD5 Checksum header without authentication and returns the HTTP response
60 [Arguments] ${data_path} ${data} ${user}=${ASDC_DESIGNER_USER_ID} ${MY_ASDC_BE_ENDPOINT}=${ASDC_BE_ENDPOINT}
61 Log Creating session ${MY_ASDC_BE_ENDPOINT}
62 ${session}= Create Session asdc ${MY_ASDC_BE_ENDPOINT}
63 ${uuid}= Generate UUID4
64 ${data_string}= Evaluate json.dumps(${data}) json
65 ${md5checksum}= Evaluate md5.new('''${data_string}''').hexdigest() modules=md5
66 ${base64md5checksum}= Evaluate base64.b64encode("${md5checksum}") modules=base64
67 ${headers}= Create Dictionary Accept=application/json Content-Type=application/json USER_ID=${user} X-TransactionId=${GLOBAL_APPLICATION_ID}-${uuid} X-FromAppId=${GLOBAL_APPLICATION_ID} Content-MD5=${base64md5checksum}
68 ${resp}= Post Request asdc ${data_path} data=${data} headers=${headers}
69 Log Received response from asdc: ${resp.text}
72 # Based on testsuite/robot/resources/asdc_interface.robot's 'Setup SDC Catalog Resource Deployment Artifact Properties' keyword
73 Add Tosca Artifact To Resource
74 [Documentation] Add Tosca artifacts to given resource id
75 [Arguments] ${artifact} ${vf_id}
76 ${blueprint_data} OperatingSystem.Get File ${ASSETS_DIR}${artifact}.yaml
77 ${payloadData}= Evaluate base64.b64encode('''${blueprint_data}'''.encode('utf-8')) modules=base64
78 ${dict}= Create Dictionary artifactLabel=${artifact} artifactName=${artifact}.yaml artifactType=DCAE_TOSCA artifactGroupType=DEPLOYMENT description=${artifact}.yaml payloadData=${payloadData}
79 ${data}= Fill JSON Template File ${ASDC_ARTIFACT_UPLOAD_TEMPLATE} ${dict}
80 # POST artifactUpload to resource
81 ${resp}= Run ASDC MD5 Post Request Unauthenticated ${ASDC_CATALOG_RESOURCES_PATH}/${vf_id}/artifacts ${data} ${ASDC_DESIGNER_USER_ID}
82 Should Be Equal As Strings ${resp.status_code} 200
85 # Directly copied from testsuite/robot/resources/asdc_interface.robot
86 Certify ASDC Catalog Resource
87 [Documentation] Certifies an ASDC Catalog Resource by its id and returns the new id
88 [Arguments] ${catalog_resource_id} ${user_id}=${ASDC_TESTER_USER_ID}
89 ${map}= Create Dictionary user_remarks=Robot remarks
90 ${data}= Fill JSON Template File ${ASDC_USER_REMARKS_TEMPLATE} ${map}
91 ${resp}= Run ASDC Post Request Unauthenticated ${ASDC_CATALOG_RESOURCES_PATH}/${catalog_resource_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certify ${data} ${user_id}
92 Should Be Equal As Strings ${resp.status_code} 200
93 [Return] ${resp.json()['uniqueId']} ${resp.json()['uuid']}
95 Add Catalog Service For Monitoring Template
96 [Documentation] Creates an ASDC Catalog Service for Monitoring Template with given name
97 [Arguments] ${service_name}
98 ${map}= Create Dictionary service_name=${service_name}
99 ${data}= Fill JSON Template File ${ASDC_CATALOG_SERVICE_TEMPLATE} ${map}
100 ${resp}= Run ASDC Post Request Unauthenticated ${ASDC_CATALOG_SERVICES_PATH} ${data}
101 Should Be Equal As Strings ${resp.status_code} 201
102 [Return] ${resp.json()['uniqueId']} ${resp.json()['uuid']}
104 # Based on testsuite/robot/resources/asdc_interface.robot's 'Add ASDC Resource Instance' keyword
105 Add ASDC Resource Instance
106 [Documentation] Creates an ASDC Resource Instance and returns its id
107 [Arguments] ${catalog_service_id} ${catalog_resource_id} ${catalog_resource_name} ${xoffset}=${0} ${yoffset}=${0} ${resourceType}=VF
108 ${milli_timestamp}= Generate Timestamp
109 ${xoffset}= Set Variable ${xoffset+306}
110 ${yoffset}= Set Variable ${yoffset+248}
111 ${map}= Create Dictionary catalog_resource_id=${catalog_resource_id} catalog_resource_name=${catalog_resource_name} milli_timestamp=${milli_timestamp} posX=${xoffset} posY=${yoffset} originType=${resourceType}
112 ${data}= Fill JSON Template File ${ASDC_RESOURCE_INSTANCE_TEMPLATE} ${map}
113 ${resp}= Run ASDC Post Request Unauthenticated ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_SERVICE_RESOURCE_INSTANCE_PATH} ${data} ${ASDC_DESIGNER_USER_ID}
114 Should Be Equal As Strings ${resp.status_code} 201
115 [Return] ${resp.json()['uniqueId']} ${resp.json()['name']}
117 # Adjusted from asdc_interface.robot
119 Checkin ASDC Catalog Service
120 [Documentation] Checks in an ASDC Catalog Service by its id
121 [Arguments] ${catalog_service_id}
122 ${map}= Create Dictionary user_remarks=Robot remarks
123 ${data}= Fill JSON Template File ${ASDC_USER_REMARKS_TEMPLATE} ${map}
124 ${resp}= Run ASDC Post Request Unauthenticated ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/checkin ${data} ${ASDC_DESIGNER_USER_ID}
125 Should Be Equal As Strings ${resp.status_code} 200
126 [Return] ${resp.json()}
128 Request Certify ASDC Catalog Service
129 [Documentation] Requests certification of an ASDC Catalog Service by its id
130 [Arguments] ${catalog_service_id}
131 ${map}= Create Dictionary user_remarks=Robot remarks
132 ${data}= Fill JSON Template File ${ASDC_USER_REMARKS_TEMPLATE} ${map}
133 ${resp}= Run ASDC Post Request Unauthenticated ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certificationRequest ${data} ${ASDC_DESIGNER_USER_ID}
134 Should Be Equal As Strings ${resp.status_code} 200
135 [Return] ${resp.json()}
137 Start Certify ASDC Catalog Service
138 [Documentation] Start certification of an ASDC Catalog Service by its id
139 [Arguments] ${catalog_service_id}
140 ${resp}= Run ASDC Post Request Unauthenticated ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/startCertification ${None} ${ASDC_TESTER_USER_ID}
141 Should Be Equal As Strings ${resp.status_code} 200
142 [Return] ${resp.json()}
144 Certify ASDC Catalog Service
145 [Documentation] Certifies an ASDC Catalog Service by its id and returns the new id
146 [Arguments] ${catalog_service_id}
147 ${map}= Create Dictionary user_remarks=Robot remarks
148 ${data}= Fill JSON Template File ${ASDC_USER_REMARKS_TEMPLATE} ${map}
149 ${resp}= Run ASDC Post Request Unauthenticated ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_LIFECYCLE_PATH}/certify ${data} ${ASDC_TESTER_USER_ID}
150 Should Be Equal As Strings ${resp.status_code} 200
151 [Return] ${resp.json()['uniqueId']}
153 Approve ASDC Catalog Service
154 [Documentation] Approves an ASDC Catalog Service by its id
155 [Arguments] ${catalog_service_id}
156 ${map}= Create Dictionary user_remarks=Robot remarks
157 ${data}= Fill JSON Template File ${ASDC_USER_REMARKS_TEMPLATE} ${map}
158 ${resp}= Run ASDC Post Request Unauthenticated ${ASDC_CATALOG_SERVICES_PATH}/${catalog_service_id}${ASDC_CATALOG_SERVICE_DISTRIBUTION_STATE_PATH}${ASDC_DISTRIBUTION_STATE_APPROVE_PATH} ${data} ${ASDC_GOVERNOR_USER_ID}
159 Should Be Equal As Strings ${resp.status_code} 200
160 [Return] ${resp.json()}