diff options
Diffstat (limited to 'ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller')
-rw-r--r-- | ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/SingleSignOnControllerTest.java | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/SingleSignOnControllerTest.java b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/SingleSignOnControllerTest.java index 75b31c97..f3c72c6b 100644 --- a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/SingleSignOnControllerTest.java +++ b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/SingleSignOnControllerTest.java @@ -71,6 +71,7 @@ import org.onap.portalsdk.core.web.support.UserUtils; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import org.springframework.web.client.RestTemplate; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.util.WebUtils; @@ -93,6 +94,9 @@ public class SingleSignOnControllerTest { @Mock URLDecoder uRLDecoder; + + @Mock + RestTemplate restTemplate; @Before public void setup() { @@ -133,6 +137,9 @@ public class SingleSignOnControllerTest { Mockito.when(PortalApiProperties.getProperty(PortalApiConstants.UEB_APP_KEY)).thenReturn("uebkey"); Mockito.when(PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REDIRECT_URL)) .thenReturn("http://test.com/roles"); + + + ModelAndView expectedResults = singleSignOnController.singleSignOnLogin(mockedRequest); assertEquals(expectedResults.getViewName(), "redirect:http://test.com/process_csp?uebAppKey=uebkey&redirectUrl=http%3A%2F%2FTestUrl%2FTest"); @@ -164,12 +171,15 @@ public class SingleSignOnControllerTest { PowerMockito.mockStatic(URLDecoder.class); PowerMockito.mockStatic(SystemProperties.class); PowerMockito.mockStatic(WebUtils.class); + PowerMockito.mockStatic(PortalApiProperties.class); Mockito.when(URLDecoder.decode(null, "UTF-8")).thenReturn("http://Test.com"); Mockito.when(mockedRequest.getParameter("redirectToPortal")).thenReturn(null); Mockito.when(SystemProperties.containsProperty(SystemProperties.APP_BASE_URL)).thenReturn(true); Mockito.when(SystemProperties.getProperty(SystemProperties.APP_BASE_URL)).thenReturn("http://TestUrl"); Mockito.when(SystemProperties.getProperty(SystemProperties.COOKIE_DOMAIN)).thenReturn("Test.com"); - Mockito.when(WebUtils.getCookie(mockedRequest, "EPService")).thenReturn(new Cookie("test", "test")); + Mockito.when(WebUtils.getCookie(mockedRequest, "EPService")).thenReturn(new Cookie("test", "{\"test\":\"test\"}")); + Mockito.when(PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REST_URL)).thenReturn("http://TestUrl"); + Mockito.when(restTemplate.postForObject(Mockito.anyString(),Mockito.any(),Matchers.any(Class.class))).thenReturn(true); User user = new User(); user.setOrgUserId("test12"); Mockito.when(UserUtils.getUserSession(mockedRequest)).thenReturn(user); @@ -185,14 +195,19 @@ public class SingleSignOnControllerTest { Mockito.when(mockedRequest.getParameter("forwardURL")).thenReturn("http://Test.com"); PowerMockito.mockStatic(URLDecoder.class); PowerMockito.mockStatic(WebUtils.class); + PowerMockito.mockStatic(PortalApiProperties.class); PowerMockito.mockStatic(SystemProperties.class); Mockito.when(URLDecoder.decode(null, "UTF-8")).thenReturn("http://Test.com"); - Mockito.when(WebUtils.getCookie(mockedRequest, "EPService")).thenReturn(new Cookie("test", "test")); + Mockito.when(WebUtils.getCookie(mockedRequest, "EPService")).thenReturn(new Cookie("test", "{\"test\":\"test\"}")); + Mockito.when(PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REST_URL)).thenReturn("http://TestUrl"); + Mockito.when(restTemplate.postForObject(Mockito.anyString(),Mockito.any(),Matchers.any(Class.class))).thenReturn(true); Mockito.when(UserUtils.getUserSession(mockedRequest)).thenReturn(user); Mockito.when(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM)).thenReturn("testauth"); Mockito.when(loginStrategy.getUserId(mockedRequest)).thenReturn("test1234"); Mockito.when(mockedRequest.getAttribute(MenuProperties.MENU_PROPERTIES_FILENAME_KEY)).thenReturn("test"); + Mockito.when(mockedRequest.getRequestURL()).thenReturn(new StringBuffer("test")); + LoginBean commandBean = new LoginBean(); commandBean.setUserid("test1234"); commandBean.setUser(null); @@ -211,11 +226,14 @@ public class SingleSignOnControllerTest { Mockito.when(mockedRequest.getParameter("forwardURL")).thenReturn("http://Test.com"); PowerMockito.mockStatic(URLDecoder.class); PowerMockito.mockStatic(WebUtils.class); + PowerMockito.mockStatic(PortalApiProperties.class); PowerMockito.mockStatic(SystemProperties.class); PowerMockito.mockStatic(UserUtils.class); Mockito.when(URLDecoder.decode(null, "UTF-8")).thenReturn("http://Test.com"); - Mockito.when(WebUtils.getCookie(mockedRequest, "EPService")).thenReturn(new Cookie("test", "test")); + Mockito.when(WebUtils.getCookie(mockedRequest, "EPService")).thenReturn(new Cookie("test", "{\"test\":\"test\"}")); + Mockito.when(PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REST_URL)).thenReturn("http://TestUrl"); + Mockito.when(restTemplate.postForObject(Mockito.anyString(),Mockito.any(),Matchers.any(Class.class))).thenReturn(true); Mockito.when(UserUtils.getUserSession(mockedRequest)).thenReturn(user); Mockito.when(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM)).thenReturn("testauth"); Mockito.when(loginStrategy.getUserId(mockedRequest)).thenReturn("test1234"); @@ -240,11 +258,14 @@ public class SingleSignOnControllerTest { Mockito.when(mockedRequest.getParameter("forwardURL")).thenReturn("http://Test.com"); PowerMockito.mockStatic(URLDecoder.class); PowerMockito.mockStatic(WebUtils.class); + PowerMockito.mockStatic(PortalApiProperties.class); PowerMockito.mockStatic(SystemProperties.class); PowerMockito.mockStatic(UserUtils.class); Mockito.when(URLDecoder.decode(null, "UTF-8")).thenReturn("http://Test.com"); - Mockito.when(WebUtils.getCookie(mockedRequest, "EPService")).thenReturn(new Cookie("test", "test")); + Mockito.when(WebUtils.getCookie(mockedRequest, "EPService")).thenReturn(new Cookie("test", "{\"test\":\"test\"}")); + Mockito.when(PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REST_URL)).thenReturn("http://TestUrl"); + Mockito.when(restTemplate.postForObject(Mockito.anyString(),Mockito.any(),Matchers.any(Class.class))).thenReturn(true); Mockito.when(UserUtils.getUserSession(mockedRequest)).thenReturn(user); Mockito.when(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM)).thenReturn(null); Mockito.when(loginStrategy.getUserId(mockedRequest)).thenReturn("test1234"); @@ -273,10 +294,13 @@ public class SingleSignOnControllerTest { Mockito.when(mockedRequest.getParameter("forwardURL")).thenReturn("http://Test.com"); PowerMockito.mockStatic(URLDecoder.class); PowerMockito.mockStatic(WebUtils.class); + PowerMockito.mockStatic(PortalApiProperties.class); PowerMockito.mockStatic(SystemProperties.class); PowerMockito.mockStatic(UserUtils.class); Mockito.when(URLDecoder.decode(null, "UTF-8")).thenReturn("http://Test.com"); - Mockito.when(WebUtils.getCookie(mockedRequest, "EPService")).thenReturn(new Cookie("test", "test")); + Mockito.when(WebUtils.getCookie(mockedRequest, "EPService")).thenReturn(new Cookie("test", "{\"test\":\"test\"}")); + Mockito.when(PortalApiProperties.getProperty(PortalApiConstants.ECOMP_REST_URL)).thenReturn("http://TestUrl"); + Mockito.when(restTemplate.postForObject(Mockito.anyString(),Mockito.any(),Matchers.any(Class.class))).thenReturn(true); Mockito.when(UserUtils.getUserSession(mockedRequest)).thenReturn(user); Mockito.when(SystemProperties.getProperty(SystemProperties.AUTHENTICATION_MECHANISM)).thenReturn("CSP"); Mockito.when(loginStrategy.getUserId(mockedRequest)).thenReturn("test1234"); |