summaryrefslogtreecommitdiffstats
path: root/datafile-app-server/src/test
diff options
context:
space:
mode:
authorJan Malkiewicz <jan.malkiewicz@nokia.com>2020-07-23 09:04:34 +0200
committerJan Malkiewicz <jan.malkiewicz@nokia.com>2020-07-30 07:42:25 +0200
commitf35b9cff9559bff870a703255c23698b31cb01be (patch)
tree73550dbd38dbfdf8489b769d2b4ffe56b5c157de /datafile-app-server/src/test
parent9be7af131a459607eebe0fe45c35abe6a41d49cc (diff)
Removed support for FTPS protocol (from now only FTPeS and sFTP will be supported).
Issue-ID: DCAEGEN2-2367 Signed-off-by: Jan Malkiewicz <jan.malkiewicz@nokia.com> Change-Id: Ifada2899431c56bdbfcf3aad73fdc9b376ae9c4f
Diffstat (limited to 'datafile-app-server/src/test')
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpesClientTest.java (renamed from datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClientTest.java)7
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/SchemeTest.java24
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/model/FileDataTest.java7
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/JsonMessageParserTest.java9
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DMaaPMessageConsumerTest.java7
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollectorTest.java41
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasksTest.java5
7 files changed, 52 insertions, 48 deletions
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClientTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpesClientTest.java
index f64cf433..8e6ff947 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpsClientTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/FtpesClientTest.java
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START======================================================================
* Copyright (C) 2018-2019 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2020 Nokia. All rights reserved.
* ===============================================================================================
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
@@ -43,7 +44,7 @@ import org.junit.jupiter.api.Test;
import org.mockito.ArgumentMatchers;
import org.springframework.http.HttpStatus;
-public class FtpsClientTest {
+public class FtpesClientTest {
private static final String REMOTE_FILE_PATH = "/dir/sample.txt";
private static final Path LOCAL_FILE_PATH = Paths.get("target/sample.txt");
@@ -63,7 +64,7 @@ public class FtpsClientTest {
private InputStream inputStreamMock = mock(InputStream.class);
private OutputStream outputStreamMock = mock(OutputStream.class);
- FtpsClient clientUnderTestSpy;
+ FtpesClient clientUnderTestSpy;
private ImmutableFileServerData createFileServerData() {
return ImmutableFileServerData.builder() //
@@ -75,7 +76,7 @@ public class FtpsClientTest {
@BeforeEach
protected void setUp() throws Exception {
- clientUnderTestSpy = spy(new FtpsClient(createFileServerData(), Paths.get(FTP_KEY_PATH), FTP_KEY_PASSWORD,
+ clientUnderTestSpy = spy(new FtpesClient(createFileServerData(), Paths.get(FTP_KEY_PATH), FTP_KEY_PASSWORD,
TRUSTED_CA_PATH, TRUSTED_CA_PASSWORD));
clientUnderTestSpy.realFtpsClient = ftpsClientMock;
}
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/SchemeTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/SchemeTest.java
index 82b5b229..b695f106 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/SchemeTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/ftp/SchemeTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2020 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +19,6 @@
package org.onap.dcaegen2.collectors.datafile.ftp;
-import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -26,22 +26,20 @@ import org.junit.jupiter.api.Test;
import org.onap.dcaegen2.collectors.datafile.exceptions.DatafileTaskException;
public class SchemeTest {
- @Test
- public void getSchemeFromString_properScheme() throws DatafileTaskException {
-
- Scheme actualScheme = Scheme.getSchemeFromString("FTPES");
- assertEquals(Scheme.FTPS, actualScheme);
- actualScheme = Scheme.getSchemeFromString("FTPS");
- assertEquals(Scheme.FTPS, actualScheme);
+ @Test
+ public void shouldReturnSchemeForSupportedProtocol() throws DatafileTaskException {
+ assertEquals(Scheme.FTPES, Scheme.getSchemeFromString("FTPES"));
+ assertEquals(Scheme.SFTP, Scheme.getSchemeFromString("SFTP"));
+ }
- actualScheme = Scheme.getSchemeFromString("SFTP");
- assertEquals(Scheme.SFTP, actualScheme);
+ @Test
+ public void shouldThrowExceptionForUnsupportedProtocol() {
+ assertThrows(DatafileTaskException.class, () -> Scheme.getSchemeFromString("FTPS"));
}
@Test
- public void getSchemeFromString_invalidScheme() {
- assertTrue(assertThrows(DatafileTaskException.class, () -> Scheme.getSchemeFromString("invalid")).getMessage()
- .startsWith("DFC does not support protocol invalid"));
+ public void shouldThrowExceptionForInvalidProtocol() {
+ assertThrows(DatafileTaskException.class, () -> Scheme.getSchemeFromString("invalid"));
}
}
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/model/FileDataTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/model/FileDataTest.java
index e4b528a9..99bf1cd4 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/model/FileDataTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/model/FileDataTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018-2019 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2020 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -62,7 +63,7 @@ public class FileDataTest {
.compression("comp") //
.fileFormatType("type") //
.fileFormatVersion("version") //
- .scheme(Scheme.FTPS) //
+ .scheme(Scheme.FTPES) //
.messageMetaData(messageMetaData()) //
.build();
}
@@ -74,7 +75,7 @@ public class FileDataTest {
.compression("comp") //
.fileFormatType("type") //
.fileFormatVersion("version") //
- .scheme(Scheme.FTPS) //
+ .scheme(Scheme.FTPES) //
.messageMetaData(messageMetaData()) //
.build();
}
@@ -86,7 +87,7 @@ public class FileDataTest {
.compression("comp") //
.fileFormatType("type") //
.fileFormatVersion("version") //
- .scheme(Scheme.FTPS) //
+ .scheme(Scheme.FTPES) //
.messageMetaData(messageMetaData()) //
.build();
}
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/JsonMessageParserTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/JsonMessageParserTest.java
index cf0cfecf..8fb8c364 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/JsonMessageParserTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/service/JsonMessageParserTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 NOKIA Intellectual Property, 2018-2019 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2020 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -105,7 +106,7 @@ class JsonMessageParserTest {
FileData expectedFileData = ImmutableFileData.builder() //
.name(PM_FILE_NAME) //
.location(LOCATION) //
- .scheme(Scheme.FTPS) //
+ .scheme(Scheme.FTPES) //
.compression(GZIP_COMPRESSION) //
.fileFormatType(FILE_FORMAT_TYPE) //
.fileFormatVersion(FILE_FORMAT_VERSION) //
@@ -157,7 +158,7 @@ class JsonMessageParserTest {
FileData expectedFileData = ImmutableFileData.builder() //
.name(PM_FILE_NAME) //
.location(LOCATION) //
- .scheme(Scheme.FTPS) //
+ .scheme(Scheme.FTPES) //
.compression(GZIP_COMPRESSION) //
.fileFormatType(FILE_FORMAT_TYPE) //
.fileFormatVersion(FILE_FORMAT_VERSION) //
@@ -277,7 +278,7 @@ class JsonMessageParserTest {
FileData expectedFileData = ImmutableFileData.builder() //
.name(PM_FILE_NAME) //
.location(LOCATION) //
- .scheme(Scheme.FTPS) //
+ .scheme(Scheme.FTPES) //
.compression(GZIP_COMPRESSION) //
.fileFormatType(FILE_FORMAT_TYPE) //
.fileFormatVersion(FILE_FORMAT_VERSION) //
@@ -489,7 +490,7 @@ class JsonMessageParserTest {
FileData expectedFileData = ImmutableFileData.builder() //
.name(PM_FILE_NAME) //
.location(LOCATION) //
- .scheme(Scheme.FTPS) //
+ .scheme(Scheme.FTPES) //
.compression(GZIP_COMPRESSION) //
.fileFormatType(FILE_FORMAT_TYPE) //
.fileFormatVersion(FILE_FORMAT_VERSION) //
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DMaaPMessageConsumerTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DMaaPMessageConsumerTest.java
index a4319d37..d4dd89f0 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DMaaPMessageConsumerTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DMaaPMessageConsumerTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2018 NOKIA Intellectual Property, 2018-2019 Nordix Foundation.
+ * Copyright (C) 2018 NOKIA Intellectual Property, 2018-2019 Nordix Foundation.
+ * Copyright (C) 2020 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -147,7 +148,7 @@ public class DMaaPMessageConsumerTest {
ftpesFileData = ImmutableFileData.builder() //
.name(PM_FILE_NAME) //
.location(FTPES_LOCATION) //
- .scheme(Scheme.FTPS) //
+ .scheme(Scheme.FTPES) //
.compression(GZIP_COMPRESSION) //
.fileFormatType(MEAS_COLLECT_FILE_FORMAT_TYPE) //
.fileFormatVersion(FILE_FORMAT_VERSION) //
@@ -178,7 +179,7 @@ public class DMaaPMessageConsumerTest {
sftpFileData = ImmutableFileData.builder() //
.name(PM_FILE_NAME) //
.location(SFTP_LOCATION) //
- .scheme(Scheme.FTPS) //
+ .scheme(Scheme.FTPES) //
.compression(GZIP_COMPRESSION) //
.fileFormatType(MEAS_COLLECT_FILE_FORMAT_TYPE) //
.fileFormatVersion(FILE_FORMAT_VERSION) //
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollectorTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollectorTest.java
index e5523251..b7b69e8d 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollectorTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollectorTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START======================================================================
* Copyright (C) 2018-2019 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2020 Nokia. All rights reserved.
* ===============================================================================================
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
@@ -40,7 +41,7 @@ import org.onap.dcaegen2.collectors.datafile.configuration.AppConfig;
import org.onap.dcaegen2.collectors.datafile.configuration.FtpesConfig;
import org.onap.dcaegen2.collectors.datafile.exceptions.DatafileTaskException;
import org.onap.dcaegen2.collectors.datafile.exceptions.NonRetryableDatafileTaskException;
-import org.onap.dcaegen2.collectors.datafile.ftp.FtpsClient;
+import org.onap.dcaegen2.collectors.datafile.ftp.FtpesClient;
import org.onap.dcaegen2.collectors.datafile.ftp.Scheme;
import org.onap.dcaegen2.collectors.datafile.ftp.SftpClient;
import org.onap.dcaegen2.collectors.datafile.model.Counters;
@@ -91,7 +92,7 @@ public class FileCollectorTest {
private static AppConfig appConfigMock = mock(AppConfig.class);
private static FtpesConfig ftpesConfigMock = mock(FtpesConfig.class);
- private FtpsClient ftpsClientMock = mock(FtpsClient.class);
+ private FtpesClient ftpesClientMock = mock(FtpesClient.class);
private SftpClient sftpClientMock = mock(SftpClient.class);
private final Map<String, String> contextMap = new HashMap<>();
@@ -159,9 +160,9 @@ public class FileCollectorTest {
@Test
public void whenFtpesFile_returnCorrectResponse() throws Exception {
FileCollector collectorUndetTest = spy(new FileCollector(appConfigMock, counters));
- doReturn(ftpsClientMock).when(collectorUndetTest).createFtpsClient(any());
+ doReturn(ftpesClientMock).when(collectorUndetTest).createFtpesClient(any());
- FileData fileData = createFileData(FTPES_LOCATION_NO_PORT, Scheme.FTPS);
+ FileData fileData = createFileData(FTPES_LOCATION_NO_PORT, Scheme.FTPES);
FilePublishInformation expectedfilePublishInformation =
createExpectedFilePublishInformation(FTPES_LOCATION_NO_PORT);
@@ -170,10 +171,10 @@ public class FileCollectorTest {
.expectNext(expectedfilePublishInformation) //
.verifyComplete();
- verify(ftpsClientMock, times(1)).open();
- verify(ftpsClientMock, times(1)).collectFile(REMOTE_FILE_LOCATION, LOCAL_FILE_LOCATION);
- verify(ftpsClientMock, times(1)).close();
- verifyNoMoreInteractions(ftpsClientMock);
+ verify(ftpesClientMock, times(1)).open();
+ verify(ftpesClientMock, times(1)).collectFile(REMOTE_FILE_LOCATION, LOCAL_FILE_LOCATION);
+ verify(ftpesClientMock, times(1)).close();
+ verifyNoMoreInteractions(ftpesClientMock);
assertEquals("collectedFiles should have been 1", 1, counters.getNoOfCollectedFiles());
assertEquals("failedFtpAttempts should have been 0", 0, counters.getNoOfFailedFtpAttempts());
@@ -211,17 +212,17 @@ public class FileCollectorTest {
@Test
public void whenFtpesFileAlwaysFail_retryAndFail() throws Exception {
FileCollector collectorUndetTest = spy(new FileCollector(appConfigMock, counters));
- doReturn(ftpsClientMock).when(collectorUndetTest).createFtpsClient(any());
+ doReturn(ftpesClientMock).when(collectorUndetTest).createFtpesClient(any());
- FileData fileData = createFileData(FTPES_LOCATION, Scheme.FTPS);
- doThrow(new DatafileTaskException("Unable to collect file.")).when(ftpsClientMock)
+ FileData fileData = createFileData(FTPES_LOCATION, Scheme.FTPES);
+ doThrow(new DatafileTaskException("Unable to collect file.")).when(ftpesClientMock)
.collectFile(REMOTE_FILE_LOCATION, LOCAL_FILE_LOCATION);
StepVerifier.create(collectorUndetTest.collectFile(fileData, 3, Duration.ofSeconds(0), contextMap))
.expectErrorMessage("Retries exhausted: 3/3") //
.verify();
- verify(ftpsClientMock, times(4)).collectFile(REMOTE_FILE_LOCATION, LOCAL_FILE_LOCATION);
+ verify(ftpesClientMock, times(4)).collectFile(REMOTE_FILE_LOCATION, LOCAL_FILE_LOCATION);
assertEquals("collectedFiles should have been 0", 0, counters.getNoOfCollectedFiles());
assertEquals("failedFtpAttempts should have been 4", 4, counters.getNoOfFailedFtpAttempts());
@@ -230,17 +231,17 @@ public class FileCollectorTest {
@Test
public void whenFtpesFileAlwaysFail_failWithoutRetry() throws Exception {
FileCollector collectorUndetTest = spy(new FileCollector(appConfigMock, counters));
- doReturn(ftpsClientMock).when(collectorUndetTest).createFtpsClient(any());
+ doReturn(ftpesClientMock).when(collectorUndetTest).createFtpesClient(any());
- FileData fileData = createFileData(FTPES_LOCATION, Scheme.FTPS);
- doThrow(new NonRetryableDatafileTaskException("Unable to collect file.")).when(ftpsClientMock)
+ FileData fileData = createFileData(FTPES_LOCATION, Scheme.FTPES);
+ doThrow(new NonRetryableDatafileTaskException("Unable to collect file.")).when(ftpesClientMock)
.collectFile(REMOTE_FILE_LOCATION, LOCAL_FILE_LOCATION);
StepVerifier.create(collectorUndetTest.collectFile(fileData, 3, Duration.ofSeconds(0), contextMap))
.expectErrorMessage("Non retryable file transfer failure") //
.verify();
- verify(ftpsClientMock, times(1)).collectFile(REMOTE_FILE_LOCATION, LOCAL_FILE_LOCATION);
+ verify(ftpesClientMock, times(1)).collectFile(REMOTE_FILE_LOCATION, LOCAL_FILE_LOCATION);
assertEquals("collectedFiles should have been 0", 0, counters.getNoOfCollectedFiles());
assertEquals("failedFtpAttempts should have been 1", 1, counters.getNoOfFailedFtpAttempts());
@@ -249,20 +250,20 @@ public class FileCollectorTest {
@Test
public void whenFtpesFileFailOnce_retryAndReturnCorrectResponse() throws Exception {
FileCollector collectorUndetTest = spy(new FileCollector(appConfigMock, counters));
- doReturn(ftpsClientMock).when(collectorUndetTest).createFtpsClient(any());
- doThrow(new DatafileTaskException("Unable to collect file.")).doNothing().when(ftpsClientMock)
+ doReturn(ftpesClientMock).when(collectorUndetTest).createFtpesClient(any());
+ doThrow(new DatafileTaskException("Unable to collect file.")).doNothing().when(ftpesClientMock)
.collectFile(REMOTE_FILE_LOCATION, LOCAL_FILE_LOCATION);
FilePublishInformation expectedfilePublishInformation =
createExpectedFilePublishInformation(FTPES_LOCATION_NO_PORT);
- FileData fileData = createFileData(FTPES_LOCATION_NO_PORT, Scheme.FTPS);
+ FileData fileData = createFileData(FTPES_LOCATION_NO_PORT, Scheme.FTPES);
StepVerifier.create(collectorUndetTest.collectFile(fileData, 3, Duration.ofSeconds(0), contextMap))
.expectNext(expectedfilePublishInformation) //
.verifyComplete();
- verify(ftpsClientMock, times(2)).collectFile(REMOTE_FILE_LOCATION, LOCAL_FILE_LOCATION);
+ verify(ftpesClientMock, times(2)).collectFile(REMOTE_FILE_LOCATION, LOCAL_FILE_LOCATION);
assertEquals("collectedFiles should have been 1", 1, counters.getNoOfCollectedFiles());
assertEquals("failedFtpAttempts should have been 1", 1, counters.getNoOfFailedFtpAttempts());
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasksTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasksTest.java
index c77f5fc2..1cb79bcf 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasksTest.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasksTest.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2020 Nokia. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -149,7 +150,7 @@ public class ScheduledTasksTest {
.fileFormatType("") //
.fileFormatVersion("") //
.location("ftpes://192.168.0.101/ftp/rop/" + PM_FILE_NAME + instanceNumber) //
- .scheme(Scheme.FTPS) //
+ .scheme(Scheme.FTPES) //
.compression("") //
.messageMetaData(messageMetaData()) //
.build();