X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=ecomp-portal-BE-os%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fportalapp%2Fportal%2Fservice%2FRemoteWebServiceCallServiceImplTest.java;h=1f34645939f3030df80fe81154d7816662bad49c;hb=ed8f6ef8cc3e329243311c5bc13dc302ade44d60;hp=ad208f395083cd847f0a8b09992025e5ea4341f6;hpb=21a8761f684745bb300e075c7e98ad897ace9eed;p=portal.git diff --git a/ecomp-portal-BE-os/src/test/java/org/onap/portalapp/portal/service/RemoteWebServiceCallServiceImplTest.java b/ecomp-portal-BE-os/src/test/java/org/onap/portalapp/portal/service/RemoteWebServiceCallServiceImplTest.java index ad208f39..1f346459 100644 --- a/ecomp-portal-BE-os/src/test/java/org/onap/portalapp/portal/service/RemoteWebServiceCallServiceImplTest.java +++ b/ecomp-portal-BE-os/src/test/java/org/onap/portalapp/portal/service/RemoteWebServiceCallServiceImplTest.java @@ -33,11 +33,12 @@ * * ============LICENSE_END============================================ * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * */ package org.onap.portalapp.portal.service; -import static org.junit.Assert.*; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.List; @@ -45,7 +46,6 @@ import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.onap.portalsdk.core.util.SystemProperties; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -55,17 +55,18 @@ import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.onap.portalapp.portal.domain.EPApp; import org.onap.portalapp.portal.framework.MockitoTestSuite; -import org.onap.portalapp.portal.service.AppsCacheService; -import org.onap.portalapp.portal.utils.EcompPortalUtils; import org.onap.portalapp.service.RemoteWebServiceCallServiceImpl; import org.onap.portalsdk.core.onboarding.util.CipherUtil; +import org.onap.portalsdk.core.onboarding.util.KeyConstants; +import org.onap.portalsdk.core.onboarding.util.KeyProperties; import org.onap.portalsdk.core.service.DataAccessService; +import org.onap.portalsdk.core.util.SystemProperties; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) -@PrepareForTest({ CipherUtil.class , SystemProperties.class}) +@PrepareForTest({ CipherUtil.class , SystemProperties.class, KeyProperties.class, KeyConstants.class}) public class RemoteWebServiceCallServiceImplTest { @@ -77,7 +78,6 @@ public class RemoteWebServiceCallServiceImplTest { @Mock DataAccessService dataAccessService; - @Before public void setup() { @@ -95,17 +95,17 @@ public class RemoteWebServiceCallServiceImplTest { public void verifyRESTCredentialTest() throws Exception { PowerMockito.mockStatic(CipherUtil.class); - PowerMockito.mockStatic(SystemProperties.class); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); String criteria= " where ueb_key = 'requestUebKey'"; List appList = new ArrayList<>(); EPApp app = new EPApp(); - app.setAppPassword("password"); + app.setAppBasicAuthPassword("password"); appList.add(app); Mockito.when(dataAccessService.getList(EPApp.class, criteria.toString(), null, null)).thenReturn(appList); String secretKey = null; - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(secretKey); - Mockito.when(CipherUtil.decryptPKC("password", - secretKey == null ? null : secretKey)).thenReturn("pwd"); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(secretKey); + Mockito.when(CipherUtil.decryptPKC("password",secretKey == null ? null : secretKey)).thenReturn("pwd"); assertFalse(remoteWebServiceCallServiceImpl.verifyRESTCredential(secretKey,"requestUebKey","requestAppName","requestPassword")); } @@ -113,18 +113,18 @@ public class RemoteWebServiceCallServiceImplTest { public void verifyRESTCredentialExceptionTest() throws Exception { PowerMockito.mockStatic(CipherUtil.class); - PowerMockito.mockStatic(SystemProperties.class); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); String criteria= " where ueb_key = 'requestUebKey'"; List appList = new ArrayList<>(); EPApp app = new EPApp(); - app.setAppPassword("password"); - app.setUsername("requestAppName"); + app.setAppBasicAuthPassword("password"); + app.setAppBasicAuthUsername("requestAppName"); appList.add(app); Mockito.when(dataAccessService.getList(EPApp.class, criteria.toString(), null, null)).thenReturn(appList); String secretKey = null; - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(secretKey); - Mockito.when(CipherUtil.decryptPKC("password", - secretKey == null ? null : secretKey)).thenReturn("pwd"); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(secretKey); + Mockito.when(CipherUtil.decryptPKC("password",secretKey == null ? null : secretKey)).thenReturn("pwd"); assertTrue(remoteWebServiceCallServiceImpl.verifyRESTCredential(secretKey,"requestUebKey","requestAppName","pwd")); } @@ -133,17 +133,18 @@ public class RemoteWebServiceCallServiceImplTest { { PowerMockito.mockStatic(CipherUtil.class); PowerMockito.mockStatic(SystemProperties.class); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); String criteria= " where ueb_key = 'requestUebKey'"; List appList = new ArrayList<>(); EPApp app = new EPApp(); - app.setAppPassword("password"); - app.setUsername("requestAppName"); + app.setAppBasicAuthPassword("password"); + app.setAppBasicAuthUsername("requestAppName"); appList.add(app); Mockito.when(dataAccessService.getList(EPApp.class, criteria.toString(), null, null)).thenReturn(null); String secretKey = null; - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(secretKey); - Mockito.when(CipherUtil.decryptPKC("password", - secretKey == null ? null : secretKey)).thenReturn("pwd"); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(secretKey); + Mockito.when(CipherUtil.decryptPKC("password",secretKey == null ? null : secretKey)).thenReturn("pwd"); assertFalse(remoteWebServiceCallServiceImpl.verifyRESTCredential(secretKey,"requestUebKey","requestAppName","pwd")); } @@ -162,8 +163,8 @@ public class RemoteWebServiceCallServiceImplTest { // String criteria= " where ueb_key = 'requestUebKey'"; List appList = new ArrayList<>(); EPApp app = new EPApp(); - app.setAppPassword("password"); - app.setUsername("requestAppName"); + app.setAppBasicAuthPassword("password"); + app.setAppBasicAuthUsername("requestAppName"); appList.add(app); Mockito.when(dataAccessService.getList(EPApp.class, criteria.toString(), null, null)).thenReturn(null); assertFalse(remoteWebServiceCallServiceImpl.verifyAppKeyCredential("test")); @@ -177,8 +178,8 @@ public class RemoteWebServiceCallServiceImplTest { String criteria= " where ueb_key = 'test'"; List appList = new ArrayList<>(); EPApp app = new EPApp(); - app.setAppPassword("password"); - app.setUsername("requestAppName"); + app.setAppBasicAuthPassword("password"); + app.setAppBasicAuthUsername("requestAppName"); appList.add(app); Mockito.when(dataAccessService.getList(EPApp.class, criteria.toString(), null, null)).thenReturn(appList); assertTrue(remoteWebServiceCallServiceImpl.verifyAppKeyCredential("test"));