aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2023-09-13 12:12:46 +0100
committerVasyl Razinkov <vasyl.razinkov@est.tech>2023-09-27 20:50:45 +0000
commit5f3e9912406897ee18c424b940881ce08d59bb44 (patch)
tree044f7d60aa41ddbd8f0fdeb54f2e16ff21bd58bf /catalog-be/src/test
parentd4fd2ca0fba827042fc5313efeaf9cdf850be647 (diff)
Remove legacy certificate handling
Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-4621 Change-Id: I834f2a0a4f73693dbb656dfa9186506bf88c62c1
Diffstat (limited to 'catalog-be/src/test')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/ExternalRefsServletTest.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/filters/GatewayFilterTest.java150
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/impl/aaf/RoleAndPermissionEnumTest.java70
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/impl/aaf/RoleAuthorizationHandlerTest.java121
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyServletTest.java3
-rw-r--r--catalog-be/src/test/resources/config/catalog-be/auth/configuration.yaml1
-rw-r--r--catalog-be/src/test/resources/config/catalog-be/configuration.yaml24
7 files changed, 0 insertions, 370 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/ExternalRefsServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/ExternalRefsServletTest.java
index b912891157..a4bf30a668 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/ExternalRefsServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/ExternalRefsServletTest.java
@@ -191,7 +191,6 @@ class ExternalRefsServletTest extends JerseyTest {
configuration.setJanusGraphInMemoryGraph(true);
HeatDeploymentArtifactTimeout heatDeploymentArtifactTimeout = new HeatDeploymentArtifactTimeout();
heatDeploymentArtifactTimeout.setDefaultMinutes(30);
- configuration.setAafAuthNeeded(false);
configuration.setHeatArtifactDeploymentTimeout(heatDeploymentArtifactTimeout);
configurationManager.setConfiguration(configuration);
ExternalConfiguration.setAppName("catalog-be");
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/filters/GatewayFilterTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/filters/GatewayFilterTest.java
deleted file mode 100644
index 56b2d46746..0000000000
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/filters/GatewayFilterTest.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2020 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.be.filters;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.mockito.Spy;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.openecomp.sdc.be.components.impl.ResponseFormatManager;
-import org.openecomp.sdc.be.config.Configuration;
-import org.openecomp.sdc.be.config.ConfigurationManager;
-import org.openecomp.sdc.be.servlets.exception.ComponentExceptionMapper;
-import org.openecomp.sdc.common.api.ConfigurationSource;
-import org.openecomp.sdc.common.api.FilterDecisionEnum;
-import org.openecomp.sdc.common.impl.ExternalConfiguration;
-import org.openecomp.sdc.common.impl.FSConfigurationSource;
-import org.openecomp.sdc.common.util.ThreadLocalsHolder;
-
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.ws.rs.core.HttpHeaders;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.when;
-
-
-@RunWith(MockitoJUnitRunner.class)
-public class GatewayFilterTest {
-
- private static final List<String> excludedUrls = Arrays.asList("test1", "test2");
- private static final String cookieName = "myCookie";
-
- static ResponseFormatManager responseFormatManager = new ResponseFormatManager();
- static ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be");
- static ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
-
- @InjectMocks
- private GatewayFilter filter;
- @Spy
- private ThreadLocalUtils threadLocalUtils;
- @Mock
- private Configuration.CookieConfig authCookieConf;
- @Mock
- private Configuration configuration;
- @Mock
- private HttpServletRequest request;
- @Mock
- private FilterChain filterChain;
- @Mock
- private HttpServletResponse response;
- @Mock
- private ComponentExceptionMapper componentExceptionMapper;
-
-
-
- @Before
- public void initMocks(){
- MockitoAnnotations.openMocks(this);
- }
-
- @Before
- public void setUp() throws ServletException {
- doNothing().when(threadLocalUtils).setUserContextFromDB(request);
- when(configuration.getAuthCookie()).thenReturn(authCookieConf);
- this.filter = new GatewayFilter(configuration);
- ThreadLocalsHolder.setApiType(null);
- assertNotNull(filter);
- }
-
- @Test
- public void validateRequestFromWhiteList() throws ServletException, IOException {
- when(authCookieConf.getExcludedUrls()).thenReturn(excludedUrls);
- when(request.getPathInfo()).thenReturn("test1");
- filter.doFilter(request, response, filterChain);
- assertTrue(ThreadLocalsHolder.getApiType().equals(FilterDecisionEnum.NA));
- Mockito.verify(filterChain, times(1)).doFilter(request, response);
- }
-
- private Enumeration getHeaderEnumerationObj(List<String> arrlist){
-
- // creating object of type Enumeration<String>
- Enumeration<String> enumer = Collections.enumeration(arrlist);
- return enumer;
- }
-
-
-
-
-
-
- private Cookie[] getCookiesFromReq(boolean isFromRequest) {
- Cookie[] cookies = new Cookie [1];
- if (isFromRequest) {
- cookies[0] = new Cookie(cookieName, "cookieData");
- }
- else {
- cookies[0] = new Cookie("dummy", "cookieData");
- }
- return cookies;
- }
-
- private String getCookieNameFromConf(boolean isFromConfiguration) {
- Cookie[] cookies = new Cookie [1];
- if (isFromConfiguration) {
- cookies[0] = new Cookie(cookieName, "cookieData");
- }
- else {
- cookies[0] = new Cookie("dummy", "cookieData");
- }
- return cookies[0].getName();
- }
-} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/aaf/RoleAndPermissionEnumTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/aaf/RoleAndPermissionEnumTest.java
deleted file mode 100644
index 2831a811a8..0000000000
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/aaf/RoleAndPermissionEnumTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2020 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.be.impl.aaf;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openecomp.sdc.be.components.impl.aaf.AafPermission;
-import org.openecomp.sdc.be.components.impl.aaf.AafRoles;
-import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
-import org.openecomp.sdc.be.config.ConfigurationManager;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.common.api.ConfigurationSource;
-import org.openecomp.sdc.common.impl.ExternalConfiguration;
-import org.openecomp.sdc.common.impl.FSConfigurationSource;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.catchThrowable;
-
-public class RoleAndPermissionEnumTest {
- private static ConfigurationSource configurationSource = new FSConfigurationSource(
- ExternalConfiguration.getChangeListener(), "src/test/resources/config/catalog-be");
- private static ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
- private final String prefix = ".app.";
-
- @Test
- public void getRoleReadOnly() {
- Assert.assertEquals(configurationManager.getConfiguration().getAafNamespace() + prefix + "readonly", AafRoles.READ_ONLY.getRole());
- }
-
- @Test
- public void getRoleAll() {
- Assert.assertEquals(configurationManager.getConfiguration().getAafNamespace() + prefix + "all", AafRoles.ALL.getRole());
- }
-
- @Test
- public void testGetEnumByStringWithExistingValue() {
- Assert.assertEquals(AafPermission.getEnumByString(AafPermission.PermNames.READ_VALUE),
- AafPermission.READ);
- Assert.assertEquals(AafPermission.getEnumByString(AafPermission.PermNames.WRITE_VALUE),
- AafPermission.WRITE);
- Assert.assertEquals(AafPermission.getEnumByString(AafPermission.PermNames.DELETE_VALUE),
- AafPermission.DELETE);
- }
-
- @Test
- public void testGetEnumByStringNonExistingValue() {
- ComponentException thrown = (ComponentException) catchThrowable(()-> AafPermission.getEnumByString("stam"));
- assertThat(thrown.getActionStatus()).isEqualTo(ActionStatus.INVALID_PROPERTY);
- assertThat(thrown.getParams()[0]).isEqualTo("stam");
- }
-
-}
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
deleted file mode 100644
index d9f249a42a..0000000000
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/aaf/RoleAuthorizationHandlerTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2020 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.be.impl.aaf;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.catchThrowable;
-import static org.mockito.Mockito.when;
-
-import java.util.Collections;
-import javax.servlet.http.HttpServletRequest;
-import org.aspectj.lang.JoinPoint;
-import org.aspectj.lang.Signature;
-import org.hibernate.validator.internal.util.annotation.AnnotationDescriptor;
-import org.hibernate.validator.internal.util.annotation.AnnotationDescriptor.Builder;
-import org.hibernate.validator.internal.util.annotation.AnnotationFactory;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.junit.jupiter.MockitoExtension;
-import org.openecomp.sdc.be.components.impl.aaf.AafPermission;
-import org.openecomp.sdc.be.components.impl.aaf.AafPermission.PermNames;
-import org.openecomp.sdc.be.components.impl.aaf.PermissionAllowed;
-import org.openecomp.sdc.be.components.impl.aaf.RoleAuthorizationHandler;
-import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
-import org.openecomp.sdc.be.config.ConfigurationManager;
-import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.servlets.BeGenericServlet;
-import org.openecomp.sdc.common.api.FilterDecisionEnum;
-import org.openecomp.sdc.common.impl.ExternalConfiguration;
-import org.openecomp.sdc.common.impl.FSConfigurationSource;
-import org.openecomp.sdc.common.util.ThreadLocalsHolder;
-
-@ExtendWith(MockitoExtension.class)
-class RoleAuthorizationHandlerTest {
-
- private RoleAuthorizationHandler roleAuthorizationHandler;
- @Mock
- private JoinPoint joinPoint;
- @Mock
- private Signature signature;
- @Mock
- private BeGenericServlet beGenericServlet;
- @Mock
- private HttpServletRequest httpServletRequest;
-
- @BeforeEach
- public void setUp() {
- MockitoAnnotations.openMocks(this);
- when(joinPoint.getSignature()).thenReturn(signature);
- when(signature.toShortString()).thenReturn("methodName");
- when(joinPoint.getThis()).thenReturn(beGenericServlet);
- 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
- void testAuthorizeRoleOnePermittedRole() {
- final String[] permsAllowed = {PermNames.WRITE_VALUE};
- final AnnotationDescriptor<PermissionAllowed> permissionDescriptor = createTestSubject(permsAllowed);
- final PermissionAllowed rolesAllowed = AnnotationFactory.create(permissionDescriptor);
- when(httpServletRequest.isUserInRole(AafPermission.getEnumByString(permsAllowed[0]).getFullPermission())).thenReturn(true);
- roleAuthorizationHandler.authorizeRole(joinPoint, rolesAllowed);
- }
-
- @Test
- void testAuthorizeRoleTwoPermittedRole() {
- final String[] permsAllowed = {PermNames.WRITE_VALUE, PermNames.READ_VALUE};
- final AnnotationDescriptor<PermissionAllowed> permissionDescriptor = createTestSubject(permsAllowed);
- final PermissionAllowed rolesAllowed = AnnotationFactory.create(permissionDescriptor);
- when(httpServletRequest.isUserInRole(AafPermission.getEnumByString(permsAllowed[0]).getFullPermission())).thenReturn(true);
- roleAuthorizationHandler.authorizeRole(joinPoint, rolesAllowed);
- }
-
- @Test
- void testAuthorizeRoleNonPermittedRole() {
- final String[] permsAllowed = {PermNames.WRITE_VALUE, PermNames.READ_VALUE};
- final AnnotationDescriptor<PermissionAllowed> permissionDescriptor = createTestSubject(permsAllowed);
- final PermissionAllowed rolesAllowed = AnnotationFactory.create(permissionDescriptor);
- when(httpServletRequest.isUserInRole(AafPermission.getEnumByString(permsAllowed[0]).getFullPermission())).thenReturn(false);
-
- final ComponentException thrown = (ComponentException) catchThrowable(() -> roleAuthorizationHandler.authorizeRole(joinPoint, rolesAllowed));
- assertThat(thrown.getActionStatus()).isEqualTo(ActionStatus.AUTH_FAILED);
- }
-
- @Test
- void testAuthorizeRoleEmptyRole() {
- final String[] permsAllowed = {};
- final AnnotationDescriptor<PermissionAllowed> permissionDescriptor = createTestSubject(permsAllowed);
- final PermissionAllowed rolesAllowed = AnnotationFactory.create(permissionDescriptor);
-
- final ComponentException thrown = (ComponentException) catchThrowable(() -> roleAuthorizationHandler.authorizeRole(joinPoint, rolesAllowed));
- assertThat(thrown.getActionStatus()).isEqualTo(ActionStatus.AUTH_FAILED);
- }
-
- private AnnotationDescriptor<PermissionAllowed> createTestSubject(final String[] permsAllowed) {
- return new Builder<>(PermissionAllowed.class, Collections.singletonMap("value", permsAllowed)).build();
- }
-
-}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyServletTest.java
index 2b790a4137..87d33b955e 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/PolicyServletTest.java
@@ -61,7 +61,6 @@ import org.mockito.Spy;
import org.openecomp.sdc.be.components.impl.BaseBusinessLogic;
import org.openecomp.sdc.be.components.impl.PolicyBusinessLogic;
import org.openecomp.sdc.be.components.impl.ResponseFormatManager;
-import org.openecomp.sdc.be.components.impl.aaf.RoleAuthorizationHandler;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.components.property.PropertyDeclarationOrchestrator;
@@ -106,7 +105,6 @@ class PolicyServletTest extends JerseySpringBaseTest {
private static ServletUtils servletUtils;
private static PropertyDeclarationOrchestrator propertyDeclarationOrchestrator;
private static ToscaOperationFacade toscaOperationFacade;
- private static RoleAuthorizationHandler roleAuthorizationHandler;
private static ResponseFormat responseFormat;
@Captor
private static ArgumentCaptor<PolicyDefinition> policyCaptor;
@@ -538,7 +536,6 @@ class PolicyServletTest extends JerseySpringBaseTest {
componentsUtils = Mockito.mock(ComponentsUtils.class);
servletUtils = Mockito.mock(ServletUtils.class);
responseFormat = Mockito.mock(ResponseFormat.class);
- roleAuthorizationHandler = Mockito.mock(RoleAuthorizationHandler.class);
}
private static class BaseBusinessLogicTest extends BaseBusinessLogic {
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
deleted file mode 100644
index f13e74bdcc..0000000000
--- a/catalog-be/src/test/resources/config/catalog-be/auth/configuration.yaml
+++ /dev/null
@@ -1 +0,0 @@
-aafAuthNeeded: true \ 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 282c4d32f0..3ec3793d43 100644
--- a/catalog-be/src/test/resources/config/catalog-be/configuration.yaml
+++ b/catalog-be/src/test/resources/config/catalog-be/configuration.yaml
@@ -97,8 +97,6 @@ cassandraConfig:
username: koko
password: bobo
ssl: false
- truststorePath : /path/path
- truststorePassword : 123123
keySpaces:
- { name: sdcaudit, replicationStrategy: SimpleStrategy, replicationInfo: ['1']}
- { name: sdcartifact, replicationStrategy: SimpleStrategy, replicationInfo: ['1']}
@@ -476,8 +474,6 @@ dmaapConsumerConfiguration:
password: XyCUPhFx9u70aklYGo6OiA==
aftDme2SslEnable: true
aftDme2ClientIgnoreSslConfig: false
- aftDme2ClientKeystore: /opt/app/jetty/base/be/config/.truststore
- aftDme2ClientKeystorePassword: XyCUPhFx9u70aklYGo6OiA==
aftDme2ClientSslCertAlias: certman
dmaapProducerConfiguration:
@@ -538,26 +534,6 @@ healthStatusExclude:
- ES
- DMAAP
-aafNamespace: com.att.sdc
-
-aafAuthNeeded: false
-
-cadiFilterParams:
- AFT_LATITUDE: "32.780140"
- AFT_LONGITUDE: "-96.800451"
- hostname: 192.168.33.10
- aaf_id: aaf@sdc.onap.org
- aaf_env: TEST
- aaf_url: https://aaftest.onap.org/locate/
- 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
-
# This configuration entry lists all node type names prefix that shall be allowed on SDC.
definedResourceNamespace:
- org.openecomp.resource.