From 5a5dc6298559ca0cbd3f60923f779f0d3a4e3de9 Mon Sep 17 00:00:00 2001 From: “Kruthi Date: Thu, 4 Jun 2020 20:32:59 +0530 Subject: Resubmitting KeyProperties changes Change-Id: Ifdf5d90b6773ef3260572eb8d8a65238262d361f Issue-ID: PORTAL-914 Signed-off-by: krutbhat@att.com --- .../controller/core/FavoritesControllerTest.java | 16 ++++++++++++---- .../portalapp/service/OnBoardingApiServiceImplTest.java | 12 +++++++++--- 2 files changed, 21 insertions(+), 7 deletions(-) (limited to 'ecomp-sdk/epsdk-app-common/src/test/java') diff --git a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/FavoritesControllerTest.java b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/FavoritesControllerTest.java index 5c54d40d..e980f2a1 100644 --- a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/FavoritesControllerTest.java +++ b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/core/FavoritesControllerTest.java @@ -53,6 +53,8 @@ import org.onap.portalsdk.core.domain.App; import org.onap.portalsdk.core.domain.User; import org.onap.portalsdk.core.onboarding.rest.FavoritesClient; 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.AppService; import org.onap.portalsdk.core.util.SystemProperties; import org.powermock.api.mockito.PowerMockito; @@ -60,7 +62,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) -@PrepareForTest({SystemProperties.class, CipherUtil.class, FavoritesClient.class}) +@PrepareForTest({SystemProperties.class, CipherUtil.class, FavoritesClient.class, KeyProperties.class, KeyConstants.class}) public class FavoritesControllerTest { @InjectMocks @@ -89,6 +91,8 @@ public class FavoritesControllerTest { HttpSession session = Mockito.mock(HttpSession.class); Mockito.when(request.getSession()).thenReturn(session); PowerMockito.mockStatic(SystemProperties.class); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); User user = new User(); user.setId(123L); Mockito.when(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME)).thenReturn("user"); @@ -101,7 +105,7 @@ public class FavoritesControllerTest { Mockito.when(appService.getDefaultApp()).thenReturn(app); PowerMockito.mockStatic(CipherUtil.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(app.getAppPassword()); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(app.getAppPassword()); Mockito.when(CipherUtil.decryptPKC(app.getAppPassword(), app.getAppPassword())).thenReturn(app.getAppPassword()); PowerMockito.mockStatic(FavoritesClient.class); @@ -120,6 +124,8 @@ public class FavoritesControllerTest { HttpSession session = Mockito.mock(HttpSession.class); Mockito.when(request.getSession()).thenReturn(session); PowerMockito.mockStatic(SystemProperties.class); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); User user = new User(); user.setId(123L); Mockito.when(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME)).thenReturn("user"); @@ -131,7 +137,7 @@ public class FavoritesControllerTest { app.setAppPassword("Password"); Mockito.when(appService.getDefaultApp()).thenReturn(app); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(app.getAppPassword()); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(app.getAppPassword()); PowerMockito.mockStatic(FavoritesClient.class); Mockito.when(FavoritesClient.getFavorites(Mockito.anyString(), Mockito.anyString(), @@ -149,6 +155,8 @@ public class FavoritesControllerTest { HttpSession session = Mockito.mock(HttpSession.class); Mockito.when(request.getSession()).thenReturn(session); PowerMockito.mockStatic(SystemProperties.class); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); User user = new User(); user.setId(123L); Mockito.when(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME)).thenReturn("user"); @@ -161,7 +169,7 @@ public class FavoritesControllerTest { Mockito.when(appService.getDefaultApp()).thenReturn(null); PowerMockito.mockStatic(CipherUtil.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(app.getAppPassword()); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(app.getAppPassword()); Mockito.when(CipherUtil.decryptPKC(app.getAppPassword(), app.getAppPassword())).thenReturn(app.getAppPassword()); PowerMockito.mockStatic(FavoritesClient.class); diff --git a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/OnBoardingApiServiceImplTest.java b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/OnBoardingApiServiceImplTest.java index 9d5e4fea..2c6827ed 100644 --- a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/OnBoardingApiServiceImplTest.java +++ b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/OnBoardingApiServiceImplTest.java @@ -65,6 +65,8 @@ import org.onap.portalsdk.core.onboarding.exception.CipherUtilException; import org.onap.portalsdk.core.onboarding.exception.PortalAPIException; import org.onap.portalsdk.core.onboarding.listener.PortalTimeoutHandler; 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.onboarding.util.PortalApiConstants; import org.onap.portalsdk.core.onboarding.util.PortalApiProperties; import org.onap.portalsdk.core.restful.domain.EcompRole; @@ -83,7 +85,7 @@ import org.powermock.modules.junit4.PowerMockRunner; import org.springframework.context.ApplicationContext; @RunWith(PowerMockRunner.class) -@PrepareForTest({ AppContextManager.class, PortalApiProperties.class, JSONUtil.class, PortalTimeoutHandler.class, SystemProperties.class, CipherUtil.class }) +@PrepareForTest({ AppContextManager.class, PortalApiProperties.class, JSONUtil.class, PortalTimeoutHandler.class, SystemProperties.class, CipherUtil.class, KeyProperties.class, KeyConstants.class }) public class OnBoardingApiServiceImplTest { @Mock @@ -426,7 +428,9 @@ public class OnBoardingApiServiceImplTest { PowerMockito.mockStatic(SystemProperties.class); PowerMockito.mockStatic(CipherUtil.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(key); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(key); Mockito.when(CipherUtil.decryptPKC(app.getAppPassword(), key)).thenReturn(app.getAppPassword()); Mockito.when(appServiceImpl.getDefaultApp()).thenReturn(app); OnBoardingApiServiceImpl onBoardingApiServiceImpl = new OnBoardingApiServiceImpl(); @@ -453,7 +457,9 @@ public class OnBoardingApiServiceImplTest { PowerMockito.mockStatic(SystemProperties.class); PowerMockito.mockStatic(CipherUtil.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(key); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(key); Mockito.when(CipherUtil.decryptPKC(app.getAppPassword(), key)).thenThrow(CipherUtilException.class); Mockito.when(appServiceImpl.getDefaultApp()).thenReturn(app); OnBoardingApiServiceImpl onBoardingApiServiceImpl = new OnBoardingApiServiceImpl(); -- cgit 1.2.3-korg