summaryrefslogtreecommitdiffstats
path: root/datafile-app-server/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'datafile-app-server/src/test')
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfigTest.java38
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/http/DfcHttpClientTest.java2
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/http/HttpsClientConnectionManagerUtilTest.java7
-rw-r--r--datafile-app-server/src/test/resources/datafile_endpoints_test.json1
-rw-r--r--datafile-app-server/src/test/resources/datafile_endpoints_test_2producers.json1
5 files changed, 28 insertions, 21 deletions
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfigTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfigTest.java
index bcbe7f82..839a9a18 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfigTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/configuration/AppConfigTest.java
@@ -66,7 +66,7 @@ import static org.mockito.Mockito.when;
* @author <a href="mailto:przemyslaw.wasala@nokia.com">Przemysław Wąsala</a> on 4/9/18
* @author <a href="mailto:henrik.b.andersson@est.tech">Henrik Andersson</a>
*/
-public class AppConfigTest {
+class AppConfigTest {
public static final String CHANGE_IDENTIFIER = "PM_MEAS_FILES";
@@ -90,6 +90,7 @@ public class AppConfigTest {
.keyPasswordPath("/src/test/resources/dfc.jks.pass") //
.trustedCa("/src/test/resources/cert.jks") //
.trustedCaPasswordPath("/src/test/resources/cert.jks.pass") //
+ .httpsHostnameVerify(true)
.build();
private AppConfig appConfigUnderTest;
@@ -105,7 +106,7 @@ public class AppConfigTest {
}
@Test
- public void whenTheConfigurationFits() throws IOException, DatafileTaskException {
+ void whenTheConfigurationFits() throws IOException, DatafileTaskException {
// When
doReturn(getCorrectJson()).when(appConfigUnderTest).createInputStream(any());
appConfigUnderTest.initialize();
@@ -122,12 +123,13 @@ public class AppConfigTest {
assertThat(publisherCfg).isEqualToComparingFieldByField(CORRECT_PUBLISHER_CONFIG);
CertificateConfig certificateConfig = appConfigUnderTest.getCertificateConfiguration();
- assertThat(certificateConfig).isNotNull();
- assertThat(certificateConfig).isEqualToComparingFieldByField(CORRECT_CERTIFICATE_CONFIGURATION);
+ assertThat(certificateConfig)
+ .isNotNull()
+ .isEqualToComparingFieldByField(CORRECT_CERTIFICATE_CONFIGURATION);
}
@Test
- public void whenTheConfigurationFits_twoProducers() throws IOException, DatafileTaskException {
+ void whenTheConfigurationFits_twoProducers() throws IOException, DatafileTaskException {
// When
doReturn(getCorrectJsonTwoProducers()).when(appConfigUnderTest).createInputStream(any());
appConfigUnderTest.loadConfigurationFromFile();
@@ -146,7 +148,7 @@ public class AppConfigTest {
}
@Test
- public void whenFileIsNotExist_ThrowException() throws DatafileTaskException {
+ void whenFileIsNotExist_ThrowException() throws DatafileTaskException {
// Given
appConfigUnderTest.setFilepath("/temp.json");
@@ -162,7 +164,7 @@ public class AppConfigTest {
}
@Test
- public void whenFileIsExistsButJsonIsIncorrect() throws IOException, DatafileTaskException {
+ void whenFileIsExistsButJsonIsIncorrect() throws IOException, DatafileTaskException {
// When
doReturn(getIncorrectJson()).when(appConfigUnderTest).createInputStream(any());
@@ -177,7 +179,7 @@ public class AppConfigTest {
}
@Test
- public void whenTheConfigurationFits_ButRootElementIsNotAJsonObject() throws IOException, DatafileTaskException {
+ void whenTheConfigurationFits_ButRootElementIsNotAJsonObject() throws IOException, DatafileTaskException {
// When
doReturn(getCorrectJson()).when(appConfigUnderTest).createInputStream(any());
@@ -195,9 +197,9 @@ public class AppConfigTest {
}
@Test
- public void whenPeriodicConfigRefreshNoEnvironmentVariables() {
+ void whenPeriodicConfigRefreshNoEnvironmentVariables() {
final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(AppConfig.class);
- Flux<AppConfig> task = appConfigUnderTest.createRefreshTask(context);
+ Flux<AppConfig> task = appConfigUnderTest.createRefreshTask();
StepVerifier //
.create(task) //
@@ -208,14 +210,14 @@ public class AppConfigTest {
}
@Test
- public void whenPeriodicConfigRefreshNoConsul() {
+ void whenPeriodicConfigRefreshNoConsul() {
doReturn(Mono.just(cbsClientConfiguration)).when(appConfigUnderTest).createCbsClientConfiguration();
doReturn(Mono.just(cbsClient)).when(appConfigUnderTest).createCbsClient(cbsClientConfiguration);
Flux<JsonObject> err = Flux.error(new IOException());
doReturn(err).when(cbsClient).updates(any(), any(), any());
final ListAppender<ILoggingEvent> logAppender = LoggingUtils.getLogListAppender(AppConfig.class);
- Flux<AppConfig> task = appConfigUnderTest.createRefreshTask(context);
+ Flux<AppConfig> task = appConfigUnderTest.createRefreshTask();
StepVerifier //
.create(task) //
@@ -227,14 +229,14 @@ public class AppConfigTest {
}
@Test
- public void whenPeriodicConfigRefreshSuccess() throws JsonIOException, JsonSyntaxException, IOException {
+ void whenPeriodicConfigRefreshSuccess() throws JsonIOException, JsonSyntaxException, IOException {
doReturn(Mono.just(cbsClientConfiguration)).when(appConfigUnderTest).createCbsClientConfiguration();
doReturn(Mono.just(cbsClient)).when(appConfigUnderTest).createCbsClient(cbsClientConfiguration);
Flux<JsonObject> json = Flux.just(getJsonRootObject());
doReturn(json).when(cbsClient).updates(any(), any(), any());
- Flux<AppConfig> task = appConfigUnderTest.createRefreshTask(context);
+ Flux<AppConfig> task = appConfigUnderTest.createRefreshTask();
StepVerifier //
.create(task) //
@@ -246,7 +248,7 @@ public class AppConfigTest {
}
@Test
- public void whenPeriodicConfigRefreshSuccess2() throws JsonIOException, JsonSyntaxException, IOException {
+ void whenPeriodicConfigRefreshSuccess2() throws JsonIOException, JsonSyntaxException, IOException {
doReturn(Mono.just(cbsClientConfiguration)).when(appConfigUnderTest).createCbsClientConfiguration();
doReturn(Mono.just(cbsClient)).when(appConfigUnderTest).createCbsClient(cbsClientConfiguration);
@@ -256,7 +258,7 @@ public class AppConfigTest {
doReturn(json, err).when(cbsClient).updates(any(), any(), any());
- Flux<AppConfig> task = appConfigUnderTest.createRefreshTask(context);
+ Flux<AppConfig> task = appConfigUnderTest.createRefreshTask();
StepVerifier //
.create(task) //
@@ -275,8 +277,8 @@ public class AppConfigTest {
assertThat(messageRouterSubscribeRequest.sourceDefinition().topicUrl())
.isEqualTo("http://localhost:2222/events/unauthenticated.VES_NOTIFICATION_OUTPUT");
SecurityKeys securityKeys = consumerConfiguration.getMessageRouterSubscriberConfig().securityKeys();
- assertThat(securityKeys.keyStore().path().toString()).isEqualTo("src/test/resources/cert.jks");
- assertThat(securityKeys.trustStore().path().toString()).isEqualTo("src/test/resources/trust.jks");
+ assertThat(securityKeys.keyStore().path().toString()).hasToString("src/test/resources/cert.jks");
+ assertThat(securityKeys.trustStore().path().toString()).hasToString("src/test/resources/trust.jks");
assertThat(consumerConfiguration.getMessageRouterSubscriber()).isNotNull();
}
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/http/DfcHttpClientTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/http/DfcHttpClientTest.java
index 98804a0c..2b8df344 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/http/DfcHttpClientTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/http/DfcHttpClientTest.java
@@ -99,7 +99,7 @@ class DfcHttpClientTest {
dfcHttpClientSpy.collectFile(REMOTE_FILE, pathMock);
dfcHttpClientSpy.close();
- verify(dfcHttpClientSpy, times(1)).getServerResponse(ArgumentMatchers.eq(REMOTE_FILE));
+ verify(dfcHttpClientSpy, times(1)).getServerResponse(REMOTE_FILE);
verify(dfcHttpClientSpy, times(1)).processDataFromServer(any(), any(), any());
verify(dfcHttpClientSpy, times(1)).isDownloadFailed(any());
}
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/http/HttpsClientConnectionManagerUtilTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/http/HttpsClientConnectionManagerUtilTest.java
index fa4473a6..6328dd3b 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/http/HttpsClientConnectionManagerUtilTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/http/HttpsClientConnectionManagerUtilTest.java
@@ -15,6 +15,7 @@
*/
package org.onap.dcaegen2.collectors.datafile.http;
+import org.apache.http.conn.ssl.DefaultHostnameVerifier;
import org.junit.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
@@ -39,13 +40,15 @@ public class HttpsClientConnectionManagerUtilTest {
@Test
public void creatingManager_successfulCase() throws Exception {
- HttpsClientConnectionManagerUtil.setupOrUpdate(KEY_PATH, KEY_PASSWORD, TRUSTED_CA_PATH, TRUSTED_CA_PASSWORD);
+ HttpsClientConnectionManagerUtil.setupOrUpdate(KEY_PATH, KEY_PASSWORD, TRUSTED_CA_PATH, TRUSTED_CA_PASSWORD, //
+ true);
assertNotNull(HttpsClientConnectionManagerUtil.instance());
}
@Test
public void creatingManager_improperSecretShouldThrowException() {
- assertThrows(DatafileTaskException.class, () -> HttpsClientConnectionManagerUtil.setupOrUpdate(KEY_PATH, KEY_IMPROPER_PASSWORD, TRUSTED_CA_PATH, TRUSTED_CA_PASSWORD));
+ assertThrows(DatafileTaskException.class, () -> HttpsClientConnectionManagerUtil.setupOrUpdate(KEY_PATH, //
+ KEY_IMPROPER_PASSWORD, TRUSTED_CA_PATH, TRUSTED_CA_PASSWORD, true));
assertThrows(DatafileTaskException.class, () -> HttpsClientConnectionManagerUtil.instance());
}
diff --git a/datafile-app-server/src/test/resources/datafile_endpoints_test.json b/datafile-app-server/src/test/resources/datafile_endpoints_test.json
index 00b2488b..7ca83b07 100644
--- a/datafile-app-server/src/test/resources/datafile_endpoints_test.json
+++ b/datafile-app-server/src/test/resources/datafile_endpoints_test.json
@@ -5,6 +5,7 @@
"dmaap.certificateConfig.keyPasswordPath": "/src/test/resources/dfc.jks.pass",
"dmaap.certificateConfig.trustedCa": "/src/test/resources/cert.jks",
"dmaap.certificateConfig.trustedCaPasswordPath": "/src/test/resources/cert.jks.pass",
+ "dmaap.certificateConfig.httpsHostnameVerify": true,
"dmaap.security.trustStorePath": "src/test/resources/trust.jks",
"dmaap.security.trustStorePasswordPath": "src/test/resources/trust.pass",
"dmaap.security.keyStorePath": "src/test/resources/cert.jks",
diff --git a/datafile-app-server/src/test/resources/datafile_endpoints_test_2producers.json b/datafile-app-server/src/test/resources/datafile_endpoints_test_2producers.json
index 73bb7448..13d09bc2 100644
--- a/datafile-app-server/src/test/resources/datafile_endpoints_test_2producers.json
+++ b/datafile-app-server/src/test/resources/datafile_endpoints_test_2producers.json
@@ -5,6 +5,7 @@
"dmaap.certificateConfig.keyPasswordPath": "/src/test/resources/dfc.jks.pass",
"dmaap.certificateConfig.trustedCa": "/src/test/resources/ftp.jks",
"dmaap.certificateConfig.trustedCaPasswordPath": "/src/test/resources/ftp.jks.pass",
+ "dmaap.certificateConfig.httpsHostnameVerify": true,
"dmaap.security.trustStorePath": "src/test/resources/trust.jks",
"dmaap.security.trustStorePasswordPath": "src/test/resources/trust.pass",
"dmaap.security.keyStorePath": "src/test/resources/cert.jks",