summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-BE-os/src
diff options
context:
space:
mode:
authorChristopher Lott (cl778h) <clott@research.att.com>2017-09-25 16:07:54 -0400
committerChristopher Lott (cl778h) <clott@research.att.com>2017-09-25 16:09:15 -0400
commit23634dba70b166ad3c79b5eadfbd32b5375d44be (patch)
treeab0ea364c8da4f91fb8c7e2819692498939fb419 /ecomp-portal-BE-os/src
parent4ba6a0f20a190030700917a6065a6779ca9d308f (diff)
MariaDB Connector and Sonar Scans; clean nl
PORTAL-50: Fix to get the Sonar coverage for ONAP PORTAL-72: Sonar scan - resolving severity Blocker issues PORTAL-86: Remove internal att.com usages from tests and other files PORTAL-102: Fixed the page refresh issue on App Account Management page PORTAL-103: Fix to enhanced notification ticket source for ONAP PORTAL-104: Replaced mysql DB connector with mariaDB Issue: PORTAL-50 PORTAL-72 PORTAL-86 PORTAL-102 PORTAL-103 PORTAL-104 Change-Id: Iae78ad34ed9ce5ae1f2d36fcbb93fbc1e39944e5 Signed-off-by: Christopher Lott (cl778h) <clott@research.att.com>
Diffstat (limited to 'ecomp-portal-BE-os/src')
-rw-r--r--ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ONAPWelcomeController.java2
-rw-r--r--ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/SearchServiceImpl.java1
-rw-r--r--ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/TicketEventServiceImpl.java18
-rw-r--r--ecomp-portal-BE-os/src/main/webapp/WEB-INF/conf/system.properties26
-rw-r--r--ecomp-portal-BE-os/src/main/webapp/WEB-INF/jsp/welcome.jsp695
-rw-r--r--ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/OpenIdConnectLoginStrategyTest.java118
-rw-r--r--ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SessionTimeoutInterceptorTest.java55
-rw-r--r--ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SimpleLoginStrategyTest.java134
-rw-r--r--ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsControllerExternalRequestOSTest.java119
-rw-r--r--ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsOSControllerTest.java150
-rw-r--r--ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ECOMPLogoutControllerTest.java77
-rw-r--r--ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/LoginControllerTest.java84
-rw-r--r--ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPLoginControllerTest.java89
-rw-r--r--ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPWelcomeControllerTest.java47
-rw-r--r--ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/PortalAdminControllerOSTest.java142
-rw-r--r--ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockEPUser.java84
-rw-r--r--ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockTestSuite.java68
-rw-r--r--ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockitoTestSuite.java75
-rw-r--r--ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/RemoteWebServiceCallServiceImplTest.java148
-rw-r--r--ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/SearchServiceImplTest.java189
-rw-r--r--ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/UserServiceImplTest.java63
21 files changed, 1617 insertions, 767 deletions
diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ONAPWelcomeController.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ONAPWelcomeController.java
index 52473102..9d8a7893 100644
--- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ONAPWelcomeController.java
+++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/controller/ONAPWelcomeController.java
@@ -48,7 +48,7 @@ public class ONAPWelcomeController extends EPRestrictedBaseController{
return "/index";
}
- @RequestMapping(value = {"/applicationsHome", "/dashboard", "/widgetsHome", "/kpidash*", "/admins", "/users", "/portalAdmins", "/applications", "/widgets", "/functionalMenu", "/contactUs", "/getAccess","/appCatalog" }, method = RequestMethod.GET)
+ @RequestMapping(value = {"/applicationsHome", "/dashboard", "/widgetsHome", "/kpidash*", "/admins", "/users", "/portalAdmins", "/applications", "/widgets", "/functionalMenu", "/contactUs", "/getAccess","/appCatalog", "/widgetOnboarding", "/accountOnboarding"}, method = RequestMethod.GET)
public String getEcompSinglePage(HttpServletRequest request, HttpServletResponse response) {
return "forward:/index.html";
}
diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/SearchServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/SearchServiceImpl.java
index 35fc00bd..2be95244 100644
--- a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/SearchServiceImpl.java
+++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/SearchServiceImpl.java
@@ -185,6 +185,7 @@ public class SearchServiceImpl implements SearchService {
}
} catch (Exception e) {
logger.error(EELFLoggerDelegate.errorLogger, "searchInPhoneBookWithToken Exception = " + EcompPortalUtils.getStackTrace(e));
+ return null;
}
return foundUsers.get(0);
}
diff --git a/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/TicketEventServiceImpl.java b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/TicketEventServiceImpl.java
new file mode 100644
index 00000000..37acfe53
--- /dev/null
+++ b/ecomp-portal-BE-os/src/main/java/org/openecomp/portalapp/portal/service/TicketEventServiceImpl.java
@@ -0,0 +1,18 @@
+package org.openecomp.portalapp.portal.service;
+
+import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.springframework.stereotype.Service;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+@Service("ticketService")
+public class TicketEventServiceImpl implements TicketEventService{
+
+ @Override
+ public String getNotificationHyperLink(JsonNode application, String ticket, String eventSource) {
+ String hyperlink = SystemProperties.getProperty(EPCommonSystemProperties.EXTERNAL_SYSTEM_NOTIFICATION_URL)+ticket;
+ return hyperlink;
+ }
+
+}
diff --git a/ecomp-portal-BE-os/src/main/webapp/WEB-INF/conf/system.properties b/ecomp-portal-BE-os/src/main/webapp/WEB-INF/conf/system.properties
index 8f74a9f2..860cc47a 100644
--- a/ecomp-portal-BE-os/src/main/webapp/WEB-INF/conf/system.properties
+++ b/ecomp-portal-BE-os/src/main/webapp/WEB-INF/conf/system.properties
@@ -18,8 +18,8 @@
# ================================================================================
###
-db.driver = com.mysql.jdbc.Driver
-db.connectionURL = jdbc:mysql://localhost:3306/ecomp_portal
+db.driver = org.mariadb.jdbc.Driver
+db.connectionURL = jdbc:mariadb:failover://localhost:3306/ecomp_portal
db.userName = XXXX
db.password = XXXX
# is the db.password property encrypted?
@@ -118,4 +118,24 @@ window_width_threshold_left_menu = 1400
window_width_threshold_right_menu = 1350
#External system notification URL
-external_system_notification_url= http://todo_external_system_notification_url?
+external_system_notification_url= https://jira.onap.org/browse/
+
+#scheduler properties
+scheduler.server.url=http://mtanjv9sdlg10.aic.cip.onap.com:8989/scheduler
+scheduler.create.new.vnf.change.instance=/v1/ChangeManagement/schedules/
+scheduler.get.time.slots=/v1/ChangeManagement/schedules/
+scheduler.submit.new.vnf.change=/v1/ChangeManagement/schedules/{scheduleId}/approvals
+vid.truststore.filename=C:\\Temp\\vid_keystore.jks
+vid.truststore.passwd.x=OBF:1wgg1wfq1uus1uui1x131x0r1x1v1x1j1uvo1uve1wg81wfi
+
+#scheduler-policy properties
+policy.server.url=https://policypdp-conexus-e2e.ecomp.cci.onap.com:8081/pdp
+policy.get.config=/api/getConfig
+policy.ClientAuth=UHlQRFBTZXJ2ZXI6dGVzdA==
+policy.client.mechId=m06814@controller.dcae.ecomp.onap.com
+policy.client.password=OBF:1ffu1qvu1t2z1l161fuk1i801nz91ro41xf71xfv1rqi1nx51i7y1fuq1kxw1t371qxw1fh0
+policy.username=testpdp
+policy.password=OBF:1igd1kft1l1a1sw61svs1kxs1kcl1idt
+policy.Authorization=dGVzdHBkcDphbHBoYTEyMw==
+policy.environment=TEST
+
diff --git a/ecomp-portal-BE-os/src/main/webapp/WEB-INF/jsp/welcome.jsp b/ecomp-portal-BE-os/src/main/webapp/WEB-INF/jsp/welcome.jsp
deleted file mode 100644
index 054c38fe..00000000
--- a/ecomp-portal-BE-os/src/main/webapp/WEB-INF/jsp/welcome.jsp
+++ /dev/null
@@ -1,695 +0,0 @@
-<%--
- ================================================================================
- eCOMP Portal
- ================================================================================
- Copyright (C) 2017 AT&T Intellectual Property
- ================================================================================
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ================================================================================
- --%>
-<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
-<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
-<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
-
-<link rel="stylesheet" type="text/css" href="static/fusion/sample/css/slider.css">
-<link rel="stylesheet" type="text/css" href="static/fusion/sample/css/scribble.css" />
-<link rel="stylesheet" type="text/css" href="static/fusion/sample/css/spacegallery.css" />
-<link rel="stylesheet" href="static/fusion/css/att_angular_gridster/ui-gridster.css"/>
-<link rel="stylesheet" href="static/fusion/css/att_angular_gridster/sandbox-gridster.css"/>
-
-<script src= "static/ebz/angular_js/angular.js"></script>
-<script src= "static/ebz/angular_js/angular-sanitize.js"></script>
-
-<script src= "static/ebz/angular_js/app.js"></script>
-<script src= "static/ebz/angular_js/gestures.js"></script>
-
-<script src="static/js/jquery-1.10.2.js"></script>
-<!-- <script src="static/fusion/js/jquery.resize.js"></script> -->
-<script src="static/fusion/js/att_angular_gridster/ui-gridster-tpls.js"></script>
-<script src="static/fusion/js/att_angular_gridster/angular-gridster.js"></script>
-
-<script src= "static/ebz/angular_js/checklist-model.js"></script>
-<script src= "static/js/modalService.js"></script>
-<script src="static/js/jquery.mask.min.js" type="text/javascript"></script>
-<script src="static/js/jquery-ui.js" type="text/javascript"></script>
-<script src="static/ebz/sandbox/att-abs-tpls.js" type="text/javascript"></script>
-<script src="static/ebz/sandbox/att-abs-tpls.min.js" type="text/javascript"></script>
-<style>
-.button--small, [class*=bg-] .button--small {
- font-size: 14px;
- };
-</style>
-
-<style>
-.gridster-item-container .gridster-item-body{
-bottom:0px;
-}
-.gridster-item-container{
-min-height:50px;
-}
-.att-accordion {
- border-width: 0px;
-}
-</style>
-
-<style>
- #myGallery {
- width: 100%;
- height: 400px;
- }
-
- #myGallery img {
- border: 2px solid #52697E;
- }
-
- a.loading {
- background: #fff url(../images/ajax_small.gif) no-repeat center;
- }
-
- .center {
- margin-left: auto;
- margin-right: auto;
- }
-
-</style>
-
-<script type="text/javascript" src="static/fusion/sample/js/FusionCharts.js"></script> <!-- Charts -->
-<script type="text/javascript" src="static/fusion/sample/js/charts.js"></script> <!-- Charts -->
-
-<script type="text/javascript" src="static/fusion/sample/js/slides.min.jquery.js"></script> <!-- Image Slider -->
-<script type="text/javascript" src="static/fusion/sample/js/scribble.js"></script> <!-- Scribble -->
-<script type="text/javascript" src="static/fusion/sample/js/eye.js"></script> <!-- Space Gallery -->
-<script type="text/javascript" src="static/fusion/sample/js/utils.js"></script> <!-- Space Gallery -->
-<script type="text/javascript" src="static/fusion/sample/js/spacegallery.js"></script> <!-- Space Gallery -->
-
- <!-- Carousel rendering -->
- <script>
- (function($){
- var initLayout = function() {
- $('#myGallery').spacegallery({loadingClass: 'loading'});
- };
-
- EYE.register(initLayout, 'init');
- })(jQuery)
- </script>
-
- <!-- Slider rendering -->
- <script>
- $(function(){
- $('#slides').slides({
- preload: true,
- preloadImage: 'static/fusion/sample/images/loading.gif',
- play: 5000,
- pause: 10000,
- hoverPause: true,
- animationStart: function(current){
- $('.caption').animate({
- bottom:-35
- },100);
- if (window.console && console.log) {
- // example return of current slide number
- //console.log('animationStart on slide: ', current);
- };
- },
- animationComplete: function(current){
- $('.caption').animate({
- bottom:0
- },200);
- if (window.console && console.log) {
- // example return of current slide number
- //console.log('animationComplete on slide: ', current);
- };
- },
- slidesLoaded: function() {
- $('.caption').animate({
- bottom:0
- },200);
- }
- });
- });
-
-
- </script>
-
-<div ng-controller="welcomeController">
- <fmt:message key="general.home" var="title" />
- <div>
- <span style="font-weight:bold;font-size:11pt;">Welcome ${sessionScope.user.firstName} ${sessionScope.user.lastName}</span>&nbsp;
- (Last Login:&nbsp;<fmt:formatDate value="${sessionScope.user.lastLoginDate}" type="date" pattern="dd MMM yyyy hh:mma zzz" var="lastLogin" /> ${lastLogin})
- </div>
-
- <div style="float:left; width:320px; height:320px; margin:10px 27px 10px 27px;color:#222222;text-shadow: 1px 1px 2px #A0A0A0;" >
- <p style="font-weight:bold;font-size:16pt;color:#0046B8;">Network </p>
- <p style="font-weight:bold;font-size:16pt;color:#0046B8;">Visualization </p>
-
- </div>
-
- <!-- Spacer required to center the Image slider (can also be used for content) -->
- <div style="float:right; width:120px; height:320px; margin:10px 27px 10px 10px;color:#222222;text-shadow: 1px 1px 2px #A0A0A0;">
- <p style="font-weight:bold;font-size:9pt;">
- You can toggle between the Image Slider and Carousel controls by clicking on the respective radio button below:
- </p>
- <input type="radio" name="viewer" onClick="$('#example').show();$('#myGallery').hide();" value="Slider" />Slider<br/>
- <input type="radio" name="viewer" onClick="$('#example').hide();$('#myGallery').show();" value="Carousel" />Carousel
-
- <br/>
- </div>
-
- <div id="container">
-
- <div style="position:relative">
- <div id="myGallery" class="spacegallery" style="position:static">
- <img src="static/fusion/sample/images/carousel/slide_b_drive_test_map.png" alt="Drive test analytics" />
- <img src="static/fusion/sample/images/carousel/slide_b_ios_throughput.png" alt="MTSA - Nationwide DL throughput for iOS devices over cellular network" />
- <img src="static/fusion/sample/images/carousel/slide_b_eppt_county.png" alt="Location based services county level drive test" />
- <img src="static/fusion/sample/images/carousel/slide_b_lata_map.png" alt="Network demand data by LATA (2020 forecast)" />
- <img src="static/fusion/sample/images/carousel/slide_b_eppt_regression.png" alt="Linear regression prediction of LBS/E911 drive test accuracy" />
- <img src="static/fusion/sample/images/carousel/slide_b_nova_sdn_map.png" alt="SDN Simulator - SNRC Traffic" />
- <span style="float:right; color:#222222;">(Click on Image to Rotate)</span>
- </div>
- </div>
- <div id="example">
- <div id="slides">
- <div class="slides_container">
- <div class="slide">
- <a href="#" title="Drive test analytics"><img src="static/fusion/sample/images/carousel/slide_b_drive_test_map.png" width="570" height="270" alt="Drive test analytics"></a>
- <div class="caption">
- <p>Drive test analytics</p>
- </div>
- </div>
- <div class="slide">
- <a href="doclib.htm" title="MTSA - Nationwide DL throughput for iOS devices over cellular network"><img src="static/fusion/sample/images/carousel/slide_b_ios_throughput.png" width="570" height="270" alt="MTSA - Nationwide DL throughput for iOS devices over cellular network"></a>
- <div class="caption">
- <p>Nationwide DL throughput for iOS devices over cellular network</p>
- </div>
- </div>
- <div class="slide">
- <a href="#" title="Network demand data by LATA (2020 forecast)"><img src="static/fusion/sample/images/carousel/slide_b_lata_map.png" width="570" height="270" alt="Network demand data by LATA (2020 forecast)"></a>
- <div class="caption">
- <p>Network demand data by LATA (2020 forecast)</p>
- </div>
- </div>
- <div class="slide">
- <a href="#" title="Location based services county level drive test"><img src="static/fusion/sample/images/carousel/slide_b_eppt_county.png" width="570" height="270" alt="Location based services county level drive test"></a>
- <div class="caption">
- <p>Location based services county level drive test</p>
- </div>
- </div>
- <div class="slide">
- <a href="broadcast_list.htm" title="SDN Simulator - SNRC Traffic"><img src="static/fusion/sample/images/carousel/slide_b_nova_sdn_map.png" width="570" height="270" alt="SDN Simulator - SNRC Traffic"></a>
- <div class="caption">
- <p>SDN Simulator - SNRC Traffic</p>
- </div>
- </div>
- <div class="slide">
- <a href="#" title="Linear regression prediction of LBS/E911 drive test accuracy"><img src="static/fusion/sample/images/carousel/slide_b_eppt_regression.png" width="570" height="270" alt="Linear regression prediction of LBS/E911 drive test accuracy"></a>
- <div class="caption" style="bottom:0">
- <p>Linear regression prediction of LBS/E911 drive test accuracy</p>
- </div>
- </div>
- </div>
- <a href="#" class="prev"><img src="static/fusion/sample/images/arrow-prev.png" width="24" height="43" alt="Arrow Prev"></a>
- <a href="#" class="next"><img src="static/fusion/sample/images/arrow-next.png" width="24" height="43" alt="Arrow Next"></a>
- </div>
- <img src="static/fusion/sample/images/example-frame.png" width="739" height="341" alt="Example Frame" id="frame">
- </div>
- </div>
-
- <center>
- <div class="gridster-container">
- <div att-gridster att-gridster-options='gridsterOpts'>
- <div att-gridster-item='item' ng-repeat="item in standardItems">
- <div att-gridster-item-header
- header-text={{item.headerText}}
- sub-header-text={{item.subHeaderText}}>
- <!--ICON BUTTONS PLACEHOLDER START-->
- <div class="tileMinMaxBtn" ng-click="toggleMinMax($index,'')">
- <span class="tileMinMaxIcon">
- <i class="icon-chevron-up" style="color:gray" ng-show="item.max"></i>
- <i class="icon-chevron-down" style="color:gray" ng-hide="item.max"></i>
- </span>
- </div>
- <!--ICON BUTTONS PLACEHOLDER END-->
- </div>
- <div att-gridster-item-body >
- <!--ACTUAL BODY CONTENT START-->
- <div align="center" style="margin-top:10px;">
- <div align="left" ng-if="item.headerText=='Dashboard' && item.max">
- <label>&nbsp; Sample Charts</label><BR>
- <iframe scrolling="no" frameBorder="0" style="width: 430px; height: 360px;" src="static/fusion/sample/html/wordcloud.html"></iframe>
- </div>
- <div ng-if="item.headerText=='Donut Chart' && item.max">
- <iframe scrolling="no" frameBorder="0" style="width: 310px; height: 210px;" src="static/fusion/sample/html/donut_d3.html"></iframe>
- </div>
- <div ng-if="item.headerText=='Area Chart' && item.max">
- <iframe scrolling="no" frameBorder="0" style="width: 310px; height: 210px;" src="static/fusion/sample/html/area_chart.html"></iframe>
- </div>
- <div ng-if="item.headerText=='Pie Chart' && item.max">
- <iframe scrolling="no" frameBorder="0" style="width: 310px; height: 210px;" src="static/fusion/sample/html/pie_chart.html"></iframe>
- </div>
- <div ng-if="item.headerText=='Line Chart' && item.max">
- <iframe scrolling="no" frameBorder="0" style="width: 310px; height: 210px;" src="static/fusion/sample/html/line_chart.html"></iframe>
- </div>
- <div ng-if="item.headerText=='Gauges' && item.max">
- <iframe scrolling="no" frameBorder="0" style="width: 310pxx; height: 210px;" src="static/fusion/sample/html/d3_gauges_demo.html"></iframe>
- </div>
-
- <div align="left" ng-if="item.headerText=='Traffic distribution by day of week' && item.max">
- <att-tabs title="gTabs" class="tabs" >
- <floating-tabs ng-model='activeTabId' size="small"></floating-tabs>
- </att-Tabs>
- <div>
- <div id="Monday" align="left"><img src="static/fusion/sample/images/tunnels/1_mon.png" width=100% height=100% alt="Monday"></div>
- <div id="Tuesday" class="hidden" align="center"><img src="static/fusion/sample/images/tunnels/2_tue.png" width=100% height=100% alt="Tuesday"></div>
- <div id="Wednesday" class="hidden" align="center"><img src="static/fusion/sample/images/tunnels/3_wed.png" width=100% height=100% alt="Wednesday"></div>
- <div id="Thursday" class="hidden" align="center"><img src="static/fusion/sample/images/tunnels/4_thu.png" width=100% height=100% alt="Thursday"></div>
- <div id="Friday" class="hidden" align="center"><img src="static/fusion/sample/images/tunnels/5_fri.png" width=100% height=100% alt="Friday"></div>
- <div id="Saturday" class="hidden" align="center"><img src="static/fusion/sample/images/tunnels/6_sat.png" width=100% height=100% alt="Saturday"></div>
- <div id="Sunday" class="hidden" align="center"><img src="static/fusion/sample/images/tunnels/7_sun.png" width=100% height=100% alt="Sunday"></div>
- </div>
- </div>
- <div align="left" ng-if="item.headerText=='Busy hour traffic analysis by day of week' && item.max">
- <att-tabs title="gTabs2">
- <floating-tabs ng-model='activeTabId2' size="small"></floating-tabs>
- </att-Tabs>
- <div>
- <div id="Incoming" align="left"><img src="static/fusion/sample/images/tunnels/BH_DLSTX_IN.png" width=100% height=100% alt="Monday"></div>
- <div id="Outgoing" class="hidden" align="center"><img src="static/fusion/sample/images/tunnels/BH_DLSTX_OUT.png" width=100% height=100% alt="Tuesday"></div>
- <div id="Default" class="hidden" align="center"><img src="static/fusion/sample/images/tunnels/BH_Nat_Def.png" width=100% height=100% alt="Wednesday"></div>
- <div id="Priority" class="hidden" align="center"><img src="static/fusion/sample/images/tunnels/BH_Nat_Priority.png" width=100% height=100% alt="Thursday"></div>
- <div id="BHNational" class="hidden" align="center"><img src="static/fusion/sample/images/tunnels/BH_Nat.png" width=100% height=100% alt="Friday"></div>
- </div>
- </div>
-
- <div align="left" ng-if="item.headerText=='Additional Samples' && item.max">
- <label>&nbsp;Quick Links</label>
- <table att-table >
-
- <tr>
- <td att-table-body width="90%" ><a href="" target="_blank">Contacts</a></td>
- <td att-table-body width="10%">
- <a ng-click="removeRole();" ><img src="static/fusion/sample/images/deleteicon.gif"></a>
- </td>
- </tr>
- <tr>
- <td att-table-body width="90%" ><a href="" target="_blank">Developer Program</a></td>
- <td att-table-body width="10%">
- <a ng-click="removeRole();" ><img src="static/fusion/sample/images/deleteicon.gif"></a>
- </td>
- </tr>
- <tr>
- <td att-table-body width="90%" ><a href="http://www.zkoss.org" target="_blank">ZK Framework</a></td>
- <td att-table-body width="10%">
- <a ng-click="removeRole();" ><img src="static/fusion/sample/images/deleteicon.gif"></a>
- </td>
- </tr>
- <tr>
- <td att-table-body width="90%" ><a href="http://jquery.com" target="_blank">JQuery</a></td>
- <td att-table-body width="10%">
- <a ng-click="removeRole();" ><img src="static/fusion/sample/images/deleteicon.gif"></a>
- </td>
- </tr>
- <tr>
- <td att-table-body width="90%" ><a href="force_cluster.html" target="_blank">RNC Visualization</a></td>
- <td att-table-body width="10%">
- <a ng-click="removeRole();" ><img src="static/fusion/sample/images/deleteicon.gif"></a>
- </td>
- </tr>
- <tr>
- <td att-table-body width="90%" ><a href="sample_heat_map.htm" target="">Heat Map</a></td>
- <td att-table-body width="10%">
- <a ng-click="removeRole();" ><img src="static/fusion/sample/images/deleteicon.gif"></a>
- </td>
- </tr>
- <tr>
- <td att-table-body width="90%" ><a href="sample_animated_map.htm" target="">Animated Map</a></td>
- <td att-table-body width="10%">
- <a ng-click="removeRole();" ><img src="static/fusion/sample/images/deleteicon.gif"></a>
- </td>
- </tr>
- <tr>
- <td att-table-body width="90%" ><a href="jbpm_drools.htm" target="_blank">Process Management</a></td>
- <td att-table-body width="10%">
- <a ng-click="removeRole();" ><img src="static/fusion/sample/images/deleteicon.gif"></a>
- </td>
- </tr>
- <tr>
- <td att-table-body width="90%" ><a href="chatRoom.htm">Chat Session</a></td>
- <td att-table-body width="10%">
- <a ng-click="removeRole();" ><img src="static/fusion/sample/images/deleteicon.gif"></a>
- </td>
- </tr>
- </table>
- </div>
- <div ng-if="item.headerText=='Sticky Notes' && item.max">
- <div style="width:100%; height:400px" id="scribble-pad"><pre id="scribble" contenteditable="true" onkeyup="storeUserScribble(this.id);"></pre></div>
- </div>
- <div ng-if="item.headerText=='Service Configuration' && item.max">
- <accordion close-others="true" css="att-accordion">
- <accordion-group heading="Service Configuration" is-open="group11.open">
- <iframe scrolling="no" frameBorder="0" align="center" width="100%" height="400px" src="static/fusion/sample/org_chart/example.html" ></iframe>
- </accordion-group>
- <accordion-group heading="VSP Service Configuration" is-open="group12.open">
- <iframe scrolling="no" frameBorder="0" align="center" width="100%" height="400px" src="static/fusion/sample/org_chart/example_vsp.html" ></iframe>
- </accordion-group>
- </accordion>
- </div>
-
- </div>
-
- <!--ACTUAL BODY CONTENT END-->
- </div>
- <!-- <div att-gridster-item-footer
- att-gridster-item-footer-link={{item.footerLink}}>
- {{item.footerLinkText}}
- </div> -->
- </div>
- </div>
- </div>
- </center>
-
-</div>
-
-<script>
-$(document).ready(function(){
- $( "#rightIcon" ).hide();
- $( "#leftIcon" ).show();
-});
-var app=angular.module("abs", ["att.abs", "modalServices","att.gridster","checklist-model"]);
-app.controller('welcomeController', function ($scope, modalService, $modal) {
-
- $scope.gridsterOpts = {
- columns: 3, // the width of the grid, in columns
- pushing: true, // whether to push other items out of the way on move or resize
- floating: true, // whether to automatically float items up so they stack (you can temporarily disable if you are adding unsorted items with ng-repeat)
- width: 'auto', // can be an integer or 'auto'. 'auto' scales gridster to be the full width of its containing element
- colWidth: 'auto', // can be an integer or 'auto'. 'auto' uses the pixel width of the element divided by 'columns'
- rowHeight: 60, // can be an integer or 'match'. Match uses the colWidth, giving you square widgets.
- margins: [10, 10], // the pixel distance between each widget
- outerMargin: true, // whether margins apply to outer edges of the grid
- swapping: true,
- draggable: {
- enabled: true, // whether dragging items is supported
- stop: function(event, uiWidget, $element) {$scope.setCookie();} // optional callback fired when item is finished dragging
- }
-
- };
-
- /* $scope.gridsterOpts = {
- columns: 6,
- width: 'auto',
- colWidth: '230',
- rowHeight: '120',
- margins: [10, 10],
- outerMargin: true,
- pushing: true,
- floating: true,
- swapping: true
- }; */
-
-
- $scope.toggleMinMax = function(index, tileName){
- if(tileName==''){
- $scope.standardItems[index].max = !$scope.standardItems[index].max;
- if($scope.standardItems[index].max)
- $scope.standardItems[index].sizeY=$scope.standardItems[index].maxHeight;
- else
- $scope.standardItems[index].sizeY=0;
- }else{
- $scope.tileTemp = $scope.$eval(tileName);
- var tileMax = $parse(tileName+'.max');
- tileMax.assign($scope, !$scope.$eval(tileName).max);
- var tileSizeY = $parse(tileName+'.sizeY');
- if($scope.tileTemp.max)
- tileSizeY.assign($scope, $scope.tileTemp.maxHeight);
- else
- tileSizeY.assign($scope, 0);
- }
- };
- // These map directly to gridsterItem options
- // IMPORTANT: Items should be placed in the grid in the order in which
- // they should appear.
- // In most cases the sorting should be by row ASC, col ASC
- $scope.standardItems = [{
- sizeX: 1,
- sizeY: 8,
- maxHeight: 8,
- row: 0,
- col: 0,
- headerText:'Dashboard',
- max:false
-
-
- },
- {
- sizeX: 1,
- sizeY: 5,
- maxHeight: 5,
- row: 0,
- col: 1,
- headerText:'Donut Chart',
- max:false
-
- },
- {
- sizeX: 1,
- sizeY: 5,
- maxHeight: 5,
- row: 0,
- col: 2,
- headerText:'Area Chart',
- max:true
- },
- {
- sizeX: 1,
- sizeY: 5,
- maxHeight: 5,
- row: 8,
- col: 0,
- headerText:'Pie Chart',
- max:false
- },
- {
- sizeX: 1,
- sizeY: 5,
- maxHeight: 5,
- row: 8,
- col: 1,
- headerText:'Line Chart',
- max:true
- },
- {
- sizeX: 1,
- sizeY: 5,
- maxHeight: 5,
- row: 8,
- col: 2,
- headerText:'Gauges',
- max:false
- },
- {
- sizeX: 1,
- sizeY: 8,
- maxHeight: 8,
- row: 16,
- col: 0,
- headerText:'Traffic distribution by day of week',
- max:false
- },
- {
- sizeX: 1,
- sizeY: 8,
- maxHeight: 8,
- row: 16,
- col: 1,
- headerText:'Busy hour traffic analysis by day of week',
- max:false
- },
- {
- sizeX: 1,
- sizeY: 6,
- maxHeight: 6,
- row: 24,
- col: 0,
- headerText:'Additional Samples',
- max:false
- },
- {
- sizeX: 1,
- sizeY: 8,
- maxHeight: 8,
- row: 24,
- col: 1,
- headerText:'Sticky Notes',
- max:false
- },
- {
- sizeX: 3,
- sizeY: 10,
- maxHeight: 10,
- row: 32,
- col: 0,
- headerText:'Service Configuration',
- max:false
- }];
-
- $.each($scope.standardItems, function(i, a){
- $scope.toggleMinMax(i,'');
- });
- $scope.activeTabId = 'Monday';
- //for generic tabs
- $scope.gTabs = [{
- title: 'Monday',
- id: 'Monday',
- url: '#Monday',
- selected: true
- },{
- title: 'Tuesday',
- id: 'Tuesday',
- url: '#Tuesday'
- },{
- title: 'Wednesday',
- id: 'Wednesday',
- url: '#Wednesday'
- },{
- title: 'Thursday',
- id: 'Thursday',
- url: '#Thursday'
- },{
- title: 'Friday',
- id: 'Friday',
- url: '#Friday'
- },{
- title: 'Saturday',
- id: 'Saturday',
- url: '#Saturday'
- },{
- title: 'Sunday',
- id: 'Sunday',
- url: '#Sunday'
- }
- ];
-
- $scope.activeTabId2 = 'Incoming';
- //for generic tabs
- $scope.gTabs2 = [{
- title: 'BH SNRC DLSTX - Incoming',
- id: 'Incoming',
- url: '#Incoming',
- selected: true
- },{
- title: 'BH SNRC DLSTX - Outgoing',
- id: 'Outgoing',
- url: '#Outgoing'
- },{
- title: 'BH National - Default',
- id: 'Default',
- url: '#Default'
- },{
- title: 'BH National - Priority',
- id: 'Priority',
- url: '#Priority'
- },{
- title: 'BH National',
- id: 'BHNational',
- url: '#BHNational'
- }
- ];
-
- $scope.activeTabId3 = 'Incoming';
- //for generic tabs
- $scope.gTabs3 = [{
- title: 'BH SNRC DLSTX - Incoming',
- id: 'Incoming',
- url: '#Incoming',
- selected: true
- },{
- title: 'BH SNRC DLSTX - Outgoing',
- id: 'Outgoing',
- url: '#Outgoing'
- },{
- title: 'BH National - Default',
- id: 'Default',
- url: '#Default'
- },{
- title: 'BH National - Priority',
- id: 'Priority',
- url: '#Priority'
- },{
- title: 'BH National',
- id: 'BHNational',
- url: '#BHNational'
- }
- ];
-
- /* $scope.$watch('activeTabId', function(newVal) {
- alert(newval);
- $('#'+newval).show();
- }, true); */
-
- $scope.toggleEastToWest = function() {
- $( "#toggle" ).toggle( 'slide');
- if ($("#leftIcon").is(":visible")) {
- $( "#rightIcon" ).show();
- $( "#leftIcon" ).hide();
- }
- else if ($("#rightIcon").is(":visible")) {
- $( "#rightIcon" ).hide();
- $( "#leftIcon" ).show();
- }
- };
-
- $scope.group1 = {
- open: true
- };
- $scope.group2 = {
- open: true
- };
- $scope.group3 = {
- open: true
- };
- $scope.group4 = {
- open: true
- };
- $scope.group5 = {
- open: true
- };
- $scope.group6 = {
- open: true
- };
- $scope.group7 = {
- open: true
- };
- $scope.group71 = {
- open: true
- };
- $scope.group8 = {
- open: true
- };
- $scope.group9 = {
- open: true
- };
- $scope.group10 = {
- open: true
- };
- $scope.group11 = {
- open: true
- };
- $scope.group12 = {
- open: false
- };
-});
-</script>
-
- <!-- Select the Slider control by default -->
- <script>$('input[name=viewer]:eq(1)').click();</script>
diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/OpenIdConnectLoginStrategyTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/OpenIdConnectLoginStrategyTest.java
new file mode 100644
index 00000000..4386ccd7
--- /dev/null
+++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/OpenIdConnectLoginStrategyTest.java
@@ -0,0 +1,118 @@
+package org.openecomp.portalapp.portal.authentication;
+
+import static org.junit.Assert.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.openecomp.portalsdk.core.onboarding.exception.PortalAPIException;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mitre.openid.connect.model.DefaultUserInfo;
+import org.mitre.openid.connect.model.UserInfo;
+import org.mockito.InjectMocks;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.portalapp.authentication.OpenIdConnectLoginStrategy;
+import org.openecomp.portalapp.portal.framework.MockitoTestSuite;
+import org.openecomp.portalapp.portal.utils.EPSystemProperties;
+import org.openecomp.portalapp.util.EPUserUtils;
+import org.openecomp.portalapp.util.SessionCookieUtil;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.springframework.util.StringUtils;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({StringUtils.class, EPUserUtils.class , SessionCookieUtil.class,SystemProperties.class})
+public class OpenIdConnectLoginStrategyTest {
+
+ @InjectMocks
+ OpenIdConnectLoginStrategy OpenIdConnectLoginStrategy = new OpenIdConnectLoginStrategy();
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
+
+ HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
+ HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
+
+ NullPointerException nullPointerException = new NullPointerException();
+
+ @Test
+ public void loginTest()
+ {
+ PowerMockito.mockStatic(StringUtils.class);
+ PowerMockito.mockStatic(EPUserUtils.class);
+ PowerMockito.mockStatic(SessionCookieUtil.class);
+
+ UserInfo userInfo = new DefaultUserInfo();
+ userInfo.setPreferredUsername("Test");
+ userInfo.setEmail("test@gmail.com");
+ userInfo.setName("first_name");
+ userInfo.setFamilyName("last_name");
+ Mockito.when(mockedRequest.getAttribute("userInfo")).thenReturn(userInfo);
+ assertTrue(OpenIdConnectLoginStrategy.login(mockedRequest, mockedResponse));
+ }
+
+ @Test
+ public void loginIfUserNullTest()
+ {
+ PowerMockito.mockStatic(SystemProperties.class);
+ UserInfo userInfo = null;
+ Mockito.when(mockedRequest.getAttribute("userInfo")).thenReturn(userInfo);
+// Mockito.when(SystemProperties.getProperty("authentication_mechanism")).thenReturn("auth");
+ assertFalse(OpenIdConnectLoginStrategy.login(mockedRequest, mockedResponse));
+ }
+
+ @Test
+ public void loginIfUserIfAuthIsOIDCTest()
+ {
+ PowerMockito.mockStatic(SystemProperties.class);
+ UserInfo userInfo = null;
+ Mockito.when(mockedRequest.getAttribute("userInfo")).thenReturn(userInfo);
+ Mockito.when(SystemProperties.getProperty("authentication_mechanism")).thenReturn("OIDC");
+ Mockito.when(SystemProperties.getProperty(EPSystemProperties.LOGIN_URL_NO_RET_VAL)).thenReturn("login_url");
+ assertFalse(OpenIdConnectLoginStrategy.login(mockedRequest, mockedResponse));
+ }
+
+ @Test
+ public void loginIfUserIfAuthNotNullTest()
+ {
+ PowerMockito.mockStatic(SystemProperties.class);
+ UserInfo userInfo = null;
+ Mockito.when(mockedRequest.getAttribute("userInfo")).thenReturn(userInfo);
+ Mockito.when(SystemProperties.getProperty("authentication_mechanism")).thenReturn("test");
+ Mockito.when(SystemProperties.getProperty(EPSystemProperties.LOGIN_URL_NO_RET_VAL)).thenReturn("login_url");
+ assertFalse(OpenIdConnectLoginStrategy.login(mockedRequest, mockedResponse));
+ }
+
+ @Test
+ public void loginIfUserExceptionest()
+ {
+ PowerMockito.mockStatic(SystemProperties.class);
+ UserInfo userInfo = null;
+ Mockito.when(mockedRequest.getAttribute("userInfo")).thenReturn(userInfo);
+ Mockito.when(SystemProperties.getProperty("authentication_mechanism")).thenThrow(nullPointerException);
+ Mockito.when(SystemProperties.getProperty(EPSystemProperties.LOGIN_URL_NO_RET_VAL)).thenReturn("login_url");
+ assertFalse(OpenIdConnectLoginStrategy.login(mockedRequest, mockedResponse));
+ }
+ @Test(expected = Exception.class)
+ public void doLoginTest() throws Exception
+ {
+ OpenIdConnectLoginStrategy.doLogin(mockedRequest, mockedResponse);
+ }
+
+ @Test(expected = PortalAPIException.class)
+ public void getUserIdTest() throws Exception
+ {
+ OpenIdConnectLoginStrategy.getUserId(mockedRequest);
+ }
+
+}
diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SessionTimeoutInterceptorTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SessionTimeoutInterceptorTest.java
new file mode 100644
index 00000000..fc827f78
--- /dev/null
+++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SessionTimeoutInterceptorTest.java
@@ -0,0 +1,55 @@
+package org.openecomp.portalapp.portal.authentication;
+
+import static org.junit.Assert.assertFalse;
+
+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.MockitoAnnotations;
+import org.openecomp.portalapp.authentication.LoginStrategy;
+import org.openecomp.portalapp.authentication.SimpleLoginStrategy;
+import org.openecomp.portalapp.controller.EPFusionBaseController;
+import org.openecomp.portalapp.portal.framework.MockitoTestSuite;
+import org.openecomp.portalapp.portal.interceptor.SessionTimeoutInterceptor;
+import org.springframework.web.method.HandlerMethod;
+
+public class SessionTimeoutInterceptorTest {
+
+
+ @Mock
+ LoginStrategy loginStrategy = new SimpleLoginStrategy();
+
+ @Mock
+ EPFusionBaseController ePFusionBaseController = new EPFusionBaseController() {
+ };
+
+ @Mock
+ HandlerMethod handlerMethod;
+
+ @InjectMocks
+ SessionTimeoutInterceptor sessionTimeoutInterceptor = new SessionTimeoutInterceptor();
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
+
+ HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
+ HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
+
+ @Test
+ public void preHandleTest() throws Exception{
+ assertFalse(sessionTimeoutInterceptor.preHandle(mockedRequest, mockedResponse, ePFusionBaseController));
+ }
+
+ @Test
+ public void preHandleTestIfMethodIsinstanceOfHandlerMethod() throws Exception{
+ assertFalse(sessionTimeoutInterceptor.preHandle(mockedRequest, mockedResponse, handlerMethod));
+ }
+}
diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SimpleLoginStrategyTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SimpleLoginStrategyTest.java
new file mode 100644
index 00000000..5093fae0
--- /dev/null
+++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/authentication/SimpleLoginStrategyTest.java
@@ -0,0 +1,134 @@
+package org.openecomp.portalapp.portal.authentication;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.portalapp.authentication.SimpleLoginStrategy;
+import org.openecomp.portalapp.command.EPLoginBean;
+import org.openecomp.portalapp.portal.domain.EPUser;
+import org.openecomp.portalapp.portal.framework.MockitoTestSuite;
+import org.openecomp.portalapp.portal.service.EPLoginService;
+import org.openecomp.portalapp.portal.service.EPRoleFunctionService;
+import org.openecomp.portalapp.portal.service.EPRoleService;
+import org.openecomp.portalapp.util.EPUserUtils;
+import org.openecomp.portalapp.util.SessionCookieUtil;
+import org.openecomp.portalsdk.core.menu.MenuProperties;
+import org.openecomp.portalsdk.core.onboarding.exception.PortalAPIException;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.springframework.util.StringUtils;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ StringUtils.class, EPUserUtils.class, SessionCookieUtil.class, SystemProperties.class,
+ SessionCookieUtil.class, MenuProperties.class })
+public class SimpleLoginStrategyTest {
+
+ @InjectMocks
+ SimpleLoginStrategy simpleLoginStrategy = new SimpleLoginStrategy();
+
+ @Mock
+ EPLoginService loginService;
+ @Mock
+ EPRoleService roleService;
+ @Mock
+ EPRoleFunctionService ePRoleFunctionService;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
+
+ HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
+ HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
+
+ NullPointerException nullPointerException = new NullPointerException();
+
+ @Test(expected = Exception.class)
+ public void loginTest() throws Exception {
+ PowerMockito.mockStatic(MenuProperties.class);
+ PowerMockito.mockStatic(SessionCookieUtil.class);
+ PowerMockito.mockStatic(StringUtils.class);
+ Mockito.when(SessionCookieUtil.getUserIdFromCookie(mockedRequest, mockedResponse)).thenReturn("guestT");
+ Mockito.when(StringUtils.isEmpty("guestT")).thenReturn(false);
+ EPLoginBean commandBean = new EPLoginBean();
+ EPUser user = new EPUser();
+ commandBean.setUser(user);
+ commandBean.setOrgUserId("guestT");
+ Mockito.when(mockedRequest.getAttribute(MenuProperties.MENU_PROPERTIES_FILENAME_KEY))
+ .thenReturn("menu_properties_filename");
+ Mockito.when(loginService.findUser(commandBean, "menu_properties_filename", null)).thenReturn(commandBean);
+ assertTrue(simpleLoginStrategy.login(mockedRequest, mockedResponse));
+ }
+
+ @Test
+ public void loginIfUserEmptyTest() throws Exception {
+ PowerMockito.mockStatic(MenuProperties.class);
+ PowerMockito.mockStatic(SessionCookieUtil.class);
+ PowerMockito.mockStatic(StringUtils.class);
+ Mockito.when(SessionCookieUtil.getUserIdFromCookie(mockedRequest, mockedResponse)).thenReturn("guestT");
+ Mockito.when(StringUtils.isEmpty("guestT")).thenReturn(true);
+ EPLoginBean commandBean = new EPLoginBean();
+ EPUser user = new EPUser();
+ commandBean.setUser(user);
+ commandBean.setOrgUserId("guestT");
+ assertFalse(simpleLoginStrategy.login(mockedRequest, mockedResponse));
+ }
+
+ @Test
+ public void loginIfAuthIsBothTest() throws Exception {
+ PowerMockito.mockStatic(SystemProperties.class);
+ PowerMockito.mockStatic(SessionCookieUtil.class);
+ PowerMockito.mockStatic(StringUtils.class);
+ Mockito.when(SessionCookieUtil.getUserIdFromCookie(mockedRequest, mockedResponse)).thenReturn("guestT");
+ Mockito.when(StringUtils.isEmpty("guestT")).thenReturn(true);
+ Mockito.when(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM)).thenReturn("BOTH");
+ assertFalse(simpleLoginStrategy.login(mockedRequest, mockedResponse));
+ }
+
+ @Test
+ public void loginIfAuthIsNotNullTest() throws Exception {
+ PowerMockito.mockStatic(SystemProperties.class);
+ PowerMockito.mockStatic(SessionCookieUtil.class);
+ PowerMockito.mockStatic(StringUtils.class);
+ Mockito.when(SessionCookieUtil.getUserIdFromCookie(mockedRequest, mockedResponse)).thenReturn("guestT");
+ Mockito.when(StringUtils.isEmpty("guestT")).thenReturn(true);
+ Mockito.when(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM)).thenReturn("Test");
+ assertFalse(simpleLoginStrategy.login(mockedRequest, mockedResponse));
+ }
+
+ @Test
+ public void loginExceptionTest() throws Exception {
+ PowerMockito.mockStatic(SystemProperties.class);
+ PowerMockito.mockStatic(SessionCookieUtil.class);
+ PowerMockito.mockStatic(StringUtils.class);
+ Mockito.when(SessionCookieUtil.getUserIdFromCookie(mockedRequest, mockedResponse)).thenReturn("guestT");
+ Mockito.when(StringUtils.isEmpty("guestT")).thenReturn(true);
+ Mockito.when(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM))
+ .thenThrow(nullPointerException);
+ assertFalse(simpleLoginStrategy.login(mockedRequest, mockedResponse));
+ }
+
+ @Test(expected = Exception.class)
+ public void doLoginTest() throws Exception {
+ simpleLoginStrategy.doLogin(mockedRequest, mockedResponse);
+ }
+
+ @Test(expected = PortalAPIException.class)
+ public void getUserIdTest() throws Exception {
+ simpleLoginStrategy.getUserId(mockedRequest);
+ }
+}
diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsControllerExternalRequestOSTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsControllerExternalRequestOSTest.java
new file mode 100644
index 00000000..049f7239
--- /dev/null
+++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsControllerExternalRequestOSTest.java
@@ -0,0 +1,119 @@
+/*package org.openecomp.portalapp.portal.controller;
+
+import static org.junit.Assert.assertEquals;
+
+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.openecomp.portalapp.portal.domain.EPUser;
+import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse;
+import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum;
+import org.openecomp.portalapp.portal.service.AdminRolesService;
+import org.openecomp.portalapp.portal.service.EPAppService;
+import org.openecomp.portalapp.portal.service.PortalAdminService;
+import org.openecomp.portalapp.portal.test.core.MockEPUser;
+import org.openecomp.portalapp.portal.transport.FieldsValidator;
+import org.openecomp.portalapp.portal.transport.OnboardingApp;
+import org.openecomp.portalapp.test.framework.MockitoTestSuite;
+import org.openecomp.portalapp.util.EPUserUtils;
+
+public class AppsControllerExternalRequestOSTest {
+
+ @Mock
+ AdminRolesService adminRolesService;
+
+ @Mock
+ EPAppService appService;
+
+ @Mock
+ PortalAdminService portalAdminService;
+
+
+ @InjectMocks
+ AppsControllerExternalRequest appsControllerExternalRequest = new AppsControllerExternalRequest();
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
+
+ HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
+ HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
+ NullPointerException nullPointerException = new NullPointerException();
+
+ MockEPUser mockUser = new MockEPUser();
+ @Mock
+ EPUserUtils ePUserUtils = new EPUserUtils();
+
+ @Test
+ public void postOnboardAppExternalFieldValidatorTestTest() {
+ PortalRestResponse<String> expectedportalRestResponse = new PortalRestResponse<String>();
+ expectedportalRestResponse.setMessage("FieldsValidator [httpStatusCode=500, errorCode=null, fields=null]");
+ expectedportalRestResponse.setResponse(null);
+ PortalRestStatusEnum portalRestStatusEnum = null;
+ expectedportalRestResponse.setStatus(portalRestStatusEnum.ERROR);
+ OnboardingApp expectedOnboardingApp = new OnboardingApp();
+ expectedOnboardingApp.id = null;
+ expectedOnboardingApp.name = "Test";
+ expectedOnboardingApp.url = "Test";
+ expectedOnboardingApp.restUrl = "Test";
+ expectedOnboardingApp.restrictedApp = false;
+ expectedOnboardingApp.isOpen = false;
+ expectedOnboardingApp.isEnabled = false;
+ List<EPUser> userList = new ArrayList<EPUser>();
+ EPUser user = mockUser.mockEPUser();
+ userList.add(user);
+ FieldsValidator expectedFieldValidator = new FieldsValidator();
+ expectedFieldValidator.setHttpStatusCode((long) 500);
+ expectedFieldValidator.setFields(null);
+ expectedFieldValidator.setErrorCode(null);
+ Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(true);
+ Mockito.when(appService.addOnboardingApp(expectedOnboardingApp, user)).thenReturn(expectedFieldValidator);
+ PortalRestResponse<String> actualPortalRestResponse = appsControllerExternalRequest
+ .postOnboardAppExternal(mockedRequest, mockedResponse, expectedOnboardingApp);
+ assertEquals(actualPortalRestResponse, expectedportalRestResponse);
+
+ }
+
+ @Test
+ public void postOnboardAppExternalIfSuperAdminTest() {
+ PortalRestResponse<String> expectedportalRestResponse = new PortalRestResponse<String>();
+ expectedportalRestResponse.setMessage(null);
+ expectedportalRestResponse.setResponse(null);
+ PortalRestStatusEnum portalRestStatusEnum = null;
+ expectedportalRestResponse.setStatus(portalRestStatusEnum.OK);
+ OnboardingApp expectedOnboardingApp = new OnboardingApp();
+ expectedOnboardingApp.id = null;
+ expectedOnboardingApp.name = "Test";
+ expectedOnboardingApp.url = "Test";
+ expectedOnboardingApp.restUrl = "Test";
+ expectedOnboardingApp.restrictedApp = false;
+ expectedOnboardingApp.isOpen = false;
+ expectedOnboardingApp.isEnabled = false;
+ List<EPUser> userList = new ArrayList<EPUser>();
+ EPUser user = mockUser.mockEPUser();
+ userList.add(user);
+ FieldsValidator expectedFieldValidator = new FieldsValidator();
+ expectedFieldValidator.setHttpStatusCode((long) 200);
+ expectedFieldValidator.setFields(null);
+ expectedFieldValidator.setErrorCode(null);
+ Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(true);
+ Mockito.when(appService.addOnboardingApp(expectedOnboardingApp, user)).thenReturn(expectedFieldValidator);
+ PortalRestResponse<String> actualPortalRestResponse = appsControllerExternalRequest
+ .postOnboardAppExternal(mockedRequest, mockedResponse, expectedOnboardingApp);
+ assertEquals(actualPortalRestResponse, expectedportalRestResponse);
+
+ }
+}
+*/ \ No newline at end of file
diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsOSControllerTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsOSControllerTest.java
new file mode 100644
index 00000000..70e7a0ca
--- /dev/null
+++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/AppsOSControllerTest.java
@@ -0,0 +1,150 @@
+package org.openecomp.portalapp.portal.controller;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.drools.core.command.assertion.AssertEquals;
+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.openecomp.portalapp.portal.domain.EPUser;
+import org.openecomp.portalapp.portal.ecomp.model.PortalRestResponse;
+import org.openecomp.portalapp.portal.ecomp.model.PortalRestStatusEnum;
+import org.openecomp.portalapp.portal.service.AdminRolesService;
+import org.openecomp.portalapp.portal.service.EPAppService;
+import org.openecomp.portalapp.portal.service.PersUserAppService;
+import org.openecomp.portalapp.portal.service.UserService;
+import org.openecomp.portalapp.portal.framework.MockEPUser;
+import org.openecomp.portalapp.portal.framework.MockitoTestSuite;
+import org.openecomp.portalapp.util.EPUserUtils;
+
+public class AppsOSControllerTest {
+
+ @Mock
+ AdminRolesService adminRolesService;
+
+ @Mock
+ EPAppService appService;
+
+ @Mock
+ PersUserAppService persUserAppService;
+
+ @Mock
+ UserService userService;
+
+ @Mock
+ EPUserUtils ePUserUtils;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @InjectMocks
+ AppsOSController appsOSController = new AppsOSController();
+
+ MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
+
+ HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
+ HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
+ NullPointerException nullPointerException = new NullPointerException();
+ MockEPUser mockUser = new MockEPUser();
+
+ @Test
+ public void saveNewUserIfUserISNullTest() {
+ PortalRestResponse<String> expectedportalRestResponse = new PortalRestResponse<String>();
+ expectedportalRestResponse.setMessage("failure");
+ expectedportalRestResponse.setResponse("New User cannot be null or empty");
+ PortalRestStatusEnum portalRestStatusEnum = null;
+ expectedportalRestResponse.setStatus(portalRestStatusEnum.ERROR);
+ EPUser user = mockUser.mockEPUser();
+ Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user);
+ PortalRestResponse<String> actualPortalRestResponse = appsOSController.saveNewUser(mockedRequest, null);
+ assertEquals(expectedportalRestResponse, actualPortalRestResponse);
+ }
+
+ @Test
+ public void saveNewUserIfUserNOtNullTest() {
+ PortalRestResponse<String> expectedportalRestResponse = new PortalRestResponse<String>();
+ expectedportalRestResponse.setMessage("failure");
+ expectedportalRestResponse.setResponse("UnAuthorized");
+ PortalRestStatusEnum portalRestStatusEnum = null;
+ expectedportalRestResponse.setStatus(portalRestStatusEnum.ERROR);
+ EPUser user = mockUser.mockEPUser();
+ EPUser user1 = mockUser.mockEPUser();
+ user1.setLoginId("guest");
+ user.setLoginId("guestT");
+ Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user1);
+ Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(false);
+ Mockito.when(adminRolesService.isAccountAdmin(user)).thenReturn(false);
+ PortalRestResponse<String> actualPortalRestResponse = appsOSController.saveNewUser(mockedRequest, user);
+ assertEquals(expectedportalRestResponse, actualPortalRestResponse);
+ }
+
+ @Test
+ public void saveNewUserAndLoggedInUserIdSameTest() throws Exception {
+ PortalRestResponse<String> expectedportalRestResponse = new PortalRestResponse<String>();
+ expectedportalRestResponse.setMessage("Success");
+ expectedportalRestResponse.setResponse("");
+ PortalRestStatusEnum portalRestStatusEnum = null;
+ expectedportalRestResponse.setStatus(portalRestStatusEnum.OK);
+ EPUser user = mockUser.mockEPUser();
+ user.setLoginId("guestT");
+ Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user);
+ Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(false);
+ Mockito.when(adminRolesService.isAccountAdmin(user)).thenReturn(false);
+ Mockito.when(mockedRequest.getParameter("isCheck")).thenReturn("test");
+ Mockito.when(userService.saveNewUser(user, "test")).thenReturn("Success");
+ PortalRestResponse<String> actualPortalRestResponse = appsOSController.saveNewUser(mockedRequest, user);
+ assertEquals(expectedportalRestResponse, actualPortalRestResponse);
+ }
+
+ @Test
+ public void saveNewUserexceptionest() throws Exception {
+ PortalRestResponse<String> expectedportalRestResponse = new PortalRestResponse<String>();
+ expectedportalRestResponse.setMessage("failure");
+ expectedportalRestResponse.setResponse(null);
+ PortalRestStatusEnum portalRestStatusEnum = null;
+ expectedportalRestResponse.setStatus(portalRestStatusEnum.ERROR);
+ EPUser user = mockUser.mockEPUser();
+ user.setLoginId("guestT");
+ Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user);
+ Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(false);
+ Mockito.when(adminRolesService.isAccountAdmin(user)).thenReturn(false);
+ Mockito.when(mockedRequest.getParameter("isCheck")).thenReturn("test");
+ Mockito.when(userService.saveNewUser(user, "test")).thenThrow(nullPointerException);
+ PortalRestResponse<String> actualPortalRestResponse = appsOSController.saveNewUser(mockedRequest, user);
+ assertEquals(expectedportalRestResponse, actualPortalRestResponse);
+ }
+
+ @Test
+ public void getCurrentUserProfileTest() {
+ String loginId = "guestT";
+ EPUser user = mockUser.mockEPUser();
+ List<EPUser> expectedList = new ArrayList<EPUser>();
+ expectedList.add(user);
+ Mockito.when(userService.getUserByUserId(loginId)).thenReturn(expectedList);
+ String expectedString = appsOSController.getCurrentUserProfile(mockedRequest, loginId);
+ assertEquals("{\"firstName\":\"test\",\"lastName\":\"test\"}", expectedString);
+ }
+
+ @Test
+ public void getCurrentUserProfileExceptionTest() {
+ String loginId = "guestT";
+ EPUser user = mockUser.mockEPUser();
+ List<EPUser> expectedList = new ArrayList<EPUser>();
+ expectedList.add(user);
+ Mockito.when(userService.getUserByUserId(loginId)).thenThrow(nullPointerException);
+ String expectedString = appsOSController.getCurrentUserProfile(mockedRequest, loginId);
+ assertEquals("{}", expectedString);
+ }
+
+}
diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ECOMPLogoutControllerTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ECOMPLogoutControllerTest.java
new file mode 100644
index 00000000..729debaa
--- /dev/null
+++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ECOMPLogoutControllerTest.java
@@ -0,0 +1,77 @@
+package org.openecomp.portalapp.portal.controller;
+
+import static org.junit.Assert.*;
+
+import javax.servlet.ServletRequestWrapper;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.mockito.stubbing.OngoingStubbing;
+import org.openecomp.portalapp.controller.ECOMPLogoutController;
+import org.openecomp.portalapp.portal.service.DashboardSearchService;
+import org.openecomp.portalapp.portal.service.DashboardSearchServiceImpl;
+import org.openecomp.portalapp.portal.framework.MockEPUser;
+import org.openecomp.portalapp.portal.utils.EPCommonSystemProperties;
+import org.openecomp.portalapp.portal.framework.MockitoTestSuite;
+import org.openecomp.portalapp.util.EPUserUtils;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.springframework.core.NamedThreadLocal;
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+import org.springframework.web.servlet.ModelAndView;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({EPUserUtils.class, EPCommonSystemProperties.class,RequestContextHolder.class,RequestAttributes.class})
+public class ECOMPLogoutControllerTest {
+
+ @Mock
+ DashboardSearchService searchService = new DashboardSearchServiceImpl();
+
+ @InjectMocks
+ ECOMPLogoutController ecompLogoutController = new ECOMPLogoutController();
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
+
+ HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
+ HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
+
+ NullPointerException nullPointerException = new NullPointerException();
+
+ MockEPUser mockUser = new MockEPUser();
+
+ @Mock
+ RequestContextHolder requestContextHolder;
+
+ @Mock
+ RequestAttributes requestAttributes;
+
+ @Test
+ public void logOutTest() throws Exception{
+ ModelAndView actualData = new ModelAndView("redirect:login.htm");
+ ModelAndView expedtedData = null;
+ ThreadLocal<RequestAttributes> requestAttributesHolder =
+ new NamedThreadLocal<RequestAttributes>("Request attributes");
+ RequestAttributes requestAttributes = new ServletRequestAttributes(mockedRequest);
+ PowerMockito.mockStatic(RequestContextHolder.class);
+ PowerMockito.mockStatic(RequestAttributes.class);
+ Mockito.when((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).thenReturn((ServletRequestAttributes) requestAttributes);
+ expedtedData = ecompLogoutController.logOut(mockedRequest, mockedResponse);
+ assertEquals(actualData.getViewName(),expedtedData.getViewName());
+ }
+
+}
diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/LoginControllerTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/LoginControllerTest.java
new file mode 100644
index 00000000..968f5811
--- /dev/null
+++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/LoginControllerTest.java
@@ -0,0 +1,84 @@
+package org.openecomp.portalapp.portal.controller;
+
+import static org.junit.Assert.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.portalapp.controller.LoginController;
+import org.openecomp.portalapp.portal.framework.MockitoTestSuite;
+import org.openecomp.portalapp.portal.service.EPLoginService;
+import org.openecomp.portalapp.portal.service.EPRoleFunctionService;
+import org.openecomp.portalapp.portal.service.EPRoleService;
+import org.openecomp.portalapp.portal.service.SharedContextService;
+import org.openecomp.portalapp.service.EPProfileService;
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.springframework.web.servlet.ModelAndView;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(SystemProperties.class)
+public class LoginControllerTest {
+
+ @Mock
+ EPProfileService service;
+ @Mock
+ EPLoginService loginService;
+ @Mock
+ SharedContextService sharedContextService;
+ @Mock
+ EPRoleService roleService;
+ @Mock
+ EPRoleFunctionService ePRoleFunctionService;
+
+ @InjectMocks
+ LoginController loginController = new LoginController();
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
+
+ HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
+ HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
+
+ NullPointerException nullPointerException = new NullPointerException();
+
+ @Test
+ public void loginIfAuthNullTest()
+ {
+ PowerMockito.mockStatic(SystemProperties.class);
+ Mockito.when(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM)).thenReturn(null);
+ ModelAndView result = loginController.login(mockedRequest);
+ assertEquals(result.getViewName(),"openIdLogin") ;
+ }
+
+ @Test
+ public void loginIfAuthOIDCTest()
+ {
+ PowerMockito.mockStatic(SystemProperties.class);
+ Mockito.when(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM)).thenReturn("OIDC");
+ ModelAndView result = loginController.login(mockedRequest);
+ assertEquals(result.getViewName(),"openIdLogin") ;
+ }
+
+ @Test
+ public void loginTest()
+ {
+ PowerMockito.mockStatic(SystemProperties.class);
+ Mockito.when(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM)).thenReturn("Test");
+ ModelAndView result = loginController.login(mockedRequest);
+ assertEquals(result.getViewName(),"login") ;
+ }
+}
diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPLoginControllerTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPLoginControllerTest.java
new file mode 100644
index 00000000..06dfc902
--- /dev/null
+++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPLoginControllerTest.java
@@ -0,0 +1,89 @@
+package org.openecomp.portalapp.portal.controller;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+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.openecomp.portalapp.controller.ONAPLoginController;
+import org.openecomp.portalapp.portal.framework.MockEPUser;
+import org.openecomp.portalapp.portal.framework.MockitoTestSuite;
+import org.openecomp.portalsdk.core.auth.LoginStrategy;
+import org.openecomp.portalsdk.core.service.LoginService;
+import org.openecomp.portalsdk.core.service.ProfileService;
+import org.openecomp.portalsdk.core.service.ProfileServiceImpl;
+import org.springframework.web.servlet.ModelAndView;
+
+public class ONAPLoginControllerTest {
+
+ @Mock
+ ProfileService ProfileService = new ProfileServiceImpl();
+
+ @Mock
+ LoginService mockLoginService;
+
+ @Mock
+ LoginStrategy loginStrategy ;
+
+ @InjectMocks
+ ONAPLoginController oNAPLoginController = new ONAPLoginController();
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
+
+ HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
+ HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
+
+ NullPointerException nullPointerException = new NullPointerException();
+
+ MockEPUser mockUser = new MockEPUser();
+
+
+ @Test
+ public void doLogin() throws Exception
+ {
+ ModelAndView expectedModelandView = null;
+ ModelAndView actualModelandView = null;
+ Mockito.when(loginStrategy.doLogin(mockedRequest, mockedResponse)).thenReturn(expectedModelandView);
+ actualModelandView= oNAPLoginController.doLogin(mockedRequest, mockedResponse);
+ assertEquals(actualModelandView,expectedModelandView);
+ }
+
+
+ @Test
+ public void ViewTest() throws Exception
+ {
+ ModelAndView expectedModelandView = new ModelAndView();
+ expectedModelandView.setViewName("testView");
+ ModelAndView actualModelandView = null;
+ Mockito.when(loginStrategy.doLogin(mockedRequest, mockedResponse)).thenReturn(expectedModelandView);
+ actualModelandView= oNAPLoginController.doLogin(mockedRequest, mockedResponse);
+ assertEquals(actualModelandView.getViewName(),expectedModelandView.getViewName());
+ }
+ @Test
+ public void getJessionIdTest() throws Exception
+ {
+ assertNull(oNAPLoginController.getJessionId(mockedRequest));
+ }
+
+ @Test
+ public void getLoginServiceTest() throws Exception
+ {
+ LoginService expectedLoginService = oNAPLoginController.getLoginService();
+ assertEquals(mockLoginService,expectedLoginService);
+ }
+
+
+
+}
diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPWelcomeControllerTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPWelcomeControllerTest.java
new file mode 100644
index 00000000..c15f366a
--- /dev/null
+++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/ONAPWelcomeControllerTest.java
@@ -0,0 +1,47 @@
+package org.openecomp.portalapp.portal.controller;
+
+import static org.junit.Assert.*;
+
+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.MockitoAnnotations;
+import org.openecomp.portalapp.controller.ONAPWelcomeController;
+import org.openecomp.portalapp.portal.framework.MockitoTestSuite;
+
+public class ONAPWelcomeControllerTest {
+
+ @InjectMocks
+ ONAPWelcomeController oNAPWelcomeController = new ONAPWelcomeController();
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+ MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
+ HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
+ HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
+ NullPointerException nullPointerException = new NullPointerException();
+
+ @Test
+ public void getIndexPageTest()
+ {
+ assertEquals(oNAPWelcomeController.getIndexPage(mockedRequest), "/index");
+ }
+
+ @Test
+ public void getEcompSinglePageTest()
+ {
+ assertEquals(oNAPWelcomeController.getEcompSinglePage(mockedRequest, mockedResponse), "forward:/index.html");
+ }
+
+ @Test
+ public void userTest()
+ {
+ assertEquals(oNAPWelcomeController.user(null), "oid-user");
+ }
+
+}
diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/PortalAdminControllerOSTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/PortalAdminControllerOSTest.java
new file mode 100644
index 00000000..65925977
--- /dev/null
+++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/controller/PortalAdminControllerOSTest.java
@@ -0,0 +1,142 @@
+/*package org.openecomp.portalapp.portal.controller;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+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.openecomp.portalapp.portal.domain.EPRole;
+import org.openecomp.portalapp.portal.domain.EPUser;
+import org.openecomp.portalapp.portal.service.AdminRolesService;
+import org.openecomp.portalapp.portal.service.AdminRolesServiceImpl;
+import org.openecomp.portalapp.portal.service.PortalAdminService;
+import org.openecomp.portalapp.portal.service.PortalAdminServiceImpl;
+import org.openecomp.portalapp.portal.test.core.MockEPUser;
+import org.openecomp.portalapp.portal.transport.FieldsValidator;
+import org.openecomp.portalapp.portal.utils.EcompPortalUtils;
+import org.openecomp.portalapp.test.framework.MockitoTestSuite;
+import org.openecomp.portalapp.util.EPUserUtils;
+import org.openecomp.portalsdk.core.service.AuditService;
+import org.openecomp.portalsdk.core.service.AuditServiceImpl;
+
+public class PortalAdminControllerOSTest {
+
+ @InjectMocks
+ PortalAdminController portalAdminController = new PortalAdminController();
+
+ @Mock
+ AdminRolesService adminRolesService = new AdminRolesServiceImpl();
+
+ @Mock
+ PortalAdminService portalAdminService = new PortalAdminServiceImpl();
+
+ @Mock
+ AuditService auditService = new AuditServiceImpl();
+
+
+ @Mock
+ EcompPortalUtils ecompPortalUtils = new EcompPortalUtils();
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
+
+ HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
+ HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
+ NullPointerException nullPointerException = new NullPointerException();
+
+ @Mock
+ EPUserUtils ePUserUtils = new EPUserUtils();
+
+ MockEPUser mockUser = new MockEPUser();
+
+ @Test
+ public void deletePortalAdminIfUserIsSuperAdminTest()
+ {
+ EPUser user = mockUser.mockEPUser();
+ Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user);
+ Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(false);
+ String userInfo = "1-test";
+ assertNull(portalAdminController.deletePortalAdmin(mockedRequest, userInfo, mockedResponse));
+
+ }
+
+ @Test
+ public void deletePortalAdminTest()
+ {
+ EPUser user = mockUser.mockEPUser();
+ Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user);
+
+ FieldsValidator expectedFieldValidator = new FieldsValidator();
+ expectedFieldValidator.setHttpStatusCode((long) 200);
+ expectedFieldValidator.setFields(null);
+ expectedFieldValidator.setErrorCode(null);
+ FieldsValidator actualFieldValidator = new FieldsValidator();
+ String userInfo = "1-test";
+ Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(true);
+ Mockito.when(portalAdminService.deletePortalAdmin((long) 1)).thenReturn(expectedFieldValidator);
+ actualFieldValidator = portalAdminController.deletePortalAdmin(mockedRequest, userInfo, mockedResponse);
+ assertEquals(actualFieldValidator,expectedFieldValidator);
+
+ }
+
+ @Test
+ public void deletePortalAdminWithNoUserInfoTest()
+ {
+ EPUser user = mockUser.mockEPUser();
+ Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user);
+ Mockito.when(adminRolesService.isSuperAdmin(user)).thenReturn(false);
+ String userInfo = "";
+ assertNull(portalAdminController.deletePortalAdmin(mockedRequest, userInfo, mockedResponse));
+ }
+
+ @Test
+ public void getRolesByAppExceptionTest()
+ {
+ EPUser user = mockUser.mockEPUser();;
+ Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user);
+ List<EPRole> expectedRoleList = new ArrayList<EPRole>();
+ EPRole ePRole = new EPRole();
+ expectedRoleList.add(ePRole);
+ Long appId = (long) 1;
+ Mockito.when(adminRolesService.getRolesByApp(user, appId)).thenThrow(nullPointerException);
+ assertNull(portalAdminController.getRolesByApp(mockedRequest, appId, mockedResponse));
+ }
+
+ @Test
+ public void getRolesByAppIfUserNullTest()
+ {
+ EPUser user = null;
+ Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user);
+ Long appId = (long) 1;
+ assertNull(portalAdminController.getRolesByApp(mockedRequest, appId, mockedResponse));
+ }
+
+ @Test
+ public void getRolesByAppTest()
+ {
+ EPUser user = mockUser.mockEPUser();
+ Mockito.when(EPUserUtils.getUserSession(mockedRequest)).thenReturn(user);
+ List<EPRole> expectedRoleList = new ArrayList<EPRole>();
+ EPRole ePRole = new EPRole();
+ expectedRoleList.add(ePRole);
+ Long appId = (long) 1;
+ Mockito.when(adminRolesService.getRolesByApp(user, appId)).thenReturn(expectedRoleList);
+ List<EPRole> actualRoleList = portalAdminController.getRolesByApp(mockedRequest, appId, mockedResponse);
+ assertEquals(actualRoleList,expectedRoleList);
+ }
+}
+*/ \ No newline at end of file
diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockEPUser.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockEPUser.java
new file mode 100644
index 00000000..d132ccf3
--- /dev/null
+++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockEPUser.java
@@ -0,0 +1,84 @@
+/*-
+ * ================================================================================
+ * ECOMP Portal
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalapp.portal.framework;
+
+import java.util.Date;
+
+import org.openecomp.portalapp.portal.domain.EPUser;
+
+public class MockEPUser {
+
+ public EPUser mockEPUser() {
+
+ EPUser ePUser = new EPUser();
+ ePUser.setOrgId(null);
+ ePUser.setManagerId(null);
+ ePUser.setFirstName("test");
+ ePUser.setLastName("test");
+ ePUser.setMiddleInitial(null);
+ ePUser.setPhone(null);
+ ePUser.setFax(null);
+ ePUser.setCellular(null);
+ ePUser.setEmail(null);
+ ePUser.setAddressId(null);
+ ePUser.setAlertMethodCd(null);
+ ePUser.setHrid(null);
+ ePUser.setOrgUserId("guestT");
+ ePUser.setOrgCode(null);
+ ePUser.setAddress1(null);
+ ePUser.setAddress2(null);
+ ePUser.setCity(null);
+ ePUser.setState(null);
+ ePUser.setZipCode(null);
+ ePUser.setCountry(null);
+ ePUser.setOrgManagerUserId(null);
+ ePUser.setLocationClli(null);
+ ePUser.setBusinessCountryCode(null);
+ ePUser.setBusinessCountryName(null);
+ ePUser.setBusinessUnit(null);
+ ePUser.setBusinessUnitName(null);
+ ePUser.setDepartment(null);
+ ePUser.setDepartmentName(null);
+ ePUser.setCompanyCode(null);
+ ePUser.setCompany(null);
+ ePUser.setZipCodeSuffix(null);
+ ePUser.setJobTitle(null);
+ ePUser.setCommandChain(null);
+ ePUser.setSiloStatus(null);
+ ePUser.setCostCenter(null);
+ ePUser.setFinancialLocCode(null);
+
+ ePUser.setLoginId(null);
+ ePUser.setLoginPwd(null);
+ Date date = new Date();
+ ePUser.setLastLoginDate(date);
+ ePUser.setActive(true);
+ ePUser.setInternal(false);
+ ePUser.setSelectedProfileId(null);
+ ePUser.setTimeZoneId(null);
+ ePUser.setOnline(true);
+ ePUser.setChatId(null);
+ ePUser.setUserApps(null);
+ ePUser.setPseudoRoles(null);
+
+ ePUser.setId((long) -1);
+ return ePUser;
+ }
+}
diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockTestSuite.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockTestSuite.java
deleted file mode 100644
index 492079f8..00000000
--- a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockTestSuite.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.openecomp.portalapp.portal.framework;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-import org.openecomp.portalapp.portal.test.controller.AppCatalogControllerTest;
-import org.openecomp.portalapp.portal.test.controller.AppContactUsControllerTest;
-import org.openecomp.portalapp.portal.test.controller.AppsControllerExternalRequestTest;
-import org.openecomp.portalapp.portal.test.controller.AppsControllerTest;
-import org.openecomp.portalapp.portal.test.controller.BEPropertyReaderControllerTest;
-import org.openecomp.portalapp.portal.test.controller.BasicAuthAccountControllerTest;
-import org.openecomp.portalapp.portal.test.controller.CommonWidgetControllerTest;
-import org.openecomp.portalapp.portal.test.controller.ConsulClientControllerTest;
-import org.openecomp.portalapp.portal.test.controller.DashboardSearchResultControllerTest;
-import org.openecomp.portalapp.portal.test.controller.ExternalAppsRestfulControllerTest;
-import org.openecomp.portalapp.portal.test.controller.FunctionalMenuControllerTest;
-import org.openecomp.portalapp.portal.test.controller.GetAccessControllerTest;
-import org.openecomp.portalapp.portal.test.controller.ManifestControllerTest;
-import org.openecomp.portalapp.portal.test.controller.MicroserviceControllerTest;
-import org.openecomp.portalapp.portal.test.controller.MicroserviceProxyControllerTest;
-import org.openecomp.portalapp.portal.test.controller.PortalAdminControllerTest;
-import org.openecomp.portalapp.portal.test.controller.RolesApprovalSystemControllerTest;
-import org.openecomp.portalapp.portal.test.controller.TicketEventControllerTest;
-import org.openecomp.portalapp.portal.test.controller.UserControllerTest;
-import org.openecomp.portalapp.portal.test.controller.UserNotificationControllerTest;
-import org.openecomp.portalapp.portal.test.controller.UserRolesControllerTest;
-import org.openecomp.portalapp.portal.test.controller.WebAnalyticsExtAppControllerTest;
-import org.openecomp.portalapp.portal.test.controller.WidgetsCatalogMarkupControllerTest;
-
-
-
-/**
- *
- *
- * Create the Test class in ecmop-portal-BE-common-test and extend from MockitoTestSuite
- * Add the class in Suite to test it
- *
- */
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
-UserRolesControllerTest.class,
-FunctionalMenuControllerTest.class,
-AppCatalogControllerTest.class,
-AppContactUsControllerTest.class,
-UserNotificationControllerTest.class,
-TicketEventControllerTest.class,
-CommonWidgetControllerTest.class,
-ConsulClientControllerTest.class,
-GetAccessControllerTest.class,
-AppsControllerTest.class,
-BasicAuthAccountControllerTest.class,
-DashboardSearchResultControllerTest.class,
-//PortalAdminControllerTest.class,
-ManifestControllerTest.class,
-BEPropertyReaderControllerTest.class,
-WebAnalyticsExtAppControllerTest.class,
-AppsControllerExternalRequestTest.class,
-WidgetsCatalogMarkupControllerTest.class,
-RolesApprovalSystemControllerTest.class,
-MicroserviceProxyControllerTest.class,
-MicroserviceControllerTest.class,
-ExternalAppsRestfulControllerTest.class,
-UserControllerTest.class
-})
-public class MockTestSuite {
-
-}
-
diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockitoTestSuite.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockitoTestSuite.java
new file mode 100644
index 00000000..3ff837dc
--- /dev/null
+++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/framework/MockitoTestSuite.java
@@ -0,0 +1,75 @@
+/*-
+ * ================================================================================
+ * ECOMP Portal
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+package org.openecomp.portalapp.portal.framework;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+public class MockitoTestSuite {
+
+
+ public MockHttpServletRequestWrapper mockedRequest = new MockHttpServletRequestWrapper(
+ Mockito.mock(HttpServletRequest.class));
+ public HttpServletResponse mockedResponse = Mockito.mock(HttpServletResponse.class);
+
+ public MockHttpServletRequestWrapper getMockedRequest() {
+ return mockedRequest;
+ }
+
+ public HttpServletResponse getMockedResponse() {
+ return mockedResponse;
+ }
+
+ public class MockHttpServletRequestWrapper extends HttpServletRequestWrapper {
+
+ HttpSession session = Mockito.mock(HttpSession.class);
+
+ public MockHttpServletRequestWrapper(HttpServletRequest request) {
+ super(request);
+
+ }
+
+ @Override
+ public HttpSession getSession() {
+
+ return session;
+ }
+
+ @Override
+ public HttpSession getSession(boolean create) {
+
+ return session;
+ }
+
+ }
+ @Test
+ public void test()
+ {
+ assert(true);
+ }
+}
diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/RemoteWebServiceCallServiceImplTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/RemoteWebServiceCallServiceImplTest.java
new file mode 100644
index 00000000..d38525b3
--- /dev/null
+++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/RemoteWebServiceCallServiceImplTest.java
@@ -0,0 +1,148 @@
+package org.openecomp.portalapp.portal.service;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.openecomp.portalsdk.core.util.SystemProperties;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.portalapp.portal.domain.EPApp;
+import org.openecomp.portalapp.portal.framework.MockitoTestSuite;
+import org.openecomp.portalapp.portal.utils.EcompPortalUtils;
+import org.openecomp.portalapp.service.RemoteWebServiceCallServiceImpl;
+import org.openecomp.portalsdk.core.onboarding.util.CipherUtil;
+import org.openecomp.portalsdk.core.service.DataAccessService;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ CipherUtil.class , SystemProperties.class})
+public class RemoteWebServiceCallServiceImplTest {
+
+
+ @InjectMocks
+ RemoteWebServiceCallServiceImpl remoteWebServiceCallServiceImpl = new RemoteWebServiceCallServiceImpl();
+
+ @Mock
+ AppsCacheService appCacheService;
+
+ @Mock
+ DataAccessService dataAccessService;
+
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
+
+ HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
+ HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
+
+ NullPointerException nullPointerException = new NullPointerException();
+
+ @Test
+ public void verifyRESTCredentialTest() throws Exception
+ {
+ PowerMockito.mockStatic(CipherUtil.class);
+ PowerMockito.mockStatic(SystemProperties.class);
+ String criteria= " where ueb_key = 'requestUebKey'";
+ List<EPApp> appList = new ArrayList<>();
+ EPApp app = new EPApp();
+ app.setAppPassword("password");
+ appList.add(app);
+ Mockito.when(dataAccessService.getList(EPApp.class, criteria.toString(), null, null)).thenReturn(appList);
+ String secretKey = null;
+ Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(secretKey);
+ Mockito.when(CipherUtil.decrypt("password",
+ secretKey == null ? null : secretKey)).thenReturn("pwd");
+ assertFalse(remoteWebServiceCallServiceImpl.verifyRESTCredential(secretKey,"requestUebKey","requestAppName","requestPassword"));
+ }
+
+ @Test
+ public void verifyRESTCredentialExceptionTest() throws Exception
+ {
+ PowerMockito.mockStatic(CipherUtil.class);
+ PowerMockito.mockStatic(SystemProperties.class);
+ String criteria= " where ueb_key = 'requestUebKey'";
+ List<EPApp> appList = new ArrayList<>();
+ EPApp app = new EPApp();
+ app.setAppPassword("password");
+ app.setUsername("requestAppName");
+ appList.add(app);
+ Mockito.when(dataAccessService.getList(EPApp.class, criteria.toString(), null, null)).thenReturn(appList);
+ String secretKey = null;
+ Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(secretKey);
+ Mockito.when(CipherUtil.decrypt("password",
+ secretKey == null ? null : secretKey)).thenReturn("pwd");
+ assertTrue(remoteWebServiceCallServiceImpl.verifyRESTCredential(secretKey,"requestUebKey","requestAppName","pwd"));
+ }
+
+ @Test
+ public void verifyRESTCredentialIfAppNullTest() throws Exception
+ {
+ PowerMockito.mockStatic(CipherUtil.class);
+ PowerMockito.mockStatic(SystemProperties.class);
+ String criteria= " where ueb_key = 'requestUebKey'";
+ List<EPApp> appList = new ArrayList<>();
+ EPApp app = new EPApp();
+ app.setAppPassword("password");
+ app.setUsername("requestAppName");
+ appList.add(app);
+ Mockito.when(dataAccessService.getList(EPApp.class, criteria.toString(), null, null)).thenReturn(null);
+ String secretKey = null;
+ Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(secretKey);
+ Mockito.when(CipherUtil.decrypt("password",
+ secretKey == null ? null : secretKey)).thenReturn("pwd");
+ assertFalse(remoteWebServiceCallServiceImpl.verifyRESTCredential(secretKey,"requestUebKey","requestAppName","pwd"));
+ }
+
+ @Test
+ public void verifyAppKeyCredentialIfKeyIsNullTest() throws Exception
+ {
+ assertFalse(remoteWebServiceCallServiceImpl.verifyAppKeyCredential(null));
+ }
+
+ @Test
+ public void verifyAppKeyCredentialTest() throws Exception
+ {
+ PowerMockito.mockStatic(CipherUtil.class);
+ PowerMockito.mockStatic(SystemProperties.class);
+ StringBuffer criteria = new StringBuffer("where ueb_key = 'requestUebKey'");
+// String criteria= " where ueb_key = 'requestUebKey'";
+ List<EPApp> appList = new ArrayList<>();
+ EPApp app = new EPApp();
+ app.setAppPassword("password");
+ app.setUsername("requestAppName");
+ appList.add(app);
+ Mockito.when(dataAccessService.getList(EPApp.class, criteria.toString(), null, null)).thenReturn(null);
+ assertFalse(remoteWebServiceCallServiceImpl.verifyAppKeyCredential("test"));
+ }
+
+ @Test
+ public void verifyAppKeyCredentialSuccessTest() throws Exception
+ {
+ PowerMockito.mockStatic(CipherUtil.class);
+ PowerMockito.mockStatic(SystemProperties.class);
+ String criteria= " where ueb_key = 'test'";
+ List<EPApp> appList = new ArrayList<>();
+ EPApp app = new EPApp();
+ app.setAppPassword("password");
+ app.setUsername("requestAppName");
+ appList.add(app);
+ Mockito.when(dataAccessService.getList(EPApp.class, criteria.toString(), null, null)).thenReturn(appList);
+ assertTrue(remoteWebServiceCallServiceImpl.verifyAppKeyCredential("test"));
+ }
+}
diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/SearchServiceImplTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/SearchServiceImplTest.java
new file mode 100644
index 00000000..fd6578f8
--- /dev/null
+++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/SearchServiceImplTest.java
@@ -0,0 +1,189 @@
+package org.openecomp.portalapp.portal.service;
+
+import static org.junit.Assert.*;
+
+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.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.portalapp.portal.domain.EPUser;
+import org.openecomp.portalapp.portal.framework.MockEPUser;
+import org.openecomp.portalapp.portal.framework.MockitoTestSuite;
+import org.openecomp.portalapp.portal.transport.UserWithNameSurnameTitle;
+import org.openecomp.portalapp.portal.utils.EcompPortalUtils;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ EcompPortalUtils.class})
+public class SearchServiceImplTest {
+
+ @InjectMocks
+ SearchServiceImpl searchServiceImpl = new SearchServiceImpl();
+
+ @Mock
+ UserService userService;
+
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
+
+ HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
+ HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
+
+ NullPointerException nullPointerException = new NullPointerException();
+ MockEPUser mockUser = new MockEPUser();
+
+ @Test
+ public void searchUsersInPhoneBookTest()
+ {
+ PowerMockito.mockStatic(EcompPortalUtils.class);
+ List<String> list = new ArrayList<>();
+ String str = "Test";
+ list.add(str);
+ Mockito.when(EcompPortalUtils.parsingByRegularExpression("Test", " ")).thenReturn(list);
+ assertEquals(searchServiceImpl.searchUsersInPhoneBook("Test"), "[]");
+ }
+
+ @Test
+ public void searchUsersInFnTableToFindUserIdTest()
+ {
+ PowerMockito.mockStatic(EcompPortalUtils.class);
+ List<String> list = new ArrayList<>();
+ String str = "Test";
+ String str2 = "Test new";
+ String str1 = "Test new1";
+ list.add(str);
+ list.add(str1);
+ list.add(str2);
+ Mockito.when(EcompPortalUtils.parsingByRegularExpression("Test", " ")).thenReturn(list);
+ List<EPUser> userList = new ArrayList();
+ EPUser user = mockUser.mockEPUser();
+ user.setLastName("Test new");
+ userList.add(user);
+ Mockito.when( this.userService.getUserByFirstLastName("Test","Test new")).thenReturn(userList);
+ String result = searchServiceImpl.searchUsersInPhoneBook("Test");
+ assertEquals("[{\"orgUserId\":\"guestT\",\"firstName\":\"test\",\"lastName\":\"Test new\",\"jobTitle\":null}]" , result);
+ }
+
+
+
+ @Test
+ public void searchUsersInFnTableFirstNameTest()
+ {
+ PowerMockito.mockStatic(EcompPortalUtils.class);
+ List<String> list = new ArrayList<>();
+ String str = "TestTT";
+ String str2 = "Test new1";
+ String str1 = "Test new";
+ String str3 = "Test new2";
+ list.add(str);
+ list.add(str1);
+ list.add(str2);
+ list.add(str3);
+ Mockito.when(EcompPortalUtils.parsingByRegularExpression("TestTT", " ")).thenReturn(list);
+ List<EPUser> userList = new ArrayList();
+ EPUser user = mockUser.mockEPUser();
+ user.setLastName("Test new");
+ user.setFirstName(null);
+ userList.add(user);
+ Mockito.when( this.userService.getUserByFirstLastName("TestTT","Test new")).thenReturn(userList);
+ assertEquals(searchServiceImpl.searchUsersInPhoneBook("TestTT"), "[]"); }
+
+
+ @Test
+ public void searchUsersInFnTableLastNameTest()
+ {
+ PowerMockito.mockStatic(EcompPortalUtils.class);
+ List<String> list = new ArrayList<>();
+ String str = "Test";
+ String str2 = "Test new";
+ String str1 = "Test new1";
+ list.add(str);
+ list.add(str1);
+ list.add(str2);
+ Mockito.when(EcompPortalUtils.parsingByRegularExpression("Test", " ")).thenReturn(list);
+ List<EPUser> userList = new ArrayList();
+ EPUser user = mockUser.mockEPUser();
+ user.setLastName(null);
+ userList.add(user);
+ Mockito.when( this.userService.getUserByFirstLastName("Test","Test new")).thenReturn(userList);
+ assertEquals(searchServiceImpl.searchUsersInPhoneBook("Test"), "[]"); }
+
+
+
+ @Test
+ public void searchUserByUserIdTest()
+ {
+ List<EPUser> userList = new ArrayList();
+ EPUser user = mockUser.mockEPUser();
+ user.setLastName("Test new");
+ userList.add(user);
+ List<EPUser> foundUsers = new ArrayList<EPUser>();
+ Mockito.when(this.userService.getUserByUserId("guestT")).thenReturn(userList);
+
+ EPUser expectedUser = searchServiceImpl.searchUserByUserId("guestT");
+ assertEquals(user, expectedUser);
+ }
+
+ @Test
+ public void searchUserByUserIdExceptionTest()
+ {
+ Mockito.when(this.userService.getUserByUserId("guestT")).thenThrow(nullPointerException);
+ assertNull(searchServiceImpl.searchUserByUserId("guestT"));
+
+ }
+
+ @Test
+ public void searchUsersByUserIdTest()
+ {
+
+ List<EPUser> userList = new ArrayList();
+ EPUser user = mockUser.mockEPUser();
+ user.setLastName("Test new");
+ userList.add(user);
+ Mockito.when(this.userService.getUserByUserId("guestT")).thenReturn(userList);
+ List<UserWithNameSurnameTitle> foundUsers = searchServiceImpl.searchUsersByUserId(user);
+ assertEquals(foundUsers.size(), 1);
+
+ }
+
+ @Test
+ public void searchUsersByUserIdExceptionTest()
+ {
+ EPUser user = mockUser.mockEPUser();
+ user.setLastName("Test new");
+ Mockito.when(this.userService.getUserByUserId("guestT")).thenThrow(nullPointerException);
+ List<UserWithNameSurnameTitle> foundUsers = searchServiceImpl.searchUsersByUserId(user);
+ assertEquals(foundUsers.size(), 0);
+
+ }
+
+ @Test
+ public void searchUsersByNameExceptionTest()
+ {
+ EPUser user = mockUser.mockEPUser();
+ user.setLastName("test");
+ user.setFirstName("test");
+
+ Mockito.when(this.userService.getUserByFirstLastName("test","test")).thenThrow(nullPointerException);
+ List<UserWithNameSurnameTitle> foundUsers = searchServiceImpl.searchUsersByName(user);
+ assertEquals(foundUsers.size(), 0);
+
+ }
+}
diff --git a/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/UserServiceImplTest.java b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/UserServiceImplTest.java
new file mode 100644
index 00000000..63a710eb
--- /dev/null
+++ b/ecomp-portal-BE-os/src/test/java/org/openecomp/portalapp/portal/service/UserServiceImplTest.java
@@ -0,0 +1,63 @@
+//package org.openecomp.portalapp.portal.service;
+//
+//import javax.servlet.http.HttpServletRequest;
+//import javax.servlet.http.HttpServletResponse;
+//
+//import org.junit.Before;
+//import org.junit.Test;
+//import org.junit.runner.RunWith;
+//import org.mockito.InjectMocks;
+//import org.mockito.Mock;
+//import org.mockito.Mockito;
+//import org.mockito.MockitoAnnotations;
+//import org.openecomp.portalapp.portal.framework.MockitoTestSuite;
+//import org.openecomp.portalapp.portal.utils.EPSystemProperties;
+//import org.openecomp.portalsdk.core.service.DataAccessService;
+//import org.openecomp.portalsdk.core.util.SystemProperties;
+//import org.powermock.api.mockito.PowerMockito;
+//
+//import java.io.BufferedReader;
+//import java.io.IOException;
+//import java.io.InputStreamReader;
+//import java.io.UnsupportedEncodingException;
+//import java.net.HttpURLConnection;
+//import org.powermock.core.classloader.annotations.PrepareForTest;
+//import org.powermock.modules.junit4.PowerMockRunner;
+//
+//
+//@RunWith(PowerMockRunner.class)
+//@PrepareForTest({ SystemProperties.class , EPSystemProperties.class , SystemProperties.class})
+//public class UserServiceImplTest {
+//
+//
+// @InjectMocks
+// UserServiceImpl userServiceImpl = new UserServiceImpl();
+//
+// @Mock
+// DataAccessService dataAccessService;
+//
+// @Mock
+// HttpURLConnection con;
+//
+// @Before
+// public void setup() {
+// MockitoAnnotations.initMocks(this);
+// }
+//
+// MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
+//
+// HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
+// HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
+//
+// @Test
+// public void getUserByUserIdTest() throws UnsupportedEncodingException, IOException
+// {
+// BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"));
+// PowerMockito.mockStatic(SystemProperties.class);
+// PowerMockito.mockStatic(EPSystemProperties.class);
+// Mockito.when(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM)).thenReturn("OIDC");
+// Mockito.when(EPSystemProperties.getProperty(EPSystemProperties.AUTH_USER_SERVER)).thenReturn("http://www.google.com");
+// Mockito.when(new BufferedReader(new InputStreamReader(con.getInputStream(), "UTF-8"))).thenReturn(reader).thenReturn(reader);
+// userServiceImpl.getUserByUserId("guestT");
+// }
+//}