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);
106 //// resourceDetails =
107 // ElementFactory.getDefaultResource("tosca.nodes.newnotgenericresource4testNew",
108 // NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS,
111 // ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
112 // NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS,
114 // serviceDetails = ElementFactory.getDefaultService();
115 // serviceUniqueId = "svc_" + serviceDetails.getName().toLowerCase() + "." +
116 // serviceBaseVersion;
117 // artifactInterfaceType = "standard";
118 // artifactOperationName = "start";
122 public void setup() throws Exception {
124 resourceBaseVersion = "0.1";
125 serviceBaseVersion = "0.1";
126 designerUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
127 adminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
129 // ElementFactory.getDefaultResource("tosca.nodes.newnotgenericresource4testNew",
130 // NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS,
132 resourceDetails = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
133 NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, adminUser);
134 serviceDetails = ElementFactory.getDefaultService();
135 serviceUniqueId = "svc_" + serviceDetails.getName().toLowerCase() + "." + serviceBaseVersion;
136 artifactInterfaceType = "standard";
137 artifactOperationName = "start";
138 consumerDataDefinition = createConsumer();
139 RestResponse deleteResponse = ConsumerRestUtils.deleteConsumer(consumerDataDefinition, adminUser);
140 BaseRestUtils.checkStatusCode(deleteResponse, "delete operation filed", false, 404, 200);
142 RestResponse createResponse = ConsumerRestUtils.createConsumer(consumerDataDefinition, adminUser);
143 BaseRestUtils.checkCreateResponse(createResponse);
147 public void downloadResourceArtifactSuccess() throws Exception {
149 RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, designerUser);
150 AssertJUnit.assertEquals("Check response code after creating resource", 201,
151 serviceResponse.getErrorCode().intValue());
154 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, designerUser);
155 AssertJUnit.assertEquals("Check response code after creating resource", 201,
156 createResource.getErrorCode().intValue());
157 Resource resource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
159 ArtifactReqDetails artifactDetails = ElementFactory
160 .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
161 // Setting the name to be with space
162 artifactDetails.setArtifactName("test artifact file.yaml");
163 // artifactDetails.set(ArtifactRestUtils.calculateChecksum(artifactDetails));
165 RestResponse addArtifactResponse = ArtifactRestUtils.addInformationalArtifactToResource(artifactDetails,
166 designerUser, resource.getUniqueId(), ArtifactRestUtils.calculateChecksum(artifactDetails));
167 AssertJUnit.assertEquals("Check response code after adding interface artifact", 200,
168 addArtifactResponse.getErrorCode().intValue());
170 // Getting expected artifact checksum
171 ArtifactDefinition artifactResp = ResponseParser
172 .convertArtifactDefinitionResponseToJavaObject(addArtifactResponse.getResponse());
173 String expectedPayloadChecksum = artifactResp.getArtifactChecksum();
175 Config config = Utils.getConfig();
176 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
177 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceBaseVersion,
178 ValidationUtils.convertToSystemName(resource.getName()), resource.getVersion(),
179 artifactResp.getArtifactName()));
180 // String fullUrlFormatted =
181 // String.format(Urls.DOWNLOAD_RESOURCE_ARTIFACT_FULL_URL,
182 // config.getCatalogBeHost(),config.getCatalogBePort(), relativeUrl);
183 // String consumerId = "dummy.ecomp";
185 ResourceReqDetails resourceInfo = new ResourceReqDetails();
186 resourceInfo.setName(resource.getName());
187 resourceInfo.setVersion(resource.getVersion());
189 Map<String, String> authorizationHeaders = new HashMap<String, String>();
190 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
191 RestResponse restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceDetails, resourceInfo,
192 artifactDetails, designerUser, authorizationHeaders);
193 // RestResponse restResponse =
194 // artifactUtils.downloadResourceArtifact(designerUser,fullUrlFormatted,
196 AssertJUnit.assertEquals("Check response code after download resource", 200,
197 restResponse.getErrorCode().intValue());
199 // Validating headers
200 // content disposition
201 List<String> contDispHeaderList = restResponse.getHeaderFields().get(Constants.CONTENT_DISPOSITION_HEADER);
202 AssertJUnit.assertNotNull(contDispHeaderList);
205 "Check content disposition header", new StringBuilder().append("attachment; filename=\"")
206 .append(artifactResp.getArtifactName()).append("\"").toString(),
207 contDispHeaderList.get(0));
210 List<String> contTypeHeaderList = restResponse.getHeaderFields().get(Constants.CONTENT_TYPE_HEADER);
211 AssertJUnit.assertNotNull(contTypeHeaderList);
212 AssertJUnit.assertEquals("Check content type", "application/octet-stream", contTypeHeaderList.get(0));
214 String actualContents = restResponse.getResponse();
216 // Contents - comparing decoded content
217 AssertJUnit.assertEquals(artifactDetails.getPayload(), Base64.encodeBase64String(actualContents.getBytes()));
219 // validating checksum
220 String actualPayloadChecksum = GeneralUtility.calculateMD5ByByteArray(actualContents.getBytes());
221 AssertJUnit.assertEquals(expectedPayloadChecksum, actualPayloadChecksum);
224 String auditAction = "DArtifactDownload";
226 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
227 BaseRestUtils.ecomp, relativeUrl, "200", "OK");
228 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
231 protected void download_serviceNameNotFound_inner(String serviceName, String serviceVersion, String resourceName,
232 String resourceVersion) throws Exception {
233 Config config = Utils.getConfig();
234 String artifactName = "kuku";
235 ArtifactReqDetails artifact = new ArtifactReqDetails();
236 artifact.setArtifactName(artifactName);
238 Map<String, String> authorizationHeaders = new HashMap<String, String>();
239 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
240 ServiceReqDetails serviceInfo = new ServiceReqDetails();
241 serviceInfo.setName(serviceName);
242 serviceInfo.setVersion(serviceVersion);
243 RestResponse restResponse = null;
244 if (resourceName != null) {
245 ResourceReqDetails resourceDetailes = new ResourceReqDetails();
246 resourceDetailes.setName(resourceName);
247 resourceDetailes.setVersion(resourceVersion);
248 relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
249 ValidationUtils.convertToSystemName(serviceName), serviceVersion,
250 ValidationUtils.convertToSystemName(resourceName), resourceVersion, artifactName));
251 restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceInfo, resourceDetailes, artifact,
252 designerUser, authorizationHeaders);
254 relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_SERVICE_ARTIFACT_RELATIVE_URL,
255 ValidationUtils.convertToSystemName(serviceName), serviceVersion, artifactName));
256 restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceInfo, artifact, designerUser,
257 authorizationHeaders);
260 // RestResponse restResponse =
261 // artifactUtils.downloadResourceArtifact(designerUser,fullUrlFormatted,
263 AssertJUnit.assertEquals("Check response code after download resource", 404,
264 restResponse.getErrorCode().intValue());
267 String auditAction = "DArtifactDownload";
269 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
270 BaseRestUtils.ecomp, relativeUrl, "404", "SVC4503: Error: Requested '"
271 + ValidationUtils.convertToSystemName(serviceName) + "' service was not found.");
272 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
275 protected void download_serviceVersionNotFound_inner(String serviceName, String serviceVersion, String resourceName,
276 String resourceVersion) throws Exception {
277 Config config = Utils.getConfig();
278 String artifactName = "kuku";
280 ArtifactReqDetails artifact = new ArtifactReqDetails();
281 artifact.setArtifactName(artifactName);
282 Map<String, String> authorizationHeaders = new HashMap<String, String>();
283 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
284 ServiceReqDetails serviceInfo = new ServiceReqDetails();
285 serviceInfo.setName(serviceName);
286 serviceInfo.setVersion(serviceVersion);
287 RestResponse restResponse = null;
288 if (resourceName != null) {
289 ResourceReqDetails resourceDetailes = new ResourceReqDetails();
290 resourceDetailes.setName(resourceName);
291 resourceDetailes.setVersion(resourceVersion);
292 relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
293 ValidationUtils.convertToSystemName(serviceName), serviceVersion,
294 ValidationUtils.convertToSystemName(resourceName), resourceVersion, artifactName));
295 restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceInfo, resourceDetailes, artifact,
296 designerUser, authorizationHeaders);
298 relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_SERVICE_ARTIFACT_RELATIVE_URL,
299 ValidationUtils.convertToSystemName(serviceName), serviceVersion, artifactName));
300 restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceInfo, artifact, designerUser,
301 authorizationHeaders);
303 // String fullUrlFormatted =
304 // String.format(Urls.DOWNLOAD_RESOURCE_ARTIFACT_FULL_URL,
305 // config.getCatalogBeHost(),config.getCatalogBePort(), relativeUrl);
306 // String consumerId = "dummy.ecomp";
308 // RestResponse restResponse =
309 // artifactUtils.downloadResourceArtifact(designerUser,fullUrlFormatted,
311 AssertJUnit.assertEquals("Check response code after download resource", 404,
312 restResponse.getErrorCode().intValue());
315 String auditAction = "DArtifactDownload";
317 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
318 BaseRestUtils.ecomp, relativeUrl, "404",
319 "SVC4504: Error: Service version " + serviceVersion + " was not found.");
320 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
323 protected String encodeUrlForDownload(String url) {
324 return url.replaceAll(" ", "%20");
327 protected ConsumerDataDefinition createConsumer() {
328 ConsumerDataDefinition consumer = new ConsumerDataDefinition();
329 consumer.setConsumerName(USER);
330 consumer.setConsumerSalt(SALT);
331 consumer.setConsumerPassword(HASHED_PASSWORD);
336 @Test(enabled = false)
337 public void downloadServiceArtifactSuccess() throws Exception {
339 RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, designerUser);
340 assertEquals("Check response code after creating resource", 201, serviceResponse.getErrorCode().intValue());
341 serviceUniqueId = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse())
344 ArtifactReqDetails artifactDetails = ElementFactory.getDefaultDeploymentArtifactForType("MURANO_PKG");
346 RestResponse addArtifactResponse = ArtifactRestUtils.addInformationalArtifactToService(artifactDetails,
347 designerUser, serviceUniqueId, ArtifactRestUtils.calculateMD5Header(artifactDetails));
348 assertEquals("Check response code after adding interface artifact", 200,
349 addArtifactResponse.getErrorCode().intValue());
351 // Getting expected artifact checksum
353 // ArtifactResJavaObject artifactResp =
354 // artifactUtils.parseInformationalArtifactResp(addArtifactResponse);
355 String expectedPayloadChecksum = ResponseParser
356 .convertArtifactDefinitionResponseToJavaObject(addArtifactResponse.getResponse()).getArtifactChecksum();
358 String artifactName = ValidationUtils.normalizeFileName(artifactDetails.getArtifactName());
360 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_SERVICE_ARTIFACT_RELATIVE_URL,
361 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceBaseVersion, artifactName));
363 Map<String, String> authorizationHeaders = new HashMap<String, String>();
364 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
365 RestResponse restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceDetails, artifactDetails,
366 designerUser, authorizationHeaders);
367 assertEquals("Check response code after download resource", 200, restResponse.getErrorCode().intValue());
369 // Validating headers
370 // content disposition
371 List<String> contDispHeaderList = restResponse.getHeaderFields().get(Constants.CONTENT_DISPOSITION_HEADER);
372 assertNotNull(contDispHeaderList);
373 assertEquals("Check content disposition header",
374 new StringBuilder().append("attachment; filename=\"").append(artifactName).append("\"").toString(),
375 contDispHeaderList.get(0));
378 List<String> contTypeHeaderList = restResponse.getHeaderFields().get(Constants.CONTENT_TYPE_HEADER);
379 assertNotNull(contTypeHeaderList);
380 assertEquals("Check content type", "application/octet-stream", contTypeHeaderList.get(0));
382 String actualContents = restResponse.getResponse();
384 assertEquals(artifactDetails.getPayload(), Base64.encodeBase64String(actualContents.getBytes()));
386 // validating checksum
387 byte[] bytes = actualContents.getBytes();
388 String actualPayloadChecksum = GeneralUtility.calculateMD5ByByteArray(bytes);
389 assertEquals(expectedPayloadChecksum, actualPayloadChecksum);
391 // validating valid zip
392 InputStream is = new ByteArrayInputStream(bytes);
393 InputStream zis = new ZipInputStream(is);
397 String auditAction = "DArtifactDownload";
399 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
400 ResourceRestUtils.ecomp, encodeUrlForDownload(relativeUrl), "200", "OK");
401 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
405 public void downloadResourceArtifact_NoConsumerId() throws Exception {
407 String artifactName = "kuku";
408 ArtifactReqDetails artifact = new ArtifactReqDetails();
409 artifact.setArtifactName(artifactName);
410 ResourceReqDetails resource = new ResourceReqDetails();
411 resource.setName("notExisting");
412 resource.setVersion("0.1");
413 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
414 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceBaseVersion,
415 ValidationUtils.convertToSystemName(resource.getName()), resource.getVersion(), artifactName));
416 serviceDetails.setVersion("0.1");
417 Map<String, String> authorizationHeaders = new HashMap<String, String>();
418 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
419 RestResponse restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceDetails, resource, artifact,
420 designerUser, authorizationHeaders, false);
421 assertEquals("Check response code after download resource", 400, restResponse.getErrorCode().intValue());
424 String auditAction = "DArtifactDownload";
426 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction, "",
427 relativeUrl, "400", "POL5001: Error: Missing 'X-ECOMP-InstanceID' HTTP header.");
428 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
432 public void downloadResourceArtifact_ResourceNameNotFound() throws Exception {
434 String artifactName = "kuku";
435 ArtifactReqDetails artifact = new ArtifactReqDetails();
436 artifact.setArtifactName(artifactName);
437 ResourceReqDetails resource = new ResourceReqDetails();
438 resource.setName("notExisting");
439 resource.setVersion("0.1");
440 serviceDetails.setVersion("0.1");
441 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
442 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceDetails.getVersion(),
443 ValidationUtils.convertToSystemName(resource.getName()), resource.getVersion(), artifactName));
445 Map<String, String> authorizationHeaders = new HashMap<String, String>();
446 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
447 RestResponse restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceDetails, resource, artifact,
448 designerUser, authorizationHeaders);
450 assertEquals("Check response code after download resource", 404, restResponse.getErrorCode().intValue());
453 String auditAction = "DArtifactDownload";
455 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
456 BaseRestUtils.ecomp, relativeUrl, "404",
457 "SVC4063: Error: Requested 'Notexisting' resource was not found.");
458 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
462 public void downloadResourceArtifact_ResourceVersionNotFound() throws Exception {
463 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, designerUser);
464 assertEquals("Check response code after creating resource", 201, createResource.getErrorCode().intValue());
466 Resource resource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
467 ResourceReqDetails resourceDetailes = new ResourceReqDetails();
468 resourceDetailes.setName(resource.getName());
469 resourceDetailes.setVersion("0.2");
471 serviceDetails.setVersion("0.1");
473 String artifactName = "kuku";
474 ArtifactReqDetails artifact = new ArtifactReqDetails();
475 artifact.setArtifactName(artifactName);
477 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
478 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceBaseVersion,
479 ValidationUtils.convertToSystemName(resourceDetailes.getName()), resourceDetailes.getVersion(),
482 Map<String, String> authorizationHeaders = new HashMap<String, String>();
483 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
484 RestResponse restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceDetails, resourceDetailes,
485 artifact, designerUser, authorizationHeaders);
486 assertEquals("Check response code after download resource", 404, restResponse.getErrorCode().intValue());
489 String auditAction = "DArtifactDownload";
491 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
492 BaseRestUtils.ecomp, relativeUrl, "404", "SVC4504: Error: Resource version 0.2 was not found.");
493 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
497 public void downloadResourceArtifact_ServiceNameNotFound() throws Exception {
499 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, designerUser);
500 assertEquals("Check response code after creating resource", 201, createResource.getErrorCode().intValue());
501 Resource resource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
502 download_serviceNameNotFound_inner("notExistingServiceName", serviceBaseVersion, resource.getName(),
503 resource.getVersion());
508 public void downloadResourceArtifact_ServiceVersionNotFound() throws Exception {
510 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, designerUser);
511 assertEquals("Check response code after creating resource", 201, createResource.getErrorCode().intValue());
512 Resource resource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
515 RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, designerUser);
516 assertEquals("Check response code after creating resource", 201, serviceResponse.getErrorCode().intValue());
517 serviceUniqueId = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse())
520 download_serviceVersionNotFound_inner(serviceDetails.getName(), "0.3", resource.getName(),
521 resource.getVersion());
525 public void downloadServiceArtifact_ServiceNameNotFound() throws Exception {
526 download_serviceNameNotFound_inner("notExistingServiceName", serviceBaseVersion, null, null);
531 public void downloadServiceArtifact_ServiceVersionNotFound() throws Exception {
534 RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, designerUser);
535 assertEquals("Check response code after creating resource", 201, serviceResponse.getErrorCode().intValue());
536 serviceUniqueId = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse())
539 download_serviceVersionNotFound_inner(serviceDetails.getName(), "0.2", null, null);