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 org.apache.commons.codec.binary.Base64;
24 import org.junit.Rule;
25 import org.junit.rules.TestName;
26 import org.openecomp.sdc.be.datatypes.elements.ConsumerDataDefinition;
27 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
28 import org.openecomp.sdc.be.model.ArtifactDefinition;
29 import org.openecomp.sdc.be.model.Resource;
30 import org.openecomp.sdc.be.model.User;
31 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
32 import org.openecomp.sdc.ci.tests.api.Urls;
33 import org.openecomp.sdc.ci.tests.config.Config;
34 import org.openecomp.sdc.ci.tests.datatypes.ArtifactReqDetails;
35 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
36 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
37 import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
38 import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
39 import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
40 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
41 import org.openecomp.sdc.ci.tests.datatypes.expected.ExpectedDistDownloadAudit;
42 import org.openecomp.sdc.ci.tests.datatypes.http.HttpHeaderEnum;
43 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
44 import org.openecomp.sdc.ci.tests.utils.Utils;
45 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
46 import org.openecomp.sdc.ci.tests.utils.rest.*;
47 import org.openecomp.sdc.ci.tests.utils.validation.AuditValidationUtils;
48 import org.openecomp.sdc.common.api.Constants;
49 import org.openecomp.sdc.common.util.GeneralUtility;
50 import org.openecomp.sdc.common.util.ValidationUtils;
51 import org.testng.AssertJUnit;
52 import org.testng.annotations.BeforeMethod;
53 import org.testng.annotations.Test;
55 import java.io.ByteArrayInputStream;
56 import java.io.InputStream;
57 import java.util.HashMap;
58 import java.util.List;
60 import java.util.zip.ZipInputStream;
62 import static org.testng.AssertJUnit.assertEquals;
63 import static org.testng.AssertJUnit.assertNotNull;
65 public class DistributionDownloadArtifactTest extends ComponentBaseTest {
67 protected static ResourceReqDetails resourceDetails;
68 protected static User designerUser;
69 protected static User adminUser;
70 protected static String resourceBaseVersion;
71 // user ci password 123456
72 protected final String authorizationHeader = "Basic Y2k6MTIzNDU2";
73 protected ConsumerDataDefinition consumerDataDefinition;
76 public static TestName name = new TestName();
77 protected static String artifactInterfaceType;
78 protected static String artifactOperationName;
80 protected static ServiceReqDetails serviceDetails;
81 protected static String serviceBaseVersion;
82 protected static String serviceUniqueId;
83 protected final String USER = "ci";
84 protected final String PASSWORD = "123456";
85 protected final String SALT = "2a1f887d607d4515d4066fe0f5452a50";
86 protected final String HASHED_PASSWORD = "0a0dc557c3bf594b1a48030e3e99227580168b21f44e285c69740b8d5b13e33b";
88 public DistributionDownloadArtifactTest() {
89 super(name, DistributionDownloadArtifactTest.class.getName());
93 // public static void InitBeforeTest() throws Exception
97 // resourceBaseVersion = "0.1";
98 // serviceBaseVersion = "0.1";
99 // designerUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
100 // adminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
102 // ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
103 // NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS,
105 // serviceDetails = ElementFactory.getDefaultService();
106 // serviceUniqueId = "svc_" + serviceDetails.getName().toLowerCase() + "." +
107 // serviceBaseVersion;
108 // artifactInterfaceType = "standard";
109 // artifactOperationName = "start";
113 public void setup() throws Exception {
115 resourceBaseVersion = "0.1";
116 serviceBaseVersion = "0.1";
117 designerUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
118 adminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
119 resourceDetails = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
120 NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, adminUser);
121 serviceDetails = ElementFactory.getDefaultService();
122 serviceUniqueId = "svc_" + serviceDetails.getName().toLowerCase() + "." + serviceBaseVersion;
123 artifactInterfaceType = "standard";
124 artifactOperationName = "start";
125 consumerDataDefinition = createConsumer();
126 RestResponse deleteResponse = ConsumerRestUtils.deleteConsumer(consumerDataDefinition, adminUser);
127 BaseRestUtils.checkStatusCode(deleteResponse, "delete operation filed", false, 404, 200);
129 RestResponse createResponse = ConsumerRestUtils.createConsumer(consumerDataDefinition, adminUser);
130 BaseRestUtils.checkCreateResponse(createResponse);
134 public void downloadResourceArtifactSuccess() throws Exception {
136 RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, designerUser);
137 AssertJUnit.assertEquals("Check response code after creating resource", 201,
138 serviceResponse.getErrorCode().intValue());
141 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, designerUser);
142 AssertJUnit.assertEquals("Check response code after creating resource", 201,
143 createResource.getErrorCode().intValue());
144 Resource resource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
146 ArtifactReqDetails artifactDetails = ElementFactory
147 .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
148 // Setting the name to be with space
149 artifactDetails.setArtifactName("test artifact file.yaml");
150 // artifactDetails.set(ArtifactRestUtils.calculateChecksum(artifactDetails));
152 RestResponse addArtifactResponse = ArtifactRestUtils.addInformationalArtifactToResource(artifactDetails,
153 designerUser, resource.getUniqueId(), ArtifactRestUtils.calculateChecksum(artifactDetails));
154 AssertJUnit.assertEquals("Check response code after adding interface artifact", 200,
155 addArtifactResponse.getErrorCode().intValue());
157 // Getting expected artifact checksum
158 ArtifactDefinition artifactResp = ResponseParser
159 .convertArtifactDefinitionResponseToJavaObject(addArtifactResponse.getResponse());
160 String expectedPayloadChecksum = artifactResp.getArtifactChecksum();
162 Config config = Utils.getConfig();
163 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
164 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceBaseVersion,
165 ValidationUtils.convertToSystemName(resource.getName()), resource.getVersion(),
166 artifactResp.getArtifactName()));
167 // String fullUrlFormatted =
168 // String.format(Urls.DOWNLOAD_RESOURCE_ARTIFACT_FULL_URL,
169 // config.getCatalogBeHost(),config.getCatalogBePort(), relativeUrl);
170 // String consumerId = "dummy.ecomp";
172 ResourceReqDetails resourceInfo = new ResourceReqDetails();
173 resourceInfo.setName(resource.getName());
174 resourceInfo.setVersion(resource.getVersion());
176 Map<String, String> authorizationHeaders = new HashMap<String, String>();
177 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
178 RestResponse restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceDetails, resourceInfo,
179 artifactDetails, designerUser, authorizationHeaders);
180 // RestResponse restResponse =
181 // artifactUtils.downloadResourceArtifact(designerUser,fullUrlFormatted,
183 AssertJUnit.assertEquals("Check response code after download resource", 200,
184 restResponse.getErrorCode().intValue());
186 // Validating headers
187 // content disposition
188 List<String> contDispHeaderList = restResponse.getHeaderFields().get(Constants.CONTENT_DISPOSITION_HEADER);
189 AssertJUnit.assertNotNull(contDispHeaderList);
192 "Check content disposition header", new StringBuilder().append("attachment; filename=\"")
193 .append(artifactResp.getArtifactName()).append("\"").toString(),
194 contDispHeaderList.get(0));
197 List<String> contTypeHeaderList = restResponse.getHeaderFields().get(Constants.CONTENT_TYPE_HEADER);
198 AssertJUnit.assertNotNull(contTypeHeaderList);
199 AssertJUnit.assertEquals("Check content type", "application/octet-stream", contTypeHeaderList.get(0));
201 String actualContents = restResponse.getResponse();
203 // Contents - comparing decoded content
204 AssertJUnit.assertEquals(artifactDetails.getPayload(), Base64.encodeBase64String(actualContents.getBytes()));
206 // validating checksum
207 String actualPayloadChecksum = GeneralUtility.calculateMD5Base64EncodedByByteArray(actualContents.getBytes());
208 AssertJUnit.assertEquals(expectedPayloadChecksum, actualPayloadChecksum);
211 String auditAction = "DArtifactDownload";
213 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
214 BaseRestUtils.ecomp, relativeUrl, "200", "OK");
215 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
218 protected void download_serviceNameNotFound_inner(String serviceName, String serviceVersion, String resourceName,
219 String resourceVersion) throws Exception {
220 Config config = Utils.getConfig();
221 String artifactName = "kuku";
222 ArtifactReqDetails artifact = new ArtifactReqDetails();
223 artifact.setArtifactName(artifactName);
225 Map<String, String> authorizationHeaders = new HashMap<String, String>();
226 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
227 ServiceReqDetails serviceInfo = new ServiceReqDetails();
228 serviceInfo.setName(serviceName);
229 serviceInfo.setVersion(serviceVersion);
230 RestResponse restResponse = null;
231 if (resourceName != null) {
232 ResourceReqDetails resourceDetailes = new ResourceReqDetails();
233 resourceDetailes.setName(resourceName);
234 resourceDetailes.setVersion(resourceVersion);
235 relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
236 ValidationUtils.convertToSystemName(serviceName), serviceVersion,
237 ValidationUtils.convertToSystemName(resourceName), resourceVersion, artifactName));
238 restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceInfo, resourceDetailes, artifact,
239 designerUser, authorizationHeaders);
241 relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_SERVICE_ARTIFACT_RELATIVE_URL,
242 ValidationUtils.convertToSystemName(serviceName), serviceVersion, artifactName));
243 restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceInfo, artifact, designerUser,
244 authorizationHeaders);
247 // RestResponse restResponse =
248 // artifactUtils.downloadResourceArtifact(designerUser,fullUrlFormatted,
250 AssertJUnit.assertEquals("Check response code after download resource", 404,
251 restResponse.getErrorCode().intValue());
254 String auditAction = "DArtifactDownload";
256 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
257 BaseRestUtils.ecomp, relativeUrl, "404", "SVC4503: Error: Requested '"
258 + ValidationUtils.convertToSystemName(serviceName) + "' service was not found.");
259 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
262 protected void download_serviceVersionNotFound_inner(String serviceName, String serviceVersion, String resourceName,
263 String resourceVersion) throws Exception {
264 Config config = Utils.getConfig();
265 String artifactName = "kuku";
267 ArtifactReqDetails artifact = new ArtifactReqDetails();
268 artifact.setArtifactName(artifactName);
269 Map<String, String> authorizationHeaders = new HashMap<String, String>();
270 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
271 ServiceReqDetails serviceInfo = new ServiceReqDetails();
272 serviceInfo.setName(serviceName);
273 serviceInfo.setVersion(serviceVersion);
274 RestResponse restResponse = null;
275 if (resourceName != null) {
276 ResourceReqDetails resourceDetailes = new ResourceReqDetails();
277 resourceDetailes.setName(resourceName);
278 resourceDetailes.setVersion(resourceVersion);
279 relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
280 ValidationUtils.convertToSystemName(serviceName), serviceVersion,
281 ValidationUtils.convertToSystemName(resourceName), resourceVersion, artifactName));
282 restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceInfo, resourceDetailes, artifact,
283 designerUser, authorizationHeaders);
285 relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_SERVICE_ARTIFACT_RELATIVE_URL,
286 ValidationUtils.convertToSystemName(serviceName), serviceVersion, artifactName));
287 restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceInfo, artifact, designerUser,
288 authorizationHeaders);
290 // String fullUrlFormatted =
291 // String.format(Urls.DOWNLOAD_RESOURCE_ARTIFACT_FULL_URL,
292 // config.getCatalogBeHost(),config.getCatalogBePort(), relativeUrl);
293 // String consumerId = "dummy.ecomp";
295 // RestResponse restResponse =
296 // artifactUtils.downloadResourceArtifact(designerUser,fullUrlFormatted,
298 AssertJUnit.assertEquals("Check response code after download resource", 404,
299 restResponse.getErrorCode().intValue());
302 String auditAction = "DArtifactDownload";
304 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
305 BaseRestUtils.ecomp, relativeUrl, "404",
306 "SVC4504: Error: Service version " + serviceVersion + " was not found.");
307 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
310 protected String encodeUrlForDownload(String url) {
311 return url.replaceAll(" ", "%20");
314 protected ConsumerDataDefinition createConsumer() {
315 ConsumerDataDefinition consumer = new ConsumerDataDefinition();
316 consumer.setConsumerName(USER);
317 consumer.setConsumerSalt(SALT);
318 consumer.setConsumerPassword(HASHED_PASSWORD);
323 @Test(enabled = true)
324 public void downloadServiceArtifactSuccess() throws Exception {
326 RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, designerUser);
327 assertEquals("Check response code after creating resource", 201, serviceResponse.getErrorCode().intValue());
328 serviceUniqueId = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse())
331 ArtifactReqDetails artifactDetails = ElementFactory.getDefaultDeploymentArtifactForType("MURANO_PKG");
333 RestResponse addArtifactResponse = ArtifactRestUtils.addInformationalArtifactToService(artifactDetails,
334 designerUser, serviceUniqueId, ArtifactRestUtils.calculateMD5Header(artifactDetails));
335 assertEquals("Check response code after adding interface artifact", 200,
336 addArtifactResponse.getErrorCode().intValue());
338 // Getting expected artifact checksum
340 // ArtifactResJavaObject artifactResp =
341 // artifactUtils.parseInformationalArtifactResp(addArtifactResponse);
342 String expectedPayloadChecksum = ResponseParser
343 .convertArtifactDefinitionResponseToJavaObject(addArtifactResponse.getResponse()).getArtifactChecksum();
345 String artifactName = ValidationUtils.normalizeFileName(artifactDetails.getArtifactName());
347 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_SERVICE_ARTIFACT_RELATIVE_URL,
348 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceBaseVersion, artifactName));
350 Map<String, String> authorizationHeaders = new HashMap<String, String>();
351 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
352 RestResponse restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceDetails, artifactDetails,
353 designerUser, authorizationHeaders);
354 assertEquals("Check response code after download resource", 200, restResponse.getErrorCode().intValue());
356 // Validating headers
357 // content disposition
358 List<String> contDispHeaderList = restResponse.getHeaderFields().get(Constants.CONTENT_DISPOSITION_HEADER);
359 assertNotNull(contDispHeaderList);
360 assertEquals("Check content disposition header",
361 new StringBuilder().append("attachment; filename=\"").append(artifactName).append("\"").toString(),
362 contDispHeaderList.get(0));
365 List<String> contTypeHeaderList = restResponse.getHeaderFields().get(Constants.CONTENT_TYPE_HEADER);
366 assertNotNull(contTypeHeaderList);
367 assertEquals("Check content type", "application/octet-stream", contTypeHeaderList.get(0));
369 String actualContents = restResponse.getResponse();
371 assertEquals(artifactDetails.getPayload(), Base64.encodeBase64String(actualContents.getBytes()));
373 // validating checksum
374 byte[] bytes = actualContents.getBytes();
375 String actualPayloadChecksum = GeneralUtility.calculateMD5Base64EncodedByByteArray(bytes);
376 assertEquals(expectedPayloadChecksum, actualPayloadChecksum);
378 // validating valid zip
379 InputStream is = new ByteArrayInputStream(bytes);
380 InputStream zis = new ZipInputStream(is);
384 String auditAction = "DArtifactDownload";
386 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
387 ResourceRestUtils.ecomp, encodeUrlForDownload(relativeUrl), "200", "OK");
388 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
392 public void downloadResourceArtifact_NoConsumerId() throws Exception {
394 String artifactName = "kuku";
395 ArtifactReqDetails artifact = new ArtifactReqDetails();
396 artifact.setArtifactName(artifactName);
397 ResourceReqDetails resource = new ResourceReqDetails();
398 resource.setName("notExisting");
399 resource.setVersion("0.1");
400 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
401 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceBaseVersion,
402 ValidationUtils.convertToSystemName(resource.getName()), resource.getVersion(), artifactName));
403 serviceDetails.setVersion("0.1");
404 Map<String, String> authorizationHeaders = new HashMap<String, String>();
405 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
406 RestResponse restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceDetails, resource, artifact,
407 designerUser, authorizationHeaders, false);
408 assertEquals("Check response code after download resource", 400, restResponse.getErrorCode().intValue());
411 String auditAction = "DArtifactDownload";
413 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction, "",
414 relativeUrl, "400", "POL5001: Error: Missing 'X-ECOMP-InstanceID' HTTP header.");
415 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
419 public void downloadResourceArtifact_ResourceNameNotFound() throws Exception {
421 String artifactName = "kuku";
422 ArtifactReqDetails artifact = new ArtifactReqDetails();
423 artifact.setArtifactName(artifactName);
424 ResourceReqDetails resource = new ResourceReqDetails();
425 resource.setName("notExisting");
426 resource.setVersion("0.1");
427 serviceDetails.setVersion("0.1");
428 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
429 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceDetails.getVersion(),
430 ValidationUtils.convertToSystemName(resource.getName()), resource.getVersion(), artifactName));
432 Map<String, String> authorizationHeaders = new HashMap<String, String>();
433 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
434 RestResponse restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceDetails, resource, artifact,
435 designerUser, authorizationHeaders);
437 assertEquals("Check response code after download resource", 404, restResponse.getErrorCode().intValue());
440 String auditAction = "DArtifactDownload";
442 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
443 BaseRestUtils.ecomp, relativeUrl, "404",
444 "SVC4063: Error: Requested 'Notexisting' resource was not found.");
445 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
449 public void downloadResourceArtifact_ResourceVersionNotFound() throws Exception {
450 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, designerUser);
451 assertEquals("Check response code after creating resource", 201, createResource.getErrorCode().intValue());
453 Resource resource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
454 ResourceReqDetails resourceDetailes = new ResourceReqDetails();
455 resourceDetailes.setName(resource.getName());
456 resourceDetailes.setVersion("0.2");
458 serviceDetails.setVersion("0.1");
460 String artifactName = "kuku";
461 ArtifactReqDetails artifact = new ArtifactReqDetails();
462 artifact.setArtifactName(artifactName);
464 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
465 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceBaseVersion,
466 ValidationUtils.convertToSystemName(resourceDetailes.getName()), resourceDetailes.getVersion(),
469 Map<String, String> authorizationHeaders = new HashMap<String, String>();
470 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
471 RestResponse restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceDetails, resourceDetailes,
472 artifact, designerUser, authorizationHeaders);
473 assertEquals("Check response code after download resource", 404, restResponse.getErrorCode().intValue());
476 String auditAction = "DArtifactDownload";
478 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
479 BaseRestUtils.ecomp, relativeUrl, "404", "SVC4504: Error: Resource version 0.2 was not found.");
480 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
484 public void downloadResourceArtifact_ServiceNameNotFound() throws Exception {
486 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, designerUser);
487 assertEquals("Check response code after creating resource", 201, createResource.getErrorCode().intValue());
488 Resource resource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
489 download_serviceNameNotFound_inner("notExistingServiceName", serviceBaseVersion, resource.getName(),
490 resource.getVersion());
495 public void downloadResourceArtifact_ServiceVersionNotFound() throws Exception {
497 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, designerUser);
498 assertEquals("Check response code after creating resource", 201, createResource.getErrorCode().intValue());
499 Resource resource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
502 RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, designerUser);
503 assertEquals("Check response code after creating resource", 201, serviceResponse.getErrorCode().intValue());
504 serviceUniqueId = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse())
507 download_serviceVersionNotFound_inner(serviceDetails.getName(), "0.3", resource.getName(),
508 resource.getVersion());
512 public void downloadServiceArtifact_ServiceNameNotFound() throws Exception {
513 download_serviceNameNotFound_inner("notExistingServiceName", serviceBaseVersion, null, null);
518 public void downloadServiceArtifact_ServiceVersionNotFound() throws Exception {
521 RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, designerUser);
522 assertEquals("Check response code after creating resource", 201, serviceResponse.getErrorCode().intValue());
523 serviceUniqueId = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse())
526 download_serviceVersionNotFound_inner(serviceDetails.getName(), "0.2", null, null);