Upgrade EPSDK-FW to version 2.6 79/1179/4
authorLott, Christopher (cl778h) <cl778h@att.com>
Thu, 17 Oct 2019 20:03:48 +0000 (16:03 -0400)
committerLott, Christopher (cl778h) <cl778h@att.com>
Mon, 21 Oct 2019 17:33:04 +0000 (13:33 -0400)
Reuse constants from that library instead of duplicating.

Change-Id: I3963b12586af39b4f09be91bc3c98da8af76eddc
Signed-off-by: Lott, Christopher (cl778h) <cl778h@att.com>
docs/release-notes.rst
webapp-backend/.gitignore
webapp-backend/pom.xml
webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardUserManager.java
webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalAuthManager.java
webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalAuthenticationFilter.java
webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/PortalRestCentralServiceTest.java

index a672a8d..42d6364 100644 (file)
@@ -30,6 +30,7 @@ Version 1.2.4, 21 Oct 2019
 * Revise user controller to answer data sent by portal, drop the mock implementation
 * Set global style for page titles
 * Align page titles to top left,decrease font size
+* Update EPSDK-FW to version 2.6
 
 Version 1.2.3, 4 Oct 2019
 -------------------------
index 891095d..02dbd44 100644 (file)
@@ -31,4 +31,4 @@
 
 /application-tlab2.properties
 /application.properties
-/users.json
+/dashboard-users.json
index ad70dcf..c62a236 100644 (file)
@@ -67,7 +67,7 @@ limitations under the License.
                <dependency>
                        <groupId>org.onap.portal.sdk</groupId>
                        <artifactId>epsdk-fw</artifactId>
-                       <version>2.4.0</version>
+                       <version>2.6.0</version>
                        <exclusions>
                                <exclusion>
                                        <groupId>commons-logging</groupId>
index 5561c0e..c5fd101 100644 (file)
@@ -49,13 +49,14 @@ public class DashboardUserManager {
 
        private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
-       public static final String USER_FILE_PATH = "/tmp/dashboard-users.json";
+       // This default value is only useful for development and testing.
+       public static final String USER_FILE_PATH = "dashboard-users.json";
 
        private final File userFile;
        private final List<EcompUser> users;
 
        /**
-        * convenience constructor that uses default file path
+        * Development/test-only constructor that uses default file path.
         * 
         * @param clear
         *                  If true, start empty and remove any existing file.
@@ -75,7 +76,7 @@ public class DashboardUserManager {
        }
 
        /**
-        * Uses specified file path
+        * Constructur that accepts a file path
         * 
         * @param userFilePath
         *                         File path
index 8eb7362..dc70f7e 100644 (file)
@@ -27,6 +27,7 @@ import java.util.Map;
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 
+import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestCentralService;
 import org.onap.portalsdk.core.onboarding.exception.CipherUtilException;
 import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
 import org.slf4j.Logger;
@@ -48,10 +49,9 @@ public class PortalAuthManager {
                        throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException,
                        InvocationTargetException, NoSuchMethodException, SecurityException {
                credentialsMap = new HashMap<>();
-               // The map keys are hardcoded in EPSDK-FW, no constants are defined :(
-               credentialsMap.put("appName", appName);
-               credentialsMap.put("username", username);
-               credentialsMap.put("password", password);
+               credentialsMap.put(IPortalRestCentralService.CREDENTIALS_APP, appName);
+               credentialsMap.put(IPortalRestCentralService.CREDENTIALS_USER, username);
+               credentialsMap.put(IPortalRestCentralService.CREDENTIALS_PASS, password);
                this.userIdCookieName = userCookie;
                // Instantiate here so configuration errors are detected at app-start time
                logger.debug("ctor: using decryptor class {}", decryptorClassName);
index febf8c9..4b6de91 100644 (file)
@@ -36,6 +36,7 @@ import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.onap.portalsdk.core.onboarding.util.KeyProperties;
 import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
 import org.onap.portalsdk.core.onboarding.util.PortalApiProperties;
 import org.onap.portalsdk.core.restful.domain.EcompRole;
@@ -43,6 +44,7 @@ import org.onap.portalsdk.core.restful.domain.EcompUser;
 import org.oransc.ric.portal.dashboard.DashboardConstants;
 import org.oransc.ric.portal.dashboard.DashboardUserManager;
 import org.oransc.ric.portal.dashboard.model.EcompUserDetails;
+import org.owasp.esapi.reference.DefaultSecurityConfiguration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.http.MediaType;
@@ -79,8 +81,9 @@ public class PortalAuthenticationFilter implements Filter {
 
        private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
-       // Unfortunately these names are not available as constants
-       private static final String[] securityPropertyFiles = { "ESAPI.properties", "key.properties", "portal.properties",
+       // Unfortunately not all file names are defined as constants
+       private static final String[] securityPropertyFiles = { KeyProperties.PROPERTY_FILE_NAME,
+                       PortalApiProperties.PROPERTY_FILE_NAME, DefaultSecurityConfiguration.DEFAULT_RESOURCE_FILE,
                        "validation.properties" };
 
        public static final String REDIRECT_URL_KEY = "redirectUrl";
index e1c48ea..1124090 100644 (file)
@@ -21,11 +21,16 @@ package org.oransc.ric.portal.dashboard.controller;
 
 import java.lang.invoke.MethodHandles;
 import java.net.URI;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
 
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
+import org.onap.portalsdk.core.restful.domain.EcompRole;
 import org.onap.portalsdk.core.restful.domain.EcompUser;
+import org.oransc.ric.portal.dashboard.DashboardConstants;
 import org.oransc.ric.portal.dashboard.config.PortalApIMockConfiguration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -68,14 +73,25 @@ public class PortalRestCentralServiceTest extends AbstractControllerTest {
                return entity;
        }
 
+       private EcompUser createEcompUser(String loginId) {
+               EcompUser user = new EcompUser();
+               user.setLoginId(loginId);
+               EcompRole role = new EcompRole();
+               role.setRoleFunctions(Collections.EMPTY_SET);
+               role.setId(1L);
+               role.setName(DashboardConstants.ROLE_NAME_ADMIN);
+               Set<EcompRole> roles = new HashSet<>();
+               roles.add(role);
+               user.setRoles(roles);
+               return user;
+       }
+
        @Test
        public void createUserTest() {
                final String loginId = "login1";
                URI create = buildUri(null, PortalApiConstants.API_PREFIX, "user");
                logger.info("Invoking {}", create);
-               EcompUser user = new EcompUser();
-               user.setLoginId(loginId);
-               HttpEntity<Object> requestEntity = getEntityWithHeaders(user);
+               HttpEntity<Object> requestEntity = getEntityWithHeaders(createEcompUser(loginId));
                ResponseEntity<String> response = restTemplate.exchange(create, HttpMethod.POST, requestEntity, String.class);
                Assertions.assertTrue(response.getStatusCode().is2xxSuccessful());
        }
@@ -84,9 +100,8 @@ public class PortalRestCentralServiceTest extends AbstractControllerTest {
        public void updateUserTest() {
                final String loginId = "login2";
                URI create = buildUri(null, PortalApiConstants.API_PREFIX, "user");
+               EcompUser user = createEcompUser(loginId);
                logger.info("Invoking {}", create);
-               EcompUser user = new EcompUser();
-               user.setLoginId(loginId);
                HttpEntity<Object> requestEntity = getEntityWithHeaders(user);
                // Create
                ResponseEntity<String> response = restTemplate.exchange(create, HttpMethod.POST, requestEntity, String.class);