diff options
author | Lott, Christopher (cl778h) <cl778h@att.com> | 2019-07-29 11:41:36 -0400 |
---|---|---|
committer | Lott, Christopher (cl778h) <cl778h@att.com> | 2019-07-30 13:35:33 -0400 |
commit | 19087734d0cd4d7e7c892490a795b01e93ba00d0 (patch) | |
tree | dc18fcd42374b9c74098b09f20ca99245b13bad5 /ecomp-sdk/epsdk-fw/src/test | |
parent | 69d4e12be832b560ed5ee1bb84a4ab3b0855310f (diff) |
Publish fixed strings as public constants
Change-Id: I47c8458a0f16251ef19043eb63cf5f392990efdf
Issue-ID: PORTAL-657
Signed-off-by: Lott, Christopher (cl778h) <cl778h@att.com>
Diffstat (limited to 'ecomp-sdk/epsdk-fw/src/test')
5 files changed, 29 insertions, 23 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)); } diff --git a/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/fw/test/ExtendSessionTimeoutTest.java b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/fw/test/ExtendSessionTimeoutTest.java index d7f7ca9c..b22cff03 100644 --- a/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/fw/test/ExtendSessionTimeoutTest.java +++ b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/fw/test/ExtendSessionTimeoutTest.java @@ -53,6 +53,7 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestCentralService; import org.onap.portalsdk.core.onboarding.crossapi.SessionCommunicationService; import org.onap.portalsdk.core.onboarding.listener.PortalTimeoutHandler; import org.onap.portalsdk.core.onboarding.listener.PortalTimeoutHandler.SessionCommInf; @@ -68,8 +69,9 @@ public class ExtendSessionTimeoutTest { public static class RestResource { @POST @Produces(MediaType.APPLICATION_JSON) - public String get( @HeaderParam("username") String username, - @HeaderParam("password") String password, @HeaderParam("uebkey") String uebkey) { + public String get( @HeaderParam(IPortalRestCentralService.CREDENTIALS_USER) String username, + @HeaderParam(IPortalRestCentralService.CREDENTIALS_PASS) String password, + @HeaderParam(IPortalRestCentralService.CREDENTIALS_UEB) String uebkey) { return "{ 'post-session' : '" + username + "' }"; } } diff --git a/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/fw/test/RestClientTest.java b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/fw/test/RestClientTest.java index 17d38264..22ce43b9 100644 --- a/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/fw/test/RestClientTest.java +++ b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/fw/test/RestClientTest.java @@ -55,6 +55,7 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestCentralService; import org.onap.portalsdk.core.onboarding.rest.RestWebServiceClient; import org.onap.portalsdk.core.onboarding.util.PortalApiConstants; import org.onap.portalsdk.core.onboarding.util.PortalApiProperties; @@ -68,18 +69,18 @@ public class RestClientTest { public static class RestResource { @GET @Produces(MediaType.APPLICATION_JSON) - public String get(@HeaderParam("LoginId") String loginId, @HeaderParam("username") String username, - @HeaderParam("password") String password) { + public String get(@HeaderParam("LoginId") String loginId, @HeaderParam(IPortalRestCentralService.CREDENTIALS_USER) String username, + @HeaderParam(IPortalRestCentralService.CREDENTIALS_PASS) String password) { return "{ 'get' : '" + loginId + "' }"; } @POST - public String post(@HeaderParam("LoginId") String loginId, @HeaderParam("username") String username, - @HeaderParam("password") String password) { + public String post(@HeaderParam("LoginId") String loginId, @HeaderParam(IPortalRestCentralService.CREDENTIALS_USER) String username, + @HeaderParam(IPortalRestCentralService.CREDENTIALS_PASS) String password) { return "{ 'post' : '" + loginId + "' }"; } @DELETE - public String delete(@HeaderParam("LoginId") String loginId, @HeaderParam("username") String username, - @HeaderParam("password") String password) { + public String delete(@HeaderParam("LoginId") String loginId, @HeaderParam(IPortalRestCentralService.CREDENTIALS_USER) String username, + @HeaderParam(IPortalRestCentralService.CREDENTIALS_PASS) String password) { return "{ 'delete' : '" + loginId + "' }"; } } diff --git a/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/fw/test/SessionSlotCheckIntervalTest.java b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/fw/test/SessionSlotCheckIntervalTest.java index b922b6c7..d24f365b 100644 --- a/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/fw/test/SessionSlotCheckIntervalTest.java +++ b/ecomp-sdk/epsdk-fw/src/test/java/org/onap/portalsdk/fw/test/SessionSlotCheckIntervalTest.java @@ -53,6 +53,7 @@ import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; +import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestCentralService; import org.onap.portalsdk.core.onboarding.crossapi.SessionCommunicationService; import org.onap.portalsdk.core.onboarding.listener.PortalTimeoutHandler; import org.onap.portalsdk.core.onboarding.listener.PortalTimeoutHandler.SessionCommInf; @@ -69,8 +70,9 @@ public class SessionSlotCheckIntervalTest { public static class RestResource { @GET @Produces(MediaType.APPLICATION_JSON) - public String get( @HeaderParam("username") String username, - @HeaderParam("password") String password, @HeaderParam("uebkey") String uebkey) { + public String get( @HeaderParam(IPortalRestCentralService.CREDENTIALS_USER) String username, + @HeaderParam(IPortalRestCentralService.CREDENTIALS_PASS) String password, + @HeaderParam(IPortalRestCentralService.CREDENTIALS_UEB) String uebkey) { // Expects only an integer, not even a POJO/JSON model. return timeoutValue; } |