diff options
Diffstat (limited to 'ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core')
2 files changed, 14 insertions, 13 deletions
diff --git a/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxyTest.java b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxyTest.java index 897f84a1..35b8bf4d 100644 --- a/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxyTest.java +++ b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPIProxyTest.java @@ -138,7 +138,7 @@ public class PortalRestAPIProxyTest { @Test public void testDoPost_WhenRequestForStoreAnalytics() throws Exception { Mockito.when(portalRestAPICentralServiceImpl.getUserId(request)).thenReturn("test"); - Mockito.when(portalRestAPICentralServiceImpl.getCredentials()).thenReturn(new HashMap(){{put("username","test");put("password","test");}}); + Mockito.when(portalRestAPICentralServiceImpl.getCredentials()).thenReturn(new HashMap(){{put(IPortalRestCentralService.CREDENTIALS_USER,"test");put(IPortalRestCentralService.CREDENTIALS_PASS,"test");}}); Mockito.when(request.getRequestURI()).thenReturn(PortalApiConstants.API_PREFIX+"/storeAnalytics"); doPost.invoke(portalRestAPIProxyObj, new Object[] {request, response}); } @@ -228,7 +228,7 @@ public class PortalRestAPIProxyTest { @Test public void testDoGet_WhenRequestForAnalytics() throws Exception { Mockito.when(portalRestAPICentralServiceImpl.getUserId(request)).thenReturn("test"); - Mockito.when(portalRestAPICentralServiceImpl.getCredentials()).thenReturn(new HashMap(){{put("username","test");put("password","test");}}); + Mockito.when(portalRestAPICentralServiceImpl.getCredentials()).thenReturn(new HashMap(){{put(IPortalRestCentralService.CREDENTIALS_USER,"test");put(IPortalRestCentralService.CREDENTIALS_PASS,"test");}}); Mockito.when(request.getRequestURI()).thenReturn(PortalApiConstants.API_PREFIX+"/analytics"); doGet.invoke(portalRestAPIProxyObj, new Object[] {request, response}); } diff --git a/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/util/AuthUtilTest.java b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/util/AuthUtilTest.java index 00745922..ec3135f1 100644 --- a/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/util/AuthUtilTest.java +++ b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/core/onboarding/util/AuthUtilTest.java @@ -48,6 +48,7 @@ import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mockito; import org.onap.aaf.cadi.CadiWrap; +import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestCentralService; import org.onap.portalsdk.core.onboarding.exception.PortalAPIException; public class AuthUtilTest { @@ -77,29 +78,29 @@ public class AuthUtilTest { @Test(expected = PortalAPIException.class) public void isAccessAllowedExceptionTest() throws PortalAPIException { Map<String, String> appCreds = new HashMap<>(); - appCreds.put("username", "test"); - appCreds.put("password", "test1"); + appCreds.put(IPortalRestCentralService.CREDENTIALS_USER, "test"); + appCreds.put(IPortalRestCentralService.CREDENTIALS_PASS, "test1"); AuthUtil.isAccessAllowed(request, "com.test", appCreds); } @Test public void isAccessAllowedTest() throws PortalAPIException { - Mockito.when(request.getHeader("username")).thenReturn("test"); - Mockito.when(request.getHeader("password")).thenReturn("test1"); + Mockito.when(request.getHeader(IPortalRestCentralService.CREDENTIALS_USER)).thenReturn("test"); + Mockito.when(request.getHeader(IPortalRestCentralService.CREDENTIALS_PASS)).thenReturn("test1"); Map<String, String> appCreds = new HashMap<>(); - appCreds.put("username", "test"); - appCreds.put("password", "test1"); + appCreds.put(IPortalRestCentralService.CREDENTIALS_USER, "test"); + appCreds.put(IPortalRestCentralService.CREDENTIALS_PASS, "test1"); assertTrue(AuthUtil.isAccessAllowed(request, "com.test", appCreds)); } @Test public void isAccessAllowedFalseTest() throws PortalAPIException { - Mockito.when(request.getHeader("username")).thenReturn("test"); - Mockito.when(request.getHeader("password")).thenReturn("test1"); + Mockito.when(request.getHeader(IPortalRestCentralService.CREDENTIALS_USER)).thenReturn("test"); + Mockito.when(request.getHeader(IPortalRestCentralService.CREDENTIALS_PASS)).thenReturn("test1"); Map<String, String> appCreds = new HashMap<>(); - appCreds.put("username", "test"); - appCreds.put("password", "test123"); - appCreds.put("appName", "testApp"); + appCreds.put(IPortalRestCentralService.CREDENTIALS_USER, "test"); + appCreds.put(IPortalRestCentralService.CREDENTIALS_PASS, "test123"); + appCreds.put(IPortalRestCentralService.CREDENTIALS_APP, "testApp"); assertFalse(AuthUtil.isAccessAllowed(request, "com.test", appCreds)); } |