diff options
Diffstat (limited to 'catalog-be/src/test')
13 files changed, 950 insertions, 1192 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java b/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java index b1c0330d4f..48a317bcf0 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java @@ -110,13 +110,7 @@ public class ElementOperationMock implements IElementOperation { } @Override - public Either<List<ArtifactType>, ActionStatus> getAllArtifactTypes() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Either<Map<String, Object>, ActionStatus> getAllDeploymentArtifactTypes() { + public List<ArtifactType> getAllArtifactTypes() { // TODO Auto-generated method stub return null; } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImplTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImplTest.java index 0b9542c269..bbe453e755 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImplTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/ArtifactInfoImplTest.java @@ -20,6 +20,9 @@ package org.openecomp.sdc.be.components.distribution.engine; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + import mockit.Deencapsulation; import org.junit.Assert; import org.junit.Test; @@ -130,23 +133,11 @@ public class ArtifactInfoImplTest extends BeConfDependentTest { } @Test - public void testGetArtifactType() throws Exception { - ArtifactInfoImpl testSubject; - ArtifactTypeEnum result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getArtifactType(); - } - - @Test - public void testSetArtifactType() throws Exception { - ArtifactInfoImpl testSubject; - ArtifactTypeEnum artifactType = null; - - // default test - testSubject = createTestSubject(); - testSubject.setArtifactType(ArtifactTypeEnum.AAI_SERVICE_MODEL); + public void testSetArtifactType() { + final ArtifactInfoImpl testSubject = createTestSubject(); + final String expectedType = ArtifactTypeEnum.AAI_SERVICE_MODEL.getType(); + testSubject.setArtifactType(expectedType); + assertThat("Artifact type should be the same", testSubject.getArtifactType(), is(expectedType)); } @Test diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java index e401df3920..3fb25dfc77 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java @@ -28,6 +28,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import fj.data.Either; +import java.util.Optional; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -37,11 +38,12 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.mockito.junit.MockitoJUnitRunner; import org.openecomp.sdc.be.components.ArtifactsResolver; +import org.openecomp.sdc.be.config.ArtifactConfigManager; import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic; import org.openecomp.sdc.be.components.utils.ArtifactBuilder; import org.openecomp.sdc.be.components.utils.ObjectGenerator; -import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig; -import org.openecomp.sdc.be.config.ConfigurationManager; +import org.openecomp.sdc.be.config.ArtifactConfiguration; +import org.openecomp.sdc.be.config.ComponentType; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao; import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus; @@ -432,15 +434,22 @@ public class ArtifactBusinessLogicTest extends BaseBusinessLogicMock{ } @Test - public void testValidMibAritactsConfiguration() { - Map<String, ArtifactTypeConfig> componentDeploymentArtifacts = - ConfigurationManager.getConfigurationManager().getConfiguration().getResourceDeploymentArtifacts(); - Map<String, ArtifactTypeConfig> componentInstanceDeploymentArtifacts = - ConfigurationManager.getConfigurationManager().getConfiguration().getResourceInstanceDeploymentArtifacts(); - assertThat(componentDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_POLL.getType())).isTrue(); - assertThat(componentDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_TRAP.getType())).isTrue(); - assertThat(componentInstanceDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_POLL.getType())).isTrue(); - assertThat(componentInstanceDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_TRAP.getType())).isTrue(); + public void testValidMibArtifactsConfiguration() { + final ArtifactConfigManager artifactConfigManager = ArtifactConfigManager.getInstance(); + Optional<ArtifactConfiguration> artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_POLL.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); + + artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_TRAP.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); + + artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_POLL.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE_INSTANCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); + artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_TRAP.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE_INSTANCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); } @Test diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java index edf561b717..cd7d9d556a 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java @@ -22,6 +22,28 @@ package org.openecomp.sdc.be.components.impl; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatCode; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_ENV_NAME; +import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_VF_ENV_NAME; + import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; @@ -30,6 +52,15 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; import fj.data.Either; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; import mockit.Deencapsulation; import org.apache.commons.codec.binary.Base64; import org.apache.commons.collections.CollectionUtils; @@ -48,11 +79,15 @@ import org.openecomp.sdc.be.MockGenerator; import org.openecomp.sdc.be.components.ArtifactsResolver; import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum; import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationInfo; +import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException; import org.openecomp.sdc.be.components.impl.exceptions.ComponentException; import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic; import org.openecomp.sdc.be.components.utils.ArtifactBuilder; import org.openecomp.sdc.be.components.utils.ObjectGenerator; import org.openecomp.sdc.be.components.validation.UserValidations; +import org.openecomp.sdc.be.config.ArtifactConfigManager; +import org.openecomp.sdc.be.config.ArtifactConfiguration; +import org.openecomp.sdc.be.config.ComponentType; import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -107,42 +142,13 @@ import org.openecomp.sdc.common.datastructure.Wrapper; import org.openecomp.sdc.common.util.GeneralUtility; import org.openecomp.sdc.exception.ResponseFormat; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyList; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_ENV_NAME; -import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_VF_ENV_NAME; - @RunWith(MockitoJUnitRunner.Silent.class) -public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ +public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock { private static final User USER = new User("John", "Doh", "jh0003", "jh0003@gmail.com", "ADMIN", System.currentTimeMillis()); private static final String RESOURCE_INSTANCE_NAME = "Service-111"; private static final String INSTANCE_ID = "S-123-444-ghghghg"; - private static final String ARTIFACT_NAME = "service-Myservice-template.yml"; private static final String ARTIFACT_LABEL = "assettoscatemplate"; private static final String ES_ARTIFACT_ID = "123123dfgdfgd0"; @@ -150,7 +156,6 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ private static final String RESOURCE_NAME = "My-Resource_Name with space"; private static final String RESOURCE_CATEGORY1 = "Network Layer 2-3"; private static final String RESOURCE_SUBCATEGORY = "Router"; - public static final String RESOURCE_CATEGORY = "Network Layer 2-3/Router"; private static final String ARTIFACT_PLACEHOLDER_FILE_EXTENSION = "fileExtension"; public static final Resource resource = Mockito.mock(Resource.class); @@ -158,7 +163,6 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ private ArtifactsBusinessLogic artifactBL; private static User user = null; private static Resource resourceResponse = null; - private static ResponseFormatManager responseManager = null; final ApplicationDataTypeCache applicationDataTypeCache = Mockito.mock(ApplicationDataTypeCache.class); @Mock public ComponentsUtils componentsUtils; @@ -196,15 +200,13 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ private Gson gson = new GsonBuilder().setPrettyPrinting().create(); private static List<ArtifactType> getAllTypes() { - List<ArtifactType> artifactTypes = new ArrayList<ArtifactType>(); - List<String> artifactTypesList = ConfigurationManager.getConfigurationManager().getConfiguration() - .getArtifactTypes(); - for (String artifactType : artifactTypesList) { - ArtifactType artifactT = new ArtifactType(); - artifactT.setName(artifactType); - artifactTypes.add(artifactT); - } - return artifactTypes; + final List<ArtifactConfiguration> artifactConfigurationList = ConfigurationManager.getConfigurationManager() + .getConfiguration().getArtifacts(); + return artifactConfigurationList.stream().map(artifactConfiguration -> { + final ArtifactType artifactType = new ArtifactType(); + artifactType.setName(artifactConfiguration.getType()); + return artifactType; + }).collect(Collectors.toList()); } @Before @@ -227,8 +229,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ when(userOperation.getUserData("jh0003", false)).thenReturn(Either.left(USER)); - Either<List<ArtifactType>, ActionStatus> getType = Either.left(getAllTypes()); - when(elementOperation.getAllArtifactTypes()).thenReturn(getType); + when(elementOperation.getAllArtifactTypes()).thenReturn(getAllTypes()); when(resource.getResourceType()).thenReturn(ResourceTypeEnum.VFC); @@ -665,15 +666,22 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ } @Test - public void testValidMibAritactsConfiguration() { - Map<String, ArtifactTypeConfig> componentDeploymentArtifacts = ConfigurationManager.getConfigurationManager() - .getConfiguration().getResourceDeploymentArtifacts(); - Map<String, ArtifactTypeConfig> componentInstanceDeploymentArtifacts = ConfigurationManager - .getConfigurationManager().getConfiguration().getResourceInstanceDeploymentArtifacts(); - assertThat(componentDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_POLL.getType())).isTrue(); - assertThat(componentDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_TRAP.getType())).isTrue(); - assertThat(componentInstanceDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_POLL.getType())).isTrue(); - assertThat(componentInstanceDeploymentArtifacts.containsKey(ArtifactTypeEnum.SNMP_TRAP.getType())).isTrue(); + public void testValidMibArtifactsConfiguration() { + final ArtifactConfigManager artifactConfigManager = ArtifactConfigManager.getInstance(); + Optional<ArtifactConfiguration> artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_POLL.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); + + artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_TRAP.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); + + artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_POLL.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE_INSTANCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); + artifactConfiguration = artifactConfigManager + .find(ArtifactTypeEnum.SNMP_TRAP.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, ComponentType.RESOURCE_INSTANCE); + assertThat(artifactConfiguration.isPresent()).isTrue(); } @Test @@ -1051,7 +1059,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ } @Test - public void testFindArtifactOnParentComponent() throws Exception { + public void testFindArtifactOnParentComponent() { ArtifactsBusinessLogic testSubject; Component component = createResourceObject(true); ComponentTypeEnum componentType = ComponentTypeEnum.RESOURCE; @@ -1063,7 +1071,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ // default test testSubject = createTestSubject(); - result = Deencapsulation.invoke(testSubject, "findArtifactOnParentComponent", new Object[]{component, + result = Deencapsulation.invoke(testSubject, "findArtifact", new Object[]{component, componentType, parentId, operation, artifactId}); } @@ -1154,9 +1162,8 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ new Object[]{componentId, instanceId, componentType}); } - @Test - public void testFindComponentInstance() throws Exception { + public void testFindComponentInstance() { ArtifactsBusinessLogic testSubject; String componentInstanceId = ""; Component component = createResourceObject(true); @@ -1168,9 +1175,8 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ new Object[]{componentInstanceId, component}); } - - @Test(expected= ComponentException.class) - public void testDeploymentArtifactTypeIsLegalForParent_shouldThrowException() throws Exception { + @Test(expected = ComponentException.class) + public void testDeploymentArtifactTypeIsLegalForParent_shouldThrowException() { ArtifactsBusinessLogic testSubject; ArtifactDefinition artifactInfo = buildArtifactPayload(); ArtifactTypeEnum artifactType = ArtifactTypeEnum.AAI_SERVICE_MODEL; @@ -1180,56 +1186,83 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ testSubject.validateDeploymentArtifactTypeIsLegalForParent(artifactInfo, artifactType, resourceDeploymentArtifacts); } - @Test - public void testFillDeploymentArtifactTypeConf() throws Exception { - ArtifactsBusinessLogic testSubject; - NodeTypeEnum parentType = NodeTypeEnum.AdditionalInfoParameters; - Map<String, ArtifactTypeConfig> result; + public void testLoadArtifactTypeConfig() { + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + //null artifactType + Optional<ArtifactConfiguration> artifactConfiguration = artifactsBusinessLogic.loadArtifactTypeConfig(null); + assertThat(artifactConfiguration.isPresent()).isFalse(); + //not configured artifactType + artifactConfiguration = artifactsBusinessLogic.loadArtifactTypeConfig("NotConfiguredArtifactType"); + assertThat(artifactConfiguration.isPresent()).isFalse(); - // default test - testSubject = createTestSubject(); - result = Deencapsulation.invoke(testSubject, "fillDeploymentArtifactTypeConf", - new Object[]{parentType}); + //valid artifactType + final String artifactType = ArtifactTypeEnum.YANG.getType(); + artifactConfiguration = artifactsBusinessLogic.loadArtifactTypeConfig(artifactType); + assertThat(artifactConfiguration.isPresent()).isTrue(); + final ArtifactConfiguration artifactConfiguration1 = artifactConfiguration.get(); + assertThat(artifactConfiguration1.getType()).isEqualTo(artifactType); + assertThat(artifactConfiguration1.getCategories()).hasSize(1); + assertThat(artifactConfiguration1.getCategories()).contains(ArtifactGroupTypeEnum.INFORMATIONAL); + assertThat(artifactConfiguration1.getComponentTypes()).hasSize(1); + assertThat(artifactConfiguration1.getComponentTypes()).contains(ComponentType.RESOURCE); + assertThat(artifactConfiguration1.getResourceTypes()).hasSize(7); + assertThat(artifactConfiguration1.getResourceTypes()) + .contains(ResourceTypeEnum.VFC.getValue(), ResourceTypeEnum.CP.getValue(), ResourceTypeEnum.VL.getValue(), + ResourceTypeEnum.VF.getValue(), ResourceTypeEnum.VFCMT.getValue(), "Abstract", + ResourceTypeEnum.CVFC.getValue()); } - @Test - public void testValidateArtifactTypeExists() throws Exception { - ArtifactsBusinessLogic testSubject; - Wrapper<ResponseFormat> responseWrapper = null; - ArtifactDefinition artifactInfo = buildArtifactPayload(); + public void testValidateArtifactExtension_acceptedExtension() { + final ArtifactDefinition artifactInfo = new ArtifactDefinition(); + artifactInfo.setArtifactName("artifact.yml"); + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + //empty accepted types + assertThatCode(() -> artifactsBusinessLogic.validateArtifactExtension(new ArtifactConfiguration(), artifactInfo)) + .doesNotThrowAnyException(); - // default test - testSubject = createTestSubject(); - testSubject.getValidArtifactType(artifactInfo); + final ArtifactConfiguration artifactConfiguration = new ArtifactConfiguration(); + artifactConfiguration.setAcceptedTypes(Arrays.asList("yml", "yaml")); + assertThatCode(() -> artifactsBusinessLogic.validateArtifactExtension(artifactConfiguration, artifactInfo)) + .doesNotThrowAnyException(); } + @Test(expected = ComponentException.class) + public void testValidateArtifactExtension_notAcceptedExtension() { + final ArtifactConfiguration artifactConfiguration = new ArtifactConfiguration(); + artifactConfiguration.setAcceptedTypes(Arrays.asList("yml", "yaml")); + final ArtifactDefinition artifactInfo = new ArtifactDefinition(); + //not accepted extension + artifactInfo.setArtifactName("artifact.xml"); - @Test - public void testGetDeploymentArtifactTypeConfig() throws Exception { - ArtifactsBusinessLogic testSubject; - NodeTypeEnum parentType = NodeTypeEnum.AdditionalInfoParameters; - ArtifactTypeEnum artifactType = ArtifactTypeEnum.AAI_SERVICE_MODEL; - ArtifactTypeConfig result; + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); - // default test - testSubject = createTestSubject(); - result = Deencapsulation.invoke(testSubject, "getDeploymentArtifactTypeConfig", - new Object[]{parentType, artifactType}); + artifactsBusinessLogic.validateArtifactExtension(artifactConfiguration, artifactInfo); } + @Test(expected = ComponentException.class) + public void testValidateArtifactExtension_noExtension() { + final ArtifactConfiguration artifactConfiguration = new ArtifactConfiguration(); + artifactConfiguration.setAcceptedTypes(Arrays.asList("yml", "yaml")); + final ArtifactDefinition artifactInfo = new ArtifactDefinition(); + //no extension in the artifact name + artifactInfo.setArtifactName("artifact"); + + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); - @Test(expected= ComponentException.class) - public void testValidateHeatEnvDeploymentArtifact_shouldThrowException() throws Exception { + artifactsBusinessLogic.validateArtifactExtension(artifactConfiguration, artifactInfo); + } + + @Test(expected = ComponentException.class) + public void testValidateHeatEnvDeploymentArtifact_shouldThrowException() { ArtifactsBusinessLogic testSubject; Component component = createResourceObject(true); String parentId = ""; ArtifactDefinition artifactInfo = buildArtifactPayload(); - NodeTypeEnum parentType = NodeTypeEnum.AdditionalInfoParameters; // default test testSubject = createTestSubject(); - testSubject.validateHeatEnvDeploymentArtifact(component, parentId, artifactInfo, parentType); + testSubject.validateHeatEnvDeploymentArtifact(component, parentId, artifactInfo); } @Test @@ -1257,47 +1290,46 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ result = Deencapsulation.invoke(testSubject, "isValidXml", new Object[]{xmlToParse}); } - @Test - public void testHeatTimeoutValue() throws Exception { - ArtifactsBusinessLogic testSubject; - boolean isCreate = false; - ArtifactDefinition artifactInfo = buildArtifactPayload(); - ArtifactDefinition currentArtifact = null; - Either<Boolean, ResponseFormat> result; - - // default test - testSubject = createTestSubject(); - testSubject.validateHeatTimeoutValue(isCreate, artifactInfo, artifactInfo); + @Test(expected = ByActionStatusComponentException.class) + public void testHeatTimeoutValue() { + final ArtifactsBusinessLogic artifactsBusinessLogic = createTestSubject(); + final ArtifactDefinition artifactInfo = buildArtifactPayload(); + artifactInfo.setTimeout(1); + artifactsBusinessLogic.validateHeatTimeoutValue(artifactInfo); + artifactInfo.setTimeout(0); + artifactsBusinessLogic.validateHeatTimeoutValue(artifactInfo); } @Test - public void testValidateHeatDeploymentArtifact() throws Exception { - ArtifactsBusinessLogic testSubject; - boolean isCreate = false; - ArtifactDefinition artifactInfo = buildArtifactPayload(); - ArtifactDefinition currentArtifact = null; - Either<Boolean, ResponseFormat> result; - - // default test - testSubject = createTestSubject(); - testSubject.validateHeatTimeoutValue(isCreate, artifactInfo, artifactInfo); + public void testValidateResourceType_resourceTypeIsAccepted() { + final ArtifactsBusinessLogic artifactsBusinessLogic = createTestSubject(); + final ArtifactDefinition artifactInfo = buildArtifactPayload(); + final List<String> typeList = Arrays + .asList(ResourceTypeEnum.VF.getValue(), ResourceTypeEnum.PNF.getValue(), ResourceTypeEnum.VFC.getValue()); + assertThatCode(() -> { + artifactsBusinessLogic.validateResourceType(ResourceTypeEnum.VF, artifactInfo, typeList); + }).doesNotThrowAnyException(); } - - @Test(expected= ComponentException.class) - public void testValidateResourceType_shouldThrowException() throws Exception { - ArtifactsBusinessLogic testSubject; - ResourceTypeEnum resourceType = ResourceTypeEnum.VF; - ArtifactDefinition artifactInfo = buildArtifactPayload(); - List<String> typeList = new ArrayList<>(); - Either<Boolean, ResponseFormat> result; - - // test 1 - testSubject = createTestSubject(); - testSubject.validateResourceType(resourceType, artifactInfo, typeList); - result = Deencapsulation.invoke(testSubject, "validateResourceType", new Object[]{resourceType, artifactInfo, typeList}); + @Test(expected=ComponentException.class) + public void testValidateResourceType_invalidResourceType() { + final ArtifactsBusinessLogic artifactsBusinessLogic = createTestSubject(); + final ArtifactDefinition artifactInfo = buildArtifactPayload(); + final List<String> typeList = Collections.singletonList(ResourceTypeEnum.PNF.getValue()); + artifactsBusinessLogic.validateResourceType(ResourceTypeEnum.VF, artifactInfo, typeList); } + @Test + public void testValidateResourceType_emptyResourceTypeConfig_resourceTypeIsAccepted() { + final ArtifactsBusinessLogic artifactsBusinessLogic = createTestSubject(); + final ArtifactDefinition artifactInfo = buildArtifactPayload(); + assertThatCode(() -> { + artifactsBusinessLogic.validateResourceType(ResourceTypeEnum.VF, artifactInfo, null); + }).doesNotThrowAnyException(); + assertThatCode(() -> { + artifactsBusinessLogic.validateResourceType(ResourceTypeEnum.VF, artifactInfo, new ArrayList<>()); + }).doesNotThrowAnyException(); + } @Test public void testValidateAndConvertHeatParameters() throws Exception { @@ -1321,7 +1353,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ // default test testSubject = createTestSubject(); - result = testSubject.getDeploymentArtifacts(component, parentType, ciId); + result = testSubject.getDeploymentArtifacts(component, ciId); } @@ -1349,6 +1381,36 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ testSubject.validateAndSetArtifactName(artifactInfo); } + @Test(expected = ComponentException.class) + public void testValidateArtifactType_notConfiguredArtifactType() { + final ArtifactsBusinessLogic artifactsBusinessLogic = createTestSubject(); + final ArtifactDefinition artifactInfo = buildArtifactPayload(); + artifactInfo.setArtifactType("notConfiguredType"); + Deencapsulation + .invoke(artifactsBusinessLogic, "validateArtifactType", artifactInfo, ComponentTypeEnum.RESOURCE); + } + + @Test(expected = ComponentException.class) + public void testValidateArtifactType_componentTypeNotSupportedByArtifactType() { + final ArtifactsBusinessLogic artifactsBusinessLogic = createTestSubject(); + final ArtifactDefinition artifactInfo = buildArtifactPayload(); + artifactInfo.setArtifactType(ArtifactTypeEnum.WORKFLOW.getType()); + + Deencapsulation + .invoke(artifactsBusinessLogic, "validateArtifactType", artifactInfo, ComponentTypeEnum.RESOURCE); + } + + @Test(expected = ComponentException.class) + public void testValidateArtifactType_groupTypeNotSupportedByArtifactType() { + final ArtifactsBusinessLogic artifactsBusinessLogic = createTestSubject(); + final ArtifactDefinition artifactInfo = buildArtifactPayload(); + artifactInfo.setArtifactType(ArtifactTypeEnum.WORKFLOW.getType()); + artifactInfo.setArtifactGroupType(ArtifactGroupTypeEnum.INFORMATIONAL); + + Deencapsulation + .invoke(artifactsBusinessLogic, "validateArtifactType", artifactInfo, ComponentTypeEnum.SERVICE); + } + @Test public void testValidateArtifactTypeNotChanged() throws Exception { ArtifactsBusinessLogic testSubject; @@ -1883,6 +1945,172 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ assertEquals(Deencapsulation.getField(testSubject, "nodeTemplateOperation"), nodeTemplateOperation); } + + @Test(expected = ComponentException.class) + public void validateDeploymentArtifact_invalidComponentType() { + ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + Component component = new Resource(); + component.setComponentType(ComponentTypeEnum.PRODUCT); + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + Deencapsulation + .invoke(artifactsBusinessLogic, "validateDeploymentArtifact", artifactDefinition, component); + } + + @Test(expected = ComponentException.class) + public void validateDeploymentArtifact_notConfiguredArtifactType() { + ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + Component component = new Resource(); + component.setComponentType(ComponentTypeEnum.RESOURCE); + artifactDefinition.setArtifactType("NotConfiguredType"); + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + Deencapsulation + .invoke(artifactsBusinessLogic, "validateDeploymentArtifact", artifactDefinition, component); + } + + @Test(expected = ComponentException.class) + public void validateDeploymentArtifact_unsupportedResourceType() { + final ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + artifactDefinition.setArtifactType(ArtifactTypeEnum.YANG.getType()); + artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.INFORMATIONAL); + final Resource resourceComponent = new Resource(); + resourceComponent.setComponentType(ComponentTypeEnum.RESOURCE); + resourceComponent.setResourceType(ResourceTypeEnum.ServiceProxy); + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + Deencapsulation + .invoke(artifactsBusinessLogic, "validateDeploymentArtifact", artifactDefinition, resourceComponent); + } + + @Test + public void validateDeploymentArtifact_validArtifact() { + final ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + artifactDefinition.setArtifactType(ArtifactTypeEnum.YANG.getType()); + artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.INFORMATIONAL); + final Resource resourceComponent = new Resource(); + resourceComponent.setComponentType(ComponentTypeEnum.RESOURCE); + resourceComponent.setResourceType(ResourceTypeEnum.VF); + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + assertThatCode(() -> { + Deencapsulation + .invoke(artifactsBusinessLogic, "validateDeploymentArtifact", artifactDefinition, resourceComponent); + }).doesNotThrowAnyException(); + + } + + @Test + public void validateHeatArtifact_validArtifact() { + final ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + artifactDefinition.setArtifactType(ArtifactTypeEnum.HEAT.getType()); + artifactDefinition.setTimeout(1); + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + assertThatCode(() -> { + Deencapsulation + .invoke(artifactsBusinessLogic, "validateHeatArtifact", new Resource(), "componentId", artifactDefinition); + }).doesNotThrowAnyException(); + } + + @Test + public void validateInputForResourceInstance() { + final String artifactId = "artifactId"; + ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + artifactDefinition.setUniqueId(artifactId); + artifactDefinition.setArtifactName(ARTIFACT_NAME); + artifactDefinition.setArtifactType(ArtifactTypeEnum.SNMP_POLL.getType()); + artifactDefinition.setArtifactLabel(ARTIFACT_LABEL); + artifactDefinition.setEsId(ES_ARTIFACT_ID); + artifactDefinition.setPayload(PAYLOAD); + artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.INFORMATIONAL); + artifactDefinition.setDescription("artifact description"); + artifactDefinition.setServiceApi(true); + artifactDefinition.setApiUrl("dumbUrl"); + + final User user = new User(); + user.setUserId("userId"); + user.setRole(Role.ADMIN.name()); + + final String parentId = "parentId"; + final Service service = new Service(); + service.setComponentType(ComponentTypeEnum.SERVICE); + service.setUniqueId(parentId); + service.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); + service.setLastUpdaterUserId(user.getUserId()); + + final ArtifactOperationInfo operationInfo = + artifactBL.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE); + + final String componentId = "componentId"; + final ComponentInstance componentInstance = new ComponentInstance(); + componentInstance.setUniqueId(componentId); + componentInstance.setComponentUid(componentId); + service.setComponentInstances(Collections.singletonList(componentInstance)); + + final Resource resource = new Resource(); + when(toscaOperationFacade.getToscaFullElement(componentId)).thenReturn(Either.left(resource)); + when(artifactToscaOperation.getAllInstanceArtifacts(parentId, componentId)).thenReturn(Either.left(new HashMap<>())); + + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + artifactsBusinessLogic.setToscaOperationFacade(toscaOperationFacade); + Object result = Deencapsulation + .invoke(artifactsBusinessLogic, "validateInput", componentId, artifactDefinition, operationInfo, artifactId, + user, "interfaceName", ARTIFACT_LABEL, ComponentTypeEnum.RESOURCE_INSTANCE, service); + assertTrue(result instanceof Either<?, ?>); + assertTrue(((Either<?, ?>) result).isLeft()); + + artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT); + + result = Deencapsulation + .invoke(artifactsBusinessLogic, "validateInput", componentId, artifactDefinition, operationInfo, artifactId, + user, "interfaceName", ARTIFACT_LABEL, ComponentTypeEnum.RESOURCE_INSTANCE, service); + assertTrue(result instanceof Either<?, ?>); + assertTrue(((Either<?, ?>) result).isLeft()); + } + + @Test + public void validateInputForResourceInstanceDeploymentArtifact() { + final String artifactId = "artifactId"; + ArtifactDefinition artifactDefinition = new ArtifactDefinition(); + artifactDefinition.setUniqueId(artifactId); + artifactDefinition.setArtifactName(ARTIFACT_NAME); + artifactDefinition.setArtifactType(ArtifactTypeEnum.SNMP_POLL.getType()); + artifactDefinition.setArtifactLabel(ARTIFACT_LABEL); + artifactDefinition.setEsId(ES_ARTIFACT_ID); + artifactDefinition.setPayload(PAYLOAD); + artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT); + artifactDefinition.setDescription("artifact description"); + + final User user = new User(); + user.setUserId("userId"); + user.setRole(Role.ADMIN.name()); + + final String parentId = "parentId"; + final Service service = new Service(); + service.setComponentType(ComponentTypeEnum.SERVICE); + service.setUniqueId(parentId); + service.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); + service.setLastUpdaterUserId(user.getUserId()); + + final ArtifactOperationInfo operationInfo = + artifactBL.new ArtifactOperationInfo(false, false, ArtifactOperationEnum.CREATE); + + final String componentId = "componentId"; + final ComponentInstance componentInstance = new ComponentInstance(); + componentInstance.setUniqueId(componentId); + componentInstance.setComponentUid(componentId); + service.setComponentInstances(Collections.singletonList(componentInstance)); + + final Resource resource = new Resource(); + when(toscaOperationFacade.getToscaFullElement(componentId)).thenReturn(Either.left(resource)); + when(artifactToscaOperation.getAllInstanceArtifacts(parentId, componentId)).thenReturn(Either.left(new HashMap<>())); + + final ArtifactsBusinessLogic artifactsBusinessLogic = getTestSubject(); + artifactsBusinessLogic.setToscaOperationFacade(toscaOperationFacade); + final Object result = Deencapsulation + .invoke(artifactsBusinessLogic, "validateInput", componentId, artifactDefinition, operationInfo, artifactId, + user, "interfaceName", ARTIFACT_LABEL, ComponentTypeEnum.RESOURCE_INSTANCE, service); + assertTrue(result instanceof Either<?, ?>); + assertTrue(((Either<?, ?>) result).isLeft()); + } + + @Test public void testHandleArtifactRequest() { @@ -1894,7 +2122,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ artifactDefinition.setPayload("Test".getBytes()); artifactDefinition.setArtifactLabel("other"); artifactDefinition.setDescription("Test artifact"); - artifactDefinition.setArtifactType(ArtifactTypeEnum.OTHER.name()); + artifactDefinition.setArtifactType(ArtifactTypeEnum.OTHER.getType()); artifactDefinition.setArtifactUUID("artifactUId"); artifactDefinition.setArtifactLabel("test"); artifactDefinition.setArtifactDisplayName("Test"); @@ -1979,7 +2207,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ ArtifactDefinition artifactDefinition = new ArtifactDefinition(); artifactDefinition.setUniqueId("artifactId"); - artifactDefinition.setArtifactType(ArtifactTypeEnum.TOSCA_CSAR.name()); + artifactDefinition.setArtifactType(ArtifactTypeEnum.TOSCA_CSAR.getType()); User user = new User(); boolean inCertificationRequest = false; boolean fetchTemplatesFromDB = false; @@ -2013,7 +2241,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ ArtifactDefinition csarArtifact = new ArtifactDefinition(); csarArtifact.setArtifactName("csarArtifact"); - csarArtifact.setArtifactType(ArtifactTypeEnum.HEAT_ENV.name()); + csarArtifact.setArtifactType(ArtifactTypeEnum.HEAT_ENV.getType()); csarArtifact.setArtifactGroupType(ArtifactGroupTypeEnum.TOSCA); when(csarUtils.createCsar(any(Component.class), anyBoolean(), anyBoolean())) @@ -2039,7 +2267,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ artifactDefinition.setArtifactName("test.csar"); artifactDefinition.setArtifactType(ComponentTypeEnum.RESOURCE.name()); - artifactDefinition.setArtifactType(ArtifactTypeEnum.HEAT.name()); + artifactDefinition.setArtifactType(ArtifactTypeEnum.HEAT.getType()); artifactDefinition.setUniqueId(artifactId); artifactDefinition.setArtifactGroupType(ArtifactGroupTypeEnum.TOSCA); @@ -2143,7 +2371,7 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ resource.setComponentInstances(componentInstanceList); componentInstance.setDeploymentArtifacts(deploymentArtifacts); - List<ArtifactDefinition> result = artifactBL.getDeploymentArtifacts(resource, parentType, ciId); + List<ArtifactDefinition> result = artifactBL.getDeploymentArtifacts(resource, ciId); assertThat(result.size() == 1).isTrue(); Assert.assertEquals(artifactDefinition.getArtifactName(), result.get(0).getArtifactName()); } @@ -2249,8 +2477,12 @@ public class ArtifactsBusinessLogicTest extends BaseBusinessLogicMock{ } private ArtifactsBusinessLogic getTestSubject() { - return new ArtifactsBusinessLogic(artifactCassandraDao, toscaExportHandler, csarUtils, lifecycleBusinessLogic, - userBusinessLogic, artifactsResolver, elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, + final ArtifactsBusinessLogic artifactsBusinessLogic = new ArtifactsBusinessLogic(artifactCassandraDao, + toscaExportHandler, csarUtils, lifecycleBusinessLogic, + userBusinessLogic, artifactsResolver, elementDao, groupOperation, groupInstanceOperation, + groupTypeOperation, interfaceOperation, interfaceLifecycleTypeOperation, artifactToscaOperation); + artifactsBusinessLogic.setComponentsUtils(componentsUtils); + return artifactsBusinessLogic; } }
\ No newline at end of file diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java index 9e563fc34c..c19d997d73 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java @@ -1842,27 +1842,27 @@ public class ResourceBusinessLogicTest { List<NonMetaArtifactInfo> artifactPathAndNameList = new ArrayList<>(); NonMetaArtifactInfo deploymentArtifactInfoToUpdate = new NonMetaArtifactInfo( deploymentArtifactToUpdate.getArtifactName(), null, - ArtifactTypeEnum.findType(deploymentArtifactToUpdate.getArtifactType()), + deploymentArtifactToUpdate.getArtifactType(), ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, deploymentArtifactToUpdate.getArtifactName(), false); NonMetaArtifactInfo informationalArtifactInfoToUpdate = new NonMetaArtifactInfo( - artifactToUpdate.getArtifactName(), null, ArtifactTypeEnum.findType(artifactToUpdate.getArtifactType()), + artifactToUpdate.getArtifactName(), null, artifactToUpdate.getArtifactType(), ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, artifactToUpdate.getArtifactName(), false); NonMetaArtifactInfo informationalArtifactInfoToUpdateFromCsar = new NonMetaArtifactInfo( - artifactToUpdate.getArtifactName(), null, ArtifactTypeEnum.findType(artifactToUpdate.getArtifactType()), + artifactToUpdate.getArtifactName(), null, artifactToUpdate.getArtifactType(), ArtifactGroupTypeEnum.INFORMATIONAL, newPayloadData, artifactToUpdate.getArtifactName(), true); NonMetaArtifactInfo deploymentArtifactInfoToUpdateFromCsar = new NonMetaArtifactInfo( - artifactToUpdate.getArtifactName(), null, ArtifactTypeEnum.findType(artifactToUpdate.getArtifactType()), + artifactToUpdate.getArtifactName(), null, artifactToUpdate.getArtifactType(), ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, artifactToUpdate.getArtifactName(), true); NonMetaArtifactInfo deploymentArtifactInfoToCreate = new NonMetaArtifactInfo(deploymentArtifactToCreateFileName, - null, ArtifactTypeEnum.OTHER, ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, + null, ArtifactTypeEnum.OTHER.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, deploymentArtifactToCreateFileName, false); NonMetaArtifactInfo informationalArtifactInfoToCreate = new NonMetaArtifactInfo(artifactInfoToCreateFileName, - null, ArtifactTypeEnum.OTHER, ArtifactGroupTypeEnum.INFORMATIONAL, newPayloadData, + null, ArtifactTypeEnum.OTHER.getType(), ArtifactGroupTypeEnum.INFORMATIONAL, newPayloadData, artifactInfoToCreateFileName, false); artifactPathAndNameList.add(deploymentArtifactInfoToUpdate); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java index 06b06b08ad..160f595e95 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceArtifactsMergeTest.java @@ -154,7 +154,7 @@ public class ComponentInstanceArtifactsMergeTest { artifactCreatedOnTheInstance.setTimeout(30); ArtifactDefinition artifactGeneratedBySubmitForTesting = new ArtifactDefinition(); artifactGeneratedBySubmitForTesting.setArtifactLabel("artifactThree"); - artifactGeneratedBySubmitForTesting.setArtifactType(ArtifactTypeEnum.VF_MODULES_METADATA.name()); + artifactGeneratedBySubmitForTesting.setArtifactType(ArtifactTypeEnum.VF_MODULES_METADATA.getType()); artifactGeneratedBySubmitForTesting.setTimeout(30); Map<String, ArtifactDefinition> componentInstanceArtifacts = new HashMap<>(); componentInstanceArtifacts.put(artifactFromTheOriginalResource.getArtifactLabel(), artifactFromTheOriginalResource); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/aaf/RoleAuthorizationHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/aaf/RoleAuthorizationHandlerTest.java index 71513c36bd..c488a9a6ca 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/aaf/RoleAuthorizationHandlerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/aaf/RoleAuthorizationHandlerTest.java @@ -53,7 +53,7 @@ import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.Silent.class) public class RoleAuthorizationHandlerTest { - private RoleAuthorizationHandler roleAuthorizationHandler = new RoleAuthorizationHandler(); + private RoleAuthorizationHandler roleAuthorizationHandler; @Mock JoinPoint joinPoint; @Mock @@ -72,6 +72,7 @@ public class RoleAuthorizationHandlerTest { when(beGenericServlet.getServletRequest()).thenReturn(httpServletRequest); ThreadLocalsHolder.setApiType(FilterDecisionEnum.EXTERNAL); new ConfigurationManager(new FSConfigurationSource(ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be/auth")); + roleAuthorizationHandler = new RoleAuthorizationHandler(); } @Test diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java index f90ef19293..974f286098 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java @@ -305,7 +305,6 @@ public class ElementServletTest extends JerseyTest { Either<UiCategories, ResponseFormat> getAllCategoriesEither = Either.left(new UiCategories()); Either<List<ArtifactType>, ActionStatus> otherEither = Either.left(new ArrayList<>()); when(elementBusinessLogic.getDefaultHeatTimeout()).thenReturn(Either.left(configurationManager.getConfiguration().getHeatArtifactDeploymentTimeout())); - when(elementBusinessLogic.getAllDeploymentArtifactTypes()).thenReturn(Either.left(new HashMap<String, Object>())); when(elementBusinessLogic.getResourceTypesMap()).thenReturn(Either.left(new HashMap<String, String>())); when(elementBusinessLogic.getAllArtifactTypes(designerUser.getUserId())) .thenReturn(otherEither); @@ -961,15 +960,12 @@ public class ElementServletTest extends JerseyTest { Configuration.HeatDeploymentArtifactTimeout heatDeploymentArtifactTimeout = new Configuration.HeatDeploymentArtifactTimeout(); heatDeploymentArtifactTimeout.setDefaultMinutes(1); Either<Configuration.HeatDeploymentArtifactTimeout, ActionStatus> defaultHeatTimeoutEither = Either.left(heatDeploymentArtifactTimeout); - Either<Map<String, Object>, ActionStatus> deploymentEither = Either.left(new HashMap<>()); Either<Map<String, String>, ActionStatus> resourceTypesMapEither = Either.left(new HashMap<>()); when(elementBusinessLogic.getAllArtifactTypes(designerUser.getUserId())) .thenReturn(otherEither); when(elementBusinessLogic.getDefaultHeatTimeout()) .thenReturn(defaultHeatTimeoutEither); - when(elementBusinessLogic.getAllDeploymentArtifactTypes()) - .thenReturn(deploymentEither); when(elementBusinessLogic.getResourceTypesMap()) .thenReturn(resourceTypesMapEither); @@ -1065,6 +1061,7 @@ public class ElementServletTest extends JerseyTest { bind(componentUtils).to(ComponentsUtils.class); bind(componentsCleanBusinessLogic).to(ComponentsCleanBusinessLogic.class); bind(elementBusinessLogic).to(ElementBusinessLogic.class); + bind(artifactsBusinessLogic).to(ArtifactsBusinessLogic.class); } }) .property("contextConfig", context); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java index cdea369fe8..c7dced79c5 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java @@ -20,6 +20,8 @@ package org.openecomp.sdc.be.tosca; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -115,7 +117,7 @@ public class CsarUtilsTest extends BeConfDependentTest { private final List<String> nodesFromPackage = Arrays.asList("tosca.nodes.Root", "tosca.nodes.Container.Application"); private NonMetaArtifactInfo createNonMetaArtifactInfoTestSubject() { - return new CsarUtils.NonMetaArtifactInfo("mock", "mock", ArtifactTypeEnum.AAI_SERVICE_MODEL, + return new CsarUtils.NonMetaArtifactInfo("mock", "mock", ArtifactTypeEnum.AAI_SERVICE_MODEL.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, new byte[0], "mock", true); } @@ -706,9 +708,9 @@ public class CsarUtilsTest extends BeConfDependentTest { @Test public void testNonMetaArtifactInfoGetArtifactType() { - NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject(); - - testSubject.getArtifactType(); + final NonMetaArtifactInfo testSubject = createNonMetaArtifactInfoTestSubject(); + assertThat("The artifact type should be as expected", + testSubject.getArtifactType(), is(ArtifactTypeEnum.AAI_SERVICE_MODEL.getType())); } @Test diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtilTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtilTest.java index 23288582ca..c9f21e41b7 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtilTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/utils/OperationArtifactUtilTest.java @@ -62,7 +62,7 @@ public class OperationArtifactUtilTest { final String actualArtifactPath = OperationArtifactUtil.createOperationArtifactPath(component, null, op, false); String expectedArtifactPath = CsarUtils.ARTIFACTS + File.separator + WordUtils.capitalizeFully(ArtifactGroupTypeEnum.DEPLOYMENT.name()) + File.separator + - ArtifactTypeEnum.WORKFLOW.name() + File.separator + BPMN_ARTIFACT_PATH + File.separator + + ArtifactTypeEnum.WORKFLOW.getType() + File.separator + BPMN_ARTIFACT_PATH + File.separator + "createBPMN.bpmn"; @@ -84,7 +84,7 @@ public class OperationArtifactUtilTest { String expectedArtifactPath = CsarUtils.ARTIFACTS + File.separator + "org.openecomp.resource.vf.TestResource_v1.0" + File.separator + WordUtils.capitalizeFully(ArtifactGroupTypeEnum.DEPLOYMENT.name()) + File.separator + - ArtifactTypeEnum.WORKFLOW.name() + + ArtifactTypeEnum.WORKFLOW.getType() + File.separator + BPMN_ARTIFACT_PATH + File.separator + "createBPMN.bpmn"; diff --git a/catalog-be/src/test/resources/config/catalog-be/auth/configuration.yaml b/catalog-be/src/test/resources/config/catalog-be/auth/configuration.yaml index 0e68b3294b..f13e74bdcc 100644 --- a/catalog-be/src/test/resources/config/catalog-be/auth/configuration.yaml +++ b/catalog-be/src/test/resources/config/catalog-be/auth/configuration.yaml @@ -1,739 +1 @@ -identificationHeaderFields: - - HTTP_IV_USER - - HTTP_CSP_FIRSTNAME - - HTTP_CSP_LASTNAME - - HTTP_IV_REMOTE_ADDRESS - - HTTP_CSP_WSTYPE - -# catalog backend hostname -beFqdn: localhost -# sdccatalog.com - -# catalog backend http port -beHttpPort: 8080 - -# catalog backend http context -beContext: /sdc/rest/config/get - -# catalog backend protocol -beProtocol: http - -# catalog backend ssl port -beSslPort: 8443 - -version: 1.1.0 -released: 2012-11-30 -toscaConformanceLevel: 8.0 -minToscaConformanceLevel: 3.0 - -janusGraphCfgFile: /home/vagrant/catalog-be/config/catalog-be/janusGraph.properties -janusGraphInMemoryGraph: false -janusGraphLockTimeout: 1800 - -# The interval to try and reconnect to janusGraph DB when it is down during ASDC startup: -janusGraphReconnectIntervalInSeconds: 3 - -# The read timeout towards Titan DB when health check is invoked: -janusGraphHealthCheckReadTimeout: 1 - -uebHealthCheckReconnectIntervalInSeconds: 15 -uebHealthCheckReadTimeout: 4 - -# Protocols -protocols: - - http - - https - -# Default imports -defaultImports: - - nodes: - file: nodes.yml - - datatypes: - file: data.yml - - capabilities: - file: capabilities.yml - - relationships: - file: relationships.yml - - groups: - file: groups.yml - - policies: - file: policies.yml - -# Users -users: - tom: passwd - bob: passwd - -neo4j: - host: neo4jhost - port: 7474 - user: neo4j - password: "12345" - -cassandraConfig: - cassandraHosts: ['localhost'] - localDataCenter: datacenter1 - reconnectTimeout : 30000 - authenticate: false - username: koko - password: bobo - ssl: false - truststorePath : /path/path - truststorePassword : 123123 - keySpaces: - - { name: sdcaudit, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - - { name: sdcartifact, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - - { name: sdccomponent, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - - { name: sdcrepository, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - - -artifactTypes: - - CHEF - - PUPPET - - SHELL - - YANG - - YANG_XML - - HEAT - - BPEL - - DG_XML - - MURANO_PKG - - WORKFLOW - - NETWORK_CALL_FLOW - - TOSCA_TEMPLATE - - TOSCA_CSAR - - AAI_SERVICE_MODEL - - AAI_VF_MODEL - - AAI_VF_MODULE_MODEL - - AAI_VF_INSTANCE_MODEL - - OTHER - - SNMP_POLL - - SNMP_TRAP - - GUIDE - -licenseTypes: - - User - - Installation - - CPU - -#Deployment artifacts placeHolder -resourceTypes: &allResourceTypes - - VFC - - CP - - VL - - VF - - VFCMT - - Abstract - - CVFC - -# validForResourceTypes usage -# validForResourceTypes: -# - VF -# - VL -deploymentResourceArtifacts: -# heat: -# displayName: "Base HEAT Template" -# type: HEAT -# validForResourceTypes: *allResourceTypes -# heatVol: -# displayName: "Volume HEAT Template" -# type: HEAT_VOL -# validForResourceTypes: *allResourceTypes -# heatNet: -# displayName: "Network HEAT Template" -# type: HEAT_NET -# validForResourceTypes: *allResourceTypes - -deploymentResourceInstanceArtifacts: - heatEnv: - displayName: "HEAT ENV" - type: HEAT_ENV - description: "Auto-generated HEAT Environment deployment artifact" - fileExtension: "env" - VfHeatEnv: - displayName: "VF HEAT ENV" - type: HEAT_ENV - description: "VF Auto-generated HEAT Environment deployment artifact" - fileExtension: "env" - -#tosca artifacts placeholders -toscaArtifacts: - assetToscaTemplate: - artifactName: -template.yml - displayName: Tosca Template - type: TOSCA_TEMPLATE - description: TOSCA representation of the asset - assetToscaCsar: - artifactName: -csar.csar - displayName: Tosca Model - type: TOSCA_CSAR - description: TOSCA definition package of the asset - - -#Informational artifacts placeHolder -excludeResourceCategory: - - Generic -excludeResourceType: - - PNF -informationalResourceArtifacts: - features: - displayName: Features - type: OTHER - capacity: - displayName: Capacity - type: OTHER - vendorTestResult: - displayName: Vendor Test Result - type: OTHER - testScripts: - displayName: Test Scripts - type: OTHER - CloudQuestionnaire: - displayName: Cloud Questionnaire (completed) - type: OTHER - HEATTemplateFromVendor: - displayName: HEAT Template from Vendor - type: HEAT - resourceSecurityTemplate: - displayName: Resource Security Template - type: OTHER - -excludeServiceCategory: - -informationalServiceArtifacts: - serviceArtifactPlan: - displayName: Service Artifact Plan - type: OTHER - summaryOfImpactsToECOMPElements: - displayName: Summary of impacts to ECOMP elements,OSSs, BSSs - type: OTHER - controlLoopFunctions: - displayName: Control Loop Functions - type: OTHER - dimensioningInfo: - displayName: Dimensioning Info - type: OTHER - affinityRules: - displayName: Affinity Rules - type: OTHER - operationalPolicies: - displayName: Operational Policies - type: OTHER - serviceSpecificPolicies: - displayName: Service-specific Policies - type: OTHER - engineeringRules: - displayName: Engineering Rules (ERD) - type: OTHER - distributionInstructions: - displayName: Distribution Instructions - type: OTHER - certificationTestResults: - displayName: TD Certification Test Results - type: OTHER - deploymentVotingRecord: - displayName: Deployment Voting Record - type: OTHER - serviceQuestionnaire: - displayName: Service Questionnaire - type: OTHER - serviceSecurityTemplate: - displayName: Service Security Template - type: OTHER - -serviceApiArtifacts: - configuration: - displayName: Configuration - type: OTHER - instantiation: - displayName: Instantiation - type: OTHER - monitoring: - displayName: Monitoring - type: OTHER - reporting: - displayName: Reporting - type: OTHER - logging: - displayName: Logging - type: OTHER - testing: - displayName: Testing - type: OTHER - -additionalInformationMaxNumberOfKeys: 50 - -systemMonitoring: - enabled: false - isProxy: false - probeIntervalInSeconds: 15 - -heatArtifactDeploymentTimeout: - defaultMinutes: 30 - minMinutes: 1 - maxMinutes: 120 - -serviceDeploymentArtifacts: - YANG_XML: - acceptedTypes: - - xml - VNF_CATALOG: - acceptedTypes: - - xml - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - UCPE_LAYER_2_CONFIGURATION: - acceptedTypes: - - xml - -#AAI Artifacts - AAI_SERVICE_MODEL: - acceptedTypes: - - xml - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - AAI_VF_INSTANCE_MODEL: - acceptedTypes: - - xml - OTHER: - acceptedTypes: - -resourceDeploymentArtifacts: - HEAT: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_VOL: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NET: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NESTED: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_ARTIFACT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VNF_CATALOG: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VF_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VENDOR_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - LIFECYCLE_OPERATIONS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - VF - - VFC - VES_EVENTS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - validForResourceTypes: *allResourceTypes - APPC_CONFIG: - acceptedTypes: - validForResourceTypes: - - VF - DCAE_TOSCA: - acceptedTypes: - - yml - - yaml - validForResourceTypes: - - VF - - VFCMT - DCAE_JSON: - acceptedTypes: - - json - validForResourceTypes: - - VF - - VFCMT - DCAE_POLICY: - acceptedTypes: - - emf - validForResourceTypes: - - VF - - VFCMT - DCAE_DOC: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - DCAE_EVENT: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - AAI_VF_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - OTHER: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - -resourceInstanceDeploymentArtifacts: - HEAT_ENV: - acceptedTypes: - - env - VF_MODULES_METADATA: - acceptedTypes: - - json - VES_EVENTS: - acceptedTypes: - - yaml - - yml - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - DCAE_INVENTORY_TOSCA: - acceptedTypes: - - yml - - yaml - DCAE_INVENTORY_JSON: - acceptedTypes: - - json - DCAE_INVENTORY_POLICY: - acceptedTypes: - - emf - DCAE_INVENTORY_DOC: - acceptedTypes: - DCAE_INVENTORY_BLUEPRINT: - acceptedTypes: - DCAE_INVENTORY_EVENT: - acceptedTypes: - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - -resourceInformationalArtifacts: - CHEF: - acceptedTypes: - validForResourceTypes: *allResourceTypes - PUPPET: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SHELL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - HEAT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - BPEL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - DG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - MURANO_PKG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - OTHER: - acceptedTypes: - validForResourceTypes: - - VFC - - CVFC - - CP - - VL - - VF - - VFCMT - - Abstract - - PNF - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - GUIDE: - acceptedTypes: - validForResourceTypes: - - VF - - VFC - - CVFC - -unLoggedUrls: - - /sdc2/rest/healthCheck - -cleanComponentsConfiguration: - cleanIntervalInMinutes: 1440 - componentsToClean: - - Resource - - Service - -artifactsIndex: resources - -heatEnvArtifactHeader: "" -heatEnvArtifactFooter: "" - -onboarding: - protocol: http - host: localhost - port: 8080 - downloadCsarUri: "/onboarding-api/v1.0/vendor-software-products/packages" - healthCheckUri: "/onboarding-api/v1.0/healthcheck" - -dcae: - protocol: http - host: 127.0.0.1 - port: 8080 - healthCheckUri: "/dcae/healthCheck" - -switchoverDetector: - gBeFqdn: AIO-BE.ecomp.idns.cip.com - gFeFqdn: AIO-FE.ecomp.idns.cip.com - beVip: 0.0.0.0 - feVip: 0.0.0.0 - beResolveAttempts: 3 - feResolveAttempts: 3 - enabled: false - interval: 60 - changePriorityUser: ecompasdc - changePriorityPassword: ecompasdc123 - publishNetworkUrl: "http://xxx.com/crt/CipDomain.ECOMP-ASDC-DEVST/config/update_network?user=root" - publishNetworkBody: '{"note":"publish network"}' - groups: - beSet: { changePriorityUrl: "http://xxx.com/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-BE.ecomp.idns.com?user=root", - changePriorityBody: '{"name":"AIO-BE.ecomp.idns.com","uri":"/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-BE.ecomp.idns.com","no_ad_redirection":false,"v4groups":{"failover_groups":["/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_mg_be","/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_bs_be"],"failover_policy":["FAILALL"]},"comment":"AIO BE G-fqdn","intended_app_proto":"DNS"}'} - feSet: { changePriorityUrl: "http://xxx.com/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-FE.ecomp.idns.com?user=root", - changePriorityBody: '{"comment":"AIO G-fqdn","name":"AIO-FE.ecomp.idns.com","v4groups":{"failover_groups":["/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_mg_fe","/crt/CipDomain.ECOMP-ASDC-DEVST/config/groups/group_bs_fe"],"failover_policy":["FAILALL"]},"no_ad_redirection":false,"intended_app_proto":"DNS","uri":"/crt/CipDomain.ECOMP-ASDC-DEVST/config/sites/AIO-FE.ecomp.idns.com"}'} - -applicationL1Cache: - datatypes: - enabled: true - firstRunDelay: 10 - pollIntervalInSec: 60 - -applicationL2Cache: - enabled: true - catalogL1Cache: - enabled: true - resourcesSizeInCache: 300 - servicesSizeInCache: 200 - productsSizeInCache: 100 - queue: - syncIntervalInSecondes: 43200 - waitOnShutDownInMinutes: 10 - numberOfCacheWorkers: 4 - -toscaValidators: - stringMaxLength: 2500 - -disableAudit: false - -vfModuleProperties: - min_vf_module_instances: - forBaseModule: 1 - forNonBaseModule: 0 - max_vf_module_instances: - forBaseModule: 1 - forNonBaseModule: - initial_count: - forBaseModule: 1 - forNonBaseModule: 0 - vf_module_type: - forBaseModule: Base - forNonBaseModule: Expansion - -genericAssetNodeTypes: - VFC: org.openecomp.resource.abstract.nodes.VFC - CVFC: org.openecomp.resource.abstract.nodes.VFC - VF : org.openecomp.resource.abstract.nodes.VF - PNF: org.openecomp.resource.abstract.nodes.PNF - Service: org.openecomp.resource.abstract.nodes.service - -workloadContext: Production -environmentContext: - defaultValue: General_Revenue-Bearing - validValues: - - Critical_Revenue-Bearing - - Vital_Revenue-Bearing - - Essential_Revenue-Bearing - - Important_Revenue-Bearing - - Needed_Revenue-Bearing - - Useful_Revenue-Bearing - - General_Revenue-Bearing - - Critical_Non-Revenue - - Vital_Non-Revenue - - Essential_Non-Revenue - - Important_Non-Revenue - - Needed_Non-Revenue - - Useful_Non-Revenue - - General_Non-Revenue - -dmaapConsumerConfiguration: - active: true - hosts: olsd004.wnsnet.com:3905 - consumerGroup: asdc - consumerId: invalidMamaUser #mama - in Order To Consume Remove This String And Replace It With -> mama - timeoutMs: 15000 - limit: 1 - pollingInterval: 2 - topic: com.sdc.23911-SDCforTestDev-v001 - latitude: 32.109333 - longitude: 34.855499 - version: 1.0 - serviceName: dmaap-v1.dev.dmaap.dt.saat.acsi.com/events - environment: TEST - partner: BOT_R - routeOffer: MR1 - protocol: https - contenttype: application/json - dme2TraceOn: true - aftEnvironment: AFTUAT - aftDme2ConnectionTimeoutMs: 15000 - aftDme2RoundtripTimeoutMs: 240000 - aftDme2ReadTimeoutMs: 50000 - dme2preferredRouterFilePath: DME2preferredRouter.txt - timeLimitForNotificationHandleMs: 0 - credential: - username: m09875@sdc.com - password: hmXYcznAljMSisdy8zgcag== - aftDme2SslEnable: true - aftDme2ClientIgnoreSslConfig: false - aftDme2ClientKeystore: /opt/app/jetty/base/be/config/.truststore - aftDme2ClientKeystorePassword: hmXYcznAljMSisdy8zgcag== - aftDme2ClientSslCertAlias: certman - -dmaapProducerConfiguration: - active: true - hosts: olsd004.wnsnet.attws.com:3904 - consumerGroup: asdc - consumerId: mama #mama - in Order To Consume Remove This String And Replace It With -> mama - timeoutMs: 15000 - limit: 1 - pollingInterval: 2 - topic: com.att.sdc.23911-msfacadesdc-v1 - latitude: 32.109333 - longitude: 34.855499 - version: 1.0 - serviceName: dmaap-v1.dev.dmaap.dt.saat.acsi.att.com/events - environment: TEST - partner: BOT_R - routeOffer: MR1 - protocol: http - contenttype: application/json - dme2TraceOn: true - aftEnvironment: AFTUAT - aftDme2ConnectionTimeoutMs: 15000 - aftDme2RoundtripTimeoutMs: 240000 - aftDme2ReadTimeoutMs: 50000 - dme2preferredRouterFilePath: DME2preferredRouter.txt - timeLimitForNotificationHandleMs: 120000 - credential: - username: m09875@sdc.att.com - password: hmXYcznAljMSisdy8zgcag== -# isActive: false -# transportType: HTTPAAF -# hosts: olsd004.wnsnet.attws.com:3904 -# consumerGroup: asdc -# consumerId: mama #mama - in Order To Consume Remove This String And Replace It With -> mama -# limit: 1000 -# timeout: 15000 -# topic: com.att.sdc.23911-msfacadesdc-v1 -# protocol: http -# contenttype: application/json -# authKey: d8fWpPuZ3JJEs8Gf:XyQeXFoxIJZGAUaJUfx+oV6JO -# authDate: 2018-05-18T13:57:37-0800 -# dme2preferredRouterFilePath: DME2preferredRouter.txt #stub , used only cause exception is thrown without it -# credential: -# username: m09875@sdc.att.com -# password: hmXYcznAljMSisdy8zgcag== -dmeConfiguration: - lookupUriFormat: "http://DME2RESOLVE/service=%s/version=1.0.0/envContext=%s/routeOffer=DEFAULT" - -excludedGroupTypesMapping: - CR: - - org.openecomp.groups.VfModule - - org.openecomp.groups.heat.HeatStack - - tosca.groups.Root - VF: - - org.openecomp.groups.VfModule - - org.openecomp.groups.heat.HeatStack - - tosca.groups.Root - Service: - - org.openecomp.groups.VfModule - - org.openecomp.groups.heat.HeatStack - - tosca.groups.Root -healthStatusExclude: - - DE - - ES - - DMAAP - -aafNamespace: com.att.sdc - -aafAuthNeeded: true - -cadiFilterParams: - AFT_LATITUDE: "32.780140" - AFT_LONGITUDE: "-96.800451" - hostname: 192.168.33.10 - aaf_id: m09875@sdc.att.com - aaf_env: TEST - aaf_url: https://aaftest.test.att.com/locate/com.att.aaf.service:2.0 - csp_domain: PROD - cadi_keyfile: /opt/app/jetty/base/be/etc/keyfile - aaf_password: enc:uI_J4jBL4YUcIZZa5uZKj3QMUC63hbS8TmDn5PSp5nO - cadi_loglevel: DEBUG - AFT_ENVIRONMENT: AFTUAT - cadiX509Issuers: CN=intermediateCA_1, OU=OSAAF, O=ONAP, C=US - cadi_truststore: /opt/app/jetty/base/be/etc/cadi_truststore.jks - cadi_truststore_password: changeit - - +aafAuthNeeded: true
\ No newline at end of file diff --git a/catalog-be/src/test/resources/config/catalog-be/auth/error-configuration.yaml b/catalog-be/src/test/resources/config/catalog-be/auth/error-configuration.yaml new file mode 100644 index 0000000000..d1b2df7b42 --- /dev/null +++ b/catalog-be/src/test/resources/config/catalog-be/auth/error-configuration.yaml @@ -0,0 +1,8 @@ +# Errors +errors: + #---------POL5003------------------------------ + AUTH_FAILED: { + code: 403 , + message: "Error: Not authorized to use the API.", + messageId: "POL5003" + }
\ No newline at end of file diff --git a/catalog-be/src/test/resources/config/catalog-be/configuration.yaml b/catalog-be/src/test/resources/config/catalog-be/configuration.yaml index 64b730b046..ca7c636ff6 100644 --- a/catalog-be/src/test/resources/config/catalog-be/configuration.yaml +++ b/catalog-be/src/test/resources/config/catalog-be/configuration.yaml @@ -87,31 +87,6 @@ cassandraConfig: - { name: sdccomponent, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - { name: sdcrepository, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - -artifactTypes: - - CHEF - - PUPPET - - SHELL - - YANG - - YANG_XML - - HEAT - - BPEL - - DG_XML - - MURANO_PKG - - WORKFLOW - - NETWORK_CALL_FLOW - - TOSCA_TEMPLATE - - TOSCA_CSAR - - AAI_SERVICE_MODEL - - AAI_VF_MODEL - - AAI_VF_MODULE_MODEL - - AAI_VF_INSTANCE_MODEL - - OTHER - - SNMP_POLL - - SNMP_TRAP - - GUIDE - - PNF_SW_INFORMATION - licenseTypes: - User - Installation @@ -274,248 +249,6 @@ heatArtifactDeploymentTimeout: minMinutes: 1 maxMinutes: 120 -serviceDeploymentArtifacts: - YANG_XML: - acceptedTypes: - - xml - VNF_CATALOG: - acceptedTypes: - - xml - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - UCPE_LAYER_2_CONFIGURATION: - acceptedTypes: - - xml - -#AAI Artifacts - AAI_SERVICE_MODEL: - acceptedTypes: - - xml - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - AAI_VF_INSTANCE_MODEL: - acceptedTypes: - - xml - OTHER: - acceptedTypes: - -resourceDeploymentArtifacts: - HEAT: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_VOL: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NET: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_NESTED: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - HEAT_ARTIFACT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VNF_CATALOG: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VF_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - VENDOR_LICENSE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_INVENTORY_PROFILE: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - MODEL_QUERY_SPEC: - acceptedTypes: - - xml - validForResourceTypes: *allResourceTypes - LIFECYCLE_OPERATIONS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - VF - - VFC - VES_EVENTS: - acceptedTypes: - - yaml - - yml - validForResourceTypes: *allResourceTypes - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - validForResourceTypes: *allResourceTypes - APPC_CONFIG: - acceptedTypes: - validForResourceTypes: - - VF - DCAE_TOSCA: - acceptedTypes: - - yml - - yaml - validForResourceTypes: - - VF - - VFCMT - DCAE_JSON: - acceptedTypes: - - json - validForResourceTypes: - - VF - - VFCMT - DCAE_POLICY: - acceptedTypes: - - emf - validForResourceTypes: - - VF - - VFCMT - DCAE_DOC: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - DCAE_EVENT: - acceptedTypes: - validForResourceTypes: - - VF - - VFCMT - AAI_VF_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - AAI_VF_MODULE_MODEL: - acceptedTypes: - - xml - validForResourceTypes: - - VF - OTHER: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - -resourceInstanceDeploymentArtifacts: - HEAT_ENV: - acceptedTypes: - - env - VF_MODULES_METADATA: - acceptedTypes: - - json - VES_EVENTS: - acceptedTypes: - - yaml - - yml - PERFORMANCE_COUNTER: - acceptedTypes: - - csv - DCAE_INVENTORY_TOSCA: - acceptedTypes: - - yml - - yaml - DCAE_INVENTORY_JSON: - acceptedTypes: - - json - DCAE_INVENTORY_POLICY: - acceptedTypes: - - emf - DCAE_INVENTORY_DOC: - acceptedTypes: - DCAE_INVENTORY_BLUEPRINT: - acceptedTypes: - DCAE_INVENTORY_EVENT: - acceptedTypes: - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - -resourceInformationalArtifacts: - CHEF: - acceptedTypes: - validForResourceTypes: *allResourceTypes - PUPPET: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SHELL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - YANG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - HEAT: - acceptedTypes: - validForResourceTypes: *allResourceTypes - BPEL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - DG_XML: - acceptedTypes: - validForResourceTypes: *allResourceTypes - MURANO_PKG: - acceptedTypes: - validForResourceTypes: *allResourceTypes - OTHER: - acceptedTypes: - validForResourceTypes: - - VFC - - CVFC - - CP - - VL - - VF - - VFCMT - - Abstract - - PNF - SNMP_POLL: - acceptedTypes: - validForResourceTypes: *allResourceTypes - SNMP_TRAP: - acceptedTypes: - validForResourceTypes: *allResourceTypes - GUIDE: - acceptedTypes: - validForResourceTypes: - - VF - - VFC - - CVFC - PNF_SW_INFORMATION: - acceptedTypes: - - yaml - - yml - validForResourceTypes: - - PNF - unLoggedUrls: - /sdc2/rest/healthCheck @@ -746,4 +479,533 @@ cadiFilterParams: # This configuration entry lists all node type names prefix that shall be allowed on SDC. definedResourceNamespace: - - org.openecomp.resource.
\ No newline at end of file + - org.openecomp.resource. + +artifacts: + - type: CONTROLLER_BLUEPRINT_ARCHIVE + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + - RESOURCE + resourceTypes: + - VF + - PNF + acceptedTypes: + - zip + - type: YANG_XML + categories: + - DEPLOYMENT + - INFORMATIONAL + componentTypes: + - SERVICE + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: VNF_CATALOG + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + - type: MODEL_INVENTORY_PROFILE + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + - type: MODEL_QUERY_SPEC + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + - type: UCPE_LAYER_2_CONFIGURATION + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + #AAI Artifacts + - type: AAI_SERVICE_MODEL + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + - type: AAI_VF_MODULE_MODEL + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + - type: AAI_VF_INSTANCE_MODEL + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + acceptedTypes: + - xml + #Plan + - type: PLAN + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + - RESOURCE + - RESOURCE_INSTANCE + resourceTypes: + - VF + - VFC + acceptedTypes: + - xml + - type: WORKFLOW + categories: + - DEPLOYMENT + componentTypes: + - SERVICE + resourceTypes: + - VFC + - CP + - VL + - VF + - CR + - VFCMT + - Abstract + - CVFC + - PNF + acceptedTypes: + - xml + - type: HEAT + categories: + - DEPLOYMENT + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - yaml + - yml + - type: HEAT_VOL + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - yaml + - yml + - type: HEAT_NET + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - yaml + - yml + - type: HEAT_NESTED + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - yaml + - yml + - type: HEAT_ARTIFACT + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - zip + - tgz + - csar + - type: VNF_CATALOG + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: VF_LICENSE + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: VENDOR_LICENSE + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: MODEL_INVENTORY_PROFILE + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: MODEL_QUERY_SPEC + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - xml + - type: LIFECYCLE_OPERATIONS + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFC + acceptedTypes: + - yaml + - yml + - type: VES_EVENTS + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + - RESOURCE_INSTANCE + resourceTypes: + - VFC + - CP + - VL + - VF + - CR + - VFCMT + - Abstract + - CVFC + - PNF + acceptedTypes: + - yaml + - yml + - type: PERFORMANCE_COUNTER + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + - RESOURCE_INSTANCE + resourceTypes: *allResourceTypes + acceptedTypes: + - csv + - type: APPC_CONFIG + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + acceptedTypes: + - type: DCAE_TOSCA + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFCMT + acceptedTypes: + - yml + - yaml + - type: DCAE_JSON + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFCMT + acceptedTypes: + - json + - type: DCAE_POLICY + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFCMT + acceptedTypes: + - emf + - type: DCAE_DOC + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFCMT + acceptedTypes: + - type: DCAE_EVENT + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFCMT + acceptedTypes: + - type: AAI_VF_MODEL + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + acceptedTypes: + - xml + - type: AAI_VF_MODULE_MODEL + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + acceptedTypes: + - xml + - type: OTHER + categories: + - DEPLOYMENT + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: + - VFC + - CVFC + - CP + - VL + - VF + - VFCMT + - Abstract + - PNF + acceptedTypes: + - type: SNMP_POLL + categories: + - DEPLOYMENT + - INFORMATIONAL + componentTypes: + - RESOURCE + - RESOURCE_INSTANCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: SNMP_TRAP + categories: + - DEPLOYMENT + - INFORMATIONAL + componentTypes: + - RESOURCE + - RESOURCE_INSTANCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: PM_DICTIONARY + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - PNF + acceptedTypes: + - yaml + - yml + - type: YANG_MODULE + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - PNF + acceptedTypes: + - yang + - type: ANSIBLE_PLAYBOOK + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - PNF + acceptedTypes: + - yaml + - yml + - type: ONBOARDED_PACKAGE + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE + resourceTypes: + - VF + - PNF + acceptedTypes: + - csar + - zip + - type: HEAT_ENV + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - env + - type: VF_MODULES_METADATA + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - json + - type: DCAE_INVENTORY_TOSCA + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - yml + - yaml + - type: DCAE_INVENTORY_JSON + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - json + - type: DCAE_INVENTORY_POLICY + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - emf + - type: DCAE_INVENTORY_DOC + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - type: DCAE_INVENTORY_BLUEPRINT + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - type: DCAE_INVENTORY_EVENT + categories: + - DEPLOYMENT + componentTypes: + - RESOURCE_INSTANCE + resourceTypes: + acceptedTypes: + - type: CHEF + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: PUPPET + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: SHELL + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: YANG + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: BPEL + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: DG_XML + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: MURANO_PKG + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: *allResourceTypes + acceptedTypes: + - type: PNF_SW_INFORMATION + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: + - PNF + acceptedTypes: + - yaml + - yml + - type: GUIDE + categories: + - INFORMATIONAL + componentTypes: + - RESOURCE + resourceTypes: + - VF + - VFC + - CVFC + - PNF + acceptedTypes: + - yaml + - yml |