2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.ci.tests.execute.distribution;
23 import static org.testng.AssertJUnit.assertEquals;
24 import static org.testng.AssertJUnit.assertNotNull;
26 import java.io.ByteArrayInputStream;
27 import java.io.InputStream;
28 import java.util.HashMap;
29 import java.util.List;
31 import java.util.zip.ZipInputStream;
33 import org.apache.commons.codec.binary.Base64;
34 import org.junit.Rule;
35 import org.junit.rules.TestName;
36 import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition;
37 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
38 import org.openecomp.sdc.be.model.ArtifactDefinition;
39 import org.openecomp.sdc.be.model.Resource;
40 import org.openecomp.sdc.be.model.User;
41 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
42 import org.openecomp.sdc.ci.tests.api.Urls;
43 import org.openecomp.sdc.ci.tests.config.Config;
44 import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
45 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
46 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
47 import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
48 import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
49 import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
50 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
51 import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedDistDownloadAudit;
52 import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
53 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
54 import org.openecomp.sdc.ci.tests.utils.Utils;
55 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
56 import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
57 import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
58 import org.openecomp.sdc.ci.tests.utils.rest.ConsumerRestUtils;
59 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
60 import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
61 import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
62 import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils;
63 import org.openecomp.sdc.common.api.Constants;
64 import org.openecomp.sdc.common.util.GeneralUtility;
65 import org.openecomp.sdc.common.util.ValidationUtils;
66 import org.testng.AssertJUnit;
67 import org.testng.annotations.BeforeMethod;
68 import org.testng.annotations.Test;
70 public class DistributionDownloadArtifactTest extends ComponentBaseTest {
72 protected static ResourceReqDetails resourceDetails;
73 protected static User designerUser;
74 protected static User adminUser;
75 protected static String resourceBaseVersion;
76 // user ci password 123456
77 protected final String authorizationHeader = "Basic Y2k6MTIzNDU2";
78 protected ConsumerDataDefinition consumerDataDefinition;
81 public static TestName name = new TestName();
82 protected static String artifactInterfaceType;
83 protected static String artifactOperationName;
85 protected static ServiceReqDetails serviceDetails;
86 protected static String serviceBaseVersion;
87 protected static String serviceUniqueId;
88 protected final String USER = "ci";
89 protected final String PASSWORD = "123456";
90 protected final String SALT = "2a1f887d607d4515d4066fe0f5452a50";
91 protected final String HASHED_PASSWORD = "0a0dc557c3bf594b1a48030e3e99227580168b21f44e285c69740b8d5b13e33b";
93 public DistributionDownloadArtifactTest() {
94 super(name, DistributionDownloadArtifactTest.class.getName());
98 // public static void InitBeforeTest() throws Exception
102 // resourceBaseVersion = "0.1";
103 // serviceBaseVersion = "0.1";
104 // designerUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
105 // adminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
107 // ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
108 // NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS,
110 // serviceDetails = ElementFactory.getDefaultService();
111 // serviceUniqueId = "svc_" + serviceDetails.getName().toLowerCase() + "." +
112 // serviceBaseVersion;
113 // artifactInterfaceType = "standard";
114 // artifactOperationName = "start";
118 public void setup() throws Exception {
120 resourceBaseVersion = "0.1";
121 serviceBaseVersion = "0.1";
122 designerUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
123 adminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
124 resourceDetails = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
125 NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, adminUser);
126 serviceDetails = ElementFactory.getDefaultService();
127 serviceUniqueId = "svc_" + serviceDetails.getName().toLowerCase() + "." + serviceBaseVersion;
128 artifactInterfaceType = "standard";
129 artifactOperationName = "start";
130 consumerDataDefinition = createConsumer();
131 RestResponse deleteResponse = ConsumerRestUtils.deleteConsumer(consumerDataDefinition, adminUser);
132 BaseRestUtils.checkStatusCode(deleteResponse, "delete operation filed", false, 404, 200);
134 RestResponse createResponse = ConsumerRestUtils.createConsumer(consumerDataDefinition, adminUser);
135 BaseRestUtils.checkCreateResponse(createResponse);
139 public void downloadResourceArtifactSuccess() throws Exception {
141 RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, designerUser);
142 AssertJUnit.assertEquals("Check response code after creating resource", 201,
143 serviceResponse.getErrorCode().intValue());
146 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, designerUser);
147 AssertJUnit.assertEquals("Check response code after creating resource", 201,
148 createResource.getErrorCode().intValue());
149 Resource resource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
151 ArtifactReqDetails artifactDetails = ElementFactory
152 .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
153 // Setting the name to be with space
154 artifactDetails.setArtifactName("test artifact file.yaml");
155 // artifactDetails.set(ArtifactRestUtils.calculateChecksum(artifactDetails));
157 RestResponse addArtifactResponse = ArtifactRestUtils.addInformationalArtifactToResource(artifactDetails,
158 designerUser, resource.getUniqueId(), ArtifactRestUtils.calculateChecksum(artifactDetails));
159 AssertJUnit.assertEquals("Check response code after adding interface artifact", 200,
160 addArtifactResponse.getErrorCode().intValue());
162 // Getting expected artifact checksum
163 ArtifactDefinition artifactResp = ResponseParser
164 .convertArtifactDefinitionResponseToJavaObject(addArtifactResponse.getResponse());
165 String expectedPayloadChecksum = artifactResp.getArtifactChecksum();
167 Config config = Utils.getConfig();
168 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
169 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceBaseVersion,
170 ValidationUtils.convertToSystemName(resource.getName()), resource.getVersion(),
171 artifactResp.getArtifactName()));
172 // String fullUrlFormatted =
173 // String.format(Urls.DOWNLOAD_RESOURCE_ARTIFACT_FULL_URL,
174 // config.getCatalogBeHost(),config.getCatalogBePort(), relativeUrl);
175 // String consumerId = "dummy.ecomp";
177 ResourceReqDetails resourceInfo = new ResourceReqDetails();
178 resourceInfo.setName(resource.getName());
179 resourceInfo.setVersion(resource.getVersion());
181 Map<String, String> authorizationHeaders = new HashMap<String, String>();
182 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
183 RestResponse restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceDetails, resourceInfo,
184 artifactDetails, designerUser, authorizationHeaders);
185 // RestResponse restResponse =
186 // artifactUtils.downloadResourceArtifact(designerUser,fullUrlFormatted,
188 AssertJUnit.assertEquals("Check response code after download resource", 200,
189 restResponse.getErrorCode().intValue());
191 // Validating headers
192 // content disposition
193 List<String> contDispHeaderList = restResponse.getHeaderFields().get(Constants.CONTENT_DISPOSITION_HEADER);
194 AssertJUnit.assertNotNull(contDispHeaderList);
197 "Check content disposition header", new StringBuilder().append("attachment; filename=\"")
198 .append(artifactResp.getArtifactName()).append("\"").toString(),
199 contDispHeaderList.get(0));
202 List<String> contTypeHeaderList = restResponse.getHeaderFields().get(Constants.CONTENT_TYPE_HEADER);
203 AssertJUnit.assertNotNull(contTypeHeaderList);
204 AssertJUnit.assertEquals("Check content type", "application/octet-stream", contTypeHeaderList.get(0));
206 String actualContents = restResponse.getResponse();
208 // Contents - comparing decoded content
209 AssertJUnit.assertEquals(artifactDetails.getPayload(), Base64.encodeBase64String(actualContents.getBytes()));
211 // validating checksum
212 String actualPayloadChecksum = GeneralUtility.calculateMD5Base64EncodedByByteArray(actualContents.getBytes());
213 AssertJUnit.assertEquals(expectedPayloadChecksum, actualPayloadChecksum);
216 String auditAction = "DArtifactDownload";
218 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
219 BaseRestUtils.ecomp, relativeUrl, "200", "OK");
220 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
223 protected void download_serviceNameNotFound_inner(String serviceName, String serviceVersion, String resourceName,
224 String resourceVersion) throws Exception {
225 Config config = Utils.getConfig();
226 String artifactName = "kuku";
227 ArtifactReqDetails artifact = new ArtifactReqDetails();
228 artifact.setArtifactName(artifactName);
230 Map<String, String> authorizationHeaders = new HashMap<String, String>();
231 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
232 ServiceReqDetails serviceInfo = new ServiceReqDetails();
233 serviceInfo.setName(serviceName);
234 serviceInfo.setVersion(serviceVersion);
235 RestResponse restResponse = null;
236 if (resourceName != null) {
237 ResourceReqDetails resourceDetailes = new ResourceReqDetails();
238 resourceDetailes.setName(resourceName);
239 resourceDetailes.setVersion(resourceVersion);
240 relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
241 ValidationUtils.convertToSystemName(serviceName), serviceVersion,
242 ValidationUtils.convertToSystemName(resourceName), resourceVersion, artifactName));
243 restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceInfo, resourceDetailes, artifact,
244 designerUser, authorizationHeaders);
246 relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_SERVICE_ARTIFACT_RELATIVE_URL,
247 ValidationUtils.convertToSystemName(serviceName), serviceVersion, artifactName));
248 restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceInfo, artifact, designerUser,
249 authorizationHeaders);
252 // RestResponse restResponse =
253 // artifactUtils.downloadResourceArtifact(designerUser,fullUrlFormatted,
255 AssertJUnit.assertEquals("Check response code after download resource", 404,
256 restResponse.getErrorCode().intValue());
259 String auditAction = "DArtifactDownload";
261 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
262 BaseRestUtils.ecomp, relativeUrl, "404", "SVC4503: Error: Requested '"
263 + ValidationUtils.convertToSystemName(serviceName) + "' service was not found.");
264 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
267 protected void download_serviceVersionNotFound_inner(String serviceName, String serviceVersion, String resourceName,
268 String resourceVersion) throws Exception {
269 Config config = Utils.getConfig();
270 String artifactName = "kuku";
272 ArtifactReqDetails artifact = new ArtifactReqDetails();
273 artifact.setArtifactName(artifactName);
274 Map<String, String> authorizationHeaders = new HashMap<String, String>();
275 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
276 ServiceReqDetails serviceInfo = new ServiceReqDetails();
277 serviceInfo.setName(serviceName);
278 serviceInfo.setVersion(serviceVersion);
279 RestResponse restResponse = null;
280 if (resourceName != null) {
281 ResourceReqDetails resourceDetailes = new ResourceReqDetails();
282 resourceDetailes.setName(resourceName);
283 resourceDetailes.setVersion(resourceVersion);
284 relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
285 ValidationUtils.convertToSystemName(serviceName), serviceVersion,
286 ValidationUtils.convertToSystemName(resourceName), resourceVersion, artifactName));
287 restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceInfo, resourceDetailes, artifact,
288 designerUser, authorizationHeaders);
290 relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_SERVICE_ARTIFACT_RELATIVE_URL,
291 ValidationUtils.convertToSystemName(serviceName), serviceVersion, artifactName));
292 restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceInfo, artifact, designerUser,
293 authorizationHeaders);
295 // String fullUrlFormatted =
296 // String.format(Urls.DOWNLOAD_RESOURCE_ARTIFACT_FULL_URL,
297 // config.getCatalogBeHost(),config.getCatalogBePort(), relativeUrl);
298 // String consumerId = "dummy.ecomp";
300 // RestResponse restResponse =
301 // artifactUtils.downloadResourceArtifact(designerUser,fullUrlFormatted,
303 AssertJUnit.assertEquals("Check response code after download resource", 404,
304 restResponse.getErrorCode().intValue());
307 String auditAction = "DArtifactDownload";
309 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
310 BaseRestUtils.ecomp, relativeUrl, "404",
311 "SVC4504: Error: Service version " + serviceVersion + " was not found.");
312 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
315 protected String encodeUrlForDownload(String url) {
316 return url.replaceAll(" ", "%20");
319 protected ConsumerDataDefinition createConsumer() {
320 ConsumerDataDefinition consumer = new ConsumerDataDefinition();
321 consumer.setConsumerName(USER);
322 consumer.setConsumerSalt(SALT);
323 consumer.setConsumerPassword(HASHED_PASSWORD);
328 @Test(enabled = false)
329 public void downloadServiceArtifactSuccess() throws Exception {
331 RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, designerUser);
332 assertEquals("Check response code after creating resource", 201, serviceResponse.getErrorCode().intValue());
333 serviceUniqueId = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse())
336 ArtifactReqDetails artifactDetails = ElementFactory.getDefaultDeploymentArtifactForType("MURANO_PKG");
338 RestResponse addArtifactResponse = ArtifactRestUtils.addInformationalArtifactToService(artifactDetails,
339 designerUser, serviceUniqueId, ArtifactRestUtils.calculateMD5Header(artifactDetails));
340 assertEquals("Check response code after adding interface artifact", 200,
341 addArtifactResponse.getErrorCode().intValue());
343 // Getting expected artifact checksum
345 // ArtifactResJavaObject artifactResp =
346 // artifactUtils.parseInformationalArtifactResp(addArtifactResponse);
347 String expectedPayloadChecksum = ResponseParser
348 .convertArtifactDefinitionResponseToJavaObject(addArtifactResponse.getResponse()).getArtifactChecksum();
350 String artifactName = ValidationUtils.normalizeFileName(artifactDetails.getArtifactName());
352 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_SERVICE_ARTIFACT_RELATIVE_URL,
353 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceBaseVersion, artifactName));
355 Map<String, String> authorizationHeaders = new HashMap<String, String>();
356 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
357 RestResponse restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceDetails, artifactDetails,
358 designerUser, authorizationHeaders);
359 assertEquals("Check response code after download resource", 200, restResponse.getErrorCode().intValue());
361 // Validating headers
362 // content disposition
363 List<String> contDispHeaderList = restResponse.getHeaderFields().get(Constants.CONTENT_DISPOSITION_HEADER);
364 assertNotNull(contDispHeaderList);
365 assertEquals("Check content disposition header",
366 new StringBuilder().append("attachment; filename=\"").append(artifactName).append("\"").toString(),
367 contDispHeaderList.get(0));
370 List<String> contTypeHeaderList = restResponse.getHeaderFields().get(Constants.CONTENT_TYPE_HEADER);
371 assertNotNull(contTypeHeaderList);
372 assertEquals("Check content type", "application/octet-stream", contTypeHeaderList.get(0));
374 String actualContents = restResponse.getResponse();
376 assertEquals(artifactDetails.getPayload(), Base64.encodeBase64String(actualContents.getBytes()));
378 // validating checksum
379 byte[] bytes = actualContents.getBytes();
380 String actualPayloadChecksum = GeneralUtility.calculateMD5Base64EncodedByByteArray(bytes);
381 assertEquals(expectedPayloadChecksum, actualPayloadChecksum);
383 // validating valid zip
384 InputStream is = new ByteArrayInputStream(bytes);
385 InputStream zis = new ZipInputStream(is);
389 String auditAction = "DArtifactDownload";
391 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
392 ResourceRestUtils.ecomp, encodeUrlForDownload(relativeUrl), "200", "OK");
393 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
397 public void downloadResourceArtifact_NoConsumerId() throws Exception {
399 String artifactName = "kuku";
400 ArtifactReqDetails artifact = new ArtifactReqDetails();
401 artifact.setArtifactName(artifactName);
402 ResourceReqDetails resource = new ResourceReqDetails();
403 resource.setName("notExisting");
404 resource.setVersion("0.1");
405 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
406 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceBaseVersion,
407 ValidationUtils.convertToSystemName(resource.getName()), resource.getVersion(), artifactName));
408 serviceDetails.setVersion("0.1");
409 Map<String, String> authorizationHeaders = new HashMap<String, String>();
410 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
411 RestResponse restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceDetails, resource, artifact,
412 designerUser, authorizationHeaders, false);
413 assertEquals("Check response code after download resource", 400, restResponse.getErrorCode().intValue());
416 String auditAction = "DArtifactDownload";
418 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction, "",
419 relativeUrl, "400", "POL5001: Error: Missing 'X-ECOMP-InstanceID' HTTP header.");
420 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
424 public void downloadResourceArtifact_ResourceNameNotFound() throws Exception {
426 String artifactName = "kuku";
427 ArtifactReqDetails artifact = new ArtifactReqDetails();
428 artifact.setArtifactName(artifactName);
429 ResourceReqDetails resource = new ResourceReqDetails();
430 resource.setName("notExisting");
431 resource.setVersion("0.1");
432 serviceDetails.setVersion("0.1");
433 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
434 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceDetails.getVersion(),
435 ValidationUtils.convertToSystemName(resource.getName()), resource.getVersion(), artifactName));
437 Map<String, String> authorizationHeaders = new HashMap<String, String>();
438 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
439 RestResponse restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceDetails, resource, artifact,
440 designerUser, authorizationHeaders);
442 assertEquals("Check response code after download resource", 404, restResponse.getErrorCode().intValue());
445 String auditAction = "DArtifactDownload";
447 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
448 BaseRestUtils.ecomp, relativeUrl, "404",
449 "SVC4063: Error: Requested 'Notexisting' resource was not found.");
450 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
454 public void downloadResourceArtifact_ResourceVersionNotFound() throws Exception {
455 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, designerUser);
456 assertEquals("Check response code after creating resource", 201, createResource.getErrorCode().intValue());
458 Resource resource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
459 ResourceReqDetails resourceDetailes = new ResourceReqDetails();
460 resourceDetailes.setName(resource.getName());
461 resourceDetailes.setVersion("0.2");
463 serviceDetails.setVersion("0.1");
465 String artifactName = "kuku";
466 ArtifactReqDetails artifact = new ArtifactReqDetails();
467 artifact.setArtifactName(artifactName);
469 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
470 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceBaseVersion,
471 ValidationUtils.convertToSystemName(resourceDetailes.getName()), resourceDetailes.getVersion(),
474 Map<String, String> authorizationHeaders = new HashMap<String, String>();
475 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
476 RestResponse restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceDetails, resourceDetailes,
477 artifact, designerUser, authorizationHeaders);
478 assertEquals("Check response code after download resource", 404, restResponse.getErrorCode().intValue());
481 String auditAction = "DArtifactDownload";
483 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
484 BaseRestUtils.ecomp, relativeUrl, "404", "SVC4504: Error: Resource version 0.2 was not found.");
485 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
489 public void downloadResourceArtifact_ServiceNameNotFound() throws Exception {
491 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, designerUser);
492 assertEquals("Check response code after creating resource", 201, createResource.getErrorCode().intValue());
493 Resource resource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
494 download_serviceNameNotFound_inner("notExistingServiceName", serviceBaseVersion, resource.getName(),
495 resource.getVersion());
500 public void downloadResourceArtifact_ServiceVersionNotFound() throws Exception {
502 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, designerUser);
503 assertEquals("Check response code after creating resource", 201, createResource.getErrorCode().intValue());
504 Resource resource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
507 RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, designerUser);
508 assertEquals("Check response code after creating resource", 201, serviceResponse.getErrorCode().intValue());
509 serviceUniqueId = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse())
512 download_serviceVersionNotFound_inner(serviceDetails.getName(), "0.3", resource.getName(),
513 resource.getVersion());
517 public void downloadServiceArtifact_ServiceNameNotFound() throws Exception {
518 download_serviceNameNotFound_inner("notExistingServiceName", serviceBaseVersion, null, null);
523 public void downloadServiceArtifact_ServiceVersionNotFound() throws Exception {
526 RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, designerUser);
527 assertEquals("Check response code after creating resource", 201, serviceResponse.getErrorCode().intValue());
528 serviceUniqueId = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse())
531 download_serviceVersionNotFound_inner(serviceDetails.getName(), "0.2", null, null);