From e2cc2530fc6d54ebc975c01a4ff887ce12f0a736 Mon Sep 17 00:00:00 2001 From: Pavel Aharoni Date: Wed, 29 Mar 2017 13:35:45 +0300 Subject: [SDC-6] sdc-distribution-client 1707 rebasing Change-Id: I322a05fd79beb6ba4fee4d32afffecf531b86e98 Signed-off-by: Pavel Aharoni --- sdc-distribution-ci/.gitignore | 1 + sdc-distribution-ci/dependency-reduced-pom.xml | 116 +++++ sdc-distribution-ci/etc/asdc-client.jks | Bin 0 -> 1177 bytes sdc-distribution-ci/etc/asdcclientstore.jks | Bin 0 -> 907 bytes sdc-distribution-ci/log4j.properties | 17 + sdc-distribution-ci/pom.xml | 69 +++ .../java/org/openecomp/test/AdvanceCallBack.java | 72 +++ .../java/org/openecomp/test/ArtifactTypeEnum.java | 77 ++++ .../main/java/org/openecomp/test/ClientTest.java | 84 ++++ .../src/main/java/org/openecomp/test/Decoder.java | 62 +++ .../org/openecomp/test/NotificationCallback.java | 39 ++ .../java/org/openecomp/test/SimpleCallback.java | 309 +++++++++++++ .../org/openecomp/test/SimpleConfiguration.java | 187 ++++++++ .../main/resources/ci/conf/attsdc-packages.yaml | 10 + .../src/main/resources/ci/conf/attsdc.yaml | 35 ++ .../src/main/resources/ci/conf/log4j.properties | 34 ++ .../src/main/resources/ci/conf/titan.properties | 5 + .../src/main/resources/ci/scripts/startTest.sh | 87 ++++ .../ClientDownloadArtifact.java | 511 +++++++++++++++++++++ 19 files changed, 1715 insertions(+) create mode 100644 sdc-distribution-ci/.gitignore create mode 100644 sdc-distribution-ci/dependency-reduced-pom.xml create mode 100644 sdc-distribution-ci/etc/asdc-client.jks create mode 100644 sdc-distribution-ci/etc/asdcclientstore.jks create mode 100644 sdc-distribution-ci/log4j.properties create mode 100644 sdc-distribution-ci/pom.xml create mode 100644 sdc-distribution-ci/src/main/java/org/openecomp/test/AdvanceCallBack.java create mode 100644 sdc-distribution-ci/src/main/java/org/openecomp/test/ArtifactTypeEnum.java create mode 100644 sdc-distribution-ci/src/main/java/org/openecomp/test/ClientTest.java create mode 100644 sdc-distribution-ci/src/main/java/org/openecomp/test/Decoder.java create mode 100644 sdc-distribution-ci/src/main/java/org/openecomp/test/NotificationCallback.java create mode 100644 sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleCallback.java create mode 100644 sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java create mode 100644 sdc-distribution-ci/src/main/resources/ci/conf/attsdc-packages.yaml create mode 100644 sdc-distribution-ci/src/main/resources/ci/conf/attsdc.yaml create mode 100644 sdc-distribution-ci/src/main/resources/ci/conf/log4j.properties create mode 100644 sdc-distribution-ci/src/main/resources/ci/conf/titan.properties create mode 100644 sdc-distribution-ci/src/main/resources/ci/scripts/startTest.sh create mode 100644 sdc-distribution-ci/src/test/java/org/openecomp/sdc/ci/tests/execute/downloadArtifactUGN/ClientDownloadArtifact.java (limited to 'sdc-distribution-ci') diff --git a/sdc-distribution-ci/.gitignore b/sdc-distribution-ci/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/sdc-distribution-ci/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/sdc-distribution-ci/dependency-reduced-pom.xml b/sdc-distribution-ci/dependency-reduced-pom.xml new file mode 100644 index 0000000..428fc14 --- /dev/null +++ b/sdc-distribution-ci/dependency-reduced-pom.xml @@ -0,0 +1,116 @@ + + + + sdc-main-distribution-client + org.openecomp.sdc + 1.0.0 + + 4.0.0 + sdc-distribution-ci + SdcDistributionCI + ${sdc.distribution.ci.version} + Distribution CI for testing distribution client + + + + maven-compiler-plugin + 2.5.1 + true + + 1.8 + 1.8 + + + + maven-shade-plugin + 2.4.3 + + + package + + shade + + + + + org.openecomp.test.ClientTest + + + + + + + + + + + att + + + nexus + 2020 + http://mavencentral.it.att.com:8084/nexus/content/groups/2020SAPC/ + + + + + nexus + att-repository-releases + http://mavencentral.it.att.com:8084/nexus/content/repositories/att-repository-releases/ + + + nexus + att-repository-snapshots + http://mavencentral.it.att.com:8084/nexus/content/repositories/att-repository-snapshots/ + + + + + rackspace + + + rackspace-public + Rackspace + https://10.208.197.75:8443/repository/maven-public/ + + + + + rackspace-public + Rackspace + https://10.208.197.75:8443/repository/maven-releases/ + + + rackspace-snapshots + Rackspace-Snapshots + https://10.208.197.75:8443/repository/maven-snapshots/ + + + rackspace-public + dav:https://ecomp-nexus:8443/repository/sdn-c-javadoc/${project.version} + + + + + + + AttCentral + http://mavencentral.it.att.com:8084/nexus/content/repositories/att-repository-releases + + + + + commons-io + commons-io + 2.5 + provided + + + commons-codec + commons-codec + 1.9 + provided + + + + diff --git a/sdc-distribution-ci/etc/asdc-client.jks b/sdc-distribution-ci/etc/asdc-client.jks new file mode 100644 index 0000000..eb0a0d3 Binary files /dev/null and b/sdc-distribution-ci/etc/asdc-client.jks differ diff --git a/sdc-distribution-ci/etc/asdcclientstore.jks b/sdc-distribution-ci/etc/asdcclientstore.jks new file mode 100644 index 0000000..5dc006d Binary files /dev/null and b/sdc-distribution-ci/etc/asdcclientstore.jks differ diff --git a/sdc-distribution-ci/log4j.properties b/sdc-distribution-ci/log4j.properties new file mode 100644 index 0000000..80b2ca8 --- /dev/null +++ b/sdc-distribution-ci/log4j.properties @@ -0,0 +1,17 @@ +log4j.rootCategory=DEBUG, CONSOLE, LOGFILE + +log4j.logger.org.openecomp.sdc=TRACE, CONSOLE, LOGFILE + +# CONSOLE is set to be a ConsoleAppender using a PatternLayout. +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n + +# LOGFILE is set to be a File appender using a PatternLayout. +log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender +log4j.appender.LOGFILE.File=logs/wordnik.log +log4j.appender.LOGFILE.Append=true +log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout +log4j.appender.LOGFILE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n +log4j.appender.LOGFILE.MaxFileSize=10MB +log4j.appender.LOGFILE.MaxBackupIndex=10 diff --git a/sdc-distribution-ci/pom.xml b/sdc-distribution-ci/pom.xml new file mode 100644 index 0000000..6e97f34 --- /dev/null +++ b/sdc-distribution-ci/pom.xml @@ -0,0 +1,69 @@ + + + 4.0.0 + + + org.openecomp.sdc + sdc-main-distribution-client + 1.1.0-SNAPSHOT + + + sdc-distribution-ci + SdcDistributionCI + Distribution CI for testing distribution client + + + + + org.json + json + 20131018 + compile + + + + org.openecomp.sdc + sdc-distribution-client + ${project.version} + compile + + + + commons-io + commons-io + 2.5 + compile + + + + commons-codec + commons-codec + 1.9 + compile + + + + ch.qos.logback + logback-classic + ${logback.version} + compile + + + + ch.qos.logback + logback-core + ${logback.version} + compile + + + + junit + junit + ${junit.version} + compile + + + + + diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/AdvanceCallBack.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/AdvanceCallBack.java new file mode 100644 index 0000000..8b2b129 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/AdvanceCallBack.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.test; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.io.FileUtils; +import org.openecomp.sdc.api.IDistributionClient; +import org.openecomp.sdc.api.results.IDistributionClientDownloadResult; +import org.openecomp.sdc.utils.DistributionActionResultEnum; + +public class AdvanceCallBack extends SimpleCallback{ + + + + public AdvanceCallBack(IDistributionClient client) { + super(client); + // TODO Auto-generated constructor stub + } + + @Override + protected void postDownloadLogic( IDistributionClientDownloadResult downloadResult) { + if( downloadResult.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS){ + saveArtifactPayloadToDisk(downloadResult); + } + + } + + protected void saveFile(byte[] bs, String fileName) { + try { + String downloadPath = SimpleConfiguration.downloadPath(); + FileOutputStream fileOuputStream = new FileOutputStream(downloadPath + fileName); + fileOuputStream.write(bs); + fileOuputStream.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + protected void saveArtifactPayloadToDisk(IDistributionClientDownloadResult downloadResult) { + System.out.println("################ Downloaded Artifact Payload Start ################"); + String fileName = downloadResult.getArtifactName().replaceAll("attachment; filename=",""); + saveFile(downloadResult.getArtifactPayload(), fileName.replaceAll("\"", "")); + System.out.println("################ Downloaded Artifact Payload End ################"); + } + + + + +} diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/ArtifactTypeEnum.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/ArtifactTypeEnum.java new file mode 100644 index 0000000..7d79571 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/ArtifactTypeEnum.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.test; + +import java.util.ArrayList; +import java.util.List; + +/** + * Enum That Represents possible Artifacts Types. + * + */ +public enum ArtifactTypeEnum { + CHEF("CHEF"), PUPPET("PUPPET"), YANG("YANG"), SHELL_SCRIPT("SHELL_SCRIPT"), ICON("ICON"), UNKNOWN("UNKNOWN"), HEAT("HEAT"), DG_XML("DG_XML"), MURANO_PKG("MURANO_PKG"), + HEAT_ENV("HEAT_ENV"), YANG_XML("YANG_XML"), HEAT_VOL("HEAT_VOL"), HEAT_NET("HEAT_NET"), OTHER("OTHER"), WORKFLOW("WORKFLOW"), NETWORK_CALL_FLOW("NETWORK_CALL_FLOW"), + TOSCA_TEMPLATE("TOSCA_TEMPLATE"), TOSCA_CSAR("TOSCA_CSAR"), VNF_CATALOG("VNF_CATALOG"), VF_LICENSE("VF_LICENSE"), VENDOR_LICENSE("VENDOR_LICENSE"), + MODEL_INVENTORY_PROFILE("MODEL_INVENTORY_PROFILE"), MODEL_QUERY_SPEC("MODEL_QUERY_SPEC"), APPC_CONFIG("APPC_CONFIG"), HEAT_NESTED("HEAT_NESTED"), + HEAT_ARTIFACT("HEAT_ARTIFACT"), VF_MODULES_METADATA("VF_MODULES_METADATA"), + // DCAE Artifacts + DCAE_TOSCA("DCAE_TOSCA"), DCAE_JSON("DCAE_JSON"), DCAE_POLICY("DCAE_POLICY"), DCAE_DOC("DCAE_DOC"), DCAE_EVENT("DCAE_EVENT"), DCAE_INVENTORY_TOSCA("DCAE_INVENTORY_TOSCA"), + DCAE_INVENTORY_JSON("DCAE_INVENTORY_JSON"), DCAE_INVENTORY_POLICY("DCAE_INVENTORY_POLICY"), DCAE_INVENTORY_DOC("DCAE_INVENTORY_DOC"), + DCAE_INVENTORY_BLUEPRINT("DCAE_INVENTORY_BLUEPRINT"), DCAE_INVENTORY_EVENT("DCAE_INVENTORY_EVENT"), + // AAI Artifacts + AAI_SERVICE_MODEL("AAI_SERVICE_MODEL"), AAI_VF_MODEL("AAI_VF_MODEL"), AAI_VF_MODULE_MODEL("AAI_VF_MODULE_MODEL"), AAI_VF_INSTANCE_MODEL("AAI_VF_INSTANCE_MODEL"), + // MIB artifacts + SNMP_POLL ("SNMP_POLL"), SNMP_TRAP("SNMP_TRAP"), GUIDE("GUIDE") + ; + + ArtifactTypeEnum(String type) { + this.type = type; + } + + private String type; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public static ArtifactTypeEnum findType(final String type) { + for (ArtifactTypeEnum ate : ArtifactTypeEnum.values()) { + // According to Pavel/Ella + if (ate.getType().equalsIgnoreCase(type)) { + return ate; + } + } + return null; + } + + public static List getAllTypes() { + List types = new ArrayList(); + for (ArtifactTypeEnum ate : ArtifactTypeEnum.values()) { + types.add(ate.getType()); + } + return types; + } +} diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/ClientTest.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/ClientTest.java new file mode 100644 index 0000000..519684b --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/ClientTest.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.test; + +import java.io.IOException; + +import org.openecomp.sdc.api.IDistributionClient; +import org.openecomp.sdc.api.consumer.INotificationCallback; +import org.openecomp.sdc.api.results.IDistributionClientResult; +import org.openecomp.sdc.impl.DistributionClientFactory; +import org.openecomp.sdc.tosca.parser.impl.SdcCsarHelperImpl; +import org.openecomp.sdc.toscaparser.ToscaParser; +import org.openecomp.sdc.toscaparser.ToscaParserFactory; +import org.openecomp.sdc.toscaparser.api.ToscaTemplate; +import org.slf4j.LoggerFactory; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.LoggerContext; + +public class ClientTest { + public static void main(String[] args) throws Exception { + /* ToscaParserFactory toscaParserFactory = null; + try { + toscaParserFactory = new ToscaParserFactory(); + ToscaParser parser = toscaParserFactory.create(); + ToscaTemplate toscaTemplate = parser.parse("test.csar"); + SdcCsarHelperImpl csarHelper = new SdcCsarHelperImpl(toscaTemplate); + String serviceSubstitutionMappingsTypeName = csarHelper.getServiceSubstitutionMappingsTypeName(); + System.out.println("serviceSubstitutionMappingsTypeName is "+serviceSubstitutionMappingsTypeName); + } + catch (Exception e){ + System.out.println(e); + } + finally{ + if (toscaParserFactory != null){ + toscaParserFactory.close(); + } + }*/ + + LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); + lc.getLogger("org.apache.http").setLevel(Level.INFO); + + IDistributionClient client = DistributionClientFactory.createDistributionClient(); + INotificationCallback callback; + Boolean download = SimpleConfiguration.toDownload(); + if( download ){ + callback = new AdvanceCallBack(client); + } + else{ + callback = new SimpleCallback(client); + } + IDistributionClientResult result = client.init(new SimpleConfiguration(), callback); + + System.out.println(result.getDistributionMessageResult()); + + System.out.println("Starting client..."); + IDistributionClientResult startResult = client.start(); + + // Thread.sleep(10000); + // client.stop(); + + System.out.println(startResult.getDistributionMessageResult()); + + } + +} diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/Decoder.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/Decoder.java new file mode 100644 index 0000000..c7345f2 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/Decoder.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.test; + +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; + +import org.apache.commons.codec.binary.Base64; + +public class Decoder { + + public static String encode(byte[] byteArrayToEncode) { + + byte[] bytesEncoded = Base64.encodeBase64(byteArrayToEncode); + String strEncoded = new String(bytesEncoded); + return strEncoded; + } + + public static String decode(String strEncoded) throws IOException { + + byte[] byteDecoded = Base64.decodeBase64(strEncoded); + String decoded = new String(byteDecoded); + + return decoded; + + } + + public static String readFileToString(String file) throws IOException { + + BufferedReader reader = new BufferedReader(new FileReader(file)); + String line = null; + StringBuilder stringBuilder = new StringBuilder(); + String ls = System.getProperty("line.separator"); + + while ((line = reader.readLine()) != null) { + stringBuilder.append(line); + stringBuilder.append(ls); + } + reader.close(); + return stringBuilder.toString(); + } + +} diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/NotificationCallback.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/NotificationCallback.java new file mode 100644 index 0000000..3b2d772 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/NotificationCallback.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.test; + +import org.openecomp.sdc.api.IDistributionClient; +import org.openecomp.sdc.api.notification.INotificationData; + +public class NotificationCallback extends SimpleCallback{ + INotificationData latestCallbackData; + public INotificationData getData() { + return latestCallbackData; + } + public NotificationCallback(IDistributionClient client) { + super(client); + } + + public void activateCallback(INotificationData data) { + this.latestCallbackData = data; + super.activateCallback(data); + } +} diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleCallback.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleCallback.java new file mode 100644 index 0000000..1166109 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleCallback.java @@ -0,0 +1,309 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.test; + +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import org.openecomp.sdc.api.IDistributionClient; +import org.openecomp.sdc.api.consumer.IDistributionStatusMessage; +import org.openecomp.sdc.api.consumer.INotificationCallback; +import org.openecomp.sdc.api.notification.IArtifactInfo; +import org.openecomp.sdc.api.notification.INotificationData; +import org.openecomp.sdc.api.notification.IResourceInstance; +import org.openecomp.sdc.api.notification.IVfModuleMetadata; +import org.openecomp.sdc.api.results.IDistributionClientDownloadResult; +import org.openecomp.sdc.api.results.IDistributionClientResult; +import org.openecomp.sdc.utils.ArtifactTypeEnum; +import org.openecomp.sdc.utils.DistributionActionResultEnum; +import org.openecomp.sdc.utils.DistributionStatusEnum; + + +public class SimpleCallback implements INotificationCallback { + protected IDistributionClient client; + public List iArtifactInfo; + + public final Map simpleCallbackResults = new HashMap(); + + public Map getSimpleCallbackResults() { + return simpleCallbackResults; + } + + public List getIArtifactInfo(){ + return iArtifactInfo; + } + public SimpleCallback(IDistributionClient client) { + this.client = client; + } + + + + + + public void activateCallback(INotificationData data) { + + List artifacts = getArtifacts(data); + + + for (IArtifactInfo iArtifactInfo : artifacts) { + + IArtifactInfo artifactMetadataByUUID = data.getArtifactMetadataByUUID(iArtifactInfo.getArtifactUUID()); + assertEquals("check artifact checksum", iArtifactInfo.getArtifactChecksum(), artifactMetadataByUUID.getArtifactChecksum()); + System.out.println(artifactMetadataByUUID.getArtifactURL()); + if (artifactMetadataByUUID.getArtifactType().equals(ArtifactTypeEnum.VF_MODULES_METADATA)){ + IDistributionClientDownloadResult download = client.download(iArtifactInfo); + if (download.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS){ + List decodeVfModuleArtifact = client.decodeVfModuleArtifact(download.getArtifactPayload()); +// assertEquals("decoded not equal to actual group amount ", decodeVfModuleArtifact.size(), 2); + if (!decodeVfModuleArtifact.isEmpty()){ + for (IVfModuleMetadata moduleMetadata : decodeVfModuleArtifact) { + List moduleArtifacts = moduleMetadata.getArtifacts(); + if (moduleArtifacts != null) { + + for (String artifactId : moduleArtifacts) { + + IArtifactInfo artifactInfo = data.getArtifactMetadataByUUID(artifactId); + IDistributionClientDownloadResult downloadArt = client.download(artifactInfo); + assertEquals(downloadArt.getDistributionActionResult(), DistributionActionResultEnum.SUCCESS); + + } + + } + } + } + } + } + } + + + for (IArtifactInfo relevantArtifact : artifacts){ + // Download Artifact + IDistributionClientDownloadResult downloadResult = client.download(relevantArtifact); + + postDownloadLogic(downloadResult); + + + + simpleCallbackResults.put("downloadResult", downloadResult); + System.out.println("downloadResult: " + downloadResult.toString()); + System.out.println("<<<<<<<<<<< Artifact content >>>>>>>>>>"); + System.out.println(Decoder.encode(downloadResult.getArtifactPayload())); + + /////Print artifact content to console/////// + +// byte[] contentInBytes = BaseEncoding.base64().decode(Decoder.encode(downloadResult.getArtifactPayload())); +// try { +// System.out.println("Source content: " + new String(contentInBytes, "UTF-8")); +// } catch (UnsupportedEncodingException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } + System.out.println("ArtInfo_timeout: "+ relevantArtifact.getArtifactTimeout()); + System.out.println("ArtInfo_Art_description: "+ relevantArtifact.getArtifactDescription()); + System.out.println("ArtInfo_Art_CheckSum: "+ relevantArtifact.getArtifactChecksum()); + System.out.println("ArtInfo_Art_Url: "+ relevantArtifact.getArtifactURL()); + System.out.println("ArtInfo_Art_Type: "+ relevantArtifact.getArtifactType()); + System.out.println("ArtInfo_Art_Name: "+ relevantArtifact.getArtifactName()); + System.out.println("ArtInfo_UUID: " + relevantArtifact.getArtifactUUID()); + System.out.println("ArtInfo_Version: " + relevantArtifact.getArtifactVersion()); + System.out.println("ArtInfo_RelatedArtifacts: "+ relevantArtifact.getRelatedArtifacts()); + + System.out.println("ArtInfo_Serv_description: " + data.getServiceDescription()); + System.out.println("ArtInfo_Serv_Name: " + data.getServiceName()); + System.out.println("Get_serviceVersion: " + data.getServiceVersion()); + System.out.println("Get_Service_UUID: " + data.getServiceUUID()); + System.out.println("ArtInfo_DistributionId: " + data.getDistributionID()); + System.out.println("ArtInfo_ServiceInvariantUUID: " + data.getServiceInvariantUUID()); + + + // assertTrue("response code is not 200, returned :" + downloadResult.getDistributionActionResult(), downloadResult.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS ); + + try { + String payload = new String(downloadResult.getArtifactPayload()); +// System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"); +// System.out.println(payload); +// System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"); + + } catch (Exception e) { + System.out.println("catch"); +// break; + // TODO: handle exception + } + + + + + if (downloadResult.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS) { + handleSuccessfullDownload(data, relevantArtifact); + } else { + handleFailedDownload(data, relevantArtifact); + } + } +// if (data != null){ +// iArtifactInfo.addAll(artifacts); +// } + + } + + private List getArtifacts(INotificationData data) { + List ret = new ArrayList(); + List resources = data.getResources(); +// data.getArtifactMetadataByUUID(arg0) + List relevantArtifactTypes = client.getConfiguration().getRelevantArtifactTypes(); + + List collect = resources.stream().flatMap( e -> e.getArtifacts().stream()).filter(p -> relevantArtifactTypes.contains(p.getArtifactType() )).collect(Collectors.toList()); +// if( resources != null ){ +// for( IResourceInstance resourceInstance : resources){ +// if( resourceInstance.getArtifacts() != null ){ +// +// +// +// ret.addAll(resourceInstance.getArtifacts()); +// +// +// } +// } +// } + ret.addAll(collect); + + List servicesArt = data.getServiceArtifacts(); + if( servicesArt != null ){ + ret.addAll(servicesArt); + } + + System.out.println("I am here: " + ret.toString()); + return ret; + } + + + + private void handleFailedDownload(INotificationData data, + IArtifactInfo relevantArtifact) { + // Send Download Status + IDistributionClientResult sendDownloadStatus = client.sendDownloadStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.DOWNLOAD_ERROR)); + postDownloadStatusSendLogic(sendDownloadStatus); + } + + private void handleSuccessfullDownload(INotificationData data, IArtifactInfo relevantArtifact) { + // Send Download Status + IDistributionClientResult sendDownloadStatus = client.sendDownloadStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.DOWNLOAD_OK)); + + simpleCallbackResults.put("sendDownloadStatus", sendDownloadStatus); +// assertTrue("response code is not 200, returned :" + sendDownloadStatus.getDistributionActionResult(), sendDownloadStatus.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS ); + + // Doing deployment ... + postDownloadStatusSendLogic(sendDownloadStatus); + boolean isDeployedSuccessfully = handleDeployment(); + IDistributionClientResult deploymentStatus; + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (isDeployedSuccessfully) { + deploymentStatus = client.sendDeploymentStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.DEPLOY_OK)); + + simpleCallbackResults.put("sendDeploymentStatus", deploymentStatus); +// assertTrue("response code is not 200, returned :" + deploymentStatus.getDistributionActionResult(), deploymentStatus.getDistributionActionResult() == DistributionActionResultEnum.SUCCESS ); + + } else { + deploymentStatus = handleFailedDeployment(data, relevantArtifact); + } + + postDeploymentStatusSendLogic(deploymentStatus); + } + + private IDistributionClientResult handleFailedDeployment(INotificationData data, IArtifactInfo relevantArtifact) { + IDistributionClientResult deploymentStatus; + boolean isAlreadyDeployed = checkIsDeployed(); + if (isAlreadyDeployed) { + deploymentStatus = client.sendDeploymentStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.ALREADY_DEPLOYED)); + } else { + deploymentStatus = client.sendDeploymentStatus(buildStatusMessage(client, data, relevantArtifact, DistributionStatusEnum.DEPLOY_ERROR)); + } + return deploymentStatus; + } + + protected void postDownloadLogic(IDistributionClientDownloadResult downloadResult) { + // TODO Auto-generated method stub + + } + + private void postDownloadStatusSendLogic( + IDistributionClientResult sendDownloadStatus) { + // TODO Auto-generated method stub + + } + + private void postDeploymentStatusSendLogic( + IDistributionClientResult deploymentStatus) { + // TODO Auto-generated method stub + + } + + private boolean checkIsDeployed() { + return false; + } + + private boolean handleDeployment() { + return true; +// to return deploy_error use return false +// return false; + } + + public static IDistributionStatusMessage buildStatusMessage( + final IDistributionClient client, final INotificationData data, + final IArtifactInfo relevantArtifact, + final DistributionStatusEnum status) { + IDistributionStatusMessage statusMessage = new IDistributionStatusMessage() { + + public long getTimestamp() { + long currentTimeMillis = System.currentTimeMillis(); + return currentTimeMillis; + } + + public DistributionStatusEnum getStatus() { + return status; + } + + public String getDistributionID() { + return data.getDistributionID(); + } + + public String getConsumerID() { + return client.getConfiguration().getConsumerID(); + } + + public String getArtifactURL() { + return relevantArtifact.getArtifactURL(); + } + }; + return statusMessage; + } + + +} diff --git a/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java b/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java new file mode 100644 index 0000000..9c07c12 --- /dev/null +++ b/sdc-distribution-ci/src/main/java/org/openecomp/test/SimpleConfiguration.java @@ -0,0 +1,187 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.test; + +import java.util.List; + +import org.openecomp.sdc.api.consumer.IConfiguration; + +public class SimpleConfiguration implements IConfiguration{ + + /*public String getUser() + { + return System.getProperty("user"); + } + + public List getRelevantArtifactTypes() { + return ArtifactTypeEnum.getAllTypes(); + } + + public int getPollingTimeout() + { + return 20; + } + + public int getPollingInterval() + { + return 20; + } + + public String getPassword() + { + return System.getProperty("password"); + } + + public String getEnvironmentName() + { + return System.getProperty("env"); + } + + public String getConsumerID() + { + return System.getProperty("consumerID"); + } + + public String getConsumerGroup() + { + return System.getProperty("groupID"); + } + + public String getAsdcAddress() + { + return System.getProperty("beAddress"); + } + + public String getKeyStorePath() + { + return ""; + } + + public String getKeyStorePassword() + { + return "Aa123456"; + } + + public boolean activateServerTLSAuth() + { + return Boolean.parseBoolean(System.getProperty("auth")); +// res.add(ArtifactTypeEnum.HEAT_ARTIFACT); +// res.add(ArtifactTypeEnum.HEAT_ENV); +// res.add(ArtifactTypeEnum.MURANO_PKG); +// res.add(ArtifactTypeEnum.VF_LICENSE); +// res.add(ArtifactTypeEnum.APPC_CONFIG); +// res.add(ArtifactTypeEnum.MODEL_INVENTORY_PROFILE); +// res.add(ArtifactTypeEnum.VNF_CATALOG); +// res.add(ArtifactTypeEnum.APPC_CONFIG); +// res.add(ArtifactTypeEnum.VF_MODULES_METADATA); +// return "PROD-Tedy-Only"; +// return "A-AI"; +// return "A-AI"; + } + + @Override + public boolean isFilterInEmptyResources() { + return false; + } + + public static String downloadPath() { + return "c:\\temp\\"; + } + + public static Boolean toDownload() { + return false; + }*/ + + public String getUser() { + return "ci"; + } + + public List getRelevantArtifactTypes() { + +// List res = new ArrayList(); +// for (ArtifactTypeEnum type : AssetTypeEnum.values()){ +// res.add(type.name()); +// } + return ArtifactTypeEnum.getAllTypes(); + } + + + public int getPollingTimeout() { + return 20; + } + + public int getPollingInterval() { + return 20; + } + + public String getPassword() { + return "123456"; + } + + public String getEnvironmentName() { + return "PROD"; + } + + public String getConsumerID() { + return "consumerVasya"; + } + + public String getConsumerGroup() { + return "groupVasya"; + + } + + public static Boolean toDownload() { + return false; + } + + public static String downloadPath() { + return "c:\\temp\\"; + } + + public String getAsdcAddress() { + return "127.0.0.1:8443"; + } + + @Override + public String getKeyStorePath() { + //return ""; + return "etc/asdc-client.jks"; + } + + @Override + public String getKeyStorePassword() { + + return "Aa123456"; + } + + @Override + public boolean activateServerTLSAuth() { + + return false; + } + + @Override + public boolean isFilterInEmptyResources() { + return false; + } + +} diff --git a/sdc-distribution-ci/src/main/resources/ci/conf/attsdc-packages.yaml b/sdc-distribution-ci/src/main/resources/ci/conf/attsdc-packages.yaml new file mode 100644 index 0000000..34a78d9 --- /dev/null +++ b/sdc-distribution-ci/src/main/resources/ci/conf/attsdc-packages.yaml @@ -0,0 +1,10 @@ +packages: + - org.openecomp.sdc.ci.tests.execute.general + - org.openecomp.sdc.ci.tests.execute.user + - org.openecomp.sdc.ci.tests.execute.property + - org.openecomp.sdc.ci.tests.execute.lifecycle + - org.openecomp.sdc.ci.tests.execute.resource + - org.openecomp.sdc.ci.tests.execute.service + - org.openecomp.sdc.ci.tests.execute.artifacts + - org.openecomp.sdc.ci.tests.execute.imports + - org.openecomp.sdc.ci.tests.execute.category \ No newline at end of file diff --git a/sdc-distribution-ci/src/main/resources/ci/conf/attsdc.yaml b/sdc-distribution-ci/src/main/resources/ci/conf/attsdc.yaml new file mode 100644 index 0000000..a9c449e --- /dev/null +++ b/sdc-distribution-ci/src/main/resources/ci/conf/attsdc.yaml @@ -0,0 +1,35 @@ +outputFolder: target +reportName: index.html +catalogBeHost: behost +catalogFeHost: fehost +esHost: eshost +disributionClientHost: disClient +catalogFePort: 8181 +catalogBePort: 8080 +disributionClientPort: 8181 +esPort: 9200 +neoHost: neoHost +neoPort: 7474 +neoDBusername: neo4j +neoDBpassword: 123456 + +resourceConfigDir: src/test/resources/CI/tests +componentsConfigDir: src/test/resources/CI/components +importResourceConfigDir: src/test/resources/CI/importResource +importResourceTestsConfigDir: src/test/resources/CI/importResourceTests +errorConfigurationFile: ../catalog-be/src/main/resources/config/error-configuration.yaml + +titanPropertiesFile: src/main/resources/ci/conf/titan.properties + +stopOnClassFailure: false + +#List of non-abstract resources to keep during titan cleanup between tests +#Only 1.0 version will be kept +resourcesNotToDelete: + - tosca.nodes.Compute + - tosca.nodes.Database + - tosca.nodes.ObjectStorage + - tosca.nodes.BlockStorage + - tosca.nodes.LoadBalancer + - org.openecomp.resource.cp.Port + - org.openecomp.resource.vl.Network \ No newline at end of file diff --git a/sdc-distribution-ci/src/main/resources/ci/conf/log4j.properties b/sdc-distribution-ci/src/main/resources/ci/conf/log4j.properties new file mode 100644 index 0000000..3e159ec --- /dev/null +++ b/sdc-distribution-ci/src/main/resources/ci/conf/log4j.properties @@ -0,0 +1,34 @@ +# Define the root logger with appender file +log4j.rootLogger = DEBUG, FILE, stdout + +# Define the file appender +log4j.appender.FILE=org.apache.log4j.RollingFileAppender +log4j.appender.FILE.File=${targetlog}logs/ci-log.out + +# Define the layout for file appender +log4j.appender.FILE.layout=org.apache.log4j.PatternLayout +log4j.appender.FILE.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss} %5p [%10c] : %m%n + +# Set the maximum file size before rollover +log4j.appender.FILE.maxFileSize=5MB + +# Set the the backup index +log4j.appender.FILE.maxBackupIndex=10 + + +############################################################# + +# Direct log messages to stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +#log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %5p %10c:%L - %m%n + +log4j.logger.org.apache.cassandra.service.StorageProxy=DEBUG +log4j.logger.com.thinkaurelius.titan.diskstorage.cassandra.CassandraTransaction=INFO, FILE, stdout + +log4j.logger.org.openecomp.sdc.ci.tests.utils=TRACE, FILE, stdout +log4j.additivity.org.openecomp.sdc.ci.tests.utils=false + + diff --git a/sdc-distribution-ci/src/main/resources/ci/conf/titan.properties b/sdc-distribution-ci/src/main/resources/ci/conf/titan.properties new file mode 100644 index 0000000..691f4d6 --- /dev/null +++ b/sdc-distribution-ci/src/main/resources/ci/conf/titan.properties @@ -0,0 +1,5 @@ +storage.backend=cassandra +storage.hostname=cassandrahost +storage.port=9160 + +cache.db-cache = false \ No newline at end of file diff --git a/sdc-distribution-ci/src/main/resources/ci/scripts/startTest.sh b/sdc-distribution-ci/src/main/resources/ci/scripts/startTest.sh new file mode 100644 index 0000000..604903a --- /dev/null +++ b/sdc-distribution-ci/src/main/resources/ci/scripts/startTest.sh @@ -0,0 +1,87 @@ +#!/bin/bash + +function usage { + echo "Usage: $0 " +} + +function exitOnError() { + if [ $1 -ne 0 ] + then + echo "Failed running task $2" + exit 2 + fi +} + +if [ $# -lt 1 ] +then + usage + exit 2 +fi + +CURRENT_DIR=`pwd` +BASEDIR=$(dirname $0) + +if [ ${BASEDIR:0:1} = "/" ] +then + FULL_PATH=$BASEDIR +else + FULL_PATH=$CURRENT_DIR/$BASEDIR +fi + +LOGS_PROP_FILE=file:${FULL_PATH}/conf/log4j.properties +############################################# +TARGET_DIR=${FULL_PATH}/target +CONF_FILE=${FULL_PATH}/conf/attsdc.yaml +DEBUG=true +MainClass=org.openecomp.sdc.ci.tests.run.StartTest + +JAR_FILE=$1 + +#TARGET_DIR=`echo ${TARGET_DIR} | sed 's/\//\//g'` +#echo $TARGET_DIR + +TESTS_DIR=/opt/app/sdc/ci/resources/tests +COMPONENTS_DIR=/opt/app/sdc/ci/resources/components + +#sed -i 's#\(outputFolder:\).*#\1 '${TARGET_DIR}'#g' $CONF_FILE +#sed -i 's#\(resourceConfigDir:\).*#\1 '${TESTS_DIR}'#g' $CONF_FILE +#sed -i 's#\(componentsConfigDir:\).*#\1 '${COMPONENTS_DIR}'#g' $CONF_FILE +TARGET_LOG_DIR="${TARGET_DIR}/" + +mkdir -p ${TARGET_DIR} +if [ -d ${TARGET_DIR} ] +then + rm -rf ${TARGET_DIR}/* + exitOnError $? "Failed_to_delete_target_dir" +fi + +debug_port=8800 +#JAVA_OPTION="-javaagent:/var/tmp/jacoco/lib/jacocoagent.jar=destfile=jacoco-it.exec" +JAVA_OPTION="" +case "$2" in + -debug) echo "Debug mode, Listen on port $debug_port"; JAVA_OPTION="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${debug_port}" ;; + "") echo "Standard mode";; + *) echo "USAGE: startTest.sh [-debug]";; +esac + +cmd="java $JAVA_OPTION -DdisplayException=true -Dtargetlog=${TARGET_LOG_DIR} -Dconfig.resource=${CONF_FILE} -Ddebug=${DEBUG} -Dlog4j.configuration=${LOGS_PROP_FILE} -cp $JAR_FILE ${MainClass}" + +#echo $cmd +#console=`$cmd` + +if [ $DEBUG == "true" ] +then + $cmd +else + $cmd >> /dev/null +fi +status=`echo $?` + + + +echo "##################################################" +echo "################# status is ${status} #################" +echo "##################################################" + +exit $status + diff --git a/sdc-distribution-ci/src/test/java/org/openecomp/sdc/ci/tests/execute/downloadArtifactUGN/ClientDownloadArtifact.java b/sdc-distribution-ci/src/test/java/org/openecomp/sdc/ci/tests/execute/downloadArtifactUGN/ClientDownloadArtifact.java new file mode 100644 index 0000000..e52223d --- /dev/null +++ b/sdc-distribution-ci/src/test/java/org/openecomp/sdc/ci/tests/execute/downloadArtifactUGN/ClientDownloadArtifact.java @@ -0,0 +1,511 @@ +/*- + * ============LICENSE_START======================================================= + * sdc-distribution-client + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.ci.tests.execute.downloadArtifactUGN; + +import org.junit.Test; + +/** + * + * @author al714h + * US510007 - Story : ASDC Distr Client - Download Artifact + * following test set partially cover the US451327 - Story : API to download the specific artifact, cover the audit message. + */ + +//public class ClientDownloadArtifact extends AttSdcTest{ + public class ClientDownloadArtifact { + +// Logger logger = null; +// +// DistributionUtils distributionUtils = new DistributionUtils(); +// DownloadArtifactDetails downloadArtifactDetails = new DownloadArtifactDetails(); +// Utils utils = new Utils(); +// DbUtils dbUtils = new DbUtils(); +// UserUtils userUtils = new UserUtils(); +// ResourceUtils resourceUtils = new ResourceUtils(); +// ServiceUtils serviceUtils = new ServiceUtils(); +// ArtifactUtils artifactUtils = new ArtifactUtils(); +// private JSONParser jsonParser = new JSONParser(); +// + String serviceBaseVersion = "0.1"; +// +// @Before +// public void before() throws Exception { +// +// distributionUtils.resetInit(); +// dbUtils.cleanAllAudits(); +// } +// @Rule +// public static TestName name = new TestName(); +// +// } +// +// @Rule +// public static TestName name = new TestName(); +// +//// public ClientDownloadArtifact() { +//// super(name, ClientDownloadArtifact.class.getName()); +//// } +// +// ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource(); +//// get default artifact info to upload +// ArtifactDefinition uploadedResourceArtifactInfo = artifactUtils.constructDefaultArtifactInfo(); +//// set artifact info for download +// downloadArtifactDetails.setArtifactName(uploadedResourceArtifactInfo.getArtifactName()); +// String artifactName = downloadArtifactDetails.getArtifactName(); +//// Andrey TODO String resourceArtifactUrl = String.format(Urls.DOWNLOAD_RESOURCE_ARTIFACT,); +// +// int numOfResourcArtifacts = 1; +// RestResponse createCertifiedResourceWithArtifacts = resourceUtils.createCertifiedResourceWithArtifacts(resourceDetails, uploadedResourceArtifactInfo, numOfResourcArtifacts); +// +// +// +// try{ +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); +// distributionUtils.verifyDownloadedArtifact(downloadArtifactRestResponse, uploadedResourceArtifactInfo); +// +// // validate audit message server side +// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); +// String action = "ArtifactDownload"; +// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); +// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); +// }finally{ +//// delete created resource +// resourceUtils.deleteResource_allVersions(resourceDetails, UserUtils.getAdminDetails()); +// } + +// } + +// send all mandatory headers only + @Test + public void downloadServiceArtifactSuccess() throws Exception{ + +//// ServiceReqDetails serviceDetails = serviceUtils.createDefaultDetailsService(); +// ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(); +// Service service = new Service(); +// try{ +//// get default artifact info to upload +// ArtifactDefinition uploadedResourceArtifactInfo = artifactUtils.constructDefaultArtifactInfo(); +// uploadedResourceArtifactInfo.setArtifactType(ArtifactTypeEnum.HEAT.getType()); +// ArtifactDefinition uploadedServiceArtifactInfo = artifactUtils.constructDefaultArtifactInfo(); +// uploadedServiceArtifactInfo.setArtifactType(ArtifactTypeEnum.MURANO_PKG.getType()); +// +//// set artifact info for download +// downloadArtifactDetails.setArtifactName(uploadedServiceArtifactInfo.getArtifactName()); +// downloadArtifactDetails.setArtifactType(ArtifactTypeEnum.MURANO_PKG.getType()); +// String artifactName = downloadArtifactDetails.getArtifactName(); +// +//// create default resource details +// ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource(); +// +// int numOfResourcArtifacts = 1; +// service = serviceUtils.createCertifiedServiceWithResourceInstanceAndArtifacts(serviceDetails, resourceDetails, uploadedResourceArtifactInfo, uploadedServiceArtifactInfo , numOfResourcArtifacts); +// logger.debug("service version = " + service.getVersion()); +// logger.debug("service distribution status = " + service.getDistributionStatus()); +// RestResponse changeDistributionStateToApprove = serviceUtils.changeDistributionStateToApprove(service, UserUtils.getGovernorDetails1()); +// +// int status = changeDistributionStateToApprove.getErrorCode(); +// assertTrue("response code is not 200, returned :" + status, status == 200); +// +// serviceDetails.setVersion(service.getVersion()); +// serviceDetails.setUniqueId(service.getUniqueId()); +// +// String responseString = changeDistributionStateToApprove.getResponse(); +// Gson gson = new Gson(); +// service = gson.fromJson(responseString, Service.class); +// ServiceMetadataDataDefinition serviceMetadataDataDefinition = gson.fromJson(responseString, ServiceMetadataDataDefinition.class); +// service.setDistributionStatus(DistributionStatusEnum.findState(serviceMetadataDataDefinition.getDistributionStatus())); +// DistributionStatusEnum distributionStatus = service.getDistributionStatus(); +// assertNotNull("distribution state is null",distributionStatus.name()); +// assertTrue("the default distribution state is invalid", DistributionStatusEnum.DISTRIBUTION_APPROVED.equals(distributionStatus)); +// +// String serviceArtifactUrl = String.format(Urls.DISTRIBUTION_DOWNLOAD_ARTIFACT,service.getName(), service.getVersion(), artifactName); +// logger.debug("download service artifact url: "+ serviceArtifactUrl+ " serviceName = " + service.getName() + " service version = " + service.getVersion() + "service artifact name = " + artifactName); +// +// +//// Log.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +//// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); +//// distributionUtils.verifyDownloadedArtifact(downloadArtifactRestResponse, uploadedArtifactInfo); +//// +//// // validate audit message server side +//// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); +//// String action = "ArtifactDownload"; +//// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); +//// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); +// }finally{ +//// delete created service +// serviceUtils.deleteService_allVersions(serviceDetails, UserUtils.getAdminDetails()); +// } + +// @Test +// public void downloadServiceArtifactSuccess() throws Exception{ +// +//// ServiceReqDetails serviceDetails = serviceUtils.createDefaultDetailsService(); +// ServiceReqDetails serviceDetails = ElementFactory.getDefaultService(); +// Service service = new Service(); +// try{ +//// get default artifact info to upload +// ArtifactDefinition uploadedResourceArtifactInfo = artifactUtils.constructDefaultArtifactInfo(); +// uploadedResourceArtifactInfo.setArtifactType(ArtifactTypeEnum.HEAT.getType()); +// ArtifactDefinition uploadedServiceArtifactInfo = artifactUtils.constructDefaultArtifactInfo(); +// uploadedServiceArtifactInfo.setArtifactType(ArtifactTypeEnum.MURANO_PKG.getType()); +// +//// set artifact info for download +// downloadArtifactDetails.setArtifactName(uploadedServiceArtifactInfo.getArtifactName()); +// downloadArtifactDetails.setArtifactType(ArtifactTypeEnum.MURANO_PKG.getType()); +// String artifactName = downloadArtifactDetails.getArtifactName(); +// +//// create default resource details +// ResourceReqDetails resourceDetails = ElementFactory.getDefaultResource(); +// +// int numOfResourcArtifacts = 1; +// service = serviceUtils.createCertifiedServiceWithResourceInstanceAndArtifacts(serviceDetails, resourceDetails, uploadedResourceArtifactInfo, uploadedServiceArtifactInfo , numOfResourcArtifacts); +// logger.debug("service version = " + service.getVersion()); +// logger.debug("service distribution status = " + service.getDistributionStatus()); +// RestResponse changeDistributionStateToApprove = serviceUtils.changeDistributionStateToApprove(service, UserUtils.getGovernorDetails1()); +// +// int status = changeDistributionStateToApprove.getErrorCode(); +// assertTrue("response code is not 200, returned :" + status, status == 200); +// +// serviceDetails.setVersion(service.getVersion()); +// serviceDetails.setUniqueId(service.getUniqueId()); +// +// String responseString = changeDistributionStateToApprove.getResponse(); +// Gson gson = new Gson(); +// service = gson.fromJson(responseString, Service.class); +// ServiceMetadataDataDefinition serviceMetadataDataDefinition = gson.fromJson(responseString, ServiceMetadataDataDefinition.class); +// service.setDistributionStatus(DistributionStatusEnum.findState(serviceMetadataDataDefinition.getDistributionStatus())); +// DistributionStatusEnum distributionStatus = service.getDistributionStatus(); +// assertNotNull("distribution state is null",distributionStatus.name()); +// assertTrue("the default distribution state is invalid", DistributionStatusEnum.DISTRIBUTION_APPROVED.equals(distributionStatus)); +// +// String serviceArtifactUrl = String.format(Urls.DISTRIBUTION_DOWNLOAD_ARTIFACT,service.getName(), service.getVersion(), artifactName); +// logger.debug("download service artifact url: "+ serviceArtifactUrl+ " serviceName = " + service.getName() + " service version = " + service.getVersion() + "service artifact name = " + artifactName); +// +// +//// Log.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +//// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); +//// distributionUtils.verifyDownloadedArtifact(downloadArtifactRestResponse, uploadedArtifactInfo); +//// +//// // validate audit message server side +//// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); +//// String action = "ArtifactDownload"; +//// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); +//// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); +// }finally{ +//// delete created service +// serviceUtils.deleteService_allVersions(serviceDetails, UserUtils.getAdminDetails()); +// } +// +// } +// +//// Andrey not relevant, dev ci should cover, qa can't influence on sending headers +////// send all headers mandatory and not mandatory +//// @Test +//// public void downloadArtifactSuccessMandatoryAndNotMandatoryHeaders() throws Exception{ +//// +//// Log.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +//// +//// Map headersMap = new HashMap(); +//// headersMap.put(HttpHeaderEnum.X_ECOMP_InstanceID.getValue(), "instar_name"); // mandatory +//// headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), "usernamePassword"); // mandatory +//// headersMap.put(HttpHeaderEnum.ACCEPT.getValue(), "application/octet-stream"); // not mandatory +//// headersMap.put(HttpHeaderEnum.X_ECOMP_REQUEST_ID_HEADER.getValue(),downloadArtifactDetails.getResourceUUID());// not mandatory +//// Log.debug("headers detailes: "+ headersMap.toString()); +//// +//// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, headersMap); +//// distributionUtils.verifyDownloadedArtifact(downloadArtifactRestResponse); +//// +////// validate audit message server side +//// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); +//// String action = "ArtifactDownload"; +//// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); +//// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); +//// +//// } +// +// +////---------------------------------Failure scenario-------------------------------------------------------------------------------- +// +//// Andrey not relevant, dev ci should cover, qa can't influence on sending headers +////// missing InstanceID mandatory header +//// @Test +//// public void downloadArtifactMissingInstanceIdHeader() throws Exception, JSONException{ +//// +//// Log.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +//// +//// Map headersMap = new HashMap(); +//// headersMap.put(HttpHeaderEnum.AUTHORIZATION.getValue(), "usernamePassword"); // mandatory +//// Log.debug("headers detailes: "+ headersMap.toString()); +//// +//// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, headersMap); +//// +//// ErrorInfo errorInfo = utils.parseYaml(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID.name()); +//// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +//// +//// List variables = Arrays.asList(); +//// utils.checkBodyResponseOnError(ActionStatus.MISSING_X_ECOMP_INSTANCE_ID.name(), variables, downloadArtifactRestResponse.getResponse())); +//// +//// } +// +//// Andrey not relevant, dev ci should cover, qa can't influence on sending headers +////// missing Authorization mandatory header +//// @Test +//// public void downloadArtifactMissingAuthorizationHeader() throws Exception, JSONException{ +//// +//// Log.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +//// +//// Map headersMap = new HashMap(); +//// headersMap.put(HttpHeaderEnum.X_ECOMP_InstanceID.getValue(), "usernamePassword"); // mandatory +//// Log.debug("headers detailes: "+ headersMap.toString()); +//// +//// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, headersMap); +//// +//// ErrorInfo errorInfo = utils.parseYaml(ActionStatus.ECOMP_RESEND_WITH_BASIC_AUTHENTICATION_CREDENTIALS.name()); +//// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +//// +//// List variables = Arrays.asList(); +//// utils.checkBodyResponseOnError(ActionStatus.ECOMP_RESEND_WITH_BASIC_AUTHENTICATION_CREDENTIALS.name(), variables, downloadArtifactRestResponse.getResponse())); +//// +//// } +// +// +//// artifact not found +// @Test +// public void downloadArtifactArtifactNotFound() throws Exception, JSONException{ +// +// downloadArtifactDetails.setArtifactName("artifactNotExist"); +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// +// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); +// +// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.DISTRIBUTION_ARTIFACT_NOT_FOUND.name()); +// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +// +// List variables = Arrays.asList(); +// utils.checkBodyResponseOnError(ActionStatus.DISTRIBUTION_ARTIFACT_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); +// +//// validate audit message server side +// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); +// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); +// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; +// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); +// +// String action = "ArtifactDownload"; +// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); +// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); +// +// } +// +//// service not found +// @Test +// public void downloadArtifactServiceNameNotFound() throws Exception, JSONException{ +// +// downloadArtifactDetails.setArtifactURL("/sdc/v1/services/serviceNotExist/0.1/artifacts/aaa.hh"); +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// +// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); +// +// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.SERVICE_NOT_FOUND.name()); +// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +// +// List variables = Arrays.asList(); +// utils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); +// +//// validate audit message server side +// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); +// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); +//// TODO Andrey, change desc message +// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; +// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); +// +// String action = "ArtifactDownload"; +// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); +// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); +// +// } +// +// +//// service version not found +// @Test +// public void downloadArtifactServiceVersionNotFound() throws Exception, JSONException{ +// +// downloadArtifactDetails.setArtifactURL("/sdc/v1/services/serviceName/0.888/artifacts/aaa.hh"); +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// +// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); +// +// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.COMPONENT_VERSION_NOT_FOUND.name()); +// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +// +// List variables = Arrays.asList(); +// utils.checkBodyResponseOnError(ActionStatus.COMPONENT_VERSION_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); +// +//// validate audit message server side +// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); +// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); +//// TODO Andrey, change desc message +// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; +// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); +// +// String action = "ArtifactDownload"; +// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); +// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); +// +// } +// +//// invalid HTTP method, PUT HTTP method +// @Test +// public void downloadArtifactByPutMethod() throws Exception, JSONException{ +// +// String method = "PUT"; +// +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// +// RestResponse downloadArtifactRestResponse = distributionUtils.sendDownloadedArtifactByMethod(downloadArtifactDetails, null, method); +// +// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name()); +// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +// +// List variables = Arrays.asList(); +// utils.checkBodyResponseOnError(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name(), variables, downloadArtifactRestResponse.getResponse()); +// +// } +// +//// invalid HTTP method, DELETE HTTP method +// @Test +// public void downloadArtifactByDeleteMethod() throws Exception, JSONException{ +// +// String method = "DELETE"; +// downloadArtifactDetails.setArtifactName("artifactNotExist"); +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// +// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); +// +// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.DISTRIBUTION_ARTIFACT_NOT_FOUND.name()); +// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +// +// List variables = Arrays.asList(); +// utils.checkBodyResponseOnError(ActionStatus.DISTRIBUTION_ARTIFACT_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); +// +//// validate audit message server side +// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); +// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); +// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; +// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); +// +// String action = "ArtifactDownload"; +// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); +// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); +// +// downloadArtifactDetails.setArtifactURL("/sdc/v1/services/serviceNotExist/0.1/artifacts/aaa.hh"); +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// +// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); +// +// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.SERVICE_NOT_FOUND.name()); +// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +// +// List variables = Arrays.asList(); +// utils.checkBodyResponseOnError(ActionStatus.SERVICE_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); +// +//// validate audit message server side +// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); +// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); +//// TODO Andrey, change desc message +// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; +// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); +// +// String action = "ArtifactDownload"; +// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); +// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); +// downloadArtifactDetails.setArtifactURL("/sdc/v1/services/serviceName/0.888/artifacts/aaa.hh"); +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// +// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); +// +// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.COMPONENT_VERSION_NOT_FOUND.name()); +// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +// +// List variables = Arrays.asList(); +// utils.checkBodyResponseOnError(ActionStatus.COMPONENT_VERSION_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse()); +// +//// validate audit message server side +// ArtifactDownloadAuditMessageInfo expectedArtifactDownloadAuditMessageInfo = distributionUtils.constructDefaultArtifactDownloadAuditMessageInfo(); +// expectedArtifactDownloadAuditMessageInfo.setStatus(errorInfo.getCode().toString()); +//// TODO Andrey, change desc message +// String desc = "Error: Artifact " + downloadArtifactDetails.getArtifactName() + " was not found"; +// expectedArtifactDownloadAuditMessageInfo.setDesc(desc); +// +// String action = "ArtifactDownload"; +// ArtifactDownloadAuditMessageInfo actualArtifactDownloadAuditMessageInfo = userUtils.parseDestributionAuditRespByAction(action); +// distributionUtils.validateArtifactDownloadAuditMessage(actualArtifactDownloadAuditMessageInfo, expectedArtifactDownloadAuditMessageInfo); +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// +// RestResponse downloadArtifactRestResponse = distributionUtils.sendDownloadedArtifactByMethod(downloadArtifactDetails, null, method); +// +// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name()); +// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +// +// List variables = Arrays.asList(); +// utils.checkBodyResponseOnError(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name(), variables, downloadArtifactRestResponse.getResponse()); +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// +// RestResponse downloadArtifactRestResponse = distributionUtils.sendDownloadedArtifactByMethod(downloadArtifactDetails, null, method); +// +// ErrorInfo errorInfo = utils.parseErrorConfigYaml(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name()); +// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +// +// List variables = Arrays.asList(); +// utils.checkBodyResponseOnError(ActionStatus.METHOD_NOT_ALLOWED_TO_DOWNLOAD_ARTIFACT.name(), variables, downloadArtifactRestResponse.getResponse()); +// downloadArtifactDetails.setArtifactChecksum("invalidChecksum"); +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// +// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); +//// TODO +// +//// ErrorInfo errorInfo = utils.parseYaml(ActionStatus.SPECIFIED_SERVICE_RESOURCE_VERSION_NOT_FOUND.name()); +//// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +//// +//// List variables = Arrays.asList(); +//// utils.checkBodyResponseOnError(ActionStatus.SPECIFIED_SERVICE_RESOURCE_VERSION_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse())); +// +// downloadArtifactDetails.setArtifactChecksum("invalidChecksum"); +// logger.debug("artifact detailes: "+ downloadArtifactDetails.toString()); +// +// RestResponse downloadArtifactRestResponse = distributionUtils.sendGetDownloadedArtifact(downloadArtifactDetails, null); +//// TODO +// +//// ErrorInfo errorInfo = utils.parseYaml(ActionStatus.SPECIFIED_SERVICE_RESOURCE_VERSION_NOT_FOUND.name()); +//// assertEquals("Check response code after artifact download request", errorInfo.getCode(), downloadArtifactRestResponse.getErrorCode()); +//// +//// List variables = Arrays.asList(); +//// utils.checkBodyResponseOnError(ActionStatus.SPECIFIED_SERVICE_RESOURCE_VERSION_NOT_FOUND.name(), variables, downloadArtifactRestResponse.getResponse())); +// +// } +// +// +// +// + + } + +} -- cgit 1.2.3-korg