From 179ff1eb0c1ac9eef4d152c47df5cb12a4584c0f Mon Sep 17 00:00:00 2001 From: "Kotta, Shireesha (sk434m)" Date: Fri, 28 Jun 2019 15:27:29 -0400 Subject: PENTEST:Do not display stack trace for the api's Issue-ID: PORTAL-654 PENTEST:Do not display stack trace for the api's and all users info for get_user api Change-Id: I68a4e3c7eba2628363275d63535290034591aa07 Signed-off-by: Kotta, Shireesha (sk434m) --- .../core/ProfileSearchControllerTest.java | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller') diff --git a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/ProfileSearchControllerTest.java b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/ProfileSearchControllerTest.java index c9bdc896..cc672156 100644 --- a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/ProfileSearchControllerTest.java +++ b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/ProfileSearchControllerTest.java @@ -55,7 +55,9 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.onap.portalapp.framework.MockitoTestSuite; +import org.onap.portalsdk.core.auth.LoginStrategy; import org.onap.portalsdk.core.domain.User; +import org.onap.portalsdk.core.onboarding.exception.PortalAPIException; import org.onap.portalsdk.core.restful.client.SharedContextRestClient; import org.onap.portalsdk.core.service.RoleService; import org.onap.portalsdk.core.service.UserProfileService; @@ -79,6 +81,9 @@ public class ProfileSearchControllerTest { @Mock private SharedContextRestClient sharedContextRestClient; + + @Mock + LoginStrategy loginStrategy; @Before public void setup() { @@ -115,18 +120,27 @@ public class ProfileSearchControllerTest { } @Test - public void getUserTest() throws IOException{ - List profileList = null; + public void getUserTest() throws IOException, PortalAPIException{ + List profileList = new ArrayList<>(); + User user = new User(); + user.setOrgUserId("test"); StringWriter sw = new StringWriter(); PrintWriter writer = new PrintWriter(sw); + Mockito.when(loginStrategy.getUserId(mockedRequest)).thenReturn("test"); Mockito.when(mockedResponse.getWriter()).thenReturn(writer); Mockito.when(service.findAll()).thenReturn(profileList); profileSearchController.getUser(mockedRequest, mockedResponse); } @Test - public void getUserExceptionTest(){ + public void getUserExceptionTest() throws IOException, PortalAPIException{ List profileList = null; + User user = new User(); + user.setOrgUserId("test"); + StringWriter sw = new StringWriter(); + PrintWriter writer = new PrintWriter(sw); + Mockito.when(loginStrategy.getUserId(mockedRequest)).thenReturn("test"); + Mockito.when(mockedResponse.getWriter()).thenReturn(writer); Mockito.when(service.findAll()).thenReturn(profileList); profileSearchController.getUser(mockedRequest, mockedResponse); } @@ -167,4 +181,4 @@ public class ProfileSearchControllerTest { public void toggleProfileActiveExceptionTest() throws IOException{ profileSearchController.toggleProfileActive(mockedRequest, mockedResponse); } -} +} \ No newline at end of file -- cgit 1.2.3-korg