diff options
author | Muni Mohan Kunchi <munmohan@att.com> | 2020-02-06 13:51:45 -0500 |
---|---|---|
committer | Muni Mohan Kunchi <munmohan@att.com> | 2020-02-06 13:54:22 -0500 |
commit | e3636b96e9938cb89bb90672cf70fff3ae790186 (patch) | |
tree | 89dd47a4a95150f70e83556a3280cf4cd02daf89 /ecomp-sdk/epsdk-app-common/src/test | |
parent | 35d028274a61ce8e77a9fa409877d93d0fce05a8 (diff) |
adding sdk changes
adding sdk changes
Issue-ID: PORTAL-830
Signed-off-by: Muni Mohan Kunchi <munmohan@att.com>
Change-Id: I0c99d3ab15fcf4c3b34d84658b64114dadbe2577
Diffstat (limited to 'ecomp-sdk/epsdk-app-common/src/test')
-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"); |