From 50fb3b40ec45a65ba7c687e290a3d7f491484b49 Mon Sep 17 00:00:00 2001 From: "Lott, Christopher (cl778h)" Date: Fri, 18 Oct 2019 12:05:49 -0400 Subject: [PATCH] Revise user controller to answer real data Answer requests for user data with EcompUser items supplied by Portal. Drop the DashboardUser model and mock data. Revise front-end to use new data type and show loginId in table. Move creation of user mgr bean to new standalone admin config classes. Change-Id: I4e4cf76296724456540db9c627ed1c37721dca75 Signed-off-by: Lott, Christopher (cl778h) --- docs/release-notes.rst | 3 +- .../{portalapi => }/DashboardUserManager.java | 14 +++- .../dashboard/config/AdminConfiguration.java | 58 +++++++++++++++++ .../dashboard/config/CaasIngressConfiguration.java | 3 +- .../dashboard/config/WebSecurityConfiguration.java | 15 ++--- .../dashboard/controller/AdminController.java | 34 +++++----- .../ric/portal/dashboard/model/DashboardUser.java | 75 --------------------- .../portalapi/PortalAuthenticationFilter.java | 1 + .../portalapi/PortalRestCentralServiceImpl.java | 1 + .../config/A1MediatorMockConfiguration.java | 2 +- .../dashboard/config/AdminMockConfiguration.java | 76 ++++++++++++++++++++++ .../dashboard/config/AnrXappMockConfiguration.java | 2 +- .../config/AppManagerMockConfiguration.java | 2 +- .../config/CaasIngressMockConfiguration.java | 2 +- .../config/E2ManagerMockConfiguration.java | 2 +- .../config/WebSecurityMockConfiguration.java | 27 -------- .../dashboard/controller/AdminControllerTest.java | 6 +- .../controller/CaasIngressControllerTest.java | 6 +- .../src/app/interfaces/dashboard.types.ts | 36 ++++++++-- .../app/services/dashboard/dashboard.service.ts | 12 ++-- webapp-frontend/src/app/user/user.component.html | 12 ++-- webapp-frontend/src/app/user/user.component.ts | 10 +-- webapp-frontend/src/app/user/user.datasource.ts | 22 +++---- 23 files changed, 242 insertions(+), 179 deletions(-) rename webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/{portalapi => }/DashboardUserManager.java (95%) create mode 100644 webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/AdminConfiguration.java delete mode 100644 webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/DashboardUser.java create mode 100644 webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AdminMockConfiguration.java diff --git a/docs/release-notes.rst b/docs/release-notes.rst index f4f2dc37..aec43e61 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -19,7 +19,7 @@ RIC Dashboard Release Notes =========================== -Version 1.2.4, 10 Oct 2019 +Version 1.2.4, 18 Oct 2019 -------------------------- * Revise a1-med-client to use API spec in new submodule ric-plt/a1; removed cached copy @@ -27,6 +27,7 @@ Version 1.2.4, 10 Oct 2019 removed cached copy * Add Platform page showing Kubernetes pods in aux and platform obtained from CAAS-Ingress * Update Angular libraries to recent stable versions +* Revise user controller to answer data sent by portal, drop the mock implementation Version 1.2.3, 4 Oct 2019 ------------------------- diff --git a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/DashboardUserManager.java b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardUserManager.java similarity index 95% rename from webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/DashboardUserManager.java rename to webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardUserManager.java index 1fb2b1f9..5561c0e0 100644 --- a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/DashboardUserManager.java +++ b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardUserManager.java @@ -17,7 +17,7 @@ * limitations under the License. * ========================LICENSE_END=================================== */ -package org.oransc.ric.portal.dashboard.portalapi; +package org.oransc.ric.portal.dashboard; import java.io.File; import java.io.IOException; @@ -30,7 +30,6 @@ import java.util.Set; import org.onap.portalsdk.core.onboarding.exception.PortalAPIException; 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.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,7 +39,7 @@ import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; /** - * Provides user-management services. + * Provides simple user-management services. * * This first implementation serializes user details to a file. * @@ -98,6 +97,15 @@ public class DashboardUserManager { } } + /** + * Gets the current users. + * + * @return List of EcompUser objects, possibly empty + */ + public List getUsers() { + return this.users; + } + /** * Gets the user with the specified login Id * diff --git a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/AdminConfiguration.java b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/AdminConfiguration.java new file mode 100644 index 00000000..696d74f6 --- /dev/null +++ b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/AdminConfiguration.java @@ -0,0 +1,58 @@ +/*- + * ========================LICENSE_START================================= + * O-RAN-SC + * %% + * Copyright (C) 2019 AT&T Intellectual Property + * %% + * 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.oransc.ric.portal.dashboard.config; + +import java.io.IOException; +import java.lang.invoke.MethodHandles; + +import org.oransc.ric.portal.dashboard.DashboardUserManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; + +/** + * Creates an instance of the user manager. + */ +@Configuration +@Profile("!test") +public class AdminConfiguration { + + private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + // Populated by the autowired constructor + private final String userfile; + + @Autowired + public AdminConfiguration(@Value("${userfile}") final String userfile) { + logger.debug("ctor userfile '{}'", userfile); + this.userfile = userfile; + } + + @Bean + // The bean (method) name must be globally unique + public DashboardUserManager userManager() throws IOException { + return new DashboardUserManager(userfile); + } + +} diff --git a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/CaasIngressConfiguration.java b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/CaasIngressConfiguration.java index 55398ded..397a5dc8 100644 --- a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/CaasIngressConfiguration.java +++ b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/CaasIngressConfiguration.java @@ -31,13 +31,14 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; import org.springframework.web.util.DefaultUriBuilderFactory; /** * Creates instances of CAAS-Ingres clients. */ -@org.springframework.context.annotation.Configuration +@Configuration @Profile("!test") public class CaasIngressConfiguration { diff --git a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/WebSecurityConfiguration.java b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/WebSecurityConfiguration.java index 9d259160..33458bad 100644 --- a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/WebSecurityConfiguration.java +++ b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/WebSecurityConfiguration.java @@ -24,17 +24,18 @@ import java.lang.invoke.MethodHandles; import java.lang.reflect.InvocationTargetException; import org.onap.portalsdk.core.onboarding.util.PortalApiConstants; +import org.oransc.ric.portal.dashboard.DashboardUserManager; import org.oransc.ric.portal.dashboard.controller.A1MediatorController; import org.oransc.ric.portal.dashboard.controller.AdminController; import org.oransc.ric.portal.dashboard.controller.AnrXappController; import org.oransc.ric.portal.dashboard.controller.AppManagerController; import org.oransc.ric.portal.dashboard.controller.E2ManagerController; import org.oransc.ric.portal.dashboard.controller.SimpleErrorController; -import org.oransc.ric.portal.dashboard.portalapi.DashboardUserManager; import org.oransc.ric.portal.dashboard.portalapi.PortalAuthManager; import org.oransc.ric.portal.dashboard.portalapi.PortalAuthenticationFilter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -69,8 +70,9 @@ public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter { private String decryptor; @Value("${portalapi.usercookie}") private String userCookie; - @Value("${userfile}") - private String userFilePath; + + @Autowired + DashboardUserManager userManager; protected void configure(HttpSecurity http) throws Exception { logger.debug("configure: portalapi.username {}", userName); @@ -117,11 +119,6 @@ public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter { return new PortalAuthManager(appName, userName, password, decryptor, userCookie); } - @Bean - public DashboardUserManager dashboardUserManagerBean() throws IOException { - return new DashboardUserManager(userFilePath); - } - /* * If this is annotated with @Bean, it is created automatically AND REGISTERED, * and Spring processes annotations in the source of the class. However, the @@ -135,7 +132,7 @@ public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter { throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { PortalAuthenticationFilter portalAuthenticationFilter = new PortalAuthenticationFilter(portalapiSecurity, - portalAuthManagerBean(), dashboardUserManagerBean()); + portalAuthManagerBean(), this.userManager); return portalAuthenticationFilter; } diff --git a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/AdminController.java b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/AdminController.java index 6b420d3c..041ddaa4 100644 --- a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/AdminController.java +++ b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/AdminController.java @@ -20,24 +20,27 @@ package org.oransc.ric.portal.dashboard.controller; import java.lang.invoke.MethodHandles; +import java.util.List; import javax.servlet.http.HttpServletResponse; +import org.onap.portalsdk.core.restful.domain.EcompUser; import org.oransc.ric.portal.dashboard.DashboardApplication; import org.oransc.ric.portal.dashboard.DashboardConstants; -import org.oransc.ric.portal.dashboard.model.DashboardUser; +import org.oransc.ric.portal.dashboard.DashboardUserManager; import org.oransc.ric.portal.dashboard.model.ErrorTransport; import org.oransc.ric.portal.dashboard.model.IDashboardResponse; import org.oransc.ric.portal.dashboard.model.SuccessTransport; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.http.MediaType; import org.springframework.security.access.annotation.Secured; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.RestController; import io.swagger.annotations.ApiOperation; @@ -57,25 +60,16 @@ public class AdminController { public static final String VERSION_METHOD = DashboardConstants.VERSION_METHOD; public static final String XAPPMETRICS_METHOD = "metrics"; - private final DashboardUser[] users; - - private static final String ACTIVE = "Active"; - private static final String INACTIVE = "Inactive"; - @Value("${metrics.url.ac}") private String acAppMetricsUrl; @Value("${metrics.url.mc}") private String mcAppMetricsUrl; + @Autowired + private DashboardUserManager dashboardUserManager; + public AdminController() { - // Mock data - users = new DashboardUser[] { // - new DashboardUser(1, "John", "Doe", ACTIVE), // - new DashboardUser(2, "Alice", "Nolan", ACTIVE), // - new DashboardUser(3, "Pierce", "King", INACTIVE), // - new DashboardUser(4, "Paul", "Smith", INACTIVE), // - new DashboardUser(5, "Jack", "Reacher", ACTIVE) }; } @ApiOperation(value = "Gets the Dashboard MANIFEST.MF property Implementation-Version.", response = SuccessTransport.class) @@ -97,16 +91,17 @@ public class AdminController { return new SuccessTransport(200, "Dashboard is healthy!"); } - @ApiOperation(value = "Gets the list of application users.", response = DashboardUser.class, responseContainer = "List") + @ApiOperation(value = "Gets the list of application users.", response = EcompUser.class, responseContainer = "List") @GetMapping(USER_METHOD) - @Secured({ DashboardConstants.ROLE_ADMIN }) - public DashboardUser[] getUsers() { + @Secured({ DashboardConstants.ROLE_ADMIN }) // regular users should not see this + public List getUsers() { logger.debug("getUsers"); - return users; + return dashboardUserManager.getUsers(); } @ApiOperation(value = "Gets the kibana metrics URL for the specified app.", response = SuccessTransport.class) @GetMapping(XAPPMETRICS_METHOD) + // No role required public IDashboardResponse getAppMetricsUrl(@RequestParam String app, HttpServletResponse response) { String metricsUrl = null; if (DashboardConstants.APP_NAME_AC.equals(app)) @@ -121,4 +116,5 @@ public class AdminController { return new ErrorTransport(400, "Client provided app name is invalid as: " + app); } } + } diff --git a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/DashboardUser.java b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/DashboardUser.java deleted file mode 100644 index e17f86d5..00000000 --- a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/model/DashboardUser.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * %% - * 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=================================== - */ - -/* - * TODO: this mocks user properties until integration with ONAP Portal is done. - */ -package org.oransc.ric.portal.dashboard.model; - -public class DashboardUser { - - private long id; - private String firstName; - private String lastName; - private String status; - - public DashboardUser() { - } - - public DashboardUser(long id, String firstName, String lastName, String status) { - this.id = id; - this.firstName = firstName; - this.lastName = lastName; - this.status = status; - } - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - -} diff --git a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalAuthenticationFilter.java b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalAuthenticationFilter.java index 10fef82d..febf8c9a 100644 --- a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalAuthenticationFilter.java +++ b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalAuthenticationFilter.java @@ -41,6 +41,7 @@ import org.onap.portalsdk.core.onboarding.util.PortalApiProperties; 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.DashboardUserManager; import org.oransc.ric.portal.dashboard.model.EcompUserDetails; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalRestCentralServiceImpl.java b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalRestCentralServiceImpl.java index 7bce9750..581ca25d 100644 --- a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalRestCentralServiceImpl.java +++ b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/portalapi/PortalRestCentralServiceImpl.java @@ -28,6 +28,7 @@ import javax.servlet.http.HttpServletRequest; import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestCentralService; import org.onap.portalsdk.core.onboarding.exception.PortalAPIException; import org.onap.portalsdk.core.restful.domain.EcompUser; +import org.oransc.ric.portal.dashboard.DashboardUserManager; import org.oransc.ric.portal.dashboard.config.SpringContextCache; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/A1MediatorMockConfiguration.java b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/A1MediatorMockConfiguration.java index 2d31c0eb..877f0976 100644 --- a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/A1MediatorMockConfiguration.java +++ b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/A1MediatorMockConfiguration.java @@ -44,8 +44,8 @@ import com.fasterxml.jackson.databind.node.ObjectNode; /** * Creates a mock implementation of the A1 mediator client API. */ -@Profile("test") @Configuration +@Profile("test") public class A1MediatorMockConfiguration { private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); diff --git a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AdminMockConfiguration.java b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AdminMockConfiguration.java new file mode 100644 index 00000000..7c52b99d --- /dev/null +++ b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AdminMockConfiguration.java @@ -0,0 +1,76 @@ +/*- + * ========================LICENSE_START================================= + * O-RAN-SC + * %% + * Copyright (C) 2019 AT&T Intellectual Property + * %% + * 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.oransc.ric.portal.dashboard.config; + +import java.io.IOException; +import java.lang.invoke.MethodHandles; +import java.util.HashSet; +import java.util.Set; + +import org.onap.portalsdk.core.onboarding.exception.PortalAPIException; +import org.onap.portalsdk.core.restful.domain.EcompRole; +import org.onap.portalsdk.core.restful.domain.EcompUser; +import org.oransc.ric.portal.dashboard.DashboardUserManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; + +/** + * Creates a user manager with mock data. + */ +@Configuration +@Profile("test") +public class AdminMockConfiguration { + + private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + @Autowired + public AdminMockConfiguration() { + } + + @Bean + // The bean (method) name must be globally unique + public DashboardUserManager userManager() throws IOException, PortalAPIException { + logger.debug("userManager: adding mock data"); + DashboardUserManager mgr = new DashboardUserManager(true); + String[] firsts = { "John", "Alice", "Pierce", "Paul", "Jack" }; + String[] lasts = { "Doe", "Nolan", "King", "Smith", "Reacher" }; + String[] logins = { "jdoe", "anolan", "pking", "psmith", "jreacher" }; + boolean[] actives = { true, true, false, false, true }; + EcompRole role = new EcompRole(); + role.setName("view"); + Set roles = new HashSet<>(); + roles.add(role); + for (int i = 0; i < firsts.length; ++i) { + EcompUser eu = new EcompUser(); + eu.setFirstName(firsts[i]); + eu.setLastName(lasts[i]); + eu.setLoginId(logins[i]); + eu.setActive(actives[i]); + eu.setRoles(roles); + mgr.createUser(eu); + } + return mgr; + } + +} diff --git a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AnrXappMockConfiguration.java b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AnrXappMockConfiguration.java index 29cc8a87..dac3ff6b 100644 --- a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AnrXappMockConfiguration.java +++ b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AnrXappMockConfiguration.java @@ -46,8 +46,8 @@ import org.springframework.http.HttpStatus; /** * Creates a mock implementation of the ANR xApp client APIs. */ -@Profile("test") @Configuration +@Profile("test") public class AnrXappMockConfiguration { private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); diff --git a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AppManagerMockConfiguration.java b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AppManagerMockConfiguration.java index f08df052..09a9d098 100644 --- a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AppManagerMockConfiguration.java +++ b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AppManagerMockConfiguration.java @@ -52,8 +52,8 @@ import org.springframework.http.HttpStatus; * Creates an implementation of the xApp manager client that answers requests * with mock data. */ -@Profile("test") @Configuration +@Profile("test") public class AppManagerMockConfiguration { private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); diff --git a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/CaasIngressMockConfiguration.java b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/CaasIngressMockConfiguration.java index b75ab5a3..6b124935 100644 --- a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/CaasIngressMockConfiguration.java +++ b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/CaasIngressMockConfiguration.java @@ -39,8 +39,8 @@ import org.springframework.context.annotation.Profile; * Creates mock implementations of Kubernetes clients that answer requests with * sample data read from the filesystem. */ -@Profile("test") @Configuration +@Profile("test") public class CaasIngressMockConfiguration { private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); diff --git a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/E2ManagerMockConfiguration.java b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/E2ManagerMockConfiguration.java index d76cb830..b3b4c9c1 100644 --- a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/E2ManagerMockConfiguration.java +++ b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/E2ManagerMockConfiguration.java @@ -49,8 +49,8 @@ import org.springframework.http.HttpStatus; /** * Creates a mock implementation of the E2 Manager client API. */ -@Profile("test") @Configuration +@Profile("test") public class E2ManagerMockConfiguration { private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); diff --git a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/WebSecurityMockConfiguration.java b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/WebSecurityMockConfiguration.java index c3623e92..80cde661 100644 --- a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/WebSecurityMockConfiguration.java +++ b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/WebSecurityMockConfiguration.java @@ -19,20 +19,12 @@ */ package org.oransc.ric.portal.dashboard.config; -import java.io.IOException; import java.lang.invoke.MethodHandles; -import java.util.HashSet; -import java.util.Set; -import org.onap.portalsdk.core.onboarding.exception.PortalAPIException; -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.portalapi.DashboardUserManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; @@ -89,23 +81,4 @@ public class WebSecurityMockConfiguration extends WebSecurityConfigurerAdapter { web.ignoring().antMatchers("/", "/csrf"); // allow swagger-ui to load } - // This implementation is so light it can be used during tests. - @Bean - public DashboardUserManager dashboardUserManager() throws IOException, PortalAPIException { - DashboardUserManager dum = new DashboardUserManager(true); - // Mock user for convenience in testing - EcompUser demo = new EcompUser(); - demo.setLoginId("demo"); - demo.setFirstName("Demo"); - demo.setLastName("User"); - demo.setActive(true); - EcompRole role = new EcompRole(); - role.setName("view"); - Set roles = new HashSet<>(); - roles.add(role); - demo.setRoles(roles); - dum.createUser(demo); - return dum; - } - } diff --git a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/AdminControllerTest.java b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/AdminControllerTest.java index c11591ee..8e426ad8 100644 --- a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/AdminControllerTest.java +++ b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/AdminControllerTest.java @@ -27,8 +27,8 @@ import java.util.Map; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import org.onap.portalsdk.core.restful.domain.EcompUser; import org.oransc.ric.portal.dashboard.DashboardConstants; -import org.oransc.ric.portal.dashboard.model.DashboardUser; import org.oransc.ric.portal.dashboard.model.ErrorTransport; import org.oransc.ric.portal.dashboard.model.SuccessTransport; import org.slf4j.Logger; @@ -61,8 +61,8 @@ public class AdminControllerTest extends AbstractControllerTest { public void getUsersTest() { URI uri = buildUri(null, AdminController.CONTROLLER_PATH, AdminController.USER_METHOD); logger.info("Invoking {}", uri); - ResponseEntity> response = testRestTemplateAdminRole().exchange(uri, HttpMethod.GET, null, - new ParameterizedTypeReference>() { + ResponseEntity> response = testRestTemplateAdminRole().exchange(uri, HttpMethod.GET, null, + new ParameterizedTypeReference>() { }); Assertions.assertFalse(response.getBody().isEmpty()); } diff --git a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/CaasIngressControllerTest.java b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/CaasIngressControllerTest.java index 3016b07c..40ee7f65 100644 --- a/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/CaasIngressControllerTest.java +++ b/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/CaasIngressControllerTest.java @@ -35,7 +35,8 @@ public class CaasIngressControllerTest extends AbstractControllerTest { public void auxTest() { final String nsAux = "ricaux"; URI uri = buildUri(null, CaasIngressController.CONTROLLER_PATH, CaasIngressController.PODS_METHOD, - CaasIngressController.PP_CLUSTER, CaasIngressController.CLUSTER_AUX, CaasIngressController.PP_NAMESPACE, nsAux); + CaasIngressController.PP_CLUSTER, CaasIngressController.CLUSTER_AUX, CaasIngressController.PP_NAMESPACE, + nsAux); logger.info("Invoking {}", uri); String s = testRestTemplateStandardRole().getForObject(uri, String.class); Assertions.assertFalse(s.isEmpty()); @@ -46,7 +47,8 @@ public class CaasIngressControllerTest extends AbstractControllerTest { public void pltTest() { final String nsPlt = "ricplt"; URI uri = buildUri(null, CaasIngressController.CONTROLLER_PATH, CaasIngressController.PODS_METHOD, - CaasIngressController.PP_CLUSTER, CaasIngressController.CLUSTER_PLT, CaasIngressController.PP_NAMESPACE, nsPlt); + CaasIngressController.PP_CLUSTER, CaasIngressController.CLUSTER_PLT, CaasIngressController.PP_NAMESPACE, + nsPlt); logger.info("Invoking {}", uri); String s = testRestTemplateStandardRole().getForObject(uri, String.class); Assertions.assertFalse(s.isEmpty()); diff --git a/webapp-frontend/src/app/interfaces/dashboard.types.ts b/webapp-frontend/src/app/interfaces/dashboard.types.ts index 906549fb..90dfd150 100644 --- a/webapp-frontend/src/app/interfaces/dashboard.types.ts +++ b/webapp-frontend/src/app/interfaces/dashboard.types.ts @@ -7,9 +7,9 @@ * 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. @@ -25,9 +25,33 @@ export interface DashboardSuccessTransport { data: string; } -export interface DashboardUser { +export interface EcompRoleFunction { + name: string; + code: string; + type: string; + action: string; +} + +export interface EcompRole { id: number; - firstName: string; - lastName: string; - status: string; + name: string; + [position: number]: EcompRoleFunction; +} + +export interface EcompUser { + orgId?: number; + managerId?: string; + firstName?: string; + middleInitial?: string; + lastName?: string; + phone?: string; + email?: string; + hrid?: string; + orgUserId?: string; + orgCode?: string; + orgManagerUserId?: string; + jobTitle?: string; + loginId: string; + active: boolean; + [position: number]: EcompRole; } diff --git a/webapp-frontend/src/app/services/dashboard/dashboard.service.ts b/webapp-frontend/src/app/services/dashboard/dashboard.service.ts index 3f420595..a9f2df62 100644 --- a/webapp-frontend/src/app/services/dashboard/dashboard.service.ts +++ b/webapp-frontend/src/app/services/dashboard/dashboard.service.ts @@ -7,9 +7,9 @@ * 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. @@ -20,7 +20,7 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; -import { DashboardSuccessTransport, DashboardUser } from '../../interfaces/dashboard.types'; +import { DashboardSuccessTransport, EcompUser } from '../../interfaces/dashboard.types'; @Injectable({ providedIn: 'root' @@ -55,10 +55,10 @@ export class DashboardService { /** * Gets Dashboard users - * @returns Observable that should yield a DashboardUser array + * @returns Observable that should yield a EcompUser array */ - getUsers(): Observable { - return this.httpClient.get(this.basePath + 'user'); + getUsers(): Observable { + return this.httpClient.get(this.basePath + 'user'); } } diff --git a/webapp-frontend/src/app/user/user.component.html b/webapp-frontend/src/app/user/user.component.html index 54c23e3a..69a94e65 100644 --- a/webapp-frontend/src/app/user/user.component.html +++ b/webapp-frontend/src/app/user/user.component.html @@ -25,9 +25,9 @@ - - ID - {{element.id}} + + Login ID + {{element.loginId}} @@ -40,9 +40,9 @@ {{element.lastName}} - - Status - {{element.status}} + + Active? + {{element.active}} diff --git a/webapp-frontend/src/app/user/user.component.ts b/webapp-frontend/src/app/user/user.component.ts index 75cf1c28..dfa78095 100644 --- a/webapp-frontend/src/app/user/user.component.ts +++ b/webapp-frontend/src/app/user/user.component.ts @@ -7,9 +7,9 @@ * 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. @@ -22,7 +22,7 @@ import { MatDialog } from '@angular/material/dialog'; import { MatSort } from '@angular/material/sort'; import { DashboardService } from '../services/dashboard/dashboard.service'; import { ErrorDialogService } from '../services/ui/error-dialog.service'; -import { DashboardUser } from './../interfaces/dashboard.types'; +import { EcompUser } from './../interfaces/dashboard.types'; import { NotificationService } from './../services/ui/notification.service'; import { UserDataSource } from './user.datasource'; import { AddDashboardUserDialogComponent } from './add-dashboard-user-dialog/add-dashboard-user-dialog.component'; @@ -36,7 +36,7 @@ import { EditDashboardUserDialogComponent } from './edit-dashboard-user-dialog/e export class UserComponent implements OnInit { - displayedColumns: string[] = ['id', 'firstName', 'lastName', 'status', 'action']; + displayedColumns: string[] = ['loginId', 'firstName', 'lastName', 'active', 'action']; dataSource: UserDataSource; @ViewChild(MatSort, {static: true}) sort: MatSort; @@ -51,7 +51,7 @@ export class UserComponent implements OnInit { this.dataSource.loadTable(); } - editUser(user: DashboardUser) { + editUser(user: EcompUser) { const dialogRef = this.dialog.open(EditDashboardUserDialogComponent, { width: '450px', data: user diff --git a/webapp-frontend/src/app/user/user.datasource.ts b/webapp-frontend/src/app/user/user.datasource.ts index 805085f1..09d17411 100644 --- a/webapp-frontend/src/app/user/user.datasource.ts +++ b/webapp-frontend/src/app/user/user.datasource.ts @@ -7,9 +7,9 @@ * 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. @@ -26,13 +26,13 @@ import { BehaviorSubject } from 'rxjs/BehaviorSubject'; import { merge } from 'rxjs'; import { of } from 'rxjs/observable/of'; import { catchError, finalize, map } from 'rxjs/operators'; -import { DashboardUser } from '../interfaces/dashboard.types'; +import { EcompUser } from '../interfaces/dashboard.types'; import { DashboardService } from '../services/dashboard/dashboard.service'; import { NotificationService } from '../services/ui/notification.service'; -export class UserDataSource extends DataSource { +export class UserDataSource extends DataSource { - private userSubject = new BehaviorSubject([]); + private userSubject = new BehaviorSubject([]); private loadingSubject = new BehaviorSubject(false); @@ -57,13 +57,13 @@ export class UserDataSource extends DataSource { }), finalize(() => this.loadingSubject.next(false)) ) - .subscribe( (users: DashboardUser[]) => { + .subscribe( (users: EcompUser[]) => { this.rowCount = users.length; this.userSubject.next(users); }); } - connect(collectionViewer: CollectionViewer): Observable { + connect(collectionViewer: CollectionViewer): Observable { const dataMutations = [ this.userSubject.asObservable(), this.sort.sortChange @@ -78,18 +78,18 @@ export class UserDataSource extends DataSource { this.loadingSubject.complete(); } - private getSortedData(data: DashboardUser[]) { + private getSortedData(data: EcompUser[]) { if (!this.sort.active || this.sort.direction === '') { return data; } - return data.sort((a: DashboardUser, b: DashboardUser) => { + return data.sort((a: EcompUser, b: EcompUser) => { const isAsc = this.sort.direction === 'asc'; switch (this.sort.active) { - case 'id': return this.compare(a.id, b.id, isAsc); + case 'loginId': return this.compare(a.loginId, b.loginId, isAsc); case 'firstName': return this.compare(a.firstName, b.firstName, isAsc); case 'lastName': return this.compare(a.lastName, b.lastName, isAsc); - case 'status': return this.compare(a.status, b.status, isAsc); + case 'active': return this.compare(a.active, b.active, isAsc); default: return 0; } }); -- 2.16.6