Reuse constants from that library instead of duplicating.
Change-Id: I3963b12586af39b4f09be91bc3c98da8af76eddc
Signed-off-by: Lott, Christopher (cl778h) <cl778h@att.com>
* 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
-------------------------
/application-tlab2.properties
/application.properties
-/users.json
+/dashboard-users.json
<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>
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.
}
/**
- * Uses specified file path
+ * Constructur that accepts a file path
*
* @param userFilePath
* File path
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;
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);
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;
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;
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";
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;
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());
}
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);