diff options
author | “Kruthi <krutbhat@att.com> | 2020-06-04 19:34:07 +0530 |
---|---|---|
committer | “Kruthi <krutbhat@att.com> | 2020-06-10 01:34:23 +0530 |
commit | 2bd47b537ff4fa78ae8f38758900022df6344cdb (patch) | |
tree | 793ee95cdaa550eb6fab92e5b52b0ac01170a702 /ecomp-portal-BE-common/src | |
parent | 30fde7dffdeb16add93ff772c8e2e212cb6850e8 (diff) |
Resubmitting KeyProperty code change since tests failed
Change-Id: I14c0f9b59229e32de45b1652e64c01dd6c1d39e3
Issue-ID: PORTAL-914
Signed-off-by: krutbhat@att.com
Diffstat (limited to 'ecomp-portal-BE-common/src')
10 files changed, 50 insertions, 26 deletions
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/interceptor/PortalResourceInterceptor.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/interceptor/PortalResourceInterceptor.java index 5a57e094..e96485d8 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/interceptor/PortalResourceInterceptor.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/interceptor/PortalResourceInterceptor.java @@ -72,6 +72,8 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.listener.PortalTimeoutHandler; import org.onap.portalsdk.core.onboarding.util.AuthUtil; 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.util.SystemProperties; @@ -370,7 +372,7 @@ public class PortalResourceInterceptor extends ResourceInterceptor { String result = ""; if (encrypted != null && encrypted.length() > 0) { try { - result = CipherUtil.decryptPKC(encrypted, SystemProperties.getProperty(SystemProperties.Decryption_Key)); + result = CipherUtil.decryptPKC(encrypted, KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed", e); throw e; @@ -384,7 +386,7 @@ public class PortalResourceInterceptor extends ResourceInterceptor { if (decryptedPwd != null && decryptedPwd.length() > 0) { try { result = CipherUtil.encryptPKC(decryptedPwd, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "encryptedPassword() failed", e); throw e; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java index 959e392f..ab504fba 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/ApplicationsRestClientServiceImpl.java @@ -67,6 +67,8 @@ import org.onap.portalapp.util.SystemType; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.exception.CipherUtilException; 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.util.SystemProperties; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; @@ -194,7 +196,7 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient if(!encriptedPwd.isEmpty() || encriptedPwd != null || StringUtils.isEmpty(encriptedPwd)){ try { decreptedAppPwd = CipherUtil.decryptPKC(encriptedPwd, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "createClientFor failed to decrypt", e); } @@ -215,7 +217,7 @@ public class ApplicationsRestClientServiceImpl implements ApplicationsRestClient String decreptedexternalAppPwd = StringUtils.EMPTY; try { decreptedexternalAppPwd = CipherUtil.decryptPKC(password, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (CipherUtilException e) { logger.error(EELFLoggerDelegate.errorLogger, "failed to decreptedexternalAppPwd when external app pwd is null", e); } diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImpl.java index 98b0f127..151430d3 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImpl.java @@ -52,6 +52,8 @@ import org.onap.portalapp.portal.utils.EPCommonSystemProperties; import org.onap.portalapp.validation.DataValidator; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; 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.springframework.beans.factory.annotation.Autowired; @@ -229,7 +231,7 @@ public class BasicAuthAccountServiceImpl implements BasicAuthAccountService{ if (encryptedPwd != null && encryptedPwd.length() > 0) { try { result = CipherUtil.decryptPKC(encryptedPwd, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword() failed", e); throw e; @@ -243,7 +245,7 @@ public class BasicAuthAccountServiceImpl implements BasicAuthAccountService{ if (decryptedPwd != null && decryptedPwd.length() > 0) { try { result = CipherUtil.encryptPKC(decryptedPwd, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "encryptedPassword() failed", e); throw e; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPAppCommonServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPAppCommonServiceImpl.java index 539ada26..0e8bdeee 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPAppCommonServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/EPAppCommonServiceImpl.java @@ -94,6 +94,8 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.ueb.Helper; import org.onap.portalsdk.core.onboarding.ueb.TopicManager; 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.service.DataAccessService; @@ -1630,7 +1632,7 @@ public class EPAppCommonServiceImpl implements EPAppService { if (encryptedAppPwd != null && !encryptedAppPwd.isEmpty()) { try { result = CipherUtil.decryptPKC(encryptedAppPwd, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed for app " + app.getName(), e); } @@ -1643,7 +1645,7 @@ public class EPAppCommonServiceImpl implements EPAppService { if (decryptedAppPwd != null && !decryptedAppPwd.isEmpty()) { try { result = CipherUtil.encryptPKC(decryptedAppPwd, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "encryptedPassword failed for app " + app.getName(), e); } diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceProxyServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceProxyServiceImpl.java index 31cb8a45..df8b59d8 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceProxyServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceProxyServiceImpl.java @@ -50,6 +50,8 @@ import org.onap.portalapp.portal.logging.aop.EPMetricsLog; import org.onap.portalapp.portal.utils.EcompPortalUtils; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; 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.util.SystemProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.EnableAspectJAutoProxy; @@ -177,7 +179,7 @@ public class MicroserviceProxyServiceImpl implements MicroserviceProxyService { if (encryptedPwd != null && encryptedPwd.length() > 0) { try { result = CipherUtil.decryptPKC(encryptedPwd, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed", e); throw e; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceServiceImpl.java index 451500d6..9d9fde3a 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceServiceImpl.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/MicroserviceServiceImpl.java @@ -52,6 +52,8 @@ import org.onap.portalapp.portal.logging.aop.EPMetricsLog; import org.onap.portalapp.portal.utils.EPCommonSystemProperties; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; 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.springframework.beans.factory.annotation.Autowired; @@ -197,7 +199,7 @@ public class MicroserviceServiceImpl implements MicroserviceService { if (encryptedPwd != null && !encryptedPwd.isEmpty()) { try { result = CipherUtil.decryptPKC(encryptedPwd, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed", e); throw e; @@ -211,7 +213,7 @@ public class MicroserviceServiceImpl implements MicroserviceService { if (decryptedPwd != null && !decryptedPwd.isEmpty()) { try { result = CipherUtil.encryptPKC(decryptedPwd, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "encryptedPassword failed", e); throw e; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java index e5543a36..3fc8c393 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/utils/EcompPortalUtils.java @@ -61,6 +61,8 @@ import org.onap.portalapp.portal.logging.format.EPAppMessagesEnum; import org.onap.portalapp.portal.logging.logic.EPLogUtil; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; 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.util.SystemProperties; import org.slf4j.MDC; import org.springframework.http.HttpHeaders; @@ -435,7 +437,7 @@ public class EcompPortalUtils { if (encrypted != null && encrypted.length() > 0) { try { result = CipherUtil.decryptPKC(encrypted, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (Exception e) { logger.error(EELFLoggerDelegate.errorLogger, "decryptedPassword failed", e); throw e; diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/service/sessionmgt/SessionCommunication.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/service/sessionmgt/SessionCommunication.java index 441e99a7..f65199c7 100644 --- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/service/sessionmgt/SessionCommunication.java +++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/service/sessionmgt/SessionCommunication.java @@ -61,6 +61,8 @@ import org.onap.portalsdk.core.exception.UrlAccessRestrictedException; import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.portalsdk.core.onboarding.exception.CipherUtilException; 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.util.SystemProperties; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; @@ -344,7 +346,7 @@ public class SessionCommunication { String decreptedexternalAppPwd = StringUtils.EMPTY; try { decreptedexternalAppPwd = CipherUtil.decryptPKC(password, - SystemProperties.getProperty(SystemProperties.Decryption_Key)); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)); } catch (CipherUtilException e) { logger.error(EELFLoggerDelegate.errorLogger, "failed to decreptedexternalAppPwd when external app pwd is null", e); } diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImplTest.java index 6382bef4..a905ca81 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImplTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/BasicAuthAccountServiceImplTest.java @@ -42,6 +42,8 @@ import org.onap.portalapp.portal.domain.EPEndpoint; import org.onap.portalapp.portal.domain.EPEndpointAccount; import org.onap.portalapp.portal.framework.MockitoTestSuite; 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.service.DataAccessServiceImpl; import org.onap.portalsdk.core.util.SystemProperties; @@ -51,7 +53,7 @@ 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 BasicAuthAccountServiceImplTest { @Mock DataAccessService dataAccessService = new DataAccessServiceImpl(); @@ -92,11 +94,12 @@ public class BasicAuthAccountServiceImplTest { @Test public void saveBasicAuthAccountTest_password() throws Exception{ PowerMockito.mockStatic(CipherUtil.class); - PowerMockito.mockStatic(SystemProperties.class); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); BasicAuthCredentials credentials = new BasicAuthCredentials(); credentials.setPassword("password"); String result = null; - Mockito.when(CipherUtil.encryptPKC("password", SystemProperties.getProperty(SystemProperties.Decryption_Key))).thenReturn(result); + Mockito.when(CipherUtil.encryptPKC("password", KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY))).thenReturn(result); basicAuthAccountServiceImpl.saveBasicAuthAccount(credentials); } @@ -163,7 +166,8 @@ public class BasicAuthAccountServiceImplTest { @Test public void getAccountDataTest_password() throws Exception { PowerMockito.mockStatic(CipherUtil.class); - PowerMockito.mockStatic(SystemProperties.class); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); List<BasicAuthCredentials> list = new ArrayList<>(); BasicAuthCredentials basicAuthCredentials = new BasicAuthCredentials(); basicAuthCredentials.setPassword("password"); @@ -171,7 +175,7 @@ public class BasicAuthAccountServiceImplTest { Mockito.when((List<BasicAuthCredentials>) dataAccessService.getList(BasicAuthCredentials.class, null)) .thenReturn(list); String result = null; - Mockito.when(CipherUtil.decryptPKC("password", SystemProperties.getProperty(SystemProperties.Decryption_Key))).thenReturn(result); + Mockito.when(CipherUtil.decryptPKC("password", KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY))).thenReturn(result); } diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/MicroserviceServiceImplTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/MicroserviceServiceImplTest.java index ae813152..bc8d4548 100644 --- a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/MicroserviceServiceImplTest.java +++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/portal/service/MicroserviceServiceImplTest.java @@ -58,6 +58,8 @@ import org.onap.portalapp.portal.domain.MicroserviceData; import org.onap.portalapp.portal.domain.MicroserviceParameter; import org.onap.portalapp.portal.utils.EPCommonSystemProperties; 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.service.DataAccessServiceImpl; import org.onap.portalsdk.core.util.SystemProperties; @@ -66,7 +68,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) -@PrepareForTest({Criterion.class, Restrictions.class, CipherUtil.class, EPCommonSystemProperties.class, SystemProperties.class, Restrictions.class}) +@PrepareForTest({Criterion.class, Restrictions.class, CipherUtil.class, EPCommonSystemProperties.class, SystemProperties.class, KeyProperties.class, KeyConstants.class}) public class MicroserviceServiceImplTest { private static final String TEST="test"; @@ -150,6 +152,8 @@ public class MicroserviceServiceImplTest { PowerMockito.mockStatic(CipherUtil.class); PowerMockito.mockStatic(Restrictions.class); PowerMockito.mockStatic(Criterion.class); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); List<MicroserviceParameter> microserviceParameters = new ArrayList<>(); MicroserviceData microserviceData = new MicroserviceData(); MicroserviceParameter microserviceParameter = new MicroserviceParameter(); @@ -168,8 +172,7 @@ public class MicroserviceServiceImplTest { Criterion serviceIdCriterion = Restrictions.eq("serviceId", 1l); restrictionsList2.add(serviceIdCriterion); Mockito.when((List<MicroserviceParameter>) dataAccessService.getList(MicroserviceParameter.class, null, restrictionsList2, null)).thenReturn(microserviceParameters); - Mockito.when(CipherUtil.decryptPKC("xyz", - SystemProperties.getProperty(SystemProperties.Decryption_Key))).thenReturn("abc"); + Mockito.when(CipherUtil.decryptPKC("xyz",KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY))).thenReturn("abc"); List<MicroserviceData> actual = microserviceServiceImpl.getMicroserviceData(); assertNotNull(actual); } @@ -181,6 +184,8 @@ public class MicroserviceServiceImplTest { PowerMockito.mockStatic(CipherUtil.class); PowerMockito.mockStatic(Restrictions.class); PowerMockito.mockStatic(Criterion.class); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); List<MicroserviceParameter> microserviceParameters = new ArrayList<>(); MicroserviceData microserviceData = new MicroserviceData(); MicroserviceParameter microserviceParameter = new MicroserviceParameter(); @@ -199,8 +204,7 @@ public class MicroserviceServiceImplTest { Criterion serviceIdCriterion = Restrictions.eq("serviceId", 1l); restrictionsList2.add(serviceIdCriterion); Mockito.when((List<MicroserviceParameter>) dataAccessService.getList(MicroserviceParameter.class, null, restrictionsList2, null)).thenReturn(microserviceParameters); - Mockito.when(CipherUtil.decryptPKC("xyz", - SystemProperties.getProperty(SystemProperties.Decryption_Key))).thenThrow(BadPaddingException.class); + Mockito.when(CipherUtil.decryptPKC("xyz",KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY))).thenThrow(BadPaddingException.class); List<MicroserviceData> actual = microserviceServiceImpl.getMicroserviceData(); assertNotNull(actual); } @@ -220,10 +224,10 @@ public class MicroserviceServiceImplTest { PowerMockito.mockStatic(CipherUtil.class); Criterion serviceIdCriterion = Restrictions.eq("serviceId", 1l); restrictionsList.add(serviceIdCriterion); - PowerMockito.mockStatic(SystemProperties.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(TEST); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(TEST); Mockito.when(CipherUtil.encryptPKC(TEST, TEST)).thenReturn(TEST); - Mockito.when((List<MicroserviceParameter>) dataAccessService.getList(MicroserviceParameter.class, null, restrictionsList, null)).thenReturn(microserviceParameters); microserviceServiceImpl.updateMicroservice(1l, buildData()); |