<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>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
</plugin>
-
</plugins>
</pluginManagement>
<plugins>
<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>
</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>
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);
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)) {
management.endpoints.enabled-by-default=false
management.endpoint.health.enabled=true
springdoc.swagger-ui.path=/docs
+springdoc.show-actuator=true
certificationService.signCertificate("TestCa", "encryptedCSR", "encryptedPK");
// then
- assertEquals(testResponse.getStatusCode(), HttpStatus.OK);
+ assertEquals(HttpStatus.OK, testResponse.getStatusCode());
assertTrue(
testResponse.toString().contains(testStringCsr)
);
@Test
void shouldTransformStringInToPemObjectAndBackToString() throws CsrDecryptionException {
// when
- PemObject pemObject = pemObjectFactory.createPmObject(TEST_PEM);
+ PemObject pemObject = pemObjectFactory.createPemObject(TEST_PEM);
String parsedPemObject = pemObjectToString(pemObject);
// then
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";
.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
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());
}