diff options
author | Tomasz Wrobel <tomasz.wrobel@nokia.com> | 2022-05-13 09:01:26 +0200 |
---|---|---|
committer | Tomasz Wrobel <tomasz.wrobel@nokia.com> | 2022-07-06 06:09:50 +0200 |
commit | 5da97dc829f00e8549ccf5617b434aa911578d8b (patch) | |
tree | fb0a293b051a7f2e46ea736356cd6edf98a9371d /datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollectorTest.java | |
parent | 7fdc015b330cf36d4a272af7e9ce31f60248bfd6 (diff) |
Make TLS connection optional1.8.0
Issue-ID: DCAEGEN2-3039
Signed-off-by: Tomasz Wrobel <tomasz.wrobel@nokia.com>
Change-Id: Id637ba17c655407009a4f40f6c93f518b99e45ff
Diffstat (limited to 'datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollectorTest.java')
-rw-r--r-- | datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollectorTest.java | 37 |
1 files changed, 36 insertions, 1 deletions
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 ceb8a989..917055cf 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,7 +1,7 @@ /*- * ============LICENSE_START====================================================================== * Copyright (C) 2018-2019 Nordix Foundation. All rights reserved. - * Copyright (C) 2020 Nokia. All rights reserved. + * Copyright (C) 2020-2022 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 @@ -18,6 +18,7 @@ package org.onap.dcaegen2.collectors.datafile.tasks; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doThrow; @@ -197,6 +198,8 @@ public class FileCollectorTest { assertEquals(0, counters.getNoOfFailedHttpAttempts(),"failedHttpAttempts should have been 0"); } + + @Test public void whenSftpFile_returnCorrectResponse() throws Exception { FileCollector collectorUndetTest = spy(new FileCollector(appConfigMock, counters)); @@ -291,6 +294,38 @@ public class FileCollectorTest { } @Test + public void whenTlsDisabled_ThrowExceptionForHttpsFile() { + when(appConfigMock.getCertificateConfiguration().enableCertAuth()).thenReturn(false); + FileCollector collectorUndetTest = spy(new FileCollector(appConfigMock, counters)); + FileData fileData = createFileData(HTTPS_LOCATION, Scheme.HTTPS); + + StepVerifier.create(collectorUndetTest.collectFile(fileData, 3, Duration.ofSeconds(0), contextMap)) + .expectErrorMessage("Retries exhausted: 3/3") + .verify(); + + StepVerifier.create(collectorUndetTest.collectFile(fileData, 3, Duration.ofSeconds(0), contextMap)) + .consumeErrorWith(throwable -> + assertEquals("HTTPS error: TLS connection is disabled", throwable.getCause().getMessage())) + .verify(); + } + + @Test + public void whenTlsDisabled_ThrowExceptionForFtpesFile() { + when(appConfigMock.getCertificateConfiguration().enableCertAuth()).thenReturn(false); + FileCollector collectorUndetTest = spy(new FileCollector(appConfigMock, counters)); + FileData fileData = createFileData(FTPES_LOCATION, Scheme.FTPES); + + StepVerifier.create(collectorUndetTest.collectFile(fileData, 3, Duration.ofSeconds(0), contextMap)) + .expectErrorMessage("Retries exhausted: 3/3") + .verify(); + + StepVerifier.create(collectorUndetTest.collectFile(fileData, 3, Duration.ofSeconds(0), contextMap)) + .consumeErrorWith(throwable -> + assertEquals("FTPES error: TLS connection is disabled", throwable.getCause().getMessage())) + .verify(); + } + + @Test public void whenFtpesFileAlwaysFail_retryAndFail() throws Exception { FileCollector collectorUndetTest = spy(new FileCollector(appConfigMock, counters)); doReturn(ftpesClientMock).when(collectorUndetTest).createFtpesClient(any()); |