summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test/java/org/onap
diff options
context:
space:
mode:
authorWojciech Sliwka <wojciech.sliwka@nokia.com>2019-07-22 09:54:28 +0000
committerGerrit Code Review <gerrit@onap.org>2019-07-22 09:54:28 +0000
commitaa9bee1fac0a5a5ee96a896de90645bb950b609a (patch)
treefa38b6e3d387cf2330a3c0c929607bac1617c63f /vid-app-common/src/test/java/org/onap
parentb491faf8b57779addeb41def6be4c8977d0d5acd (diff)
parent673b18baae5db233d3da2a2b40f9b5d772c6cee2 (diff)
Merge "Allow full-path to certificate and remove implicit Optional::toString"
Diffstat (limited to 'vid-app-common/src/test/java/org/onap')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/aai/util/HttpsAuthClientTest.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/aai/util/HttpsAuthClientTest.java b/vid-app-common/src/test/java/org/onap/vid/aai/util/HttpsAuthClientTest.java
index 3336a8af9..b48efd619 100644
--- a/vid-app-common/src/test/java/org/onap/vid/aai/util/HttpsAuthClientTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/aai/util/HttpsAuthClientTest.java
@@ -22,6 +22,7 @@
package org.onap.vid.aai.util;
+import java.nio.file.FileSystems;
import org.mockito.Mock;
import org.onap.vid.aai.exceptions.HttpClientBuilderException;
@@ -33,6 +34,7 @@ import org.togglz.core.manager.FeatureManager;
import javax.net.ssl.SSLContext;
import java.util.Optional;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.*;
import static org.mockito.MockitoAnnotations.initMocks;
@@ -55,6 +57,7 @@ public class HttpsAuthClientTest {
public void setUp() throws Exception {
initMocks(this);
when(systemPropertyHelper.getAAITruststoreFilename()).thenReturn(Optional.of("filename"));
+ when(systemPropertyHelper.getAAIKeystoreFilename()).thenReturn(Optional.of("keystorefilename"));
when(systemPropertyHelper.getDecryptedKeystorePassword()).thenReturn("password");
when(systemPropertyHelper.getDecryptedTruststorePassword()).thenReturn("password");
}
@@ -79,6 +82,34 @@ public class HttpsAuthClientTest {
}
@Test
+ public void getKeystorePath_whenNotConfigured_yieldEmptyString() {
+ // when
+ when(sslContextProvider.getSslContext(anyString(), anyString(), any())).thenReturn(sslContext);
+
+ //then
+ assertThat(createTestSubject().getKeystorePath()).isEqualTo(CERT_FILE_PATH + FileSystems.getDefault().getSeparator() + "keystorefilename");
+ }
+
+ @Test
+ public void getKeystorePath_whenConfigured_yieldPathAndFile() {
+ // when
+ when(systemPropertyHelper.getAAIKeystoreFilename()).thenReturn(Optional.empty());
+
+ //then
+ assertThat(createTestSubject().getKeystorePath()).isEqualTo("");
+ }
+
+ @Test
+ public void getKeystorePath_whenConfiguredWithSlash_yieldFilenameWithoutPath() {
+ // when
+ final String filenameWithSlash = "/path/to/keystorefilename";
+ when(systemPropertyHelper.getAAIKeystoreFilename()).thenReturn(Optional.of(filenameWithSlash));
+
+ //then
+ assertThat(createTestSubject().getKeystorePath()).isEqualTo(filenameWithSlash);
+ }
+
+ @Test
public void testGetUnsecuredClient() throws Exception {
// when
when(systemPropertyHelper.isClientCertEnabled()).thenReturn(false);