aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogumil Zebek <bogumil.zebek@nokia.com>2020-07-13 12:13:00 +0000
committerGerrit Code Review <gerrit@onap.org>2020-07-13 12:13:00 +0000
commit20b07f71edc5ad3f862033b4ac4075ceaa76c9a8 (patch)
treece506bb83283169dd423cb57b57b1c8948def19c
parentd452d840291e4f59fdcac91b9ba7b9c2486bdcd3 (diff)
parente64680cd62b468a25b763457c2e1d31414081c29 (diff)
Merge "Add subfolders creation"1.2.0
-rw-r--r--certService/pom.xml4
-rw-r--r--certService/version.properties2
-rw-r--r--certServiceClient/README.md2
-rw-r--r--certServiceClient/pom.xml4
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/ArtifactsCreatorProvider.java2
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ConvertedArtifactsCreatorFactory.java2
-rw-r--r--certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/writer/CertFileWriter.java16
-rw-r--r--certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/writer/CertFileWriterTest.java48
-rw-r--r--certServiceClient/version.properties2
-rw-r--r--docs/sections/release-notes.rst41
-rw-r--r--pom.xml2
-rw-r--r--version.properties2
12 files changed, 88 insertions, 39 deletions
diff --git a/certService/pom.xml b/certService/pom.xml
index 5cc45cd5..9febd167 100644
--- a/certService/pom.xml
+++ b/certService/pom.xml
@@ -18,10 +18,10 @@
<parent>
<groupId>org.onap.aaf.certservice</groupId>
<artifactId>aaf-certservice</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.2.0-SNAPSHOT</version>
</parent>
<artifactId>aaf-certservice-api</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.2.0-SNAPSHOT</version>
<name>aaf-certservice-api</name>
<description>AAF Certification Service Api</description>
<packaging>jar</packaging>
diff --git a/certService/version.properties b/certService/version.properties
index 7b8b963a..00ef5645 100644
--- a/certService/version.properties
+++ b/certService/version.properties
@@ -1,5 +1,5 @@
major=1
-minor=1
+minor=2
patch=0
base_version=${major}.${minor}.${patch}
release_version=${base_version}
diff --git a/certServiceClient/README.md b/certServiceClient/README.md
index adb5d4fb..b3005345 100644
--- a/certServiceClient/README.md
+++ b/certServiceClient/README.md
@@ -26,7 +26,7 @@ CertService API and client must be running in same network.
You need certificate and trust anchors (in JKS format) to connect to CertService API via HTTPS. Information how to generate truststore and keystore files you can find in CertService main README.
-Information how to run you can find in CertService main README and official documentation, see [Read The Docs](https://onap-doc.readthedocs.io/projects/onap-aaf-certservice/en/latest/sections/usage.html)
+Information how to run you can find in CertService main README and official documentation, see [Read The Docs](https://docs.onap.org/projects/onap-aaf-certservice/en/latest/sections/usage.html)
### Logs locally
diff --git a/certServiceClient/pom.xml b/certServiceClient/pom.xml
index 50ae677e..e176b18e 100644
--- a/certServiceClient/pom.xml
+++ b/certServiceClient/pom.xml
@@ -5,12 +5,12 @@
<parent>
<artifactId>aaf-certservice</artifactId>
<groupId>org.onap.aaf.certservice</groupId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>aaf-certservice-client</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.2.0-SNAPSHOT</version>
<name>aaf-certservice-client</name>
<description>AAF Certification Service Api Client</description>
<packaging>jar</packaging>
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/ArtifactsCreatorProvider.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/ArtifactsCreatorProvider.java
index 06a4cc6e..954f3d30 100644
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/ArtifactsCreatorProvider.java
+++ b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/ArtifactsCreatorProvider.java
@@ -40,7 +40,7 @@ public enum ArtifactsCreatorProvider {
PEM("PEM") {
@Override
ArtifactsCreator create(String destPath) {
- return new PemArtifactsCreator(new CertFileWriter(destPath), new PrivateKeyToPemEncoder());
+ return new PemArtifactsCreator(CertFileWriter.createWithDir(destPath), new PrivateKeyToPemEncoder());
}
};
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ConvertedArtifactsCreatorFactory.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ConvertedArtifactsCreatorFactory.java
index 586e2952..bda796eb 100644
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ConvertedArtifactsCreatorFactory.java
+++ b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/conversion/ConvertedArtifactsCreatorFactory.java
@@ -28,7 +28,7 @@ public class ConvertedArtifactsCreatorFactory {
public static ConvertedArtifactsCreator createConverter(String destPath, String fileExtension, String keyStoreType) {
return new ConvertedArtifactsCreator(
- new CertFileWriter(destPath),
+ CertFileWriter.createWithDir(destPath),
new RandomPasswordGenerator(),
new PemConverter(keyStoreType),
fileExtension);
diff --git a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/writer/CertFileWriter.java b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/writer/CertFileWriter.java
index 2829517c..fec3ebd3 100644
--- a/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/writer/CertFileWriter.java
+++ b/certServiceClient/src/main/java/org/onap/aaf/certservice/client/certification/writer/CertFileWriter.java
@@ -23,6 +23,7 @@ import org.onap.aaf.certservice.client.certification.exception.CertFileWriterExc
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Path;
@@ -32,10 +33,15 @@ public class CertFileWriter {
private static final Logger LOGGER = LoggerFactory.getLogger(CertFileWriter.class);
private final String destPath;
- public CertFileWriter(String destPath) {
+ private CertFileWriter(String destPath) {
this.destPath = destPath;
}
+ public static CertFileWriter createWithDir(String destPath) {
+ createDirIfNotExists(destPath);
+ return new CertFileWriter(destPath);
+ }
+
public void saveData(byte[] data, String filename) throws CertFileWriterException {
LOGGER.debug("Attempt to save file {} in path {}", filename, destPath);
try (FileOutputStream outputStream = new FileOutputStream(Path.of(destPath, filename).toString())) {
@@ -45,4 +51,12 @@ public class CertFileWriter {
throw new CertFileWriterException(e);
}
}
+
+ private static void createDirIfNotExists(String destPath) {
+ File destFolderPath = new File(destPath);
+ if (!destFolderPath.exists()) {
+ LOGGER.debug("Destination path not exists, subdirectories are created");
+ destFolderPath.mkdirs();
+ }
+ }
}
diff --git a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/writer/CertFileWriterTest.java b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/writer/CertFileWriterTest.java
index 61c4d835..c45876ec 100644
--- a/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/writer/CertFileWriterTest.java
+++ b/certServiceClient/src/test/java/org/onap/aaf/certservice/client/certification/writer/CertFileWriterTest.java
@@ -20,8 +20,8 @@
package org.onap.aaf.certservice.client.certification.writer;
import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
import org.onap.aaf.certservice.client.certification.exception.CertFileWriterException;
import java.io.File;
@@ -35,48 +35,42 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
class CertFileWriterTest {
- private static final String RESOURCES_PATH = "src/test/resources";
- private static final String OUTPUT_PATH = RESOURCES_PATH + "/generatedFiles/";
+ private static final String RESOURCES_PATH = "src/test/resources/";
+ private static final String OUTPUT_PATH = RESOURCES_PATH + "generatedFiles/";
+ private static final String NOT_EXISTING_OUTPUT_PATH = OUTPUT_PATH + "directoryDoesNotExist/";
private static final String TRUSTSTORE_P12 = "truststore.p12";
- private static final String ERROR_MESSAGE = "java.io.FileNotFoundException: src/test/resources/generatedFiles/thisPathDoesNotExist/truststore.p12 (No such file or directory)";
-
private File outputDirectory = new File(OUTPUT_PATH);
- @BeforeEach
- void createDirectory() {
- outputDirectory.mkdir();
- }
-
@AfterEach
void cleanUpFiles() {
- List.of(outputDirectory.listFiles()).forEach(f -> f.delete());
- outputDirectory.delete();
+ deleteDirectoryRecursive(outputDirectory);
}
- @Test
- void certFileWriterShouldCreateFilesWithDataInGivenLocation()
+ @ParameterizedTest
+ @ValueSource(strings = {OUTPUT_PATH, NOT_EXISTING_OUTPUT_PATH})
+ void certFileWriterShouldCreateFilesWithDataInGivenLocation(String outputPath)
throws IOException, CertFileWriterException {
// given
+ File truststore = new File(outputPath + TRUSTSTORE_P12);
+ CertFileWriter certFileWriter = CertFileWriter.createWithDir(outputPath);
final byte[] data = new byte[]{-128, 1, 2, 3, 127};
- File truststore = new File(OUTPUT_PATH + TRUSTSTORE_P12);
- CertFileWriter certFileWriter = new CertFileWriter(OUTPUT_PATH);
// when
certFileWriter.saveData(data, TRUSTSTORE_P12);
// then
assertThat(truststore.exists()).isTrue();
- assertThat(Files.readAllBytes(Path.of(OUTPUT_PATH + TRUSTSTORE_P12))).isEqualTo(data);
+ assertThat(Files.readAllBytes(Path.of(outputPath + TRUSTSTORE_P12))).isEqualTo(data);
}
- @Test
- void certFileWriterShouldThrowCertFileWriterExceptionWhenOutputDirectoryDoesNotExist() {
- // given
- final byte[] data = new byte[]{-128, 1, 2, 3, 0};
- CertFileWriter certFileWriter = new CertFileWriter(OUTPUT_PATH + "thisPathDoesNotExist/");
-
- // when then
- assertThatThrownBy(() -> certFileWriter.saveData(data, TRUSTSTORE_P12))
- .isInstanceOf(CertFileWriterException.class).hasMessage(ERROR_MESSAGE);
+ private void deleteDirectoryRecursive(File dirForDeletion) {
+ List.of(dirForDeletion.listFiles()).forEach(file -> {
+ if (file.isDirectory()) {
+ deleteDirectoryRecursive(file);
+ }
+ file.delete();
+ });
+ dirForDeletion.delete();
}
+
}
diff --git a/certServiceClient/version.properties b/certServiceClient/version.properties
index 7b8b963a..00ef5645 100644
--- a/certServiceClient/version.properties
+++ b/certServiceClient/version.properties
@@ -1,5 +1,5 @@
major=1
-minor=1
+minor=2
patch=0
base_version=${major}.${minor}.${patch}
release_version=${base_version}
diff --git a/docs/sections/release-notes.rst b/docs/sections/release-notes.rst
index 7d32480d..daeab0f2 100644
--- a/docs/sections/release-notes.rst
+++ b/docs/sections/release-notes.rst
@@ -6,6 +6,47 @@
Release Notes
==============
+Version: 1.2.0
+--------------
+
+:Release Date:
+
+**New Features**
+
+ - Client creates subdirectories in given OUTPUT_PATH and place certificate into it.
+
+**Bug Fixes**
+
+ N/A
+
+**Known Issues**
+
+ N/A
+
+**Security Notes**
+
+ N/A
+
+*Fixed Security Issues*
+
+ N/A
+
+*Known Security Issues*
+
+ N/A
+
+*Known Vulnerabilities in Used Modules*
+
+ N/A
+
+**Upgrade Notes**
+
+**Deprecation Notes**
+
+**Other**
+
+===========
+
Version: 1.1.0
--------------
diff --git a/pom.xml b/pom.xml
index b5ca7eff..8126ee99 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
</parent>
<groupId>org.onap.aaf.certservice</groupId>
<artifactId>aaf-certservice</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.2.0-SNAPSHOT</version>
<name>aaf-certservice</name>
<description>AAF Certification Service</description>
<packaging>pom</packaging>
diff --git a/version.properties b/version.properties
index 7b8b963a..00ef5645 100644
--- a/version.properties
+++ b/version.properties
@@ -1,5 +1,5 @@
major=1
-minor=1
+minor=2
patch=0
base_version=${major}.${minor}.${patch}
release_version=${base_version}