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";
89 // public static void InitBeforeTest() throws Exception
93 // resourceBaseVersion = "0.1";
94 // serviceBaseVersion = "0.1";
95 // designerUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
96 // adminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
98 // ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
99 // NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS,
101 // serviceDetails = ElementFactory.getDefaultService();
102 // serviceUniqueId = "svc_" + serviceDetails.getName().toLowerCase() + "." +
103 // serviceBaseVersion;
104 // artifactInterfaceType = "standard";
105 // artifactOperationName = "start";
109 public void setup() throws Exception {
111 resourceBaseVersion = "0.1";
112 serviceBaseVersion = "0.1";
113 designerUser = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
114 adminUser = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
115 resourceDetails = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VFC,
116 NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, adminUser);
117 serviceDetails = ElementFactory.getDefaultService();
118 serviceUniqueId = "svc_" + serviceDetails.getName().toLowerCase() + "." + serviceBaseVersion;
119 artifactInterfaceType = "standard";
120 artifactOperationName = "start";
121 consumerDataDefinition = createConsumer();
122 RestResponse deleteResponse = ConsumerRestUtils.deleteConsumer(consumerDataDefinition, adminUser);
123 BaseRestUtils.checkStatusCode(deleteResponse, "delete operation filed", false, 404, 200);
125 RestResponse createResponse = ConsumerRestUtils.createConsumer(consumerDataDefinition, adminUser);
126 BaseRestUtils.checkCreateResponse(createResponse);
130 public void downloadResourceArtifactSuccess() throws Exception {
132 RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, designerUser);
133 AssertJUnit.assertEquals("Check response code after creating resource", 201,
134 serviceResponse.getErrorCode().intValue());
137 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, designerUser);
138 AssertJUnit.assertEquals("Check response code after creating resource", 201,
139 createResource.getErrorCode().intValue());
140 Resource resource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
142 ArtifactReqDetails artifactDetails = ElementFactory
143 .getDefaultDeploymentArtifactForType(ArtifactTypeEnum.HEAT.getType());
144 // Setting the name to be with space
145 artifactDetails.setArtifactName("test artifact file.yaml");
146 // artifactDetails.set(ArtifactRestUtils.calculateChecksum(artifactDetails));
148 RestResponse addArtifactResponse = ArtifactRestUtils.addInformationalArtifactToResource(artifactDetails,
149 designerUser, resource.getUniqueId(), ArtifactRestUtils.calculateChecksum(artifactDetails));
150 AssertJUnit.assertEquals("Check response code after adding interface artifact", 200,
151 addArtifactResponse.getErrorCode().intValue());
153 // Getting expected artifact checksum
154 ArtifactDefinition artifactResp = ResponseParser
155 .convertArtifactDefinitionResponseToJavaObject(addArtifactResponse.getResponse());
156 String expectedPayloadChecksum = artifactResp.getArtifactChecksum();
158 Config config = Utils.getConfig();
159 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
160 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceBaseVersion,
161 ValidationUtils.convertToSystemName(resource.getName()), resource.getVersion(),
162 artifactResp.getArtifactName()));
163 // String fullUrlFormatted =
164 // String.format(Urls.DOWNLOAD_RESOURCE_ARTIFACT_FULL_URL,
165 // config.getCatalogBeHost(),config.getCatalogBePort(), relativeUrl);
166 // String consumerId = "dummy.ecomp";
168 ResourceReqDetails resourceInfo = new ResourceReqDetails();
169 resourceInfo.setName(resource.getName());
170 resourceInfo.setVersion(resource.getVersion());
172 Map<String, String> authorizationHeaders = new HashMap<String, String>();
173 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
174 RestResponse restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceDetails, resourceInfo,
175 artifactDetails, designerUser, authorizationHeaders);
176 // RestResponse restResponse =
177 // artifactUtils.downloadResourceArtifact(designerUser,fullUrlFormatted,
179 AssertJUnit.assertEquals("Check response code after download resource", 200,
180 restResponse.getErrorCode().intValue());
182 // Validating headers
183 // content disposition
184 List<String> contDispHeaderList = restResponse.getHeaderFields().get(Constants.CONTENT_DISPOSITION_HEADER);
185 AssertJUnit.assertNotNull(contDispHeaderList);
188 "Check content disposition header", new StringBuilder().append("attachment; filename=\"")
189 .append(artifactResp.getArtifactName()).append("\"").toString(),
190 contDispHeaderList.get(0));
193 List<String> contTypeHeaderList = restResponse.getHeaderFields().get(Constants.CONTENT_TYPE_HEADER);
194 AssertJUnit.assertNotNull(contTypeHeaderList);
195 AssertJUnit.assertEquals("Check content type", "application/octet-stream", contTypeHeaderList.get(0));
197 String actualContents = restResponse.getResponse();
199 // Contents - comparing decoded content
200 AssertJUnit.assertEquals(artifactDetails.getPayload(), Base64.encodeBase64String(actualContents.getBytes()));
202 // validating checksum
203 String actualPayloadChecksum = GeneralUtility.calculateMD5Base64EncodedByByteArray(actualContents.getBytes());
204 AssertJUnit.assertEquals(expectedPayloadChecksum, actualPayloadChecksum);
207 String auditAction = "DArtifactDownload";
209 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
210 BaseRestUtils.ecomp, relativeUrl, "200", "OK");
211 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
214 protected void download_serviceNameNotFound_inner(String serviceName, String serviceVersion, String resourceName,
215 String resourceVersion) throws Exception {
216 Config config = Utils.getConfig();
217 String artifactName = "kuku";
218 ArtifactReqDetails artifact = new ArtifactReqDetails();
219 artifact.setArtifactName(artifactName);
221 Map<String, String> authorizationHeaders = new HashMap<String, String>();
222 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
223 ServiceReqDetails serviceInfo = new ServiceReqDetails();
224 serviceInfo.setName(serviceName);
225 serviceInfo.setVersion(serviceVersion);
226 RestResponse restResponse = null;
227 if (resourceName != null) {
228 ResourceReqDetails resourceDetailes = new ResourceReqDetails();
229 resourceDetailes.setName(resourceName);
230 resourceDetailes.setVersion(resourceVersion);
231 relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
232 ValidationUtils.convertToSystemName(serviceName), serviceVersion,
233 ValidationUtils.convertToSystemName(resourceName), resourceVersion, artifactName));
234 restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceInfo, resourceDetailes, artifact,
235 designerUser, authorizationHeaders);
237 relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_SERVICE_ARTIFACT_RELATIVE_URL,
238 ValidationUtils.convertToSystemName(serviceName), serviceVersion, artifactName));
239 restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceInfo, artifact, designerUser,
240 authorizationHeaders);
243 // RestResponse restResponse =
244 // artifactUtils.downloadResourceArtifact(designerUser,fullUrlFormatted,
246 AssertJUnit.assertEquals("Check response code after download resource", 404,
247 restResponse.getErrorCode().intValue());
250 String auditAction = "DArtifactDownload";
252 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
253 BaseRestUtils.ecomp, relativeUrl, "404", "SVC4503: Error: Requested '"
254 + ValidationUtils.convertToSystemName(serviceName) + "' service was not found.");
255 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
258 protected void download_serviceVersionNotFound_inner(String serviceName, String serviceVersion, String resourceName,
259 String resourceVersion) throws Exception {
260 Config config = Utils.getConfig();
261 String artifactName = "kuku";
263 ArtifactReqDetails artifact = new ArtifactReqDetails();
264 artifact.setArtifactName(artifactName);
265 Map<String, String> authorizationHeaders = new HashMap<String, String>();
266 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
267 ServiceReqDetails serviceInfo = new ServiceReqDetails();
268 serviceInfo.setName(serviceName);
269 serviceInfo.setVersion(serviceVersion);
270 RestResponse restResponse = null;
271 if (resourceName != null) {
272 ResourceReqDetails resourceDetailes = new ResourceReqDetails();
273 resourceDetailes.setName(resourceName);
274 resourceDetailes.setVersion(resourceVersion);
275 relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
276 ValidationUtils.convertToSystemName(serviceName), serviceVersion,
277 ValidationUtils.convertToSystemName(resourceName), resourceVersion, artifactName));
278 restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceInfo, resourceDetailes, artifact,
279 designerUser, authorizationHeaders);
281 relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_SERVICE_ARTIFACT_RELATIVE_URL,
282 ValidationUtils.convertToSystemName(serviceName), serviceVersion, artifactName));
283 restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceInfo, artifact, designerUser,
284 authorizationHeaders);
286 // String fullUrlFormatted =
287 // String.format(Urls.DOWNLOAD_RESOURCE_ARTIFACT_FULL_URL,
288 // config.getCatalogBeHost(),config.getCatalogBePort(), relativeUrl);
289 // String consumerId = "dummy.ecomp";
291 // RestResponse restResponse =
292 // artifactUtils.downloadResourceArtifact(designerUser,fullUrlFormatted,
294 AssertJUnit.assertEquals("Check response code after download resource", 404,
295 restResponse.getErrorCode().intValue());
298 String auditAction = "DArtifactDownload";
300 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
301 BaseRestUtils.ecomp, relativeUrl, "404",
302 "SVC4504: Error: Service version " + serviceVersion + " was not found.");
303 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
306 protected String encodeUrlForDownload(String url) {
307 return url.replaceAll(" ", "%20");
310 protected ConsumerDataDefinition createConsumer() {
311 ConsumerDataDefinition consumer = new ConsumerDataDefinition();
312 consumer.setConsumerName(USER);
313 consumer.setConsumerSalt(SALT);
314 consumer.setConsumerPassword(HASHED_PASSWORD);
319 @Test(enabled = true)
320 public void downloadServiceArtifactSuccess() throws Exception {
322 RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, designerUser);
323 assertEquals("Check response code after creating resource", 201, serviceResponse.getErrorCode().intValue());
324 serviceUniqueId = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse())
327 ArtifactReqDetails artifactDetails = ElementFactory.getDefaultDeploymentArtifactForType("MURANO_PKG");
329 RestResponse addArtifactResponse = ArtifactRestUtils.addInformationalArtifactToService(artifactDetails,
330 designerUser, serviceUniqueId, ArtifactRestUtils.calculateMD5Header(artifactDetails));
331 assertEquals("Check response code after adding interface artifact", 200,
332 addArtifactResponse.getErrorCode().intValue());
334 // Getting expected artifact checksum
336 // ArtifactResJavaObject artifactResp =
337 // artifactUtils.parseInformationalArtifactResp(addArtifactResponse);
338 String expectedPayloadChecksum = ResponseParser
339 .convertArtifactDefinitionResponseToJavaObject(addArtifactResponse.getResponse()).getArtifactChecksum();
341 String artifactName = ValidationUtils.normalizeFileName(artifactDetails.getArtifactName());
343 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_SERVICE_ARTIFACT_RELATIVE_URL,
344 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceBaseVersion, artifactName));
346 Map<String, String> authorizationHeaders = new HashMap<String, String>();
347 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
348 RestResponse restResponse = ArtifactRestUtils.downloadServiceArtifact(serviceDetails, artifactDetails,
349 designerUser, authorizationHeaders);
350 assertEquals("Check response code after download resource", 200, restResponse.getErrorCode().intValue());
352 // Validating headers
353 // content disposition
354 List<String> contDispHeaderList = restResponse.getHeaderFields().get(Constants.CONTENT_DISPOSITION_HEADER);
355 assertNotNull(contDispHeaderList);
356 assertEquals("Check content disposition header",
357 new StringBuilder().append("attachment; filename=\"").append(artifactName).append("\"").toString(),
358 contDispHeaderList.get(0));
361 List<String> contTypeHeaderList = restResponse.getHeaderFields().get(Constants.CONTENT_TYPE_HEADER);
362 assertNotNull(contTypeHeaderList);
363 assertEquals("Check content type", "application/octet-stream", contTypeHeaderList.get(0));
365 String actualContents = restResponse.getResponse();
367 assertEquals(artifactDetails.getPayload(), Base64.encodeBase64String(actualContents.getBytes()));
369 // validating checksum
370 byte[] bytes = actualContents.getBytes();
371 String actualPayloadChecksum = GeneralUtility.calculateMD5Base64EncodedByByteArray(bytes);
372 assertEquals(expectedPayloadChecksum, actualPayloadChecksum);
374 // validating valid zip
375 InputStream is = new ByteArrayInputStream(bytes);
376 InputStream zis = new ZipInputStream(is);
380 String auditAction = "DArtifactDownload";
382 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
383 ResourceRestUtils.ecomp, encodeUrlForDownload(relativeUrl), "200", "OK");
384 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
388 public void downloadResourceArtifact_NoConsumerId() throws Exception {
390 String artifactName = "kuku";
391 ArtifactReqDetails artifact = new ArtifactReqDetails();
392 artifact.setArtifactName(artifactName);
393 ResourceReqDetails resource = new ResourceReqDetails();
394 resource.setName("notExisting");
395 resource.setVersion("0.1");
396 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
397 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceBaseVersion,
398 ValidationUtils.convertToSystemName(resource.getName()), resource.getVersion(), artifactName));
399 serviceDetails.setVersion("0.1");
400 Map<String, String> authorizationHeaders = new HashMap<String, String>();
401 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
402 RestResponse restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceDetails, resource, artifact,
403 designerUser, authorizationHeaders, false);
404 assertEquals("Check response code after download resource", 400, restResponse.getErrorCode().intValue());
407 String auditAction = "DArtifactDownload";
409 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction, "",
410 relativeUrl, "400", "POL5001: Error: Missing 'X-ECOMP-InstanceID' HTTP header.");
411 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
415 public void downloadResourceArtifact_ResourceNameNotFound() throws Exception {
417 String artifactName = "kuku";
418 ArtifactReqDetails artifact = new ArtifactReqDetails();
419 artifact.setArtifactName(artifactName);
420 ResourceReqDetails resource = new ResourceReqDetails();
421 resource.setName("notExisting");
422 resource.setVersion("0.1");
423 serviceDetails.setVersion("0.1");
424 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
425 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceDetails.getVersion(),
426 ValidationUtils.convertToSystemName(resource.getName()), resource.getVersion(), artifactName));
428 Map<String, String> authorizationHeaders = new HashMap<String, String>();
429 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
430 RestResponse restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceDetails, resource, artifact,
431 designerUser, authorizationHeaders);
433 assertEquals("Check response code after download resource", 404, restResponse.getErrorCode().intValue());
436 String auditAction = "DArtifactDownload";
438 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
439 BaseRestUtils.ecomp, relativeUrl, "404",
440 "SVC4063: Error: Requested 'Notexisting' resource was not found.");
441 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
445 public void downloadResourceArtifact_ResourceVersionNotFound() throws Exception {
446 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, designerUser);
447 assertEquals("Check response code after creating resource", 201, createResource.getErrorCode().intValue());
449 Resource resource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
450 ResourceReqDetails resourceDetailes = new ResourceReqDetails();
451 resourceDetailes.setName(resource.getName());
452 resourceDetailes.setVersion("0.2");
454 serviceDetails.setVersion("0.1");
456 String artifactName = "kuku";
457 ArtifactReqDetails artifact = new ArtifactReqDetails();
458 artifact.setArtifactName(artifactName);
460 String relativeUrl = encodeUrlForDownload(String.format(Urls.DISTRIB_DOWNLOAD_RESOURCE_ARTIFACT_RELATIVE_URL,
461 ValidationUtils.convertToSystemName(serviceDetails.getName()), serviceBaseVersion,
462 ValidationUtils.convertToSystemName(resourceDetailes.getName()), resourceDetailes.getVersion(),
465 Map<String, String> authorizationHeaders = new HashMap<String, String>();
466 authorizationHeaders.put(HttpHeaderEnum.AUTHORIZATION.getValue(), authorizationHeader);
467 RestResponse restResponse = ArtifactRestUtils.downloadResourceArtifact(serviceDetails, resourceDetailes,
468 artifact, designerUser, authorizationHeaders);
469 assertEquals("Check response code after download resource", 404, restResponse.getErrorCode().intValue());
472 String auditAction = "DArtifactDownload";
474 ExpectedDistDownloadAudit expectedDistDownloadAudit = new ExpectedDistDownloadAudit(auditAction,
475 BaseRestUtils.ecomp, relativeUrl, "404", "SVC4504: Error: Resource version 0.2 was not found.");
476 AuditValidationUtils.validateAudit(expectedDistDownloadAudit, auditAction);
480 public void downloadResourceArtifact_ServiceNameNotFound() throws Exception {
482 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, designerUser);
483 assertEquals("Check response code after creating resource", 201, createResource.getErrorCode().intValue());
484 Resource resource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
485 download_serviceNameNotFound_inner("notExistingServiceName", serviceBaseVersion, resource.getName(),
486 resource.getVersion());
491 public void downloadResourceArtifact_ServiceVersionNotFound() throws Exception {
493 RestResponse createResource = ResourceRestUtils.createResource(resourceDetails, designerUser);
494 assertEquals("Check response code after creating resource", 201, createResource.getErrorCode().intValue());
495 Resource resource = ResponseParser.convertResourceResponseToJavaObject(createResource.getResponse());
498 RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, designerUser);
499 assertEquals("Check response code after creating resource", 201, serviceResponse.getErrorCode().intValue());
500 serviceUniqueId = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse())
503 download_serviceVersionNotFound_inner(serviceDetails.getName(), "0.3", resource.getName(),
504 resource.getVersion());
508 public void downloadServiceArtifact_ServiceNameNotFound() throws Exception {
509 download_serviceNameNotFound_inner("notExistingServiceName", serviceBaseVersion, null, null);
514 public void downloadServiceArtifact_ServiceVersionNotFound() throws Exception {
517 RestResponse serviceResponse = ServiceRestUtils.createService(serviceDetails, designerUser);
518 assertEquals("Check response code after creating resource", 201, serviceResponse.getErrorCode().intValue());
519 serviceUniqueId = ResponseParser.convertServiceResponseToJavaObject(serviceResponse.getResponse())
522 download_serviceVersionNotFound_inner(serviceDetails.getName(), "0.2", null, null);