summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--certService/pom.xml33
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/CsrModelFactory.java6
-rw-r--r--certService/src/main/java/org/onap/aaf/certservice/certification/PemObjectFactory.java2
-rw-r--r--certService/src/main/resources/application.properties1
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/api/CertificationServiceTest.java2
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/certification/PemObjectFactoryTest.java4
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/certification/model/CsrModelTest.java8
7 files changed, 44 insertions, 12 deletions
diff --git a/certService/pom.xml b/certService/pom.xml
index d5b6e7d3..89e70232 100644
--- a/certService/pom.xml
+++ b/certService/pom.xml
@@ -40,6 +40,8 @@
<bouncycastle.version>1.60</bouncycastle.version>
<docker-maven-plugin.version>0.33.0</docker-maven-plugin.version>
<docker.tag>${project.version}</docker.tag>
+ <springdoc-openapi-maven-plugin.apiDocsUrl>http://localhost:8080/v3/api-docs
+ </springdoc-openapi-maven-plugin.apiDocsUrl>
</properties>
<dependencyManagement>
@@ -135,7 +137,6 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
</plugin>
-
</plugins>
</pluginManagement>
<plugins>
@@ -148,6 +149,18 @@
<goal>repackage</goal>
</goals>
</execution>
+ <execution>
+ <id>pre-integration-test</id>
+ <goals>
+ <goal>start</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>post-integration-test</id>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
</executions>
</plugin>
<plugin>
@@ -174,6 +187,24 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.springdoc</groupId>
+ <artifactId>springdoc-openapi-maven-plugin</artifactId>
+ <version>0.2</version>
+ <executions>
+ <execution>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <apiDocsUrl>${springdoc-openapi-maven-plugin.apiDocsUrl}</apiDocsUrl>
+ <outputFileName>api-docs.json</outputFileName>
+ <outputDir>${project.build.directory}</outputDir>
+ </configuration>
+ </plugin>
</plugins>
</build>
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/CsrModelFactory.java b/certService/src/main/java/org/onap/aaf/certservice/certification/CsrModelFactory.java
index 80858f4d..98daa6eb 100644
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/CsrModelFactory.java
+++ b/certService/src/main/java/org/onap/aaf/certservice/certification/CsrModelFactory.java
@@ -39,14 +39,14 @@ public class CsrModelFactory {
private final PemObjectFactory pemObjectFactory = new PemObjectFactory();
public CsrModel createCsrModel(StringBase64 csr, StringBase64 privateKey) throws CsrDecryptionException {
- LOGGER.debug("Decoded CSR: \n{}", csr.asString());
+ LOGGER.debug("Decoded CSR: \n{}", csr);
try {
- PemObject pemObject = pemObjectFactory.createPmObject(csr.asString());
+ PemObject pemObject = pemObjectFactory.createPemObject(csr.asString());
PKCS10CertificationRequest decodedCsr = new PKCS10CertificationRequest(
pemObject.getContent()
);
- PemObject decodedPrivateKey = pemObjectFactory.createPmObject(privateKey.asString());
+ PemObject decodedPrivateKey = pemObjectFactory.createPemObject(privateKey.asString());
return new CsrModel(decodedCsr, decodedPrivateKey);
} catch (IOException e) {
throw new CsrDecryptionException("Incorrect CSR, decryption failed", e);
diff --git a/certService/src/main/java/org/onap/aaf/certservice/certification/PemObjectFactory.java b/certService/src/main/java/org/onap/aaf/certservice/certification/PemObjectFactory.java
index e3339cc4..08ffc56d 100644
--- a/certService/src/main/java/org/onap/aaf/certservice/certification/PemObjectFactory.java
+++ b/certService/src/main/java/org/onap/aaf/certservice/certification/PemObjectFactory.java
@@ -31,7 +31,7 @@ import org.onap.aaf.certservice.certification.exceptions.CsrDecryptionException;
public class PemObjectFactory {
- public PemObject createPmObject(String pem) throws CsrDecryptionException {
+ public PemObject createPemObject(String pem) throws CsrDecryptionException {
try (StringReader stringReader = new StringReader(pem);
PemReader pemReader = new PemReader(stringReader)) {
diff --git a/certService/src/main/resources/application.properties b/certService/src/main/resources/application.properties
index a157ae66..b9ce108a 100644
--- a/certService/src/main/resources/application.properties
+++ b/certService/src/main/resources/application.properties
@@ -2,3 +2,4 @@
management.endpoints.enabled-by-default=false
management.endpoint.health.enabled=true
springdoc.swagger-ui.path=/docs
+springdoc.show-actuator=true
diff --git a/certService/src/test/java/org/onap/aaf/certservice/api/CertificationServiceTest.java b/certService/src/test/java/org/onap/aaf/certservice/api/CertificationServiceTest.java
index 99ca09b9..9367fcb1 100644
--- a/certService/src/test/java/org/onap/aaf/certservice/api/CertificationServiceTest.java
+++ b/certService/src/test/java/org/onap/aaf/certservice/api/CertificationServiceTest.java
@@ -67,7 +67,7 @@ class CertificationServiceTest {
certificationService.signCertificate("TestCa", "encryptedCSR", "encryptedPK");
// then
- assertEquals(testResponse.getStatusCode(), HttpStatus.OK);
+ assertEquals(HttpStatus.OK, testResponse.getStatusCode());
assertTrue(
testResponse.toString().contains(testStringCsr)
);
diff --git a/certService/src/test/java/org/onap/aaf/certservice/certification/PemObjectFactoryTest.java b/certService/src/test/java/org/onap/aaf/certservice/certification/PemObjectFactoryTest.java
index 67d7f1dc..2fa747db 100644
--- a/certService/src/test/java/org/onap/aaf/certservice/certification/PemObjectFactoryTest.java
+++ b/certService/src/test/java/org/onap/aaf/certservice/certification/PemObjectFactoryTest.java
@@ -46,7 +46,7 @@ class PemObjectFactoryTest {
@Test
void shouldTransformStringInToPemObjectAndBackToString() throws CsrDecryptionException {
// when
- PemObject pemObject = pemObjectFactory.createPmObject(TEST_PEM);
+ PemObject pemObject = pemObjectFactory.createPemObject(TEST_PEM);
String parsedPemObject = pemObjectToString(pemObject);
// then
@@ -57,7 +57,7 @@ class PemObjectFactoryTest {
void shouldThrowExceptionWhenParsingPemFailed() {
// when
Exception exception = assertThrows(
- CsrDecryptionException.class, () -> pemObjectFactory.createPmObject(TEST_WRONG_PEM)
+ CsrDecryptionException.class, () -> pemObjectFactory.createPemObject(TEST_WRONG_PEM)
);
String expectedMessage = "Unable to create PEM";
diff --git a/certService/src/test/java/org/onap/aaf/certservice/certification/model/CsrModelTest.java b/certService/src/test/java/org/onap/aaf/certservice/certification/model/CsrModelTest.java
index ffce61d8..c6ff2a9f 100644
--- a/certService/src/test/java/org/onap/aaf/certservice/certification/model/CsrModelTest.java
+++ b/certService/src/test/java/org/onap/aaf/certservice/certification/model/CsrModelTest.java
@@ -77,7 +77,7 @@ class CsrModelTest {
.thenReturn(wrongKryInfo);
when(wrongKryInfo.getEncoded())
.thenThrow(new IOException());
- PemObject testPrivateKey = pemObjectFactory.createPmObject(TEST_PK);
+ PemObject testPrivateKey = pemObjectFactory.createPemObject(TEST_PK);
CsrModel csrModel = new CsrModel(testCsr, testPrivateKey);
// when
@@ -96,16 +96,16 @@ class CsrModelTest {
private CsrModel generateTestCsrModel() throws CsrDecryptionException, IOException {
PemObjectFactory pemObjectFactory = new PemObjectFactory();
PKCS10CertificationRequest testCsr = new PKCS10CertificationRequest(
- pemObjectFactory.createPmObject(TEST_CSR).getContent()
+ pemObjectFactory.createPemObject(TEST_CSR).getContent()
);
- PemObject testPrivateKey = pemObjectFactory.createPmObject(TEST_PK);
+ PemObject testPrivateKey = pemObjectFactory.createPemObject(TEST_PK);
return new CsrModel(testCsr, testPrivateKey);
}
private PemObject generateTestPublicKey() throws CsrDecryptionException, IOException {
PemObjectFactory pemObjectFactory = new PemObjectFactory();
PKCS10CertificationRequest testCsr = new PKCS10CertificationRequest(
- pemObjectFactory.createPmObject(TEST_CSR).getContent()
+ pemObjectFactory.createPemObject(TEST_CSR).getContent()
);
return new PemObject("PUBLIC KEY", testCsr.getSubjectPublicKeyInfo().getEncoded());
}