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.apache.log4j.lf5.util.ResourceUtils;
35 import org.junit.Rule;
36 import org.junit.rules.TestName;
37 import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition;
38 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
39 import org.openecomp.sdc.be.model.ArtifactDefinition;
40 import org.openecomp.sdc.be.model.Resource;
41 import org.openecomp.sdc.be.model.User;
42 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
43 import org.openecomp.sdc.ci.tests.api.Urls;
44 import org.openecomp.sdc.ci.tests.config.Config;
45 import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
46 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
47 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
48 import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
49 import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
50 import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
51 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
52 import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedDistDownloadAudit;
53 import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
54 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
55 import org.openecomp.sdc.ci.tests.utils.Utils;
56 import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
57 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
58 import org.openecomp.sdc.ci.tests.utils.rest.ArtifactRestUtils;
59 import org.openecomp.sdc.ci.tests.utils.rest.BaseRestUtils;
60 import org.openecomp.sdc.ci.tests.utils.rest.ConsumerRestUtils;
61 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
62 import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser;
63 import org.openecomp.sdc.ci.tests.utils.rest.ServiceRestUtils;
64 import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils;
65 import org.openecomp.sdc.common.api.Constants;
66 import org.openecomp.sdc.common.util.GeneralUtility;
67 import org.openecomp.sdc.common.util.ValidationUtils;
68 import org.testng.AssertJUnit;
69 import org.testng.annotations.BeforeClass;
70 import org.testng.annotations.BeforeMethod;
71 import org.testng.annotations.Test;
73 public class DistributionDownloadArtifactTest extends ComponentBaseTest {
75 protected static ResourceReqDetails resourceDetails;
76 protected static User designerUser;
77 protected static User adminUser;
78 protected static String resourceBaseVersion;
79 // user ci password 123456
80 protected final String authorizationHeader = "Basic Y2k6MTIzNDU2";
81 protected ConsumerDataDefinition consumerDataDefinition;
84 public static TestName name = new TestName();
85 protected static String artifactInterfaceType;
86 protected static String artifactOperationName;
88 protected static ServiceReqDetails serviceDetails;
89 protected static String serviceBaseVersion;
90 protected static String serviceUniqueId;
91 protected final String USER = "ci";
92 protected final String PASSWORD = "123456";
93 protected final String SALT = "2a1f887d607d4515d4066fe0f5452a50";
94 protected final String HASHED_PASSWORD = "0a0dc557c3bf594b1a48030e3e99227580168b21f44e285c69740b8d5b13e33b";
96 public DistributionDownloadArtifactTest() {
97 super(name, DistributionDownloadArtifactTest.class.getName());
101 // public static void InitBeforeTest() throws Exception
105 // resourceBaseVersion = "0.1";
106 // serviceBaseVersion = "0.1";
107 // designerUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
108 // adminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
110 // ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
111 // NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS,
113 // serviceDetails = ElementFactory.getDefaultService();
114 // serviceUniqueId = "svc_" + serviceDetails.getName().toLowerCase() + "." +
115 // serviceBaseVersion;
116 // artifactInterfaceType = "standard";
117 // artifactOperationName = "start";
121 public void setup() throws Exception {
123 resourceBaseVersion = "0.1";
124 serviceBaseVersion = "0.1";
125 designerUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
126 adminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
127 resourceDetails = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
128 NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, adminUser);
129 serviceDetails = ElementFactory.getDefaultService();
130 serviceUniqueId = "svc_" + serviceDetails.getName().toLowerCase() + "." + serviceBaseVersion;
131 artifactInterfaceType = "standard";
132 artifactOperationName = "start";
133 consumerDataDefinition = createConsumer();
134 RestResponse deleteResponse = ConsumerRestUtils.deleteConsumer(consumerDataDefinition, adminUser);
135 BaseRestUtils.checkStatusCode(deleteResponse, "delete operation filed", false, 404, 200);
137 RestResponse createResponse = ConsumerRestUtils.createConsumer(consumerDataDefinition, adminUser);
138 BaseRestUtils.checkCreateResponse(createResponse);
142 public void downloadResourceArtifactSuccess() throws Exception {
144 RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, designerUser);
145 AssertJUnit.assertEquals("Check response code after creating resource", 201,
146 serviceResponse.getErrorCode().intValue());
149 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, designerUser);
150 AssertJUnit.assertEquals("Check response code after creating resource", 201,
151 createResource.getErrorCode().intValue());
152 Resource resource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
154 ArtifactReqDetails artifactDetails = ElementFactory
155 .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
156 // Setting the name to be with space
157 artifactDetails.setArtifactName("test artifact file.yaml");
158 // artifactDetails.set(ArtifactRestUtils.calculateChecksum(artifactDetails));
160 RestResponse addArtifactResponse = ArtifactRestUtils.addInformationalArtifactToResource(artifactDetails,
161 designerUser, resource.getUniqueId(), ArtifactRestUtils.calculateChecksum(artifactDetails));
162 AssertJUnit.assertEquals("Check response code after adding interface artifact", 200,
163 addArtifactResponse.getErrorCode().intValue());
165 // Getting expected artifact checksum
166 ArtifactDefinition artifactResp = ResponseParser
167 .convertArtifactDefinitionResponseToJavaObject(addArtifactResponse.getResponse());
168 String expectedPayloadChecksum = artifactResp.getArtifactChecksum();
170 Config config = Utils.getConfig();
171 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
172 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceBaseVersion,
173 ValidationUtils.convertToSystemName(resource.getName()), resource.getVersion(),
174 artifactResp.getArtifactName()));
175 // String fullUrlFormatted =
176 // String.format(Urls.DOWNLOAD_RESOURCE_ARTIFACT_FULL_URL,
177 // config.getCatalogBeHost(),config.getCatalogBePort(), relativeUrl);
178 // String consumerId = "dummy.ecomp";
180 ResourceReqDetails resourceInfo = new ResourceReqDetails();
181 resourceInfo.setName(resource.getName());
182 resourceInfo.setVersion(resource.getVersion());
184 Map<String, String> authorizationHeaders = new HashMap<String, String>();
185 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
186 RestResponse restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceDetails, resourceInfo,
187 artifactDetails, designerUser, authorizationHeaders);
188 // RestResponse restResponse =
189 // artifactUtils.downloadResourceArtifact(designerUser,fullUrlFormatted,
191 AssertJUnit.assertEquals("Check response code after download resource", 200,
192 restResponse.getErrorCode().intValue());
194 // Validating headers
195 // content disposition
196 List<String> contDispHeaderList = restResponse.getHeaderFields().get(Constants.CONTENT_DISPOSITION_HEADER);
197 AssertJUnit.assertNotNull(contDispHeaderList);
200 "Check content disposition header", new StringBuilder().append("attachment; filename=\"")
201 .append(artifactResp.getArtifactName()).append("\"").toString(),
202 contDispHeaderList.get(0));
205 List<String> contTypeHeaderList = restResponse.getHeaderFields().get(Constants.CONTENT_TYPE_HEADER);
206 AssertJUnit.assertNotNull(contTypeHeaderList);
207 AssertJUnit.assertEquals("Check content type", "application/octet-stream", contTypeHeaderList.get(0));
209 String actualContents = restResponse.getResponse();
211 // Contents - comparing decoded content
212 AssertJUnit.assertEquals(artifactDetails.getPayload(), Base64.encodeBase64String(actualContents.getBytes()));
214 // validating checksum
215 String actualPayloadChecksum = GeneralUtility.calculateMD5ByByteArray(actualContents.getBytes());
216 AssertJUnit.assertEquals(expectedPayloadChecksum, actualPayloadChecksum);
219 String auditAction = "DArtifactDownload";
221 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
222 BaseRestUtils.ecomp, relativeUrl, "200", "OK");
223 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
226 protected void download_serviceNameNotFound_inner(String serviceName, String serviceVersion, String resourceName,
227 String resourceVersion) throws Exception {
228 Config config = Utils.getConfig();
229 String artifactName = "kuku";
230 ArtifactReqDetails artifact = new ArtifactReqDetails();
231 artifact.setArtifactName(artifactName);
233 Map<String, String> authorizationHeaders = new HashMap<String, String>();
234 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
235 ServiceReqDetails serviceInfo = new ServiceReqDetails();
236 serviceInfo.setName(serviceName);
237 serviceInfo.setVersion(serviceVersion);
238 RestResponse restResponse = null;
239 if (resourceName != null) {
240 ResourceReqDetails resourceDetailes = new ResourceReqDetails();
241 resourceDetailes.setName(resourceName);
242 resourceDetailes.setVersion(resourceVersion);
243 relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
244 ValidationUtils.convertToSystemName(serviceName), serviceVersion,
245 ValidationUtils.convertToSystemName(resourceName), resourceVersion, artifactName));
246 restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceInfo, resourceDetailes, artifact,
247 designerUser, authorizationHeaders);
249 relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_SERVICE_ARTIFACT_RELATIVE_URL,
250 ValidationUtils.convertToSystemName(serviceName), serviceVersion, artifactName));
251 restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceInfo, artifact, designerUser,
252 authorizationHeaders);
255 // RestResponse restResponse =
256 // artifactUtils.downloadResourceArtifact(designerUser,fullUrlFormatted,
258 AssertJUnit.assertEquals("Check response code after download resource", 404,
259 restResponse.getErrorCode().intValue());
262 String auditAction = "DArtifactDownload";
264 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
265 BaseRestUtils.ecomp, relativeUrl, "404", "SVC4503: Error: Requested '"
266 + ValidationUtils.convertToSystemName(serviceName) + "' service was not found.");
267 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
270 protected void download_serviceVersionNotFound_inner(String serviceName, String serviceVersion, String resourceName,
271 String resourceVersion) throws Exception {
272 Config config = Utils.getConfig();
273 String artifactName = "kuku";
275 ArtifactReqDetails artifact = new ArtifactReqDetails();
276 artifact.setArtifactName(artifactName);
277 Map<String, String> authorizationHeaders = new HashMap<String, String>();
278 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
279 ServiceReqDetails serviceInfo = new ServiceReqDetails();
280 serviceInfo.setName(serviceName);
281 serviceInfo.setVersion(serviceVersion);
282 RestResponse restResponse = null;
283 if (resourceName != null) {
284 ResourceReqDetails resourceDetailes = new ResourceReqDetails();
285 resourceDetailes.setName(resourceName);
286 resourceDetailes.setVersion(resourceVersion);
287 relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
288 ValidationUtils.convertToSystemName(serviceName), serviceVersion,
289 ValidationUtils.convertToSystemName(resourceName), resourceVersion, artifactName));
290 restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceInfo, resourceDetailes, artifact,
291 designerUser, authorizationHeaders);
293 relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_SERVICE_ARTIFACT_RELATIVE_URL,
294 ValidationUtils.convertToSystemName(serviceName), serviceVersion, artifactName));
295 restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceInfo, artifact, designerUser,
296 authorizationHeaders);
298 // String fullUrlFormatted =
299 // String.format(Urls.DOWNLOAD_RESOURCE_ARTIFACT_FULL_URL,
300 // config.getCatalogBeHost(),config.getCatalogBePort(), relativeUrl);
301 // String consumerId = "dummy.ecomp";
303 // RestResponse restResponse =
304 // artifactUtils.downloadResourceArtifact(designerUser,fullUrlFormatted,
306 AssertJUnit.assertEquals("Check response code after download resource", 404,
307 restResponse.getErrorCode().intValue());
310 String auditAction = "DArtifactDownload";
312 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
313 BaseRestUtils.ecomp, relativeUrl, "404",
314 "SVC4504: Error: Service version " + serviceVersion + " was not found.");
315 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
318 protected String encodeUrlForDownload(String url) {
319 return url.replaceAll(" ", "%20");
322 protected ConsumerDataDefinition createConsumer() {
323 ConsumerDataDefinition consumer = new ConsumerDataDefinition();
324 consumer.setConsumerName(USER);
325 consumer.setConsumerSalt(SALT);
326 consumer.setConsumerPassword(HASHED_PASSWORD);
331 @Test(enabled = false)
332 public void downloadServiceArtifactSuccess() throws Exception {
334 RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, designerUser);
335 assertEquals("Check response code after creating resource", 201, serviceResponse.getErrorCode().intValue());
336 serviceUniqueId = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse())
339 ArtifactReqDetails artifactDetails = ElementFactory.getDefaultDeploymentArtifactForType("MURANO_PKG");
341 RestResponse addArtifactResponse = ArtifactRestUtils.addInformationalArtifactToService(artifactDetails,
342 designerUser, serviceUniqueId, ArtifactRestUtils.calculateMD5Header(artifactDetails));
343 assertEquals("Check response code after adding interface artifact", 200,
344 addArtifactResponse.getErrorCode().intValue());
346 // Getting expected artifact checksum
348 // ArtifactResJavaObject artifactResp =
349 // artifactUtils.parseInformationalArtifactResp(addArtifactResponse);
350 String expectedPayloadChecksum = ResponseParser
351 .convertArtifactDefinitionResponseToJavaObject(addArtifactResponse.getResponse()).getArtifactChecksum();
353 String artifactName = ValidationUtils.normalizeFileName(artifactDetails.getArtifactName());
355 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_SERVICE_ARTIFACT_RELATIVE_URL,
356 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceBaseVersion, artifactName));
358 Map<String, String> authorizationHeaders = new HashMap<String, String>();
359 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
360 RestResponse restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceDetails, artifactDetails,
361 designerUser, authorizationHeaders);
362 assertEquals("Check response code after download resource", 200, restResponse.getErrorCode().intValue());
364 // Validating headers
365 // content disposition
366 List<String> contDispHeaderList = restResponse.getHeaderFields().get(Constants.CONTENT_DISPOSITION_HEADER);
367 assertNotNull(contDispHeaderList);
368 assertEquals("Check content disposition header",
369 new StringBuilder().append("attachment; filename=\"").append(artifactName).append("\"").toString(),
370 contDispHeaderList.get(0));
373 List<String> contTypeHeaderList = restResponse.getHeaderFields().get(Constants.CONTENT_TYPE_HEADER);
374 assertNotNull(contTypeHeaderList);
375 assertEquals("Check content type", "application/octet-stream", contTypeHeaderList.get(0));
377 String actualContents = restResponse.getResponse();
379 assertEquals(artifactDetails.getPayload(), Base64.encodeBase64String(actualContents.getBytes()));
381 // validating checksum
382 byte[] bytes = actualContents.getBytes();
383 String actualPayloadChecksum = GeneralUtility.calculateMD5ByByteArray(bytes);
384 assertEquals(expectedPayloadChecksum, actualPayloadChecksum);
386 // validating valid zip
387 InputStream is = new ByteArrayInputStream(bytes);
388 InputStream zis = new ZipInputStream(is);
392 String auditAction = "DArtifactDownload";
394 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
395 ResourceRestUtils.ecomp, encodeUrlForDownload(relativeUrl), "200", "OK");
396 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
400 public void downloadResourceArtifact_NoConsumerId() throws Exception {
402 String artifactName = "kuku";
403 ArtifactReqDetails artifact = new ArtifactReqDetails();
404 artifact.setArtifactName(artifactName);
405 ResourceReqDetails resource = new ResourceReqDetails();
406 resource.setName("notExisting");
407 resource.setVersion("0.1");
408 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
409 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceBaseVersion,
410 ValidationUtils.convertToSystemName(resource.getName()), resource.getVersion(), artifactName));
411 serviceDetails.setVersion("0.1");
412 Map<String, String> authorizationHeaders = new HashMap<String, String>();
413 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
414 RestResponse restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceDetails, resource, artifact,
415 designerUser, authorizationHeaders, false);
416 assertEquals("Check response code after download resource", 400, restResponse.getErrorCode().intValue());
419 String auditAction = "DArtifactDownload";
421 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction, "",
422 relativeUrl, "400", "POL5001: Error: Missing 'X-ECOMP-InstanceID' HTTP header.");
423 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
427 public void downloadResourceArtifact_ResourceNameNotFound() throws Exception {
429 String artifactName = "kuku";
430 ArtifactReqDetails artifact = new ArtifactReqDetails();
431 artifact.setArtifactName(artifactName);
432 ResourceReqDetails resource = new ResourceReqDetails();
433 resource.setName("notExisting");
434 resource.setVersion("0.1");
435 serviceDetails.setVersion("0.1");
436 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
437 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceDetails.getVersion(),
438 ValidationUtils.convertToSystemName(resource.getName()), resource.getVersion(), artifactName));
440 Map<String, String> authorizationHeaders = new HashMap<String, String>();
441 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
442 RestResponse restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceDetails, resource, artifact,
443 designerUser, authorizationHeaders);
445 assertEquals("Check response code after download resource", 404, restResponse.getErrorCode().intValue());
448 String auditAction = "DArtifactDownload";
450 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
451 BaseRestUtils.ecomp, relativeUrl, "404",
452 "SVC4063: Error: Requested 'Notexisting' resource was not found.");
453 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
457 public void downloadResourceArtifact_ResourceVersionNotFound() throws Exception {
458 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, designerUser);
459 assertEquals("Check response code after creating resource", 201, createResource.getErrorCode().intValue());
461 Resource resource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
462 ResourceReqDetails resourceDetailes = new ResourceReqDetails();
463 resourceDetailes.setName(resource.getName());
464 resourceDetailes.setVersion("0.2");
466 serviceDetails.setVersion("0.1");
468 String artifactName = "kuku";
469 ArtifactReqDetails artifact = new ArtifactReqDetails();
470 artifact.setArtifactName(artifactName);
472 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
473 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceBaseVersion,
474 ValidationUtils.convertToSystemName(resourceDetailes.getName()), resourceDetailes.getVersion(),
477 Map<String, String> authorizationHeaders = new HashMap<String, String>();
478 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
479 RestResponse restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceDetails, resourceDetailes,
480 artifact, designerUser, authorizationHeaders);
481 assertEquals("Check response code after download resource", 404, restResponse.getErrorCode().intValue());
484 String auditAction = "DArtifactDownload";
486 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
487 BaseRestUtils.ecomp, relativeUrl, "404", "SVC4504: Error: Resource version 0.2 was not found.");
488 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
492 public void downloadResourceArtifact_ServiceNameNotFound() throws Exception {
494 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, designerUser);
495 assertEquals("Check response code after creating resource", 201, createResource.getErrorCode().intValue());
496 Resource resource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
497 download_serviceNameNotFound_inner("notExistingServiceName", serviceBaseVersion, resource.getName(),
498 resource.getVersion());
503 public void downloadResourceArtifact_ServiceVersionNotFound() throws Exception {
505 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, designerUser);
506 assertEquals("Check response code after creating resource", 201, createResource.getErrorCode().intValue());
507 Resource resource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
510 RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, designerUser);
511 assertEquals("Check response code after creating resource", 201, serviceResponse.getErrorCode().intValue());
512 serviceUniqueId = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse())
515 download_serviceVersionNotFound_inner(serviceDetails.getName(), "0.3", resource.getName(),
516 resource.getVersion());
520 public void downloadServiceArtifact_ServiceNameNotFound() throws Exception {
521 download_serviceNameNotFound_inner("notExistingServiceName", serviceBaseVersion, null, null);
526 public void downloadServiceArtifact_ServiceVersionNotFound() throws Exception {
529 RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, designerUser);
530 assertEquals("Check response code after creating resource", 201, serviceResponse.getErrorCode().intValue());
531 serviceUniqueId = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse())
534 download_serviceVersionNotFound_inner(serviceDetails.getName(), "0.2", null, null);