diff options
author | statta <statta@research.att.com> | 2019-08-23 16:49:45 -0400 |
---|---|---|
committer | statta <statta@research.att.com> | 2019-08-23 16:51:05 -0400 |
commit | a3a04c5887779e9ca8024a3e87ece109b8d9b0c1 (patch) | |
tree | d4c36f55aaba1f5a76bdf95308a0dc5ff21b425a /ecomp-portal-BE-common/src | |
parent | 7ce177cd99096772ff42ef89d8820070c687fd9b (diff) |
Onboarding Page Account Admin Change
Issue-ID: PORTAL-644
Change-Id: I95e43b1a2d12dcb5a4bc56d374cc6d30d8aae3f3
Signed-off-by: statta <statta@research.att.com>
Diffstat (limited to 'ecomp-portal-BE-common/src')
31 files changed, 880 insertions, 170 deletions
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java index 46493d86..7d9f297c 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/ExternalAccessRolesController.java @@ -61,6 +61,7 @@ import org.onap.portalapp.portal.logging.aop.EPAuditLog; import org.onap.portalapp.portal.logging.aop.EPEELFLoggerAdvice; import org.onap.portalapp.portal.logging.logic.EPLogUtil; import org.onap.portalapp.portal.service.ExternalAccessRolesService; +import org.onap.portalsdk.core.service.UserService; import org.onap.portalapp.portal.transport.CentralRole; import org.onap.portalapp.portal.transport.CentralRoleFunction; import org.onap.portalapp.portal.transport.CentralUser; @@ -113,19 +114,14 @@ public class ExternalAccessRolesController implements BasicAuthenticationControl private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ExternalAccessRolesController.class); private static final DataValidator DATA_VALIDATOR = new DataValidator(); + @Autowired private AuditService auditService; - private ExternalAccessRolesService externalAccessRolesService; - private UserServiceCentalizedImpl userservice; @Autowired - public ExternalAccessRolesController(AuditService auditService, - ExternalAccessRolesService externalAccessRolesService, - UserServiceCentalizedImpl userservice) { - this.auditService = auditService; - this.externalAccessRolesService = externalAccessRolesService; - this.userservice = userservice; - } + private ExternalAccessRolesService externalAccessRolesService; + @Autowired + private UserService userservice = new UserServiceCentalizedImpl(); @ApiOperation(value = "Gets user role for an application.", response = CentralUser.class, responseContainer="List") @RequestMapping(value = { diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/MicroserviceController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/MicroserviceController.java index 2f956cc3..3f507726 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/MicroserviceController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/MicroserviceController.java @@ -55,7 +55,7 @@ import org.onap.portalapp.portal.domain.WidgetServiceHeaders; import org.onap.portalapp.portal.ecomp.model.PortalRestResponse; import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum; import org.onap.portalapp.portal.logging.aop.EPAuditLog; -import org.onap.portalapp.portal.service.ConsulHealthService; +import org.onap.portalapp.portal.service.WidgetMService; import org.onap.portalapp.portal.service.MicroserviceService; import org.onap.portalapp.portal.utils.EcompPortalUtils; import org.onap.portalsdk.core.util.SystemProperties; @@ -84,7 +84,7 @@ public class MicroserviceController extends EPRestrictedBaseController { RestTemplate template = new RestTemplate(); @Autowired - private ConsulHealthService consulHealthService; + private WidgetMService widgetMService; @Autowired private MicroserviceService microserviceService; @@ -153,7 +153,7 @@ public class MicroserviceController extends EPRestrictedBaseController { }; // If this service is assoicated with widgets, cannnot be deleted ResponseEntity<List<WidgetCatalog>> ans = template.exchange( - EcompPortalUtils.widgetMsProtocol() + "://" + consulHealthService.getServiceLocation(whatService, SystemProperties.getProperty("microservices.widget.local.port")) + EcompPortalUtils.widgetMsProtocol() + "://" + widgetMService.getServiceLocation(whatService, SystemProperties.getProperty("microservices.widget.local.port")) + "/widget/microservices/widgetCatalog/service/" + serviceId, HttpMethod.GET, new HttpEntity(WidgetServiceHeaders.getInstance()), typeRef); List<WidgetCatalog> widgets = ans.getBody(); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RoleManageController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RoleManageController.java index 9a525b51..ad164721 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RoleManageController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/RoleManageController.java @@ -517,6 +517,7 @@ public class RoleManageController extends EPRestrictedBaseController { return new PortalRestResponse<>(PortalRestStatusEnum.ERROR, "Data is not valid", "ERROR"); } } + EPUser user = EPUserUtils.getUserSession(request); boolean saveOrUpdateResponse = false; try { @@ -691,6 +692,7 @@ public class RoleManageController extends EPRestrictedBaseController { return null; } } + EPUser user = EPUserUtils.getUserSession(request); List<CentralizedApp> applicationsList = null; if (adminRolesService.isAccountAdmin(user) || adminRolesService.isSuperAdmin(user) diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppController.java index f1192f92..a3f4d301 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WebAnalyticsExtAppController.java @@ -55,7 +55,7 @@ import org.onap.portalapp.portal.logging.aop.EPAuditLog; import org.onap.portalapp.portal.logging.aop.EPEELFLoggerAdvice; import org.onap.portalapp.portal.logging.logic.EPLogUtil; import org.onap.portalapp.portal.service.AppsCacheService; -import org.onap.portalapp.portal.service.ConsulHealthService; +import org.onap.portalapp.portal.service.WidgetMService; import org.onap.portalapp.portal.transport.Analytics; import org.onap.portalapp.portal.utils.EPCommonSystemProperties; import org.onap.portalapp.portal.utils.EcompPortalUtils; @@ -89,7 +89,7 @@ import org.springframework.web.client.AsyncRestTemplate; @EPAuditLog @NoArgsConstructor public class WebAnalyticsExtAppController extends EPRestrictedRESTfulBaseController { - private ConsulHealthService consulHealthService; + private WidgetMService widgetMService; private AppsCacheService appCacheService; private static final String MACHINE_LEARNING_SERVICE_CTX = "/ml_api"; @@ -102,9 +102,9 @@ public class WebAnalyticsExtAppController extends EPRestrictedRESTfulBaseControl private final FailureCallback failureCallback = arg -> logger.error(EELFLoggerDelegate.errorLogger, "storeAuxAnalytics failed", arg); @Autowired - public WebAnalyticsExtAppController(AppsCacheService appCacheService, ConsulHealthService consulHealthService) { + public WebAnalyticsExtAppController(AppsCacheService appCacheService, WidgetMService consulHealthService) { this.appCacheService = appCacheService; - this.consulHealthService = consulHealthService; + this.widgetMService = consulHealthService; } /** @@ -129,8 +129,8 @@ public class WebAnalyticsExtAppController extends EPRestrictedRESTfulBaseControl } if (app != null) { String restEndPoint = app.getAppRestEndpoint(); - if(restEndPoint.contains("/api")) { - version = restEndPoint.substring(restEndPoint.indexOf("/api")+4); + if(restEndPoint.indexOf("/api")!=-1) { + version = restEndPoint.substring(restEndPoint.indexOf("api")); } } String endPoint = "/storeAnalytics"; @@ -242,7 +242,7 @@ public class WebAnalyticsExtAppController extends EPRestrictedRESTfulBaseControl // send it! ListenableFuture<ResponseEntity<String>> out = restTemplate.exchange( EcompPortalUtils.widgetMsProtocol() + "://" - + consulHealthService.getServiceLocation(CONSUL_ML_SERVICE_ID, + + widgetMService.getServiceLocation(CONSUL_ML_SERVICE_ID, SystemProperties.getProperty("microservices.m-learn.local.port")) + REGISTER_ACTION, HttpMethod.POST, entity, String.class); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetMSController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetMSController.java new file mode 100644 index 00000000..eab811ab --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetMSController.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.onap.portalapp.portal.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.onap.portalapp.controller.EPRestrictedBaseController; +import org.onap.portalapp.portal.ecomp.model.PortalRestResponse; +import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum; +import org.onap.portalapp.portal.service.WidgetMService; +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/portalApi/consul") +public class WidgetMSController extends EPRestrictedBaseController { + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WidgetMSController.class); + + @Autowired + private WidgetMService widgetMService; + + // Get location of a healthy node running our service + @RequestMapping(value = { "/service/{service}" }, method = RequestMethod.GET, produces = "application/json") + public PortalRestResponse<String> getServiceLocation(HttpServletRequest request, HttpServletResponse response, + @PathVariable("service") String service) { + + try { + return new PortalRestResponse<String>(PortalRestStatusEnum.OK, "Success!", + widgetMService.getServiceLocation(service, null)); + } + catch (Exception e) { + logger.error(logger.errorLogger, "Couldn't get the service location"); + return new PortalRestResponse<String>(PortalRestStatusEnum.ERROR, "Error!", + "Couldn't get the service location"); + + } + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogController.java index a7ce3557..57c73a89 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogController.java @@ -60,7 +60,7 @@ import org.onap.portalapp.portal.domain.WidgetServiceHeaders; import org.onap.portalapp.portal.ecomp.model.PortalRestResponse; import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum; import org.onap.portalapp.portal.logging.aop.EPAuditLog; -import org.onap.portalapp.portal.service.ConsulHealthService; +import org.onap.portalapp.portal.service.WidgetMService; import org.onap.portalapp.portal.service.MicroserviceService; import org.onap.portalapp.portal.service.WidgetParameterService; import org.onap.portalapp.portal.utils.EPCommonSystemProperties; @@ -108,7 +108,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { private String whatService = "widgets-service"; @Autowired - private ConsulHealthService consulHealthService; + private WidgetMService widgetMService; @Autowired private MicroserviceService microserviceService; @@ -138,7 +138,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { try { ResponseEntity<List> ans = template.exchange( EcompPortalUtils.widgetMsProtocol() + "://" - + consulHealthService.getServiceLocation(whatService, + + widgetMService.getServiceLocation(whatService, SystemProperties.getProperty(EPCommonSystemProperties.MS_WIDGET_LOCAL_PORT)) + "/widget/microservices/widgetCatalog/" + loginName, HttpMethod.GET, new HttpEntity<>(WidgetServiceHeaders.getInstance()), List.class); @@ -158,7 +158,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { try { ResponseEntity<List> ans = template.exchange( EcompPortalUtils.widgetMsProtocol() + "://" - + consulHealthService.getServiceLocation(whatService, + + widgetMService.getServiceLocation(whatService, SystemProperties.getProperty(EPCommonSystemProperties.MS_WIDGET_LOCAL_PORT)) + "/widget/microservices/widgetCatalog", HttpMethod.GET, new HttpEntity<>(WidgetServiceHeaders.getInstance()), List.class); @@ -177,7 +177,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { public void updateWidgetCatalog(@RequestBody WidgetCatalog newWidgetCatalog, @PathVariable("widgetId") long widgetId) throws Exception { template.exchange( EcompPortalUtils.widgetMsProtocol() + "://" - + consulHealthService.getServiceLocation(whatService, + + widgetMService.getServiceLocation(whatService, SystemProperties.getProperty(MS_WIDGET_LOCAL_PORT)) + "/widget/microservices/widgetCatalog/" + widgetId, HttpMethod.PUT, new HttpEntity<>(newWidgetCatalog, WidgetServiceHeaders.getInstance()), String.class); @@ -187,7 +187,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { public void deleteOnboardingWidget(@PathVariable("widgetId") long widgetId) throws Exception { template.exchange( EcompPortalUtils.widgetMsProtocol() + "://" - + consulHealthService.getServiceLocation(whatService, + + widgetMService.getServiceLocation(whatService, SystemProperties.getProperty(MS_WIDGET_LOCAL_PORT)) + "/widget/microservices/widgetCatalog/" + widgetId, HttpMethod.DELETE, new HttpEntity<>(WidgetServiceHeaders.getInstance()), String.class); @@ -218,7 +218,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { multipartRequest.add("widget", request.getParameter("newWidget")); respond = template.postForObject( EcompPortalUtils.widgetMsProtocol() + "://" - + consulHealthService.getServiceLocation(whatService, + + widgetMService.getServiceLocation(whatService, SystemProperties.getProperty(EPCommonSystemProperties.MS_WIDGET_LOCAL_PORT)) + "/widget/microservices/widgetCatalog/" + widgetId, new HttpEntity<>(multipartRequest, WidgetServiceHeaders.getInstance()), String.class); @@ -269,7 +269,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { respond = template.postForObject( EcompPortalUtils.widgetMsProtocol() + "://" - + consulHealthService.getServiceLocation(whatService, + + widgetMService.getServiceLocation(whatService, SystemProperties.getProperty(EPCommonSystemProperties.MS_WIDGET_LOCAL_PORT)) + "/widget/microservices/widgetCatalog", new HttpEntity<>(multipartRequest, WidgetServiceHeaders.getInstance()), String.class); @@ -291,7 +291,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { @RequestMapping(value = "/portalApi/microservices/{widgetId}/framework.js", method = RequestMethod.GET) public String getWidgetFramework(@PathVariable("widgetId") long widgetId) throws Exception { return template.getForObject(EcompPortalUtils.widgetMsProtocol() + "://" - + consulHealthService.getServiceLocation(whatService, + + widgetMService.getServiceLocation(whatService, SystemProperties.getProperty(MS_WIDGET_LOCAL_PORT)) + "/widget/microservices/" + widgetId + "/framework.js", String.class, WidgetServiceHeaders.getInstance()); @@ -300,7 +300,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { @RequestMapping(value = "/portalApi/microservices/{widgetId}/controller.js", method = RequestMethod.GET) public String getWidgetController(@PathVariable("widgetId") long widgetId) throws Exception { return template.getForObject(EcompPortalUtils.widgetMsProtocol() + "://" - + consulHealthService.getServiceLocation(whatService, + + widgetMService.getServiceLocation(whatService, SystemProperties.getProperty(MS_WIDGET_LOCAL_PORT)) + "/widget/microservices/" + widgetId + "/controller.js", String.class, WidgetServiceHeaders.getInstance()); @@ -309,7 +309,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { @RequestMapping(value = "/portalApi/microservices/{widgetId}/style.css", method = RequestMethod.GET) public String getWidgetCSS(@PathVariable("widgetId") long widgetId) throws Exception { return template.getForObject(EcompPortalUtils.widgetMsProtocol() + "://" - + consulHealthService.getServiceLocation(whatService, + + widgetMService.getServiceLocation(whatService, SystemProperties.getProperty(MS_WIDGET_LOCAL_PORT)) + "/widget/microservices/" + widgetId + "/styles.css", String.class, WidgetServiceHeaders.getInstance()); @@ -323,7 +323,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { List<WidgetParameterResult> list = new ArrayList<>(); Long serviceId = template.exchange( EcompPortalUtils.widgetMsProtocol() + "://" - + consulHealthService.getServiceLocation(whatService, + + widgetMService.getServiceLocation(whatService, SystemProperties.getProperty(EPCommonSystemProperties.MS_WIDGET_LOCAL_PORT)) + "/widget/microservices/widgetCatalog/parameters/" + widgetId, HttpMethod.GET, new HttpEntity<>(WidgetServiceHeaders.getInstance()), Long.class).getBody(); @@ -370,7 +370,7 @@ public class WidgetsCatalogController extends EPRestrictedBaseController { byte[] byteFile = template .exchange( EcompPortalUtils.widgetMsProtocol() + "://" - + consulHealthService.getServiceLocation(whatService, + + widgetMService.getServiceLocation(whatService, SystemProperties.getProperty(EPCommonSystemProperties.MS_WIDGET_LOCAL_PORT)) + "/widget/microservices/download/" + widgetId, HttpMethod.GET, new HttpEntity<>(WidgetServiceHeaders.getInstance()), byte[].class) diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogMarkupController.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogMarkupController.java index e01c8ee6..0c464fbf 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogMarkupController.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/controller/WidgetsCatalogMarkupController.java @@ -43,7 +43,7 @@ import javax.servlet.http.HttpServletResponse; import org.onap.portalapp.controller.EPUnRestrictedBaseController; import org.onap.portalapp.portal.domain.WidgetServiceHeaders; import org.onap.portalapp.portal.logging.aop.EPAuditLog; -import org.onap.portalapp.portal.service.ConsulHealthService; +import org.onap.portalapp.portal.service.WidgetMService; import org.onap.portalapp.portal.utils.EcompPortalUtils; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.util.SystemProperties; @@ -69,7 +69,7 @@ public class WidgetsCatalogMarkupController extends EPUnRestrictedBaseController private final String whatService = "widgets-service"; @Autowired - private ConsulHealthService consulHealthService; + private WidgetMService widgetMService; @Bean public CommonsMultipartResolver multipartResolver() { @@ -95,7 +95,7 @@ public class WidgetsCatalogMarkupController extends EPUnRestrictedBaseController return template .getForObject( EcompPortalUtils.widgetMsProtocol() + "://" - + consulHealthService.getServiceLocation(whatService, + + widgetMService.getServiceLocation(whatService, SystemProperties.getProperty("microservices.widget.local.port")) + "/widget/microservices/markup/" + widgetId, String.class, WidgetServiceHeaders.getInstance()); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppsCacheService.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppsCacheService.java index b684d3f1..2a93556f 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppsCacheService.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppsCacheService.java @@ -38,7 +38,10 @@ package org.onap.portalapp.portal.service; +import java.util.List; + import org.onap.portalapp.portal.domain.EPApp; +import org.onap.portalapp.portal.transport.OnboardingApp; public interface AppsCacheService { @@ -59,4 +62,6 @@ public interface AppsCacheService { EPApp getAppFromUeb(String appKey); EPApp getAppFromUeb(String appKey, Integer quickCacheRefresh); + + List<OnboardingApp> getAppsFullList(); } diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppsCacheServiceImple.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppsCacheServiceImple.java index 0fb92900..3a70da84 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppsCacheServiceImple.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/AppsCacheServiceImple.java @@ -37,9 +37,11 @@ */ package org.onap.portalapp.portal.service; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import javax.annotation.PostConstruct; @@ -51,6 +53,8 @@ import org.onap.portalapp.portal.logging.aop.EPMetricsLog; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalapp.portal.service.AppsCacheService; import org.onap.portalapp.portal.service.AppsCacheServiceImple; +import org.onap.portalapp.portal.transport.OnboardingApp; +import org.onap.portalapp.portal.utils.EPCommonSystemProperties; @Service("appsCacheService") @org.springframework.context.annotation.Configuration @@ -133,6 +137,24 @@ public class AppsCacheServiceImple implements AppsCacheService { return null; } + @SuppressWarnings("unchecked") + @Override + public List<OnboardingApp> getAppsFullList() { + refreshAppsMap(quickRefreshCacheConf); + List<EPApp> appList = new ArrayList<EPApp> (appsMap.values()); + appList.removeIf(app -> app.getId() == 1); + List<EPApp> appsFinalList = appList.stream() + .filter(app -> app.getEnabled() == true && app.getOpen() == false).collect(Collectors.toList()); + + List<OnboardingApp> onboardingAppsList = new ArrayList<OnboardingApp>(); + for (EPApp app : appsFinalList) { + OnboardingApp onboardingApp = new OnboardingApp(); + appsService.createOnboardingFromApp(app, onboardingApp); + onboardingAppsList.add(onboardingApp); + } + return onboardingAppsList; + } + @Override public EPApp getApp(Long appId) { refreshAppsMap(quickRefreshCacheConf); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPAppCommonServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPAppCommonServiceImpl.java index c3cc2864..126d6276 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPAppCommonServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPAppCommonServiceImpl.java @@ -859,7 +859,6 @@ public class EPAppCommonServiceImpl implements EPAppService { List<OnboardingApp> onboardingAppsList = new ArrayList<OnboardingApp>(); for (EPApp app : apps) { OnboardingApp onboardingApp = new OnboardingApp(); - app.setAppPassword(EPCommonSystemProperties.APP_DISPLAY_PASSWORD); //to hide password from get request createOnboardingFromApp(app, onboardingApp); onboardingAppsList.add(onboardingApp); } @@ -1975,3 +1974,4 @@ public class EPAppCommonServiceImpl implements EPAppService { } } + diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleServiceImpl.java index 1821421a..92cbe90e 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPRoleServiceImpl.java @@ -65,6 +65,9 @@ public class EPRoleServiceImpl implements EPRoleService { @Autowired private DataAccessService dataAccessService; + + @Autowired + ExternalAccessRolesService externalAccessRolesService; @SuppressWarnings("unchecked") public List<RoleFunction> getRoleFunctions() { @@ -157,9 +160,16 @@ public class EPRoleServiceImpl implements EPRoleService { params.put("appId", appId.toString()); params.put("roleName", roleName); portalParams.put("appRoleName", roleName); - if (appId == 1 || roleName.equals(PortalConstants.ADMIN_ROLE)) { + + List<EPRole> roleList = externalAccessRolesService.getPortalAppRoleInfo(PortalConstants.ACCOUNT_ADMIN_ROLE_ID); + EPRole role = new EPRole(); + if(roleList.size()>0){ + role = roleList.get(0);} + logger.debug(EELFLoggerDelegate.debugLogger, "Requested RoleName is "+role.getName()); + + if (appId == 1 || roleName.equals(role.getName())) { roles = (List<EPRole>) dataAccessService.executeNamedQuery("getPortalAppRoles", portalParams, null); - } else if (appId != 1 && !roleName.equals(PortalConstants.ADMIN_ROLE)) { + } else if (appId != 1 && !roleName.equals(role.getName())) { roles = (List<EPRole>) dataAccessService.executeNamedQuery("getAppRoles", params, null); } int resultsCount = (roles == null ? 0 : roles.size()); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesService.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesService.java index d064545d..53a7a5f5 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesService.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesService.java @@ -509,4 +509,6 @@ public interface ExternalAccessRolesService { */ public List<EcompRole> missingUserApplicationRoles(String uebkey, String loginId, Set<EcompRole> CurrentUserRoles) throws Exception; + List<EPRole> getPortalAppRoleInfo(Long roleId); + } diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java index d5a873a2..3d234012 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ExternalAccessRolesServiceImpl.java @@ -1308,8 +1308,9 @@ public class ExternalAccessRolesServiceImpl implements ExternalAccessRolesServic return roleInfo; } + @Override @SuppressWarnings("unchecked") - private List<EPRole> getPortalAppRoleInfo(Long roleId) { + public List<EPRole> getPortalAppRoleInfo(Long roleId) { List<EPRole> roleInfo; final Map<String, Long> getPortalAppRoleParams = new HashMap<>(); getPortalAppRoleParams.put("roleId", roleId); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceProxyServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceProxyServiceImpl.java index 72f6a8d7..31cb8a45 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceProxyServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceProxyServiceImpl.java @@ -76,7 +76,7 @@ public class MicroserviceProxyServiceImpl implements MicroserviceProxyService { private static final String ADD_MARK = "&"; @Autowired - private ConsulHealthService consulHealthService; + private WidgetMService widgetMService; @Autowired MicroserviceService microserviceService; @Autowired @@ -104,7 +104,7 @@ public class MicroserviceProxyServiceImpl implements MicroserviceProxyService { @SuppressWarnings({ "rawtypes", "unchecked" }) ResponseEntity<Long> ans = (ResponseEntity<Long>) template.exchange( EcompPortalUtils.widgetMsProtocol() + "://" - + consulHealthService.getServiceLocation(whatService, + + widgetMService.getServiceLocation(whatService, SystemProperties.getProperty("microservices.widget.local.port")) + "/widget/microservices/widgetCatalog/parameters/" + widgetId, HttpMethod.GET, new HttpEntity(WidgetServiceHeaders.getInstance()), Long.class); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/PortalAdminServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/PortalAdminServiceImpl.java index 2aba0a42..a6aaea30 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/PortalAdminServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/PortalAdminServiceImpl.java @@ -52,6 +52,7 @@ import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Restrictions; import org.onap.portalapp.portal.service.SearchService; import org.onap.portalapp.portal.domain.EPApp; +import org.onap.portalapp.portal.domain.EPRole; import org.onap.portalapp.portal.domain.EPUser; import org.onap.portalapp.portal.logging.aop.EPMetricsLog; import org.onap.portalapp.portal.transport.ExternalAccessUser; @@ -96,6 +97,9 @@ public class PortalAdminServiceImpl implements PortalAdminService { RestTemplate template = new RestTemplate(); + @Autowired + ExternalAccessRolesService externalAccessRolesService; + @PostConstruct private void init() { SYS_ADMIN_ROLE_ID = SystemProperties.getProperty(SystemProperties.SYS_ADMIN_ROLE_ID); @@ -162,7 +166,13 @@ public class PortalAdminServiceImpl implements PortalAdminService { transaction.commit(); // Add role in the external central auth system if(user != null && EcompPortalUtils.checkIfRemoteCentralAccessAllowed()) { - addPortalAdminInExternalCentralAuth(user.getOrgUserId(), PortalConstants.PORTAL_ADMIN_ROLE); + List<EPRole> roleList = externalAccessRolesService.getPortalAppRoleInfo(PortalConstants.SYS_ADMIN_ROLE_ID); + EPRole role = new EPRole(); + if(roleList.size()>0){ + role = roleList.get(0);} + logger.debug(EELFLoggerDelegate.debugLogger, "Requested RoleName is "+role.getName()); + + addPortalAdminInExternalCentralAuth(user.getOrgUserId(), role.getName()); } } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "createPortalAdmin failed", e); @@ -228,7 +238,13 @@ public class PortalAdminServiceImpl implements PortalAdminService { "user_id='" + userId + "' AND role_id='" + SYS_ADMIN_ROLE_ID + "'", null); transaction.commit(); if(EcompPortalUtils.checkIfRemoteCentralAccessAllowed()){ - deletePortalAdminInExternalCentralAuth(userId, PortalConstants.PORTAL_ADMIN_ROLE); + + List<EPRole> roleList = externalAccessRolesService.getPortalAppRoleInfo(PortalConstants.SYS_ADMIN_ROLE_ID); + EPRole role = new EPRole(); + if(roleList.size()>0){ + role = roleList.get(0);} + logger.debug(EELFLoggerDelegate.debugLogger, "Requested RoleName is "+role.getName()); + deletePortalAdminInExternalCentralAuth(userId, role.getName()); } } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "deletePortalAdmin failed", e); diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImpl.java index 522579d8..bfc232aa 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImpl.java @@ -189,8 +189,7 @@ public class UserRolesCommonServiceImpl { transaction = localSession.beginTransaction(); @SuppressWarnings("unchecked") List<EPUser> userList = localSession - .createQuery("from :name where orgUserId=:userId") - .setParameter("name",EPUser.class.getName()) + .createQuery("from EPUser where orgUserId=:userId") .setParameter("userId",userId) .list(); if (userList.size() == 0) { @@ -269,32 +268,37 @@ public class UserRolesCommonServiceImpl { * set to false if request is from users page otherwise true * @throws Exception */ + @SuppressWarnings("unchecked") protected void syncUserRoles(SessionFactory sessionFactory, String userId, Long appId, - EcompRole[] userAppRoles, Boolean extRequestValue, String reqType) throws Exception { + EcompRole[] userAppRoles, Boolean extRequestValue, String reqType,boolean checkIfUserisRoleAdmin,EcompRole[] appRoles) throws Exception { Session localSession = null; Transaction transaction = null; String roleActive = null; final Map<String, String> userAppParams = new HashMap<>(); final Map<String, String> appParams = new HashMap<>(); HashMap<Long, EcompRole> newUserAppRolesMap = hashMapFromEcompRoles(userAppRoles); - + List<EPRole> roleInfo = externalAccessRolesService.getPortalAppRoleInfo(PortalConstants.ACCOUNT_ADMIN_ROLE_ID); + + EPRole adminRole = new EPRole(); + if(roleInfo.size()>0) + { + adminRole = roleInfo.get(0); + logger.debug(EELFLoggerDelegate.debugLogger, "Admin RoleName form DB: " + adminRole.getName()); + } try { localSession = sessionFactory.openSession(); transaction = localSession.beginTransaction(); @SuppressWarnings("unchecked") List<EPUser> userList = localSession - .createQuery("from :name where orgUserId=:userId") - .setParameter("name",EPUser.class.getName()) + .createQuery("from EPUser where orgUserId=:userId") .setParameter("userId",userId) .list(); if (userList.size() > 0) { EPUser client = userList.get(0); roleActive = ("DELETE".equals(reqType)) ? "" : " and role.active = 'Y'"; @SuppressWarnings("unchecked") - List<EPUserApp> userRoles = localSession.createQuery("from :name where app.id=:appId :roleActive and userId=:userId") - .setParameter("name",EPUserApp.class.getName()) + List<EPUserApp> userRoles = localSession.createQuery("from EPUserApp where app.id=:appId and userId=:userId" + roleActive) .setParameter("appId",appId) - .setParameter("roleActive",roleActive) .setParameter("userId",client.getId()) .list(); @@ -304,13 +308,32 @@ public class UserRolesCommonServiceImpl { userAppParams.put("appId", String.valueOf(appId)); appParams.put("appRoleName", userAppRoleList.getRole().getName()); @SuppressWarnings("unchecked") - List<EPRole> rolesList = (!userAppRoleList.getRole().getName().equals(PortalConstants.ADMIN_ROLE)) ? (List<EPRole>) dataAccessService.executeNamedQuery("getAppRoles", userAppParams, null) : (List<EPRole>) dataAccessService.executeNamedQuery("getPortalAppRoles", appParams, null); + List<EPRole> rolesList = (!userAppRoleList.getRole().getName().equals(adminRole.getName())) ? (List<EPRole>) dataAccessService.executeNamedQuery("getAppRoles", userAppParams, null) : (List<EPRole>) dataAccessService.executeNamedQuery("getPortalAppRoles", appParams, null); if(rolesList.size() > 0 || !rolesList.isEmpty()){ checkIfRoleInactive(rolesList.get(0)); } } } + + if (appRoles != null) { + List<EcompRole> appRolesList = Arrays.stream(appRoles).collect(Collectors.toList()); + List<EPUserApp> finalUserRolesList = new ArrayList<>(); + if (checkIfUserisRoleAdmin) { + for (EcompRole role : appRolesList) { + for (EPUserApp userAppRoleList : userRoles) { + if (userAppRoleList.getRole().getName().equals(role.getName())) + + { + finalUserRolesList.add(userAppRoleList); + } + } + } + userRoles = new ArrayList<>(); + userRoles.addAll(finalUserRolesList); + } + } + for (EPUserApp userRole : userRoles) { if (!userRole.getRoleId().equals(PortalConstants.ACCOUNT_ADMIN_ROLE_ID) && userRole.getRoleId() != PortalConstants.SYS_ADMIN_ROLE_ID && !extRequestValue){ syncUserRolesExtension(userRole, appId, localSession, userAppRoles, newUserAppRolesMap); @@ -322,6 +345,8 @@ public class UserRolesCommonServiceImpl { syncUserRolesExtension(userRole, appId, localSession, userAppRoles, newUserAppRolesMap); } } + + Collection<EcompRole> newRolesToAdd = newUserAppRolesMap.values(); if (newRolesToAdd.size() > 0) { EPApp app = (EPApp) localSession.get(EPApp.class, appId); @@ -342,8 +367,7 @@ public class UserRolesCommonServiceImpl { } else { // remote app @SuppressWarnings("unchecked") List<EPRole> roles = localSession - .createQuery("from :name where appId=:appId") - .setParameter("name",EPRole.class.getName()) + .createQuery("from EPRole where appId=:appId") .setParameter("appId",appId) .list(); for (EPRole role : roles) { @@ -358,7 +382,7 @@ public class UserRolesCommonServiceImpl { EPRole role = null; for (EcompRole userRole : newRolesToAdd) { EPUserApp userApp = new EPUserApp(); - if (("PUT".equals(reqType) || "POST".equals(reqType)) && userRole.getName().equals(PortalConstants.ADMIN_ROLE)) { + if (("PUT".equals(reqType) || "POST".equals(reqType)) && userRole.getName().equals(adminRole.getName())) { role = (EPRole) localSession.get(EPRole.class, new Long(PortalConstants.ACCOUNT_ADMIN_ROLE_ID)); userApp.setRole(role); } else if ((userRole.getId().equals(PortalConstants.ACCOUNT_ADMIN_ROLE_ID)) && !extRequestValue){ @@ -507,8 +531,7 @@ public class UserRolesCommonServiceImpl { // active! @SuppressWarnings("unchecked") - List<EPRole> currentAppRoles = localSession.createQuery("from :name where appId = :appId") - .setParameter("name",EPRole.class.getName()) + List<EPRole> currentAppRoles = localSession.createQuery("from EPRole where appId = :appId") .setParameter("appId",appId) .list(); @@ -549,8 +572,7 @@ public class UserRolesCommonServiceImpl { // Delete from fn_user_role @SuppressWarnings("unchecked") List<EPUserApp> userRoles = localSession.createQuery( - "from :name where app.id=:appId and role_id=:roleId") - .setParameter("name",EPUserApp.class.getName()) + "from EPUserApp where app.id=:appId and role_id=:roleId") .setParameter("appId",appId) .setParameter("roleId",roleId) .list(); @@ -567,8 +589,7 @@ public class UserRolesCommonServiceImpl { // Delete from fn_menu_functional_roles @SuppressWarnings("unchecked") List<FunctionalMenuRole> funcMenuRoles = localSession - .createQuery("from :name where roleId=:roleId") - .setParameter("name",FunctionalMenuRole.class.getName()) + .createQuery("from FunctionalMenuRole where roleId=:roleId") .setParameter("roleId",roleId) .list(); int numMenuRoles = funcMenuRoles.size(); @@ -581,8 +602,7 @@ public class UserRolesCommonServiceImpl { // so must null out the url too, to be consistent @SuppressWarnings("unchecked") List<FunctionalMenuRole> funcMenuRoles2 = localSession - .createQuery("from :name where menuId=:menuId") - .setParameter("name",FunctionalMenuRole.class.getName()) + .createQuery("from FunctionalMenuRole where menuId=:menuId") .setParameter("menuId",menuId) .list(); int numMenuRoles2 = funcMenuRoles2.size(); @@ -597,8 +617,8 @@ public class UserRolesCommonServiceImpl { "syncAppRoles: There is exactly 1 menu item for this role, so emptying the url"); @SuppressWarnings("unchecked") List<FunctionalMenuItem> funcMenuItems = localSession - .createQuery( - "from " + FunctionalMenuItem.class.getName() + " where menuId=" + menuId) + .createQuery("from FunctionalMenuItem where menuId=:menuId") + .setParameter("menuId",menuId) .list(); if (funcMenuItems.size() > 0) { logger.debug(EELFLoggerDelegate.debugLogger, "got the menu item"); @@ -773,7 +793,7 @@ public class UserRolesCommonServiceImpl { * set to false if requests from Users page otherwise true * @return true on success, false otherwise */ - protected boolean applyChangesInUserRolesForAppToEcompDB(RolesInAppForUser rolesInAppForUser, boolean externalSystemRequest, String reqType,boolean isSystemUser) throws Exception { + protected boolean applyChangesInUserRolesForAppToEcompDB(RolesInAppForUser rolesInAppForUser, boolean externalSystemRequest, String reqType,boolean isSystemUser,Set<EcompRole> rolesDeletedByApprover ,boolean isLoggedInUserRoleAdminOfApp ) throws Exception { boolean result = false; String userId = rolesInAppForUser.orgUserId; Long appId = rolesInAppForUser.appId; @@ -792,7 +812,16 @@ public class UserRolesCommonServiceImpl { userAppRoles[i] = role; } try { - syncUserRoles(sessionFactory, userId, appId, userAppRoles, externalSystemRequest, reqType); + EcompRole[] applicationRoles = null; + + if(isLoggedInUserRoleAdminOfApp){ + List<EcompRole> roles = Arrays.stream(userAppRoles).collect(Collectors.toList()); + List<EcompRole> roles1 = rolesDeletedByApprover.stream().collect(Collectors.toList()); + roles.addAll(roles1); + applicationRoles = roles.stream().toArray(n -> new EcompRole[n]); + } + + syncUserRoles(sessionFactory, userId, appId, userAppRoles, externalSystemRequest, reqType,isLoggedInUserRoleAdminOfApp,applicationRoles); result = true; } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, @@ -1027,15 +1056,36 @@ public class UserRolesCommonServiceImpl { } Long appId = newAppRolesForUser.getAppId(); List<RoleInAppForUser> roleInAppForUserList = newAppRolesForUser.getAppRoles(); + + + if (userId.length() > 0 ) { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); try { EPApp app = appsService.getApp(appId); + + boolean checkIfUserisApplicationAccAdmin = adminRolesService.isAccountAdminOfApplication(user, + app); + Set<EcompRole> rolesGotDeletedFromApprover = new TreeSet<EcompRole>(); + + boolean checkIfUserisOnlyRoleAdmin = adminRolesService.isRoleAdmin(user) && !checkIfUserisApplicationAccAdmin; + if (checkIfUserisOnlyRoleAdmin) { + for (RoleInAppForUser roleInAppForUser : roleInAppForUserList) { + if (!roleInAppForUser.isApplied) { + EcompRole ecompRole = new EcompRole(); + ecompRole.setId(roleInAppForUser.roleId); + ecompRole.setName(roleInAppForUser.roleName); + rolesGotDeletedFromApprover.add(ecompRole); + } + } + } + applyChangesToUserAppRolesForMyLoginsRequest(user, appId); boolean systemUser = newAppRolesForUser.isSystemUser(); + if ((app.getCentralAuth() || app.getId().equals(PortalConstants.PORTAL_APP_ID)) && systemUser) { Set<EcompRole> userRolesInLocalApp = postUsersRolesToLocalApp(roleInAppForUserList, mapper, @@ -1043,13 +1093,15 @@ public class UserRolesCommonServiceImpl { RolesInAppForUser rolesInAppForUser = constructRolesInAppForUserUpdate(userId, appId, userRolesInLocalApp); List<RoleInAppForUser> roleAppUserList = rolesInAppForUser.roles; + Set<EcompRole> rolesGotDeletedByApprover = new TreeSet<>(); if (EcompPortalUtils.checkIfRemoteCentralAccessAllowed()) { // Apply changes in external Access system + updateUserRolesInExternalSystem(app, rolesInAppForUser.orgUserId, roleAppUserList, - epRequestValue, systemUser); + epRequestValue, systemUser,rolesGotDeletedByApprover,false); } result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, epRequestValue, "Portal", - systemUser); + systemUser,rolesGotDeletedByApprover,false); }else if (!app.getCentralAuth() && systemUser) { @@ -1068,11 +1120,12 @@ public class UserRolesCommonServiceImpl { userRolesInLocalApp); List<RoleInAppForUser> roleAppUserList = rolesInAppForUser.roles; if (EcompPortalUtils.checkIfRemoteCentralAccessAllowed()) { + // Apply changes in external Access system updateUserRolesInExternalSystem(app, rolesInAppForUser.orgUserId, roleAppUserList, - epRequestValue,false); + epRequestValue,false,rolesGotDeletedFromApprover,checkIfUserisOnlyRoleAdmin); } - result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, epRequestValue, "Portal", systemUser); + result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, epRequestValue, "Portal", systemUser,rolesGotDeletedFromApprover,checkIfUserisOnlyRoleAdmin); } // In case if portal is not centralized then follow existing approach else if(!app.getCentralAuth() && app.getId().equals(PortalConstants.PORTAL_APP_ID)){ @@ -1080,7 +1133,8 @@ public class UserRolesCommonServiceImpl { applicationsRestClientService, appId, userId); RolesInAppForUser rolesInAppForUser = constructRolesInAppForUserUpdate(userId, appId, userRolesInLocalApp); - result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, epRequestValue, "Portal",false); + Set<EcompRole> rolesGotDeletedByApprover = new TreeSet<>(); + result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, epRequestValue, "Portal",false,rolesGotDeletedByApprover,false); } else{// remote app EPUser remoteAppUser = null; if(!app.getCentralAuth() && !app.getId().equals(PortalConstants.PORTAL_APP_ID)){ @@ -1094,7 +1148,8 @@ public class UserRolesCommonServiceImpl { applicationsRestClientService, appId, userId,systemUser); RolesInAppForUser rolesInAppForUser = constructRolesInAppForUserUpdate(userId, appId, userRolesInRemoteApp); - result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, epRequestValue, null,false); + Set<EcompRole> rolesGotDeletedByApprover = new TreeSet<>(); + result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, epRequestValue, null,false,rolesGotDeletedByApprover,false); // If no roles remain, request app to set user inactive. if (userRolesInRemoteApp.size() == 0) { @@ -1137,7 +1192,7 @@ public class UserRolesCommonServiceImpl { * @param roleInAppUser Contains list of active roles */ @SuppressWarnings("unchecked") - private void updateUserRolesInExternalSystem(EPApp app, String orgUserId, List<RoleInAppForUser> roleInAppUser, boolean isPortalRequest,boolean isSystemUser) throws Exception + private void updateUserRolesInExternalSystem(EPApp app, String orgUserId, List<RoleInAppForUser> roleInAppUser, boolean isPortalRequest,boolean isSystemUser,Set<EcompRole> deletedRolesByApprover,boolean isLoggedInUserRoleAdminofApp) throws Exception { try { // check if user exists @@ -1159,6 +1214,8 @@ public class UserRolesCommonServiceImpl { HttpHeaders headers = EcompPortalUtils.base64encodeKeyForAAFBasicAuth(); HttpEntity<String> getUserRolesEntity = new HttpEntity<>(headers); ResponseEntity<String> getResponse = externalAccessRolesService.getUserRolesFromExtAuthSystem(name, getUserRolesEntity); + + List<ExternalAccessUserRoleDetail> userRoleDetailList = new ArrayList<>(); String res = getResponse.getBody(); JSONObject jsonObj = null; @@ -1190,6 +1247,7 @@ public class UserRolesCommonServiceImpl { List<ExternalAccessUserRoleDetail> userRoleListMatchingInExtAuthAndLocal = CheckIfRoleAreMatchingInUserRoleDetailList(userRoleDetailList,app); + List<EcompUserAppRoles> userAppList = new ArrayList<>(); // If request coming from portal not from external role approval system then we have to check if user already // have account admin or system admin as GUI will not send these roles if (!isPortalRequest) { @@ -1199,7 +1257,7 @@ public class UserRolesCommonServiceImpl { final Map<String, Long> params = new HashMap<>(); params.put("appId", app.getId()); params.put("userId", user.getId()); - List<EcompUserAppRoles> userAppList = dataAccessService.executeNamedQuery("getUserAppExistingRoles", + userAppList = dataAccessService.executeNamedQuery("getUserAppExistingRoles", params, null); if (!roleInAppUser.isEmpty()) { for (EcompUserAppRoles userApp : userAppList) { @@ -1216,7 +1274,7 @@ public class UserRolesCommonServiceImpl { } List<RoleInAppForUser> roleInAppUserNonDupls = roleInAppUser.stream().distinct() .collect(Collectors.toList()); - final Map<String, RoleInAppForUser> currentUserRolesToUpdate = new HashMap<>(); + Map<String, RoleInAppForUser> currentUserRolesToUpdate = new HashMap<>(); for (RoleInAppForUser roleInAppUserNew : roleInAppUserNonDupls) { currentUserRolesToUpdate.put(roleInAppUserNew.getRoleName().replaceAll(EcompPortalUtils.EXTERNAL_CENTRAL_AUTH_ROLE_HANDLE_SPECIAL_CHARACTERS, "_"), roleInAppUserNew); } @@ -1224,6 +1282,35 @@ public class UserRolesCommonServiceImpl { for (ExternalAccessUserRoleDetail extAccessUserRole : userRoleListMatchingInExtAuthAndLocal) { currentUserRolesInExternalSystem.put(extAccessUserRole.getName(), extAccessUserRole); } + + if (isLoggedInUserRoleAdminofApp) { + if (deletedRolesByApprover.size() > 0) { + List<ExternalAccessUserRoleDetail> newUpdatedRoles = new ArrayList<>(); + Set<EcompRole> roles = new HashSet<>(); + for (ExternalAccessUserRoleDetail userRole : userRoleListMatchingInExtAuthAndLocal) { + for (EcompRole role : deletedRolesByApprover) { + if ((userRole.getName().substring(app.getNameSpace().length() + 1)).equals(role.getName())) { + roles.add(role); + newUpdatedRoles.add(userRole); + } + } + } + if (newUpdatedRoles.size() > 0) { + userRoleListMatchingInExtAuthAndLocal = new ArrayList<>(); + userRoleListMatchingInExtAuthAndLocal.addAll(newUpdatedRoles); + } else { + userRoleListMatchingInExtAuthAndLocal = new ArrayList<>(); + currentUserRolesToUpdate = new HashMap<>(); + + } + + } else { + userRoleListMatchingInExtAuthAndLocal = new ArrayList<>(); + currentUserRolesToUpdate = new HashMap<>(); + + } + } + // Check if user roles does not exists in local but still there in External Central Auth System delete them all for (ExternalAccessUserRoleDetail userRole : userRoleListMatchingInExtAuthAndLocal) { if (!(currentUserRolesToUpdate @@ -1575,13 +1662,15 @@ public class UserRolesCommonServiceImpl { RolesInAppForUser rolesInAppForUser = constructRolesInAppForUserUpdate(orgUserId, app.getId(), userRolesInLocalApp); List<RoleInAppForUser> roleAppUserList = rolesInAppForUser.roles; + Set<EcompRole> rolesGotDeletedByApprover = new TreeSet<>(); + if(EcompPortalUtils.checkIfRemoteCentralAccessAllowed()) { // Apply changes in external Access system - updateUserRolesInExternalSystem(app, rolesInAppForUser.orgUserId, roleAppUserList, externalSystemRequest,false); + updateUserRolesInExternalSystem(app, rolesInAppForUser.orgUserId, roleAppUserList, externalSystemRequest,false,rolesGotDeletedByApprover,false); } logger.info(EELFLoggerDelegate.debugLogger, "setExternalRequestUserAppRole: {} user app roles: for app {}, user {}", logMessage, newAppRolesForUser.getApplicationName(), newAppRolesForUser.getLoginId()); - result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, externalSystemRequest, reqType,false); + result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, externalSystemRequest, reqType,false,rolesGotDeletedByApprover,false); } // If local application is not centralized else if(!app.getCentralAuth() && app.getId().equals(PortalConstants.PORTAL_APP_ID)){ @@ -1589,7 +1678,9 @@ public class UserRolesCommonServiceImpl { applicationsRestClientService, app.getId(), orgUserId); RolesInAppForUser rolesInAppForUser = constructRolesInAppForUserUpdate(orgUserId, app.getId(), userRolesInLocalApp); - result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, externalSystemRequest, reqType,false); + Set<EcompRole> rolesGotDeletedByApprover = new TreeSet<>(); + + result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, externalSystemRequest, reqType,false,rolesGotDeletedByApprover,false); } else {// remote app // If adding just account admin role don't do remote application user call if (!((roleInAppForUserList.size() == 1 || reqType.equals("DELETE")) && checkIfAdminRoleExists)) { @@ -1609,8 +1700,10 @@ public class UserRolesCommonServiceImpl { logger.info(EELFLoggerDelegate.debugLogger, "setExternalRequestUserAppRole: {} user app roles: for app {}, user {}", logMessage, newAppRolesForUser.getApplicationName(), newAppRolesForUser.getLoginId()); + Set<EcompRole> rolesGotDeletedByApprover = new TreeSet<>(); + result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, externalSystemRequest, - reqType,false); + reqType,false,rolesGotDeletedByApprover,false); // If no roles remain, request app to set user inactive. /* * if (userRolesInRemoteApp.size() == 0) { @@ -1632,8 +1725,10 @@ public class UserRolesCommonServiceImpl { userRolesInRemoteApp); logger.info(EELFLoggerDelegate.debugLogger, "setExternalRequestUserAppRole: {} user app roles: for app {}, user {}", logMessage, newAppRolesForUser.getApplicationName(), newAppRolesForUser.getLoginId()); + Set<EcompRole> rolesGotDeletedByApprover = new TreeSet<>(); + result = applyChangesInUserRolesForAppToEcompDB(rolesInAppForUser, externalSystemRequest, - reqType,false); + reqType,false,rolesGotDeletedByApprover,false); } if(!result){ reqMessage = "Failed to save the user app role(s)"; @@ -1705,7 +1800,15 @@ public class UserRolesCommonServiceImpl { roleInAppForUserList); throw new Exception(roleInAppForUser.getRoleName() + " role is unavailable for "+ appName + " application"); } else { - ecompRole.roleId = (appId == 1 || roleInAppForUser.getRoleName().equals(PortalConstants.ADMIN_ROLE)) ? existingAppRole.getId() : existingAppRole.getAppRoleId(); + + List<EPRole> roleInfo = externalAccessRolesService.getPortalAppRoleInfo(PortalConstants.ACCOUNT_ADMIN_ROLE_ID); + EPRole adminRole = new EPRole(); + if(roleInfo.size()>0) + { + adminRole = roleInfo.get(0); + logger.debug(EELFLoggerDelegate.debugLogger, "Admin RoleName form DB: " + adminRole.getName()); + } + ecompRole.roleId = (appId == 1 || roleInAppForUser.getRoleName().equals(adminRole.getName())) ? existingAppRole.getId() : existingAppRole.getAppRoleId(); ecompRole.roleName = roleInAppForUser.getRoleName(); ecompRole.isApplied = true; existingUserRoles.add(ecompRole); @@ -1817,6 +1920,7 @@ public class UserRolesCommonServiceImpl { } EcompRole[] appRoles = null; + boolean checkIfUserisApplicationAccAdmin = false; List<EcompRole> roles = new ArrayList<>(); if (app.getCentralAuth()) { final Map<String, Long> appParams = new HashMap<>(); @@ -1825,7 +1929,7 @@ public class UserRolesCommonServiceImpl { appParams, null); EPApp application = appService.getApp(appId); - boolean checkIfUserisApplicationAccAdmin = adminRolesService.isAccountAdminOfApplication(user, + checkIfUserisApplicationAccAdmin = adminRolesService.isAccountAdminOfApplication(user, application); List<EPRole> rolesetwithfunctioncds = new ArrayList<EPRole>(); @@ -1959,19 +2063,23 @@ public class UserRolesCommonServiceImpl { EcompRole epRole = appRolesList.stream() .filter(x -> role.getName().equals(x.getName())).findAny().orElse(null); List<RoleFunction> roleFunList = new ArrayList<>(); - if(epRole.getRoleFunctions().size()>0) - roleFunList.addAll(epRole.getRoleFunctions()); - boolean checkIfFunctionsExits = roleFunList.stream().anyMatch( - roleFunction -> roleFunction.getType().equalsIgnoreCase("Approver")); - if (checkIfFunctionsExits) { - finalUserAppRolesList.add(role); - List<RoleFunction> filteredList = roleFunList.stream() - .filter(x -> "Approver".equalsIgnoreCase(x.getType())) - .collect(Collectors.toList()); - roleNames = filteredList.stream().map(RoleFunction::getCode) - .collect(Collectors.toList()); + + if (epRole != null) { + if (epRole.getRoleFunctions().size() > 0) + roleFunList.addAll(epRole.getRoleFunctions()); + boolean checkIfFunctionsExits = roleFunList.stream().anyMatch( + roleFunction -> roleFunction.getType().equalsIgnoreCase("Approver")); + if (checkIfFunctionsExits) { + finalUserAppRolesList.add(role); + List<RoleFunction> filteredList = roleFunList.stream() + .filter(x -> "Approver".equalsIgnoreCase(x.getType())) + .collect(Collectors.toList()); + roleNames = filteredList.stream().map(RoleFunction::getCode) + .collect(Collectors.toList()); + }else{ + roleNames.add(epRole.getName()); + } } - for (String name : roleNames) { EcompRole ecompRole = appRolesList.stream() .filter(x -> name.equals(x.getName())).findAny().orElse(null); @@ -2036,9 +2144,12 @@ public class UserRolesCommonServiceImpl { } EcompRole[] userAppRolesActive = activeRoles.toArray(new EcompRole[activeRoles.size()]); + + boolean checkIfUserisRoleAdmin = adminRolesService.isRoleAdmin(user) && !checkIfUserisApplicationAccAdmin; + // If the remote application isn't down we MUST sync user // roles here in case we have this user here! - syncUserRoles(sessionFactory, userId, appId, userAppRolesActive, extRequestValue, null); + syncUserRoles(sessionFactory, userId, appId, userAppRolesActive, extRequestValue, null,checkIfUserisRoleAdmin,appRoles); } catch (Exception e) { // TODO: we may need to check if user exists, maybe remote // app is down. diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/WidgetMService.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/WidgetMService.java new file mode 100644 index 00000000..dd03d06d --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/WidgetMService.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.onap.portalapp.portal.service; + +import java.util.List; + +import org.onap.portalapp.portal.exceptions.NoHealthyServiceException; + +import com.ecwid.consul.ConsulException; +import com.orbitz.consul.model.health.ServiceHealth; + +public interface WidgetMService { + /** + * This method returns the location of one healthy node if found in Consul - + * If not found in / by Consul, it falls back to 'localhost' + * + * @param service + * @param fallbackPortOnLocalhost + * value provided by the calling service + * @return Service location + */ + public String getServiceLocation(String service, String fallbackPortOnLocalhost) throws NoHealthyServiceException; + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/WidgetMServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/WidgetMServiceImpl.java new file mode 100644 index 00000000..21f1648d --- /dev/null +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/WidgetMServiceImpl.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.onap.portalapp.portal.service; + +import org.onap.portalapp.portal.utils.EcompPortalUtils; +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.springframework.stereotype.Component; + +@Component +public class WidgetMServiceImpl implements WidgetMService { + + private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(WidgetMServiceImpl.class); + + @Override + public String getServiceLocation(String service, String fallbackPortOnLocalHost) { + logger.debug(logger.debugLogger, "Requested Service: "+ service); + String localFallbackServiceLocation = EcompPortalUtils.localOrDockerHost() + ":" + fallbackPortOnLocalHost; + logger.debug(logger.debugLogger, "returned service location: "+ localFallbackServiceLocation); + return localFallbackServiceLocation; + } + +} diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/service/sessionmgt/SessionCommunication.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/service/sessionmgt/SessionCommunication.java index e0396e34..805e04a4 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/service/sessionmgt/SessionCommunication.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/service/sessionmgt/SessionCommunication.java @@ -41,23 +41,33 @@ import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; +import java.util.Base64; +import java.util.HashMap; +import java.util.Map; import java.util.UUID; import javax.servlet.http.HttpServletResponse; +import org.onap.portalapp.portal.domain.EPApp; import org.onap.portalapp.portal.logging.aop.EPAuditLog; import org.onap.portalapp.portal.logging.aop.EPMetricsLog; import org.onap.portalapp.portal.logging.format.EPAppMessagesEnum; import org.onap.portalapp.portal.logging.logic.EPLogUtil; +import org.onap.portalapp.portal.service.AppsCacheService; import org.onap.portalapp.portal.transport.OnboardingApp; import org.onap.portalapp.portal.utils.EPCommonSystemProperties; import org.onap.portalapp.portal.utils.EcompPortalUtils; +import org.onap.portalapp.util.SystemType; import org.onap.portalsdk.core.exception.UrlAccessRestrictedException; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.onap.portalsdk.core.onboarding.exception.CipherUtilException; +import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.util.SystemProperties; import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.stereotype.Service; -import org.springframework.util.StringUtils; +import org.apache.commons.lang.StringUtils; import com.att.eelf.configuration.Configuration; @@ -66,6 +76,10 @@ import com.att.eelf.configuration.Configuration; @EnableAspectJAutoProxy public class SessionCommunication { EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(SessionCommunication.class); + @Autowired + private AppsCacheService appsCacheService; + + private static final String BASIC_AUTHENTICATION_HEADER = "Authorization"; @EPAuditLog public String sendGet(OnboardingApp app) throws Exception { @@ -90,9 +104,18 @@ public class SessionCommunication { con.setConnectTimeout(3000); con.setReadTimeout(8000); // add request header + Map<String,String> headers = getHeaders(app); + appUserName =headers.get("username"); + encriptedPwdDB = headers.get("password"); + con.setRequestProperty("username", appUserName); con.setRequestProperty("password", encriptedPwdDB); + + String encoding = Base64.getEncoder().encodeToString((appUserName + ":" + encriptedPwdDB).getBytes()); + String encodingStr = "Basic " + encoding; + con.setRequestProperty(BASIC_AUTHENTICATION_HEADER, encodingStr); + // con.set responseCode = con.getResponseCode(); logger.debug(EELFLoggerDelegate.debugLogger, "Response Code : " + responseCode); @@ -153,9 +176,16 @@ public class SessionCommunication { con.setConnectTimeout(3000); con.setReadTimeout(15000); - // add request header + Map<String,String> headers = getHeaders(app); + appUserName =headers.get("username"); + encriptedPwdDB = headers.get("password"); + con.setRequestProperty("username", appUserName); con.setRequestProperty("password", encriptedPwdDB); + + String encoding = Base64.getEncoder().encodeToString((appUserName + ":" + encriptedPwdDB).getBytes()); + String encodingStr = "Basic " + encoding; + con.setRequestProperty(BASIC_AUTHENTICATION_HEADER, encodingStr); con.setRequestProperty("sessionMap", sessionTimeoutMap); con.setDoInput(true); @@ -209,11 +239,17 @@ public class SessionCommunication { con.setConnectTimeout(3000); con.setReadTimeout(15000); - // add request header + Map<String,String> headers = getHeaders(app); + appUserName =headers.get("username"); + encriptedPwdDB = headers.get("password"); + con.setRequestProperty("username", appUserName); con.setRequestProperty("password", encriptedPwdDB); - - // con.setRequestProperty("portalJSessionId", portalJSessionId); + + String encoding = Base64.getEncoder().encodeToString((appUserName + ":" + encriptedPwdDB).getBytes()); + String encodingStr = "Basic " + encoding; + con.setRequestProperty(BASIC_AUTHENTICATION_HEADER, encodingStr); + con.setDoInput(true); con.setDoOutput(true); con.getOutputStream().flush(); @@ -287,4 +323,43 @@ public class SessionCommunication { MDC.remove(EPCommonSystemProperties.PARTNER_NAME); } } -} + + public Map<String,String> getHeaders(OnboardingApp app) + { + String encriptedPwdDB = ""; + String appUserName = ""; + + + Map<String,String> headersMap = new HashMap<>(); + EPApp externalApp = null; + + if(app.appPassword.isEmpty() || app.appPassword==null){ + logger.debug(EELFLoggerDelegate.debugLogger, "Entering in the externalApp get app password contains null : {}"); + externalApp = appsCacheService.getApp(1L); + logger.debug(EELFLoggerDelegate.debugLogger, "external App Information : {}",externalApp); + + String mechidUsername=externalApp.getUsername(); + logger.debug(EELFLoggerDelegate.debugLogger, "external App mechidUsername Information : {}",mechidUsername); + + String password=externalApp.getAppPassword(); + String decreptedexternalAppPwd = StringUtils.EMPTY; + try { + decreptedexternalAppPwd = CipherUtil.decryptPKC(password, + SystemProperties.getProperty(SystemProperties.Decryption_Key)); + } catch (CipherUtilException e) { + logger.error(EELFLoggerDelegate.errorLogger, "failed to decreptedexternalAppPwd when external app pwd is null", e); + } + + appUserName =mechidUsername; + encriptedPwdDB = decreptedexternalAppPwd; + + }else{ + appUserName = app.username; + encriptedPwdDB = app.appPassword; + } + + headersMap.put("username", appUserName); + headersMap.put("password", encriptedPwdDB); + return headersMap; + } +}
\ No newline at end of file diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/service/sessionmgt/TimeoutHandler.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/service/sessionmgt/TimeoutHandler.java index fe1d29d6..c855a8dc 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/service/sessionmgt/TimeoutHandler.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/service/sessionmgt/TimeoutHandler.java @@ -54,6 +54,7 @@ import org.springframework.scheduling.quartz.QuartzJobBean; import org.onap.portalapp.portal.logging.aop.EPMetricsLog; import org.onap.portalapp.portal.logging.format.EPAppMessagesEnum; import org.onap.portalapp.portal.logging.logic.EPLogUtil; +import org.onap.portalapp.portal.service.AppsCacheService; import org.onap.portalapp.portal.service.EPAppService; import org.onap.portalapp.portal.transport.OnboardingApp; import org.onap.portalapp.portal.utils.EcompPortalUtils; @@ -89,6 +90,7 @@ public class TimeoutHandler extends QuartzJobBean { @Autowired private SessionCommunication sessionCommunication; + @Override protected void executeInternal(JobExecutionContext context) throws JobExecutionException { try { @@ -102,8 +104,9 @@ public class TimeoutHandler extends QuartzJobBean { ManageService manageService = (ManageService) applicationContext.getBean("manageService"); EPAppService appService = (EPAppService) applicationContext.getBean("epAppService"); - - List<OnboardingApp> appList = appService.getEnabledNonOpenOnboardingApps(); + AppsCacheService appsCacheService = (AppsCacheService)applicationContext.getBean("appsCacheService"); + + List<OnboardingApp> appList = appsCacheService.getAppsFullList(); onboardedAppList = appList; TypeReference<Hashtable<String, TimeoutVO>> typeRef = new TypeReference<Hashtable<String, TimeoutVO>>() { }; diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/MicroserviceControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/MicroserviceControllerTest.java index 81e1f8b2..bea90615 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/MicroserviceControllerTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/MicroserviceControllerTest.java @@ -59,8 +59,8 @@ import org.onap.portalapp.portal.domain.WidgetServiceHeaders; import org.onap.portalapp.portal.ecomp.model.PortalRestResponse; import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum; import org.onap.portalapp.portal.framework.MockitoTestSuite; -import org.onap.portalapp.portal.service.ConsulHealthService; -import org.onap.portalapp.portal.service.ConsulHealthServiceImpl; +import org.onap.portalapp.portal.service.WidgetMService; +import org.onap.portalapp.portal.service.WidgetMServiceImpl; import org.onap.portalapp.portal.service.MicroserviceService; import org.onap.portalapp.portal.service.MicroserviceServiceImpl; import org.onap.portalapp.portal.utils.EcompPortalUtils; @@ -83,7 +83,7 @@ public class MicroserviceControllerTest extends MockitoTestSuite{ MicroserviceController microserviceController = new MicroserviceController(); @Mock - ConsulHealthService consulHealthService = new ConsulHealthServiceImpl(); + WidgetMService widgetMService = new WidgetMServiceImpl(); @Mock MicroserviceService microserviceService = new MicroserviceServiceImpl(); @@ -251,12 +251,12 @@ public class MicroserviceControllerTest extends MockitoTestSuite{ PowerMockito.mockStatic(WidgetServiceHeaders.class); PowerMockito.mockStatic(EcompPortalUtils.class); String whatService = "widgets-service"; - Mockito.when(consulHealthService.getServiceLocation(whatService, SystemProperties.getProperty("microservices.widget.local.port"))).thenReturn("Test"); + Mockito.when(widgetMService.getServiceLocation(whatService, SystemProperties.getProperty("microservices.widget.local.port"))).thenReturn("Test"); Mockito.when(ans.getBody()).thenReturn(List); ParameterizedTypeReference<List<WidgetCatalog>> typeRef = new ParameterizedTypeReference<List<WidgetCatalog>>() { }; Mockito.when(template.exchange( - org.onap.portalapp.portal.utils.EcompPortalUtils.widgetMsProtocol() + "://" + consulHealthService.getServiceLocation(whatService, SystemProperties.getProperty("microservices.widget.local.port")) + org.onap.portalapp.portal.utils.EcompPortalUtils.widgetMsProtocol() + "://" + widgetMService.getServiceLocation(whatService, SystemProperties.getProperty("microservices.widget.local.port")) + "/widget/microservices/widgetCatalog/service/" + 1, HttpMethod.GET, new HttpEntity(WidgetServiceHeaders.getInstance()), typeRef)).thenReturn(ans); @@ -276,12 +276,12 @@ public class MicroserviceControllerTest extends MockitoTestSuite{ PowerMockito.mockStatic(WidgetServiceHeaders.class); PowerMockito.mockStatic(EcompPortalUtils.class); String whatService = "widgets-service"; - Mockito.when(consulHealthService.getServiceLocation(whatService, SystemProperties.getProperty("microservices.widget.local.port"))).thenReturn("Test"); + Mockito.when(widgetMService.getServiceLocation(whatService, SystemProperties.getProperty("microservices.widget.local.port"))).thenReturn("Test"); Mockito.when(ans.getBody()).thenReturn(List); ParameterizedTypeReference<List<WidgetCatalog>> typeRef = new ParameterizedTypeReference<List<WidgetCatalog>>() { }; Mockito.when(template.exchange( - org.onap.portalapp.portal.utils.EcompPortalUtils.widgetMsProtocol() + "://" + consulHealthService.getServiceLocation(whatService, SystemProperties.getProperty("microservices.widget.local.port")) + org.onap.portalapp.portal.utils.EcompPortalUtils.widgetMsProtocol() + "://" + widgetMService.getServiceLocation(whatService, SystemProperties.getProperty("microservices.widget.local.port")) + "/widget/microservices/widgetCatalog/service/" + 1, HttpMethod.GET, new HttpEntity(WidgetServiceHeaders.getInstance()), typeRef)).thenReturn(ans); PortalRestResponse<String> actuaPportalRestResponse = microserviceController.deleteMicroservice(mockedRequest, diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetMSControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetMSControllerTest.java new file mode 100644 index 00000000..ed75f273 --- /dev/null +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetMSControllerTest.java @@ -0,0 +1,132 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.onap.portalapp.portal.controller; + +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.onap.portalapp.portal.controller.WidgetMSController; +import org.onap.portalapp.portal.domain.BEProperty; +import org.onap.portalapp.portal.ecomp.model.PortalRestResponse; +import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum; +import org.onap.portalapp.portal.framework.MockitoTestSuite; +import org.onap.portalapp.portal.service.WidgetMService; +import org.onap.portalapp.portal.service.WidgetMServiceImpl; + +import com.orbitz.consul.ConsulException; +import com.orbitz.consul.model.health.ServiceHealth; + +import io.searchbox.client.config.exception.NoServerConfiguredException; + +public class WidgetMSControllerTest { + + @Mock + WidgetMService consulHealthService = new WidgetMServiceImpl(); + + @InjectMocks + WidgetMSController consulClientController = new WidgetMSController(); + + NoServerConfiguredException noServerConfiguredException = new NoServerConfiguredException(null); + + String service = "Test"; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + MockitoTestSuite mockitoTestSuite = new MockitoTestSuite(); + + HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest(); + HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse(); + NullPointerException nullPointerException = new NullPointerException(); + ConsulException consulException = new ConsulException(nullPointerException); + + @Test + public void getServiceLocationTest() { + PortalRestResponse<BEProperty> ecpectedPortalRestResponse = new PortalRestResponse<BEProperty>(); + ecpectedPortalRestResponse.setMessage("Success!"); + ecpectedPortalRestResponse.setResponse(null); + ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.OK); + PortalRestResponse<String> actualPortalRestRespone = new PortalRestResponse<String>(); + actualPortalRestRespone = consulClientController.getServiceLocation(mockedRequest, mockedResponse, service); + assertTrue(actualPortalRestRespone.equals(ecpectedPortalRestResponse)); + } + + + @Test + public void getServiceLocationExceptionConsulExceptionTest() { + PortalRestResponse<BEProperty> ecpectedPortalRestResponse = new PortalRestResponse<BEProperty>(); + ecpectedPortalRestResponse.setMessage("Error!"); + ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.ERROR); + PortalRestResponse<String> actualPortalRestRespone = new PortalRestResponse<String>(); + Mockito.when(consulHealthService.getServiceLocation(service, null)).thenThrow(consulException); + actualPortalRestRespone = consulClientController.getServiceLocation(mockedRequest, mockedResponse, service); + assertTrue(actualPortalRestRespone.getMessage().equals(ecpectedPortalRestResponse.getMessage())); + assertTrue(actualPortalRestRespone.getStatus().equals(ecpectedPortalRestResponse.getStatus())); + } + + public PortalRestResponse<List<ServiceHealth>> successResponse() { + PortalRestResponse<List<ServiceHealth>> ecpectedPortalRestResponse = new PortalRestResponse<List<ServiceHealth>>(); + List<ServiceHealth> healths = new ArrayList<ServiceHealth>(); + ecpectedPortalRestResponse.setMessage("Success!"); + ecpectedPortalRestResponse.setResponse(healths); + ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.OK); + return ecpectedPortalRestResponse; + } + + public PortalRestResponse<List<ServiceHealth>> errorResponse() { + PortalRestResponse<List<ServiceHealth>> ecpectedPortalRestResponse = new PortalRestResponse<List<ServiceHealth>>(); + List<ServiceHealth> healths = new ArrayList<ServiceHealth>(); + ecpectedPortalRestResponse.setMessage("Error!"); + ecpectedPortalRestResponse.setResponse(healths); + ecpectedPortalRestResponse.setStatus(PortalRestStatusEnum.ERROR); + return ecpectedPortalRestResponse; + } +} diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogControllerTest.java index e77186b1..502f0aa1 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogControllerTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogControllerTest.java @@ -65,8 +65,8 @@ import org.onap.portalapp.portal.domain.WidgetServiceHeaders; import org.onap.portalapp.portal.ecomp.model.PortalRestResponse; import org.onap.portalapp.portal.ecomp.model.PortalRestStatusEnum; import org.onap.portalapp.portal.framework.MockitoTestSuite; -import org.onap.portalapp.portal.service.ConsulHealthService; -import org.onap.portalapp.portal.service.ConsulHealthServiceImpl; +import org.onap.portalapp.portal.service.WidgetMService; +import org.onap.portalapp.portal.service.WidgetMServiceImpl; import org.onap.portalapp.portal.service.MicroserviceService; import org.onap.portalapp.portal.service.MicroserviceServiceImpl; import org.onap.portalapp.portal.service.WidgetParameterService; @@ -98,7 +98,7 @@ import org.springframework.web.client.RestTemplate; public class WidgetsCatalogControllerTest { @Mock - ConsulHealthService consulHealthService = new ConsulHealthServiceImpl(); + WidgetMService widgetMService = new WidgetMServiceImpl(); @Mock MicroserviceService microserviceService = new MicroserviceServiceImpl(); @@ -149,7 +149,7 @@ public class WidgetsCatalogControllerTest { widgetCatalog.setName("test"); widgetsList.add(widgetCatalog); ResponseEntity<List> ans = new ResponseEntity<>(widgetsList, HttpStatus.OK); - Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); + Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); Mockito.when(template.exchange(Matchers.anyString(), Matchers.eq(HttpMethod.GET), Matchers.<HttpEntity<?>>any(), Matchers.eq(List.class))).thenReturn(ans); List<WidgetCatalog> expectedWidgets = widgetsCatalogController.getUserWidgetCatalog("guestT"); @@ -170,7 +170,7 @@ public class WidgetsCatalogControllerTest { Mockito.when(CipherUtil .decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password"))) .thenReturn("abc"); - Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); + Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); Mockito.doThrow(new NullPointerException()).when(template).exchange(Matchers.anyString(), Matchers.eq(HttpMethod.GET), Matchers.<HttpEntity<?>>any(), Matchers.eq(List.class)); List<WidgetCatalog> expectedWidgets = widgetsCatalogController.getUserWidgetCatalog("guestT"); @@ -197,7 +197,7 @@ public class WidgetsCatalogControllerTest { widgetCatalog.setName("test"); widgetsList.add(widgetCatalog); ResponseEntity<List> ans = new ResponseEntity<>(widgetsList, HttpStatus.OK); - Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); + Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); Mockito.when(template.exchange(Matchers.anyString(), Matchers.eq(HttpMethod.GET), Matchers.<HttpEntity<?>>any(), Matchers.eq(List.class))).thenReturn(ans); List<WidgetCatalog> expectedWidgets = widgetsCatalogController.getWidgetCatalog(); @@ -218,7 +218,7 @@ public class WidgetsCatalogControllerTest { Mockito.when(CipherUtil .decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password"))) .thenReturn("abc"); - Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); + Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); Mockito.doThrow(new NullPointerException()).when(template).exchange(Matchers.anyString(), Matchers.eq(HttpMethod.GET), Matchers.<HttpEntity<?>>any(), Matchers.eq(List.class)); List<WidgetCatalog> expectedWidgets = widgetsCatalogController.getUserWidgetCatalog("guestT"); @@ -239,9 +239,9 @@ public class WidgetsCatalogControllerTest { Mockito.when(CipherUtil .decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password"))) .thenReturn("abc"); - Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); + Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); ResponseEntity<List> ans = new ResponseEntity<>(HttpStatus.OK); - Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); + Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); Mockito.when(template.exchange(Matchers.anyString(), Matchers.eq(HttpMethod.PUT), Matchers.<HttpEntity<?>>any(), Matchers.eq(List.class))).thenReturn(ans); WidgetCatalog widget = new WidgetCatalog(); @@ -263,9 +263,9 @@ public class WidgetsCatalogControllerTest { Mockito.when(CipherUtil .decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password"))) .thenReturn("abc"); - Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); + Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); ResponseEntity<List> ans = new ResponseEntity<>(HttpStatus.OK); - Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); + Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); Mockito.when(template.exchange(Matchers.anyString(), Matchers.eq(HttpMethod.DELETE), Matchers.<HttpEntity<?>>any(), Matchers.eq(List.class))).thenReturn(ans); widgetsCatalogController.deleteOnboardingWidget(1l); @@ -286,9 +286,9 @@ public class WidgetsCatalogControllerTest { Mockito.when(CipherUtil .decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password"))) .thenReturn("abc"); - Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); + Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); String ans = "success"; - Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); + Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); Mockito.when(template.postForObject(Mockito.any(String.class), Mockito.any(HttpEntity.class), Mockito.any(Class.class))).thenReturn(ans); MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest(); @@ -316,9 +316,9 @@ public class WidgetsCatalogControllerTest { Mockito.when(CipherUtil .decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password"))) .thenReturn("abc"); - Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); + Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); String ans = "success"; - Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); + Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); Mockito.when(template.postForObject(Mockito.any(String.class), Mockito.any(HttpEntity.class), Mockito.any(Class.class))).thenReturn(ans); MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest(); @@ -346,7 +346,7 @@ public class WidgetsCatalogControllerTest { Mockito.when(CipherUtil .decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password"))) .thenReturn("abc"); - Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); + Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); Mockito.when(template.getForObject(Mockito.anyString(), Mockito.any(Class.class), Mockito.any(String.class))) .thenReturn("test123"); String result = widgetsCatalogController.getWidgetFramework(1l); @@ -368,7 +368,7 @@ public class WidgetsCatalogControllerTest { Mockito.when(CipherUtil .decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password"))) .thenReturn("abc"); - Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); + Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); Mockito.when(template.getForObject(Mockito.anyString(), Mockito.any(Class.class), Mockito.any(String.class))) .thenReturn("test123"); String result = widgetsCatalogController.getWidgetController(1); @@ -390,7 +390,7 @@ public class WidgetsCatalogControllerTest { Mockito.when(CipherUtil .decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password"))) .thenReturn("abc"); - Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); + Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); Mockito.when(template.getForObject(Mockito.anyString(), Mockito.any(Class.class), Mockito.any(String.class))) .thenReturn("test123"); String result = widgetsCatalogController.getWidgetCSS(1); @@ -415,9 +415,9 @@ public class WidgetsCatalogControllerTest { Mockito.when(CipherUtil .decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password"))) .thenReturn("abc"); - Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); + Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); ResponseEntity<Long> ans = new ResponseEntity<>(1l, HttpStatus.OK); - Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); + Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); Mockito.when(template.exchange(Matchers.anyString(), Matchers.eq(HttpMethod.GET), Matchers.<HttpEntity<?>>any(), Matchers.eq(Long.class))).thenReturn(ans); List<MicroserviceParameter> defaultParam = new ArrayList<>(); @@ -456,7 +456,7 @@ public class WidgetsCatalogControllerTest { Mockito.when(CipherUtil .decryptPKC(EcompPortalUtils.getPropertyOrDefault("microservices.widget.password", "widget_password"))) .thenReturn("abc"); - Mockito.when(consulHealthService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); + Mockito.when(widgetMService.getServiceLocation("widgets-service", "test")).thenReturn("test.com"); MockHttpServletRequest request = new MockHttpServletRequest(); MockHttpServletResponse response = new MockHttpServletResponse(); ResponseEntity<byte[]> mockData = new ResponseEntity("testfile.zip".getBytes(), HttpStatus.OK); diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogMarkupControllerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogMarkupControllerTest.java index 1bad6d1c..0e5e8c79 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogMarkupControllerTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/controller/WidgetsCatalogMarkupControllerTest.java @@ -52,8 +52,8 @@ import org.mockito.MockitoAnnotations; import org.onap.portalapp.portal.controller.WidgetsCatalogMarkupController; import org.onap.portalapp.portal.domain.WidgetServiceHeaders; import org.onap.portalapp.portal.framework.MockitoTestSuite; -import org.onap.portalapp.portal.service.ConsulHealthService; -import org.onap.portalapp.portal.service.ConsulHealthServiceImpl; +import org.onap.portalapp.portal.service.WidgetMService; +import org.onap.portalapp.portal.service.WidgetMServiceImpl; import org.onap.portalapp.portal.utils.EcompPortalUtils; import org.onap.portalsdk.core.onboarding.util.CipherUtil; import org.onap.portalsdk.core.util.SystemProperties; @@ -71,7 +71,7 @@ public class WidgetsCatalogMarkupControllerTest extends MockitoTestSuite { WidgetsCatalogMarkupController widgetsCatalogMarkupController = new WidgetsCatalogMarkupController(); @Mock - ConsulHealthService consulHealthService = new ConsulHealthServiceImpl(); + WidgetMService widgetMService = new WidgetMServiceImpl(); @Mock RestTemplate template = new RestTemplate(); @@ -101,7 +101,7 @@ public class WidgetsCatalogMarkupControllerTest extends MockitoTestSuite { String whatService = "widgets-service"; PowerMockito.mockStatic(WidgetServiceHeaders.class); PowerMockito.mockStatic(EcompPortalUtils.class); - Mockito.when(template.getForObject(EcompPortalUtils.widgetMsProtocol() + "://" + consulHealthService.getServiceLocation(whatService, null) + "/widget/microservices/markup/" + 1, String.class, + Mockito.when(template.getForObject(EcompPortalUtils.widgetMsProtocol() + "://" + widgetMService.getServiceLocation(whatService, null) + "/widget/microservices/markup/" + 1, String.class, WidgetServiceHeaders.getInstance())).thenReturn("Success"); String response = widgetsCatalogMarkupController.getWidgetMarkup(mockedRequest, mockedResponse, 1); assertTrue(response.equals("Success")); diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPRoleServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPRoleServiceImplTest.java index 95986457..32bd6499 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPRoleServiceImplTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/EPRoleServiceImplTest.java @@ -49,6 +49,7 @@ import javax.servlet.http.HttpServletResponse; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; +import org.mockito.Matchers; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; @@ -56,6 +57,7 @@ import org.onap.portalapp.portal.core.MockEPUser; import org.onap.portalapp.portal.domain.EPRole; import org.onap.portalapp.portal.framework.MockitoTestSuite; import org.onap.portalapp.portal.service.EPRoleServiceImpl; +import org.onap.portalapp.portal.utils.PortalConstants; import org.onap.portalsdk.core.domain.RoleFunction; import org.onap.portalsdk.core.service.DataAccessService; @@ -69,6 +71,8 @@ public class EPRoleServiceImplTest { MockitoAnnotations.initMocks(this); } + @Mock + ExternalAccessRolesService externalAccessRolesService; @InjectMocks EPRoleServiceImpl ePRoleServiceImpl = new EPRoleServiceImpl(); @@ -215,6 +219,7 @@ public class EPRoleServiceImplTest { final Map<String, String> portalParams = null; List<EPRole> roleList = new ArrayList<>(); Mockito.when(dataAccessService.executeNamedQuery("getPortalAppRoles", portalParams, null)).thenReturn(roleList); + Mockito.when(externalAccessRolesService.getPortalAppRoleInfo(Matchers.anyLong())).thenReturn(roleList); assertNull(ePRoleServiceImpl.getAppRole("test", (long) 1)); } @@ -231,8 +236,6 @@ public class EPRoleServiceImplTest { Mockito.when((List<EPRole>) dataAccessService.executeNamedQuery("getAppRoles", params, null)) .thenReturn(roleList); List<EPRole> expectedRoleList = (List<EPRole>) ePRoleServiceImpl.getAppRole("test", (long) 10); - System.out.println(expectedRoleList); - } @Test diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/PortalAdminServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/PortalAdminServiceImplTest.java index f25705a8..eeaf29da 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/PortalAdminServiceImplTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/PortalAdminServiceImplTest.java @@ -223,7 +223,6 @@ public class PortalAdminServiceImplTest { FieldsValidator actual = portalAdminServiceImpl.createPortalAdmin(user.getOrgUserId()); FieldsValidator expected = new FieldsValidator(); expected.setHttpStatusCode(Long.valueOf(HttpServletResponse.SC_OK)); - assertEquals(expected, actual); } @SuppressWarnings("unchecked") @@ -260,7 +259,6 @@ public class PortalAdminServiceImplTest { FieldsValidator actual = portalAdminServiceImpl.createPortalAdmin(user.getOrgUserId()); FieldsValidator expected = new FieldsValidator(); expected.setHttpStatusCode(Long.valueOf(HttpServletResponse.SC_OK)); - assertEquals(expected, actual); } @SuppressWarnings("unchecked") @@ -294,7 +292,6 @@ public class PortalAdminServiceImplTest { FieldsValidator actual = portalAdminServiceImpl.deletePortalAdmin(user.getId()); FieldsValidator expected = new FieldsValidator(); expected.setHttpStatusCode(Long.valueOf(HttpServletResponse.SC_OK)); - assertEquals(expected, actual); } } diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImplTest.java index 9b5058d3..4d07c792 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImplTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/UserRolesCommonServiceImplTest.java @@ -55,7 +55,6 @@ import java.util.TreeSet; import javax.servlet.http.HttpServletResponse; import org.apache.cxf.transport.http.HTTPException; -import org.drools.core.command.assertion.AssertEquals; import org.hibernate.Query; import org.hibernate.SQLQuery; import org.hibernate.Session; @@ -364,11 +363,11 @@ public class UserRolesCommonServiceImplTest { Mockito.when(epAppCommonServiceImpl.getApp(mockApp.getId())).thenReturn(mockApp); List<RoleInAppForUser> mockRoleInAppForUserList = new ArrayList<>(); RoleInAppForUser mockRoleInAppForUser = new RoleInAppForUser(); - mockRoleInAppForUser.setIsApplied(true); + mockRoleInAppForUser.setIsApplied(false); mockRoleInAppForUser.setRoleId(333l); mockRoleInAppForUser.setRoleName("test1"); RoleInAppForUser mockRoleInAppForUser2 = new RoleInAppForUser(); - mockRoleInAppForUser2.setIsApplied(true); + mockRoleInAppForUser2.setIsApplied(false); mockRoleInAppForUser2.setRoleId(777l); mockRoleInAppForUser2.setRoleName("test2"); RoleInAppForUser mockRoleInAppForUser3 = new RoleInAppForUser(); @@ -447,34 +446,31 @@ public class UserRolesCommonServiceImplTest { .thenReturn(mockEcompRoleArray); // syncAppRolesTest - Mockito.when(session.createQuery("from :name where appId = :appId")) + Mockito.when(session.createQuery("from EPRole where appId = :appId")) .thenReturn(epRoleQuery); - Mockito.when(epRoleQuery.setParameter("name",EPRole.class.getName())).thenReturn(epRoleQuery); Mockito.when(epRoleQuery.setParameter("appId",mockApp.getId())).thenReturn(epRoleQuery); Mockito.doReturn(mockEPRoleList).when(epRoleQuery).list(); - Mockito.when(session.createQuery("from :name where app.id=:appId and role_id=:roleId")) + Mockito.when(session.createQuery("from EPUserApp where app.id=:appId and role_id=:roleId")) .thenReturn(epUserAppsQuery); - Mockito.when(epUserAppsQuery.setParameter("name",EPUserApp.class.getName())).thenReturn(epUserAppsQuery); Mockito.when(epUserAppsQuery.setParameter("appId",mockApp.getId())).thenReturn(epUserAppsQuery); Mockito.when(epUserAppsQuery.setParameter("roleId",15l)).thenReturn(epUserAppsQuery); Mockito.doReturn(mockUserRolesList).when(epUserAppsQuery).list(); - Mockito.when(session.createQuery("from :name where roleId=:roleId")) + Mockito.when(session.createQuery("from FunctionalMenuRole where roleId=:roleId")) .thenReturn(epFunctionalMenuQuery); - Mockito.when(epFunctionalMenuQuery.setParameter("name",FunctionalMenuRole.class.getName())).thenReturn(epFunctionalMenuQuery); Mockito.when(epFunctionalMenuQuery.setParameter("roleId",15l)).thenReturn(epFunctionalMenuQuery); Mockito.doReturn(mockFunctionalMenuRolesList).when(epFunctionalMenuQuery).list(); - Mockito.when(session.createQuery("from :name where menuId=:menuId")) + Mockito.when(session.createQuery("from FunctionalMenuRole where menuId=:menuId")) .thenReturn(epFunctionalMenuQuery2); - Mockito.when(epFunctionalMenuQuery2.setParameter("name",FunctionalMenuRole.class.getName())).thenReturn(epFunctionalMenuQuery2); - Mockito.when(epFunctionalMenuQuery2.setParameter("menuId",10l)).thenReturn(epFunctionalMenuQuery2); + Mockito.when(epFunctionalMenuQuery2.setParameter(Matchers.anyString(),Matchers.anyLong())).thenReturn(epFunctionalMenuQuery2); Mockito.doReturn(mockFunctionalMenuRolesList).when(epFunctionalMenuQuery2).list(); - Mockito.when(session.createQuery("from " + FunctionalMenuItem.class.getName() + " where menuId=" + 10l)) + Mockito.when(session.createQuery("from FunctionalMenuItem where menuId=:menuId")) .thenReturn(epFunctionalMenuItemQuery); + Mockito.when(epFunctionalMenuItemQuery.setParameter(Matchers.anyString(),Matchers.anyLong())).thenReturn(epFunctionalMenuItemQuery); Mockito.doReturn(mockFunctionalMenuItemList).when(epFunctionalMenuItemQuery).list(); List<EcompRole> mockEcompRoleList2 = new ArrayList<>(); EcompRole mockUserAppRoles = new EcompRole(); @@ -488,12 +484,14 @@ public class UserRolesCommonServiceImplTest { EcompRole[] mockEcompRoleArray2 = mockEcompRoleList2.toArray(new EcompRole[mockEcompRoleList2.size()]); Mockito.when(applicationsRestClientService.get(EcompRole[].class, mockApp.getId(), String.format("/user/%s/roles", user.getOrgUserId()))).thenReturn(mockEcompRoleArray2); - // SyncUserRoleTest - Mockito.when(session - .createQuery("from " + EPUser.class.getName() + " where orgUserId='" + user.getOrgUserId() + "'")) + + + Mockito.when(session.createQuery( + "from EPUser where orgUserId=:userId")) .thenReturn(epUserListQuery); + Mockito.when(epUserListQuery.setParameter("userId","guestT")).thenReturn(epUserListQuery); Mockito.doReturn(mockEpUserList).when(epUserListQuery).list(); - + List<EPUserApp> mockUserRolesList2 = new ArrayList<>(); EPUserApp mockEpUserAppRoles = new EPUserApp(); mockEpUserAppRoles.setApp(mockApp); @@ -501,9 +499,15 @@ public class UserRolesCommonServiceImplTest { mockEpUserAppRoles.setUserId(user.getId()); mockUserRolesList2.add(mockEpUserAppRoles); Mockito.when(session.createQuery( - "from org.onap.portalapp.portal.domain.EPUserApp where app.id=2 and role.active = 'Y' and userId=2")) + "from EPUserApp where app.id=:appId and userId=:userId and role.active = 'Y'")) .thenReturn(epUserRolesListQuery); + + Mockito.when(epUserRolesListQuery.setParameter("appId",2)).thenReturn(epUserRolesListQuery); + Mockito.when(epUserRolesListQuery.setParameter("userId",2)).thenReturn(epUserRolesListQuery); + Mockito.doReturn(mockUserRolesList2).when(epUserRolesListQuery).list(); + + List<RoleInAppForUser> roleInAppForUser = userRolesCommonServiceImpl.getAppRolesForUser(2l, user.getOrgUserId(), true, user); assertEquals(roleInAppForUser, mockRoleInAppForUserList); @@ -669,7 +673,7 @@ public class UserRolesCommonServiceImplTest { Mockito.when(session.createSQLQuery("update fn_role set app_id = null where app_id = 1 ")) .thenReturn(epsetAppWithUserRoleUpdateEPRoleQuery); ExternalRequestFieldsValidator actual = userRolesCommonServiceImpl.setAppWithUserRoleStateForUser(user, mockWithRolesForUser); - assertTrue(actual.isResult()); + assertFalse(actual.isResult()); } private List<EcompUserAppRoles> getCurrentUserRoles(EPUser user, EPApp mockApp) { @@ -816,7 +820,7 @@ public class UserRolesCommonServiceImplTest { assertEquals(expected.isResult(), false); } - /*@SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") @Test public void setExternalRequestUserAppRoleMerdianCentralizedAppTest() throws Exception { PowerMockito.mockStatic(SystemProperties.class); @@ -984,7 +988,7 @@ public class UserRolesCommonServiceImplTest { .setExternalRequestUserAppRole(externalSystemUser, "POST"); assertTrue(mockExternalRequestFieldsValidator.equals(externalRequestFieldsValidator)); } -*/ + @SuppressWarnings("unchecked") @Test public void setExternalRequestUserAppRoleMerdianNonCentralizedAppTest() throws Exception { diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/WidgetMServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/WidgetMServiceImplTest.java new file mode 100644 index 00000000..2ed86bfe --- /dev/null +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/WidgetMServiceImplTest.java @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal + * =================================================================== + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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.onap.portalapp.portal.service; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.*; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.onap.portalapp.portal.utils.EcompPortalUtils; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import com.orbitz.consul.Consul; +import com.orbitz.consul.HealthClient; +import com.orbitz.consul.model.ConsulResponse; +import com.orbitz.consul.model.health.ServiceHealth; +import com.orbitz.consul.Consul.Builder; +import com.orbitz.consul.model.health.Node; +import com.orbitz.consul.model.health.Service; +@RunWith(PowerMockRunner.class) +@PrepareForTest({ Consul.class ,EcompPortalUtils.class}) +public class WidgetMServiceImplTest { + + private static final String TEST="test"; + @InjectMocks + WidgetMServiceImpl widgetMServiceImpl; + + @Mock + Builder builder; + @Mock + Consul consul ; + @Mock + HealthClient healthClient; + @Mock + ServiceHealth serviceHealth; + @Mock + ConsulResponse<List<ServiceHealth>> response; + @Mock + Node node; + @Mock + Service service; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void getServiceLocation_Error() { + PowerMockito.mockStatic(EcompPortalUtils.class); + PowerMockito.when(EcompPortalUtils.localOrDockerHost()).thenReturn(TEST); + String location = widgetMServiceImpl.getServiceLocation(TEST, TEST); + assertNotNull(location); + } + +} diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/service/sessionmgt/SessionCommunicationTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/service/sessionmgt/SessionCommunicationTest.java index 2fdf0fe1..708f446a 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/service/sessionmgt/SessionCommunicationTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/service/sessionmgt/SessionCommunicationTest.java @@ -47,17 +47,21 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; import org.mockito.MockitoAnnotations; +import org.onap.portalapp.portal.domain.EPApp; +import org.onap.portalapp.portal.service.AppsCacheService; +import org.onap.portalapp.portal.service.AppsCacheServiceImple; import org.onap.portalapp.portal.transport.OnboardingApp; +import org.onap.portalsdk.core.onboarding.util.CipherUtil; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import org.slf4j.MDC; - -import com.att.eelf.configuration.Configuration; @RunWith(PowerMockRunner.class) -@PrepareForTest({URL.class, HttpURLConnection.class}) +@PrepareForTest({URL.class, HttpURLConnection.class,CipherUtil.class}) public class SessionCommunicationTest { @Before @@ -68,6 +72,8 @@ public class SessionCommunicationTest { @InjectMocks SessionCommunication sessionCommunication = new SessionCommunication(); + @Mock + AppsCacheService appsCacheService = new AppsCacheServiceImple(); @Test public void sendGetConnectionRefusedTest() throws Exception { @@ -94,6 +100,36 @@ public class SessionCommunicationTest { } @Test + public void sendGetConnectionRefusedTest1() throws Exception { + OnboardingApp app = new OnboardingApp(); + app.setRestrictedApp(false); + app.setUebKey("test"); + app.setUebSecret("test"); + app.setUebTopicName("test"); + app.isCentralAuth = true; + app.isEnabled = true; + app.isOpen =false; + app.name = "test"; + app.restUrl ="http://localhost:1234"; + app.username = "test"; + app.appPassword = ""; + EPApp epApp = new EPApp(); + epApp.setUsername("test"); + epApp.setAppPassword("xyz1234"); + PowerMockito.mockStatic(CipherUtil.class); + PowerMockito.when(CipherUtil.decryptPKC(Matchers.anyString(),Matchers.anyString())).thenReturn("test"); + Mockito.when(appsCacheService.getApp(1L)).thenReturn(epApp); + URL u = PowerMockito.mock(URL.class); + HttpURLConnection huc = PowerMockito.mock(HttpURLConnection.class); + String url = "http://localhost:1234/sessionTimeOuts"; + PowerMockito.whenNew(URL.class).withArguments(url).thenReturn(u); + PowerMockito.whenNew(HttpURLConnection.class).withAnyArguments().thenReturn(huc); + PowerMockito.when(huc.getResponseCode()).thenReturn(200); + String actual = sessionCommunication.sendGet(app); + assertEquals("", actual); + } + + @Test public void pingSessionConnectionRefusedTest() throws Exception { OnboardingApp app = new OnboardingApp(); app.setRestrictedApp(false); @@ -148,4 +184,4 @@ public class SessionCommunicationTest { sessionCommunication.clear(true); } -} +}
\ No newline at end of file diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/util/EPUserUtilsTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/util/EPUserUtilsTest.java index 80ca1424..db6ca2f7 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/util/EPUserUtilsTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/util/EPUserUtilsTest.java @@ -59,7 +59,6 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.codec.binary.Hex; -import org.drools.core.command.assertion.AssertEquals; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/validation/DataValidatorTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/validation/DataValidatorTest.java index 2dbfdcd7..f6e3e1a5 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/validation/DataValidatorTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/validation/DataValidatorTest.java @@ -45,7 +45,6 @@ import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; import javax.validation.ValidatorFactory; -import org.drools.core.command.assertion.AssertEquals; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; |