diff options
author | Sunder Tattavarada <statta@research.att.com> | 2020-06-10 18:02:50 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-06-10 18:02:50 +0000 |
commit | 485cbdfa0a498e43b1464f63db5427d08e09dbd7 (patch) | |
tree | 4d9c0b95c5839309288d3b03a8e7d8514ca6a48a /ecomp-sdk/epsdk-core/src/test | |
parent | 9c9c3bdb37389cb6e49278038b27c445e7cdb6b6 (diff) | |
parent | 5a5dc6298559ca0cbd3f60923f779f0d3a4e3de9 (diff) |
Merge "Resubmitting KeyProperties changes"
Diffstat (limited to 'ecomp-sdk/epsdk-core/src/test')
2 files changed, 33 insertions, 13 deletions
diff --git a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/RestApiRequestBuilderTest.java b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/RestApiRequestBuilderTest.java index 099f4c42..132ab546 100644 --- a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/RestApiRequestBuilderTest.java +++ b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/RestApiRequestBuilderTest.java @@ -48,13 +48,15 @@ import org.mockito.Mockito; import org.onap.portalsdk.core.domain.App; import org.onap.portalsdk.core.onboarding.rest.RestWebServiceClient; 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.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) -@PrepareForTest({ SystemProperties.class, CipherUtil.class, RestWebServiceClient.class }) +@PrepareForTest({ SystemProperties.class, CipherUtil.class, RestWebServiceClient.class, KeyProperties.class, KeyConstants.class }) public class RestApiRequestBuilderTest { @InjectMocks @@ -77,10 +79,12 @@ public class RestApiRequestBuilderTest { String status = "SUCCESS"; PowerMockito.mockStatic(SystemProperties.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(app.getAppPassword()); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(app.getAppPassword()); PowerMockito.mockStatic(CipherUtil.class); Mockito.when(CipherUtil.decryptPKC(app.getAppPassword(), - SystemProperties.getProperty(SystemProperties.Decryption_Key))).thenReturn(app.getAppPassword()); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY))).thenReturn(app.getAppPassword()); PowerMockito.mockStatic(RestWebServiceClient.class); @@ -110,7 +114,9 @@ public class RestApiRequestBuilderTest { app.setAppPassword("Password"); PowerMockito.mockStatic(SystemProperties.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(app.getAppPassword()); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(app.getAppPassword()); Mockito.when(appService.getDefaultApp()).thenReturn(app); restApiRequestBuilder.getViaREST(restEndPoint, isBasicAuth, userId); @@ -155,10 +161,12 @@ public class RestApiRequestBuilderTest { String status = "SUCCESS"; PowerMockito.mockStatic(SystemProperties.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(app.getAppPassword()); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(app.getAppPassword()); PowerMockito.mockStatic(CipherUtil.class); Mockito.when(CipherUtil.decryptPKC(app.getAppPassword(), - SystemProperties.getProperty(SystemProperties.Decryption_Key))).thenReturn(app.getAppPassword()); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY))).thenReturn(app.getAppPassword()); PowerMockito.mockStatic(RestWebServiceClient.class); RestWebServiceClient client = Mockito.mock(RestWebServiceClient.class); @@ -187,7 +195,9 @@ public class RestApiRequestBuilderTest { app.setAppPassword("Password"); PowerMockito.mockStatic(SystemProperties.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(app.getAppPassword()); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(app.getAppPassword()); Mockito.when(appService.getDefaultApp()).thenReturn(app); restApiRequestBuilder.postViaREST(restEndPoint, isBasicAuth,content, userId); @@ -230,10 +240,12 @@ public class RestApiRequestBuilderTest { String status = "SUCCESS"; PowerMockito.mockStatic(SystemProperties.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(app.getAppPassword()); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(app.getAppPassword()); PowerMockito.mockStatic(CipherUtil.class); Mockito.when(CipherUtil.decryptPKC(app.getAppPassword(), - SystemProperties.getProperty(SystemProperties.Decryption_Key))).thenReturn(app.getAppPassword()); + KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY))).thenReturn(app.getAppPassword()); PowerMockito.mockStatic(RestWebServiceClient.class); RestWebServiceClient client = Mockito.mock(RestWebServiceClient.class); @@ -262,7 +274,9 @@ public class RestApiRequestBuilderTest { app.setAppPassword("Password"); PowerMockito.mockStatic(SystemProperties.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(app.getAppPassword()); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(app.getAppPassword()); Mockito.when(appService.getDefaultApp()).thenReturn(app); restApiRequestBuilder.deleteViaRest(restEndPoint, isBasicAuth,content, userId); diff --git a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/WebServiceCallServiceImplTest.java b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/WebServiceCallServiceImplTest.java index 69e9b410..89c2fabf 100644 --- a/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/WebServiceCallServiceImplTest.java +++ b/ecomp-sdk/epsdk-core/src/test/java/org/onap/portalsdk/core/service/WebServiceCallServiceImplTest.java @@ -48,13 +48,15 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.onap.portalsdk.core.domain.App; 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.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 WebServiceCallServiceImplTest { @InjectMocks @@ -78,7 +80,9 @@ public class WebServiceCallServiceImplTest { Mockito.when(appService.getDefaultApp()).thenReturn(app); PowerMockito.mockStatic(CipherUtil.class); PowerMockito.mockStatic(SystemProperties.class); - Mockito.when(SystemProperties.getProperty(SystemProperties.Decryption_Key)).thenReturn(secretKey); + PowerMockito.mockStatic(KeyProperties.class); + PowerMockito.mockStatic(KeyConstants.class); + Mockito.when(KeyProperties.getProperty(KeyConstants.CIPHER_ENCRYPTION_KEY)).thenReturn(secretKey); Mockito.when(CipherUtil.decryptPKC(Mockito.anyString(), Mockito.anyString())).thenReturn(requestPassword); webServiceCallServiceImpl.verifyRESTCredential(secretKey, requestAppName, requestPassword); Assert.assertTrue(true); @@ -95,7 +99,9 @@ public class WebServiceCallServiceImplTest { Mockito.when(appService.getDefaultApp()).thenReturn(app); PowerMockito.mockStatic(CipherUtil.class); PowerMockito.mockStatic(SystemProperties.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(Mockito.anyString(), Mockito.anyString())).thenReturn("Key"); webServiceCallServiceImpl.verifyRESTCredential(secretKey, requestAppName, requestPassword); Assert.assertFalse(false); |