summaryrefslogtreecommitdiffstats
path: root/certService/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'certService/src/test/java/org')
-rw-r--r--certService/src/test/java/org/onap/oom/certservice/api/CertificationControllerTest.java39
-rw-r--r--certService/src/test/java/org/onap/oom/certservice/certification/CertificationData.java128
-rw-r--r--certService/src/test/java/org/onap/oom/certservice/certification/CertificationProviderTest.java86
-rw-r--r--certService/src/test/java/org/onap/oom/certservice/certification/CertificationResponseModelFactoryTest.java (renamed from certService/src/test/java/org/onap/oom/certservice/certification/CertificationModelFactoryTest.java)86
-rw-r--r--certService/src/test/java/org/onap/oom/certservice/certification/TestUtils.java2
-rw-r--r--certService/src/test/java/org/onap/oom/certservice/certification/conversion/CsrModelFactoryTest.java (renamed from certService/src/test/java/org/onap/oom/certservice/certification/CsrModelFactoryTest.java)17
-rw-r--r--certService/src/test/java/org/onap/oom/certservice/certification/conversion/OldCertificateModelFactoryTest.java (renamed from certService/src/test/java/org/onap/oom/certservice/certification/X509CertificateModelFactoryTest.java)56
-rw-r--r--certService/src/test/java/org/onap/oom/certservice/certification/conversion/PemObjectFactoryTest.java (renamed from certService/src/test/java/org/onap/oom/certservice/certification/PemObjectFactoryTest.java)12
-rw-r--r--certService/src/test/java/org/onap/oom/certservice/certification/conversion/PemStringToCertificateConverterTest.java (renamed from certService/src/test/java/org/onap/oom/certservice/certification/PemStringToCertificateConverterTest.java)2
-rw-r--r--certService/src/test/java/org/onap/oom/certservice/certification/conversion/RsaContentSignerBuilderTest.java (renamed from certService/src/test/java/org/onap/oom/certservice/certification/RsaContentSignerBuilderTest.java)14
-rw-r--r--certService/src/test/java/org/onap/oom/certservice/certification/conversion/X509CertificateBuilderTest.java (renamed from certService/src/test/java/org/onap/oom/certservice/certification/X509CertificateBuilderTest.java)13
-rw-r--r--certService/src/test/java/org/onap/oom/certservice/certification/model/CsrModelTest.java4
-rw-r--r--certService/src/test/java/org/onap/oom/certservice/cmpv2client/ClientTestData.java50
-rw-r--r--certService/src/test/java/org/onap/oom/certservice/cmpv2client/Cmpv2ClientTest.java31
14 files changed, 357 insertions, 183 deletions
diff --git a/certService/src/test/java/org/onap/oom/certservice/api/CertificationControllerTest.java b/certService/src/test/java/org/onap/oom/certservice/api/CertificationControllerTest.java
index 4ac0b50d..81c2d39a 100644
--- a/certService/src/test/java/org/onap/oom/certservice/api/CertificationControllerTest.java
+++ b/certService/src/test/java/org/onap/oom/certservice/api/CertificationControllerTest.java
@@ -34,13 +34,13 @@ import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.oom.certservice.certification.exception.CertificateDecryptionException;
import org.onap.oom.certservice.certification.model.CertificateUpdateModel;
-import org.onap.oom.certservice.certification.CertificationModelFactory;
+import org.onap.oom.certservice.certification.CertificationResponseModelFactory;
import org.onap.oom.certservice.certification.exception.Cmpv2ServerNotFoundException;
import org.onap.oom.certservice.certification.exception.CsrDecryptionException;
import org.onap.oom.certservice.certification.exception.DecryptionException;
import org.onap.oom.certservice.certification.exception.KeyDecryptionException;
import org.onap.oom.certservice.certification.model.CertificateUpdateModel.CertificateUpdateModelBuilder;
-import org.onap.oom.certservice.certification.model.CertificationModel;
+import org.onap.oom.certservice.certification.model.CertificationResponseModel;
import org.onap.oom.certservice.cmpv2client.exceptions.CmpClientException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -67,32 +67,33 @@ class CertificationControllerTest {
private CertificationController certificationController;
@Mock
- private CertificationModelFactory certificationModelFactory;
+ private CertificationResponseModelFactory certificationResponseModelFactory;
@BeforeEach
void serUp() {
- certificationController = new CertificationController(certificationModelFactory);
+ certificationController = new CertificationController(certificationResponseModelFactory);
}
@Test
void shouldReturnDataAboutCsrBaseOnEncodedParameters()
throws DecryptionException, CmpClientException {
// Given
- CertificationModel testCertificationModel = new CertificationModel(
+ CertificationResponseModel testCertificationResponseModel = new CertificationResponseModel(
Arrays.asList("ENTITY_CERT", "INTERMEDIATE_CERT"),
Arrays.asList("CA_CERT", "EXTRA_CA_CERT")
);
- when(certificationModelFactory.createCertificationModel(TEST_ENCODED_CSR, TEST_ENCODED_PK, TEST_CA_NAME))
- .thenReturn(testCertificationModel);
+ when(certificationResponseModelFactory
+ .provideCertificationModelFromInitialRequest(TEST_ENCODED_CSR, TEST_ENCODED_PK, TEST_CA_NAME))
+ .thenReturn(testCertificationResponseModel);
// When
- ResponseEntity<CertificationModel> responseCertificationModel =
+ ResponseEntity<CertificationResponseModel> responseCertificationModel =
certificationController.signCertificate(TEST_CA_NAME, TEST_ENCODED_CSR, TEST_ENCODED_PK);
// Then
assertEquals(HttpStatus.OK, responseCertificationModel.getStatusCode());
assertThat(responseCertificationModel.getBody()
- ).isEqualToComparingFieldByField(testCertificationModel);
+ ).isEqualToComparingFieldByField(testCertificationResponseModel);
}
@@ -101,7 +102,8 @@ class CertificationControllerTest {
throws DecryptionException, CmpClientException {
// Given
String expectedMessage = "Incorrect CSR, decryption failed";
- when(certificationModelFactory.createCertificationModel(TEST_WRONG_ENCODED_CSR, TEST_ENCODED_PK, TEST_CA_NAME))
+ when(certificationResponseModelFactory
+ .provideCertificationModelFromInitialRequest(TEST_WRONG_ENCODED_CSR, TEST_ENCODED_PK, TEST_CA_NAME))
.thenThrow(new CsrDecryptionException(expectedMessage));
// When
@@ -121,7 +123,8 @@ class CertificationControllerTest {
throws DecryptionException, CmpClientException {
// Given
String expectedMessage = "Incorrect PEM, decryption failed";
- when(certificationModelFactory.createCertificationModel(TEST_ENCODED_CSR, TEST_WRONG_ENCODED_PK, TEST_CA_NAME))
+ when(certificationResponseModelFactory
+ .provideCertificationModelFromInitialRequest(TEST_ENCODED_CSR, TEST_WRONG_ENCODED_PK, TEST_CA_NAME))
.thenThrow(new KeyDecryptionException(expectedMessage));
// When
@@ -141,7 +144,8 @@ class CertificationControllerTest {
throws DecryptionException, CmpClientException {
// Given
String expectedMessage = "No server found for given CA name";
- when(certificationModelFactory.createCertificationModel(TEST_ENCODED_CSR, TEST_ENCODED_PK, TEST_WRONG_CA_NAME))
+ when(certificationResponseModelFactory
+ .provideCertificationModelFromInitialRequest(TEST_ENCODED_CSR, TEST_ENCODED_PK, TEST_WRONG_CA_NAME))
.thenThrow(new Cmpv2ServerNotFoundException(expectedMessage));
// When
@@ -160,20 +164,21 @@ class CertificationControllerTest {
void shouldUpdateEndpointReturnDataAboutCsrBaseOnEncodedParameters()
throws DecryptionException, CmpClientException, CertificateDecryptionException {
// Given
- CertificationModel testCertificationModel = new CertificationModel(
+ CertificationResponseModel testCertificationResponseModel = new CertificationResponseModel(
Arrays.asList("ENTITY_CERT", "INTERMEDIATE_CERT"),
Arrays.asList("CA_CERT", "EXTRA_CA_CERT")
);
- when(certificationModelFactory.createCertificationModel(TEST_CERTIFICATE_UPDATE_MODEL)).thenReturn(testCertificationModel);
+ when(certificationResponseModelFactory.provideCertificationModelFromUpdateRequest(TEST_CERTIFICATE_UPDATE_MODEL)).thenReturn(
+ testCertificationResponseModel);
// When
- ResponseEntity<CertificationModel> responseCertificationModel =
+ ResponseEntity<CertificationResponseModel> responseCertificationModel =
certificationController.updateCertificate(TEST_CA_NAME, TEST_ENCODED_CSR,
TEST_ENCODED_PK, TEST_ENCODED_OLD_CERT, TEST_ENCODED_OLD_PK);
// Then
assertEquals(HttpStatus.OK, responseCertificationModel.getStatusCode());
- assertThat(responseCertificationModel.getBody()).isEqualToComparingFieldByField(testCertificationModel);
+ assertThat(responseCertificationModel.getBody()).isEqualToComparingFieldByField(testCertificationResponseModel);
}
@Test
@@ -181,7 +186,7 @@ class CertificationControllerTest {
throws DecryptionException, CertificateDecryptionException, CmpClientException {
// Given
String expectedMessage = "Incorrect certificate, decryption failed";
- when(certificationModelFactory.createCertificationModel(TEST_CERTIFICATE_UPDATE_MODEL))
+ when(certificationResponseModelFactory.provideCertificationModelFromUpdateRequest(TEST_CERTIFICATE_UPDATE_MODEL))
.thenThrow(new CertificateDecryptionException(expectedMessage));
// When
diff --git a/certService/src/test/java/org/onap/oom/certservice/certification/CertificationData.java b/certService/src/test/java/org/onap/oom/certservice/certification/CertificationData.java
new file mode 100644
index 00000000..11e81807
--- /dev/null
+++ b/certService/src/test/java/org/onap/oom/certservice/certification/CertificationData.java
@@ -0,0 +1,128 @@
+/*
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.oom.certservice.certification;
+
+
+final class CertificationData {
+
+ private CertificationData() {
+ }
+
+ private static final String BEGIN_CERTIFICATE = "-----BEGIN CERTIFICATE-----\n";
+ private static final String END_CERTIFICATE = "-----END CERTIFICATE-----";
+
+ static final String EXTRA_CA_CERT = ""
+ + BEGIN_CERTIFICATE
+ + "MIIDvzCCAqcCFF5DejiyfoNfPiiMmBXulniBewBGMA0GCSqGSIb3DQEBCwUAMIGb\n"
+ + "MQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2Fu\n"
+ + "LUZyYW5jaXNjbzEZMBcGA1UECgwQTGludXgtRm91bmRhdGlvbjENMAsGA1UECwwE\n"
+ + "T05BUDEVMBMGA1UEAwwMbmV3Lm9uYXAub3JnMR4wHAYJKoZIhvcNAQkBFg90ZXN0\n"
+ + "ZXJAb25hcC5vcmcwHhcNMjAwMjEyMDk1OTM3WhcNMjEwMjExMDk1OTM3WjCBmzEL\n"
+ + "MAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDVNhbi1G\n"
+ + "cmF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G88UCmbwN\n"
+ + "d7BoGMy06y5MJxyXEZG0vR7eNeLey0TIh+rAszAFPsIQvrOHW+HuA+WLQAj1mhnm\n"
+ + END_CERTIFICATE;
+
+}
diff --git a/certService/src/test/java/org/onap/oom/certservice/certification/CertificationProviderTest.java b/certService/src/test/java/org/onap/oom/certservice/certification/CertificationProviderTest.java
index 7d75a655..192050dc 100644
--- a/certService/src/test/java/org/onap/oom/certservice/certification/CertificationProviderTest.java
+++ b/certService/src/test/java/org/onap/oom/certservice/certification/CertificationProviderTest.java
@@ -20,8 +20,25 @@
package org.onap.oom.certservice.certification;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+import static org.onap.oom.certservice.certification.TestData.TEST_CMPv2_KEYSTORE;
+import static org.onap.oom.certservice.certification.TestData.TEST_CMPv2_TRUSTSTORE;
+
+import java.io.IOException;
+import java.io.InputStream;
import java.io.StringReader;
+import java.nio.charset.StandardCharsets;
+import java.security.NoSuchProviderException;
+import java.security.Security;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+import java.util.Collections;
import java.util.List;
+import java.util.Objects;
import org.apache.commons.io.IOUtils;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter;
@@ -33,30 +50,13 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.oom.certservice.certification.configuration.model.Cmpv2Server;
-import org.onap.oom.certservice.certification.model.CertificateUpdateModel;
-import org.onap.oom.certservice.certification.model.CertificateUpdateModel.CertificateUpdateModelBuilder;
-import org.onap.oom.certservice.certification.model.CertificationModel;
+import org.onap.oom.certservice.certification.model.CertificationResponseModel;
import org.onap.oom.certservice.certification.model.CsrModel;
+import org.onap.oom.certservice.certification.model.OldCertificateModel;
import org.onap.oom.certservice.cmpv2client.api.CmpClient;
import org.onap.oom.certservice.cmpv2client.exceptions.CmpClientException;
import org.onap.oom.certservice.cmpv2client.model.Cmpv2CertificationModel;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-import java.security.NoSuchProviderException;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-import java.util.Collections;
-import java.util.Objects;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.when;
-import static org.onap.oom.certservice.certification.TestData.TEST_CMPv2_KEYSTORE;
-import static org.onap.oom.certservice.certification.TestData.TEST_CMPv2_TRUSTSTORE;
-
@ExtendWith(MockitoExtension.class)
class CertificationProviderTest {
@@ -71,19 +71,18 @@ class CertificationProviderTest {
private Cmpv2Server testServer;
@Mock
private CmpClient cmpClient;
+ @Mock
+ private OldCertificateModel oldCertificateModel;
private CertificationProvider certificationProvider;
- private static final CertificateUpdateModel TEST_CERTIFICATE_UPDATE_MODEL = new CertificateUpdateModelBuilder()
- .setEncodedCsr("encodedCSR")
- .setEncodedPrivateKey("encodedPK")
- .setEncodedOldCert("encodedOldCert")
- .setEncodedOldPrivateKey("encodedOldPK")
- .setCaName("TestCA")
- .build();
private static final String EXPECTED_BEGIN_OF_CERTIFICATE = "-----BEGIN CERTIFICATE-----\n";
private static final String EXPECTED_END_OF_CERTIFICATE = "-----END CERTIFICATE-----\n";
+ static {
+ Security.addProvider(new BouncyCastleProvider());
+ }
+
@BeforeEach
public void init() {
certificationProvider = new CertificationProvider(cmpClient);
@@ -94,10 +93,10 @@ class CertificationProviderTest {
throws CertificateException, NoSuchProviderException, IOException, CmpClientException {
// When
when(
- cmpClient.createCertificate(any(CsrModel.class), any(Cmpv2Server.class))
+ cmpClient.executeInitializationRequest(any(CsrModel.class), any(Cmpv2Server.class))
).thenReturn(createCorrectClientResponse());
- CertificationModel certificationModel = certificationProvider.signCsr(csrModel, server);
+ CertificationResponseModel certificationModel = certificationProvider.executeInitializationRequest(csrModel, server);
// Then
InputStream certificate = getClass().getClassLoader().getResourceAsStream("certificateModelChain.first");
@@ -114,8 +113,6 @@ class CertificationProviderTest {
assertThat(trustedCertificateModel).isEqualTo(expectedTrustedCertificate);
}
-
-
@Test
void certificationProviderThrowCmpClientWhenCallingClientFailsForSignCsr()
throws CmpClientException {
@@ -123,13 +120,13 @@ class CertificationProviderTest {
String expectedErrorMessage = "connecting to CMP client failed";
when(
- cmpClient.createCertificate(any(CsrModel.class), any(Cmpv2Server.class))
+ cmpClient.executeInitializationRequest(any(CsrModel.class), any(Cmpv2Server.class))
).thenThrow(new CmpClientException(expectedErrorMessage));
// When
Exception exception = assertThrows(
CmpClientException.class, () ->
- certificationProvider.signCsr(testCsrModel, testServer)
+ certificationProvider.executeInitializationRequest(testCsrModel, testServer)
);
// Then
@@ -142,11 +139,11 @@ class CertificationProviderTest {
// When
when(
- cmpClient.updateCertificate(any(CsrModel.class), any(Cmpv2Server.class), any(CertificateUpdateModel.class))
+ cmpClient.executeKeyUpdateRequest(any(CsrModel.class), any(Cmpv2Server.class), any(OldCertificateModel.class))
).thenReturn(getCMPv2CertificationModel());
- CertificationModel certificationModel = certificationProvider
- .updateCertificate(csrModel, server, TEST_CERTIFICATE_UPDATE_MODEL);
+ CertificationResponseModel certificationModel = certificationProvider
+ .executeKeyUpdateRequest(csrModel, server, oldCertificateModel);
List<String> certificateChain = certificationModel.getCertificateChain();
List<String> trustedCertificates = certificationModel.getTrustedCertificates();
@@ -164,11 +161,11 @@ class CertificationProviderTest {
throws IOException, CertificateException, CmpClientException {
when(
- cmpClient.certificationRequest(any(CsrModel.class), any(Cmpv2Server.class))
+ cmpClient.executeInitializationRequest(any(CsrModel.class), any(Cmpv2Server.class))
).thenReturn(getCMPv2CertificationModel());
- CertificationModel certificationModel = certificationProvider
- .certificationRequest(csrModel, server);
+ CertificationResponseModel certificationModel = certificationProvider
+ .executeInitializationRequest(csrModel, server);
List<String> certificateChain = certificationModel.getCertificateChain();
List<String> trustedCertificates = certificationModel.getTrustedCertificates();
@@ -188,13 +185,13 @@ class CertificationProviderTest {
String expectedErrorMessage = "Exception occurred while send request to CMPv2 Server";
when(
- cmpClient.updateCertificate(any(CsrModel.class), any(Cmpv2Server.class), any(CertificateUpdateModel.class))
+ cmpClient.executeKeyUpdateRequest(any(CsrModel.class), any(Cmpv2Server.class), any(OldCertificateModel.class))
).thenThrow(new CmpClientException(expectedErrorMessage));
// When
Exception exception = assertThrows(
CmpClientException.class, () ->
- certificationProvider.updateCertificate(testCsrModel, testServer, TEST_CERTIFICATE_UPDATE_MODEL)
+ certificationProvider.executeKeyUpdateRequest(testCsrModel, testServer, oldCertificateModel)
);
// Then
@@ -206,9 +203,8 @@ class CertificationProviderTest {
throws CertificateException, NoSuchProviderException {
InputStream certificateChain = getClass().getClassLoader().getResourceAsStream("certificateChain.first");
InputStream trustedCertificate = getClass().getClassLoader().getResourceAsStream("trustedCertificates.first");
- X509Certificate x509Certificate = new CertificateFactoryProvider().generateCertificate(certificateChain);
- X509Certificate x509TrustedCertificate =
- new CertificateFactoryProvider().generateCertificate(trustedCertificate);
+ X509Certificate x509Certificate = generateCertificate(certificateChain);
+ X509Certificate x509TrustedCertificate = generateCertificate(trustedCertificate);
return new Cmpv2CertificationModel(
Collections.singletonList(x509Certificate),
Collections.singletonList(x509TrustedCertificate));
@@ -233,4 +229,8 @@ class CertificationProviderTest {
.getCertificate(certHolder);
return List.of(x509Certificate);
}
+
+ private X509Certificate generateCertificate(InputStream inStream) throws CertificateException, NoSuchProviderException {
+ return (X509Certificate) CertificateFactory.getInstance("X.509", "BC").generateCertificate(inStream);
+ }
}
diff --git a/certService/src/test/java/org/onap/oom/certservice/certification/CertificationModelFactoryTest.java b/certService/src/test/java/org/onap/oom/certservice/certification/CertificationResponseModelFactoryTest.java
index c7454f46..205513f5 100644
--- a/certService/src/test/java/org/onap/oom/certservice/certification/CertificationModelFactoryTest.java
+++ b/certService/src/test/java/org/onap/oom/certservice/certification/CertificationResponseModelFactoryTest.java
@@ -48,19 +48,22 @@ import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.onap.oom.certservice.certification.configuration.Cmpv2ServerProvider;
import org.onap.oom.certservice.certification.configuration.model.Cmpv2Server;
+import org.onap.oom.certservice.certification.conversion.CsrModelFactory;
+import org.onap.oom.certservice.certification.conversion.OldCertificateModelFactory;
+import org.onap.oom.certservice.certification.conversion.StringBase64;
import org.onap.oom.certservice.certification.exception.CertificateDecryptionException;
import org.onap.oom.certservice.certification.exception.Cmpv2ServerNotFoundException;
import org.onap.oom.certservice.certification.exception.CsrDecryptionException;
import org.onap.oom.certservice.certification.exception.DecryptionException;
import org.onap.oom.certservice.certification.model.CertificateUpdateModel;
import org.onap.oom.certservice.certification.model.CertificateUpdateModel.CertificateUpdateModelBuilder;
-import org.onap.oom.certservice.certification.model.CertificationModel;
+import org.onap.oom.certservice.certification.model.CertificationResponseModel;
import org.onap.oom.certservice.certification.model.CsrModel;
-import org.onap.oom.certservice.certification.model.X509CertificateModel;
+import org.onap.oom.certservice.certification.model.OldCertificateModel;
import org.onap.oom.certservice.cmpv2client.exceptions.CmpClientException;
@ExtendWith(MockitoExtension.class)
-class CertificationModelFactoryTest {
+class CertificationResponseModelFactoryTest {
private static final String TEST_CA_NAME = "TestCA";
private static final String ENCODED_CSR = getEncodedString(TEST_CSR);
@@ -80,7 +83,7 @@ class CertificationModelFactoryTest {
.setCaName(TEST_CA_NAME)
.build();
- private CertificationModelFactory certificationModelFactory;
+ private CertificationResponseModelFactory certificationResponseModelFactory;
@Mock
private Cmpv2ServerProvider cmpv2ServerProvider;
@@ -89,9 +92,11 @@ class CertificationModelFactoryTest {
@Mock
private CertificationProvider certificationProvider;
@Mock
- private X509CertificateModelFactory x509CertificateModelFactory;
+ private OldCertificateModelFactory oldCertificateModelFactory;
@Mock
private UpdateRequestTypeDetector updateRequestTypeDetector;
+ @Mock
+ private OldCertificateModel testOldCertificateModel;
private static String getEncodedString(String testCsr) {
return Base64.getEncoder().encodeToString(testCsr.getBytes());
@@ -99,9 +104,9 @@ class CertificationModelFactoryTest {
@BeforeEach
void setUp() {
- certificationModelFactory =
- new CertificationModelFactory(csrModelFactory, cmpv2ServerProvider, certificationProvider,
- x509CertificateModelFactory, updateRequestTypeDetector);
+ certificationResponseModelFactory =
+ new CertificationResponseModelFactory(csrModelFactory, cmpv2ServerProvider, certificationProvider,
+ oldCertificateModelFactory, updateRequestTypeDetector);
}
@Test
@@ -114,8 +119,9 @@ class CertificationModelFactoryTest {
mockCertificateProviderCertificateSigning(csrModel, testServer);
// When
- CertificationModel certificationModel =
- certificationModelFactory.createCertificationModel(ENCODED_CSR, ENCODED_PK, TEST_CA_NAME);
+ CertificationResponseModel certificationModel =
+ certificationResponseModelFactory
+ .provideCertificationModelFromInitialRequest(ENCODED_CSR, ENCODED_PK, TEST_CA_NAME);
// Then
assertEquals(2, certificationModel.getCertificateChain().size());
@@ -141,7 +147,8 @@ class CertificationModelFactoryTest {
// When
Exception exception = assertThrows(
DecryptionException.class, () ->
- certificationModelFactory.createCertificationModel(ENCODED_WRONG_CSR, ENCODED_WRONG_PK, TEST_CA_NAME)
+ certificationResponseModelFactory
+ .provideCertificationModelFromInitialRequest(ENCODED_WRONG_CSR, ENCODED_WRONG_PK, TEST_CA_NAME)
);
// Then
@@ -163,7 +170,8 @@ class CertificationModelFactoryTest {
// When
Exception exception = assertThrows(
Cmpv2ServerNotFoundException.class, () ->
- certificationModelFactory.createCertificationModel(ENCODED_CSR, ENCODED_PK, TEST_CA_NAME)
+ certificationResponseModelFactory
+ .provideCertificationModelFromInitialRequest(ENCODED_CSR, ENCODED_PK, TEST_CA_NAME)
);
// Then
@@ -178,7 +186,7 @@ class CertificationModelFactoryTest {
CsrModel csrModel = mockCsrFactoryModelCreation();
Cmpv2Server testServer = mockCmpv2ProviderServerSelection();
when(
- certificationProvider.signCsr(csrModel, testServer)
+ certificationProvider.executeInitializationRequest(csrModel, testServer)
).thenThrow(
new CmpClientException(expectedMessage)
);
@@ -186,7 +194,8 @@ class CertificationModelFactoryTest {
// When
Exception exception = assertThrows(
CmpClientException.class, () ->
- certificationModelFactory.createCertificationModel(ENCODED_CSR, ENCODED_PK, TEST_CA_NAME)
+ certificationResponseModelFactory
+ .provideCertificationModelFromInitialRequest(ENCODED_CSR, ENCODED_PK, TEST_CA_NAME)
);
// Then
@@ -196,16 +205,17 @@ class CertificationModelFactoryTest {
@Test
void shouldPerformKurWhenCsrAndOldCertDataMatch()
throws CertificateDecryptionException, DecryptionException, CmpClientException {
- //given
+ // Given
CsrModel csrModel = mockCsrFactoryModelCreation();
Cmpv2Server testServer = mockCmpv2ProviderServerSelection();
mockCertificateProviderCertificateUpdate(csrModel, testServer);
mockCertificateFactoryModelCreation();
when(updateRequestTypeDetector.isKur(any(), any())).thenReturn(true);
- //when, then
+ when(oldCertificateModelFactory.createCertificateModel(any(), any())).thenReturn(testOldCertificateModel);
- CertificationModel certificationModel = certificationModelFactory
- .createCertificationModel(TEST_CERTIFICATE_UPDATE_MODEL);
+ // When
+ CertificationResponseModel certificationModel = certificationResponseModelFactory
+ .provideCertificationModelFromUpdateRequest(TEST_CERTIFICATE_UPDATE_MODEL);
// Then
assertEquals(2, certificationModel.getCertificateChain().size());
@@ -214,7 +224,7 @@ class CertificationModelFactoryTest {
assertThat(certificationModel.getTrustedCertificates()).contains(CA_CERT, EXTRA_CA_CERT);
verify(certificationProvider, times(1))
- .updateCertificate(csrModel, testServer, TEST_CERTIFICATE_UPDATE_MODEL);
+ .executeKeyUpdateRequest(csrModel, testServer, testOldCertificateModel);
}
@Test
@@ -227,14 +237,15 @@ class CertificationModelFactoryTest {
Cmpv2Server testServer = mockCmpv2ProviderServerSelection();
mockCertificateFactoryModelCreation();
- when(certificationProvider.updateCertificate(csrModel, testServer, TEST_CERTIFICATE_UPDATE_MODEL))
+ when(oldCertificateModelFactory.createCertificateModel(any(), any())).thenReturn(testOldCertificateModel);
+ when(certificationProvider.executeKeyUpdateRequest(csrModel, testServer, testOldCertificateModel))
.thenThrow(new CmpClientException(expectedMessage));
when(updateRequestTypeDetector.isKur(any(), any())).thenReturn(true);
// When
Exception exception = assertThrows(
CmpClientException.class, () ->
- certificationModelFactory.createCertificationModel(TEST_CERTIFICATE_UPDATE_MODEL)
+ certificationResponseModelFactory.provideCertificationModelFromUpdateRequest(TEST_CERTIFICATE_UPDATE_MODEL)
);
// Then
@@ -251,8 +262,8 @@ class CertificationModelFactoryTest {
mockCertificateFactoryModelCreation();
// When
when(updateRequestTypeDetector.isKur(any(), any())).thenReturn(false);
- CertificationModel certificationModel = certificationModelFactory
- .createCertificationModel(TEST_CERTIFICATE_UPDATE_MODEL);
+ CertificationResponseModel certificationModel = certificationResponseModelFactory
+ .provideCertificationModelFromUpdateRequest(TEST_CERTIFICATE_UPDATE_MODEL);
// Then
assertEquals(2, certificationModel.getCertificateChain().size());
assertThat(certificationModel.getCertificateChain()).contains(INTERMEDIATE_CERT, ENTITY_CERT);
@@ -260,43 +271,43 @@ class CertificationModelFactoryTest {
assertThat(certificationModel.getTrustedCertificates()).contains(CA_CERT, EXTRA_CA_CERT);
verify(certificationProvider, times(1))
- .certificationRequest(csrModel, testServer);
+ .executeCertificationRequest(csrModel, testServer);
}
@Test
void shouldThrowCertificateDecryptionExceptionWhenOldCertificateInvalid()
throws CertificateDecryptionException {
//given
- when(x509CertificateModelFactory.createCertificateModel(any()))
+ when(oldCertificateModelFactory.createCertificateModel(any(), any()))
.thenThrow(new CertificateDecryptionException("Incorrect certificate, decryption failed"));
//when, then
assertThrows(
CertificateDecryptionException.class, () ->
- certificationModelFactory.createCertificationModel(TEST_CERTIFICATE_UPDATE_MODEL)
+ certificationResponseModelFactory.provideCertificationModelFromUpdateRequest(TEST_CERTIFICATE_UPDATE_MODEL)
);
}
private void mockCertificateProviderCertificateUpdate(CsrModel csrModel, Cmpv2Server testServer)
throws CmpClientException {
- CertificationModel expectedCertificationModel = getCertificationModel();
+ CertificationResponseModel expectedCertificationModel = getCertificationModel();
when(
- certificationProvider.updateCertificate(csrModel, testServer, TEST_CERTIFICATE_UPDATE_MODEL)
+ certificationProvider.executeKeyUpdateRequest(csrModel, testServer, testOldCertificateModel)
).thenReturn(expectedCertificationModel);
}
private void mockCertificateProviderCertificationRequest(CsrModel csrModel, Cmpv2Server testServer)
throws CmpClientException {
- CertificationModel expectedCertificationModel = getCertificationModel();
+ CertificationResponseModel expectedCertificationModel = getCertificationModel();
when(
- certificationProvider.certificationRequest(csrModel, testServer)
+ certificationProvider.executeCertificationRequest(csrModel, testServer)
).thenReturn(expectedCertificationModel);
}
private void mockCertificateProviderCertificateSigning(CsrModel csrModel, Cmpv2Server testServer)
throws CmpClientException {
- CertificationModel expectedCertificationModel = getCertificationModel();
+ CertificationResponseModel expectedCertificationModel = getCertificationModel();
when(
- certificationProvider.signCsr(csrModel, testServer)
+ certificationProvider.executeInitializationRequest(csrModel, testServer)
).thenReturn(expectedCertificationModel);
}
@@ -315,10 +326,10 @@ class CertificationModelFactoryTest {
return csrModel;
}
- private X509CertificateModel mockCertificateFactoryModelCreation()
+ private OldCertificateModel mockCertificateFactoryModelCreation()
throws CertificateDecryptionException {
- final X509CertificateModel certificateModel = mock(X509CertificateModel.class);
- when(x509CertificateModelFactory.createCertificateModel(any())).thenReturn(certificateModel);
+ final OldCertificateModel certificateModel = mock(OldCertificateModel.class);
+ when(oldCertificateModelFactory.createCertificateModel(any(), any())).thenReturn(certificateModel);
return certificateModel;
}
@@ -330,11 +341,10 @@ class CertificationModelFactoryTest {
return mock(CsrModel.class);
}
- private CertificationModel getCertificationModel() {
+ private CertificationResponseModel getCertificationModel() {
List<String> testTrustedCertificates = Arrays.asList(CA_CERT, EXTRA_CA_CERT);
List<String> testCertificationChain = Arrays.asList(INTERMEDIATE_CERT, ENTITY_CERT);
- return new CertificationModel(testCertificationChain, testTrustedCertificates);
+ return new CertificationResponseModel(testCertificationChain, testTrustedCertificates);
}
-
}
diff --git a/certService/src/test/java/org/onap/oom/certservice/certification/TestUtils.java b/certService/src/test/java/org/onap/oom/certservice/certification/TestUtils.java
index 0dceda19..0284b0af 100644
--- a/certService/src/test/java/org/onap/oom/certservice/certification/TestUtils.java
+++ b/certService/src/test/java/org/onap/oom/certservice/certification/TestUtils.java
@@ -23,6 +23,8 @@ package org.onap.oom.certservice.certification;
import org.bouncycastle.util.encoders.Base64;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemWriter;
+import org.onap.oom.certservice.certification.conversion.CsrModelFactory;
+import org.onap.oom.certservice.certification.conversion.StringBase64;
import org.onap.oom.certservice.certification.exception.DecryptionException;
import org.onap.oom.certservice.certification.exception.KeyDecryptionException;
import org.onap.oom.certservice.certification.model.CsrModel;
diff --git a/certService/src/test/java/org/onap/oom/certservice/certification/CsrModelFactoryTest.java b/certService/src/test/java/org/onap/oom/certservice/certification/conversion/CsrModelFactoryTest.java
index eb6a0550..26624867 100644
--- a/certService/src/test/java/org/onap/oom/certservice/certification/CsrModelFactoryTest.java
+++ b/certService/src/test/java/org/onap/oom/certservice/certification/conversion/CsrModelFactoryTest.java
@@ -18,23 +18,24 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.oom.certservice.certification;
+package org.onap.oom.certservice.certification.conversion;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.onap.oom.certservice.certification.TestData.TEST_CSR;
+import static org.onap.oom.certservice.certification.TestData.TEST_PK;
+import static org.onap.oom.certservice.certification.TestData.TEST_WRONG_CSR;
+import static org.onap.oom.certservice.certification.TestData.TEST_WRONG_PEM;
import org.bouncycastle.util.encoders.Base64;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.onap.oom.certservice.certification.TestData;
import org.onap.oom.certservice.certification.exception.CsrDecryptionException;
import org.onap.oom.certservice.certification.exception.DecryptionException;
import org.onap.oom.certservice.certification.exception.KeyDecryptionException;
import org.onap.oom.certservice.certification.model.CsrModel;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.onap.oom.certservice.certification.TestData.TEST_CSR;
-import static org.onap.oom.certservice.certification.TestData.TEST_PK;
-import static org.onap.oom.certservice.certification.TestData.TEST_WRONG_CSR;
-import static org.onap.oom.certservice.certification.TestData.TEST_WRONG_PEM;
-
class CsrModelFactoryTest {
diff --git a/certService/src/test/java/org/onap/oom/certservice/certification/X509CertificateModelFactoryTest.java b/certService/src/test/java/org/onap/oom/certservice/certification/conversion/OldCertificateModelFactoryTest.java
index bad4887b..4adf0355 100644
--- a/certService/src/test/java/org/onap/oom/certservice/certification/X509CertificateModelFactoryTest.java
+++ b/certService/src/test/java/org/onap/oom/certservice/certification/conversion/OldCertificateModelFactoryTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.oom.certservice.certification;
+package org.onap.oom.certservice.certification.conversion;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -26,10 +26,11 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x509.GeneralName;
import org.junit.jupiter.api.Test;
+import org.onap.oom.certservice.certification.X509CertificateParser;
import org.onap.oom.certservice.certification.exception.CertificateDecryptionException;
-import org.onap.oom.certservice.certification.model.X509CertificateModel;
+import org.onap.oom.certservice.certification.model.OldCertificateModel;
-class X509CertificateModelFactoryTest {
+class OldCertificateModelFactoryTest {
private static final String ENCODED_CERTIFICATE_STRING =
"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUVpekNDQXZPZ0F3SUJBZ0lVR0VwMkdaNlk4"
@@ -123,11 +124,44 @@ class X509CertificateModelFactoryTest {
+ "bE8wdHErc2lJK1Y0T3lORkhadnJHQUNaUTNxYUFUZlozYlN3RVcKYkg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TlncDJ1NTM4L0M2Rm15ZnVxZXpZbm1Nd1dzQn"
+ + "FwRXJ5MCtCc3Y4ZG1sOVdSUE9NZU56c2E0UFUKVzdTWjJCMHZWMndBZTBCT2JzRTVpSmxnRzZaam"
+ + "JYR25TRjI0NTl4TzJRS0JnRER1cXJBcThQMXpXU28wcWZ0QgpkTS9Xc3p6U3VZRHdjemhvajNKek"
+ + "5VK3lvQ3g4ejNzY0NML240eXFUT1RiWVhLTXFHbUVrSW01eXJ1SWlJeHBRCmNJM1pDUlVZbHZDY0"
+ + "FaeCtiVU1QSXNkek1TeGJMaHNqSU5Oc3F4dDJlMlQvd2dJWXpWenVERExpZ1drN1lDZkEKNDJ4YX"
+ + "VldHQ0M21qM25wYUFvcURIVG92Ci0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K";
+
+
private static final String SUBJECT = "CN=onap.org,OU=Linux-Foundation,O=ONAP,L=San-Francisco,ST=California,C=US";
private static final GeneralName GENERAL_NAME = new GeneralName(GeneralName.dNSName, "test.onap.org");
- private final X509CertificateModelFactory factory =
- new X509CertificateModelFactory(new PemStringToCertificateConverter(), new X509CertificateParser());
+ private final OldCertificateModelFactory factory =
+ new OldCertificateModelFactory(new PemStringToCertificateConverter(), new X509CertificateParser());
@Test
void shouldCorrectlyParseX509CertificateFromCertificate()
@@ -135,11 +169,12 @@ class X509CertificateModelFactoryTest {
//given
StringBase64 base64EncodedCertificate = new StringBase64(ENCODED_CERTIFICATE_STRING);
//when
- final X509CertificateModel certificateModel = factory.createCertificateModel(base64EncodedCertificate);
+ final OldCertificateModel certificateModel = factory.createCertificateModel(base64EncodedCertificate, ENCODED_PRIVATE_KEY);
//then
- assertThat(certificateModel.getCertificate()).isNotNull();
+ assertThat(certificateModel.getOldCertificate()).isNotNull();
assertThat(certificateModel.getSubjectData()).isEqualTo(new X500Name(SUBJECT));
assertThat(certificateModel.getSans()).containsExactly(GENERAL_NAME);
+ assertThat(certificateModel.getOldPrivateKey()).isNotNull();
}
@Test
@@ -148,11 +183,12 @@ class X509CertificateModelFactoryTest {
//given
StringBase64 base64EncodedCertificate = new StringBase64(ENCODED_CERTIFICATE_CHAIN_STRING);
//when
- final X509CertificateModel certificateModel = factory.createCertificateModel(base64EncodedCertificate);
+ final OldCertificateModel certificateModel = factory.createCertificateModel(base64EncodedCertificate, ENCODED_PRIVATE_KEY);
//then
- assertThat(certificateModel.getCertificate()).isNotNull();
+ assertThat(certificateModel.getOldCertificate()).isNotNull();
assertThat(certificateModel.getSubjectData()).isEqualTo(new X500Name(SUBJECT));
assertThat(certificateModel.getSans()).containsExactly(GENERAL_NAME);
+ assertThat(certificateModel.getOldPrivateKey()).isNotNull();
}
@Test
@@ -160,7 +196,7 @@ class X509CertificateModelFactoryTest {
//given
StringBase64 base64EncodedCertificate = new StringBase64("");
//when, then
- assertThatThrownBy(() -> factory.createCertificateModel(base64EncodedCertificate))
+ assertThatThrownBy(() -> factory.createCertificateModel(base64EncodedCertificate, ENCODED_PRIVATE_KEY))
.isInstanceOf(CertificateDecryptionException.class);
}
}
diff --git a/certService/src/test/java/org/onap/oom/certservice/certification/PemObjectFactoryTest.java b/certService/src/test/java/org/onap/oom/certservice/certification/conversion/PemObjectFactoryTest.java
index 68cfa1a1..2df9490e 100644
--- a/certService/src/test/java/org/onap/oom/certservice/certification/PemObjectFactoryTest.java
+++ b/certService/src/test/java/org/onap/oom/certservice/certification/conversion/PemObjectFactoryTest.java
@@ -18,12 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.oom.certservice.certification;
-
-import org.bouncycastle.util.io.pem.PemObject;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.onap.oom.certservice.certification.exception.DecryptionException;
+package org.onap.oom.certservice.certification.conversion;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -32,6 +27,11 @@ import static org.onap.oom.certservice.certification.TestData.TEST_PEM;
import static org.onap.oom.certservice.certification.TestData.TEST_WRONG_PEM;
import static org.onap.oom.certservice.certification.TestUtils.pemObjectToString;
+import org.bouncycastle.util.io.pem.PemObject;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.onap.oom.certservice.certification.exception.DecryptionException;
+
class PemObjectFactoryTest {
diff --git a/certService/src/test/java/org/onap/oom/certservice/certification/PemStringToCertificateConverterTest.java b/certService/src/test/java/org/onap/oom/certservice/certification/conversion/PemStringToCertificateConverterTest.java
index ecdb1a2e..708d59ab 100644
--- a/certService/src/test/java/org/onap/oom/certservice/certification/PemStringToCertificateConverterTest.java
+++ b/certService/src/test/java/org/onap/oom/certservice/certification/conversion/PemStringToCertificateConverterTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.oom.certservice.certification;
+package org.onap.oom.certservice.certification.conversion;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
diff --git a/certService/src/test/java/org/onap/oom/certservice/certification/RsaContentSignerBuilderTest.java b/certService/src/test/java/org/onap/oom/certservice/certification/conversion/RsaContentSignerBuilderTest.java
index eebe1815..2694d514 100644
--- a/certService/src/test/java/org/onap/oom/certservice/certification/RsaContentSignerBuilderTest.java
+++ b/certService/src/test/java/org/onap/oom/certservice/certification/conversion/RsaContentSignerBuilderTest.java
@@ -18,23 +18,21 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.oom.certservice.certification;
+package org.onap.oom.certservice.certification.conversion;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.onap.oom.certservice.certification.TestUtils.createCsrModel;
+
+import java.io.IOException;
+import java.security.PrivateKey;
import org.bouncycastle.operator.ContentSigner;
import org.bouncycastle.operator.OperatorCreationException;
import org.bouncycastle.pkcs.PKCS10CertificationRequest;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.onap.oom.certservice.certification.RsaContentSignerBuilder;
import org.onap.oom.certservice.certification.exception.DecryptionException;
import org.onap.oom.certservice.certification.model.CsrModel;
-import java.io.IOException;
-import java.security.PrivateKey;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.onap.oom.certservice.certification.TestUtils.createCsrModel;
-
class RsaContentSignerBuilderTest {
private RsaContentSignerBuilder rsaContentSignerBuilder;
diff --git a/certService/src/test/java/org/onap/oom/certservice/certification/X509CertificateBuilderTest.java b/certService/src/test/java/org/onap/oom/certservice/certification/conversion/X509CertificateBuilderTest.java
index 52ed99e7..bf9d1cfb 100644
--- a/certService/src/test/java/org/onap/oom/certservice/certification/X509CertificateBuilderTest.java
+++ b/certService/src/test/java/org/onap/oom/certservice/certification/conversion/X509CertificateBuilderTest.java
@@ -18,8 +18,13 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.oom.certservice.certification;
+package org.onap.oom.certservice.certification.conversion;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.onap.oom.certservice.certification.TestUtils.createCsrModel;
+
+import java.io.IOException;
+import java.security.PrivateKey;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.cert.X509v3CertificateBuilder;
import org.bouncycastle.operator.ContentSigner;
@@ -30,12 +35,6 @@ import org.junit.jupiter.api.Test;
import org.onap.oom.certservice.certification.exception.DecryptionException;
import org.onap.oom.certservice.certification.model.CsrModel;
-import java.io.IOException;
-import java.security.PrivateKey;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.onap.oom.certservice.certification.TestUtils.createCsrModel;
-
class X509CertificateBuilderTest {
private X509CertificateBuilder certificateBuilder;
diff --git a/certService/src/test/java/org/onap/oom/certservice/certification/model/CsrModelTest.java b/certService/src/test/java/org/onap/oom/certservice/certification/model/CsrModelTest.java
index 84c1cca0..72837e56 100644
--- a/certService/src/test/java/org/onap/oom/certservice/certification/model/CsrModelTest.java
+++ b/certService/src/test/java/org/onap/oom/certservice/certification/model/CsrModelTest.java
@@ -27,8 +27,8 @@ import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
import org.bouncycastle.pkcs.PKCS10CertificationRequest;
import org.bouncycastle.util.io.pem.PemObject;
import org.junit.jupiter.api.Test;
-import org.onap.oom.certservice.certification.Pkcs10CertificationRequestFactory;
-import org.onap.oom.certservice.certification.PemObjectFactory;
+import org.onap.oom.certservice.certification.conversion.Pkcs10CertificationRequestFactory;
+import org.onap.oom.certservice.certification.conversion.PemObjectFactory;
import org.onap.oom.certservice.certification.TestData;
import org.onap.oom.certservice.certification.exception.CsrDecryptionException;
import org.onap.oom.certservice.certification.exception.DecryptionException;
diff --git a/certService/src/test/java/org/onap/oom/certservice/cmpv2client/ClientTestData.java b/certService/src/test/java/org/onap/oom/certservice/cmpv2client/ClientTestData.java
index 0d8b80bd..cfee3af6 100644
--- a/certService/src/test/java/org/onap/oom/certservice/cmpv2client/ClientTestData.java
+++ b/certService/src/test/java/org/onap/oom/certservice/cmpv2client/ClientTestData.java
@@ -20,49 +20,43 @@
package org.onap.oom.certservice.cmpv2client;
-import org.onap.oom.certservice.certification.model.CertificateUpdateModel;
-import org.onap.oom.certservice.certification.model.CertificateUpdateModel.CertificateUpdateModelBuilder;
+import org.onap.oom.certservice.certification.conversion.PemStringToCertificateConverter;
+import org.onap.oom.certservice.certification.conversion.StringBase64;
+import org.onap.oom.certservice.certification.conversion.OldCertificateModelFactory;
+import org.onap.oom.certservice.certification.X509CertificateParser;
+import org.onap.oom.certservice.certification.exception.CertificateDecryptionException;
+import org.onap.oom.certservice.certification.model.OldCertificateModel;
public final class ClientTestData {
static final String KUR_CORRECT_SERVER_RESPONSE_ENCODED = "MIIQ1DCCAV0CAQKkVTBTMRUwEwYKCZImiZPyLGQBAQwFMTIzNDUxFTATBgNVBAMMDE1hbmFnZW1lbnRDQTEjMCEGA1UECgwaRUpCQ0EgQ29udGFpbmVyIFF1aWNrc3RhcnSkeTB3MREwDwYDVQQDDAhvbmFwLm9yZzEZMBcGA1UECwwQTGludXgtRm91bmRhdGlvbjENMAsGA1UECgwET05BUDEWMBQGA1UEBwwNU2FuLUZyYW5ja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UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsFAAOCAYEAbHgd0HWObYRmd8wv7u4AbCnEG5wugwAOYabGLmTNdDMzlbDJSFf/41EcqHUhujqhRjuFEFna3mLfWBGceICBlEjlgBhTC5FfAo+k85AE0/e4HYoJKdTpSd887PWRpP4o/TC0mFHCmCjuhUTEGBeKZLLAHU5sZkrG4/YzTXWZ396UYYe6gc/wgOSZuF06HrSCmqeeyVqLbHZyQN/qdYTQELXs2vj2gG6jhAMUIdD4Du+9DJC3v6lBKVCh6/gw6a77Eu+8aChLjyIiL+YRDkeMNmqEEqCRc1iugk4JS003CPnr1UftHnU3kcCTsgCOCn2ZGYAqaO93dcHz7SyNoqVNObsydX4TOH2OSF9Ti0mDFT9A/KFOMUI7bPP1zNmHp9DrlNOrsho04SBt1HlTTsgvq15RGDOtQApc1VHC4LnLX4JeZ3IEoLUgNQfs0GIYnt0XMSbTdOfCvC9ojQ1eeSJHAMpeg6AGxnAJnrcQygt0259YEShLfiSaPgULwbGFCUWe";
- private static final String TEST_CA = "TestCA";
private static final String WRONG_OLD_CERT = "wrong old cert";
private static final String WRONG_OLD_PRIVATE_KEY = "wrong old private key";
- private static final String TEST_ENCODED_CSR = "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURSBSRVFVRVNULS0tLS0KTUlJQzV6Q0NBYzhDQVFBd2R6RUxNQWtHQTFVRUJoTUNWVk14RXpBUkJnTlZCQWdNQ2tOaGJHbG1iM0p1YVdFeApGakFVQmdOVkJBY01EVk5oYmkxR2NtRnVZMmx6WTI4eERUQUxCZ05WQkFzTUJFOU9RVkF4R1RBWEJnTlZCQW9NCkVFeHBiblY0TFVadmRXNWtZWFJwYjI0eEVUQVBCZ05WQkFNTUNHOXVZWEF1YjNKbk1JSUJJakFOQmdrcWhraUcKOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXdVZmxSZ3k4d2tRajFib1hucGY5Q2lmakN6Y1lWSnJnTlZnVQplVnlOWjltczZIY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HYlVyOCs5Q2IwR0J1dzNITUVMN05mNmFQSWVjOG8ydXphVHU3WXlOegpjYlN4WmMyUzRpeVpSbjdkTldQSmtFUVFGd1dPNlBOYzRwd0xSeC9zR3pHdlY0cFZGdlRuOGE3c0FiVXpwcnZBCmRDNFdjYnJhNE1wTFFKczZqNWJoUFJ1QlRsSXBnZEVhdkVSM1J5bUVGUTBSRHdER2thSndNbkdVVTlqSWdFN3AKR282RG5aV2RJZEFoRlN2Q3RybERLL1NGYmVKM3RTNlMrSUxXUDgydWU3Q0UwSnYrUEVoUnc5aWVreE5hRElNbwpzeXcvM2tnSUNnckV3RjJzUHY5UnVLQ212V3NrMkdKaHRRcXZSK3FFRE5FQW15aXJodFh6L214QUZ0dy9ualpVCjBBPT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQoK";
+ private static final OldCertificateModelFactory factory =
+ new OldCertificateModelFactory(new PemStringToCertificateConverter(), new X509CertificateParser());
- public static final CertificateUpdateModel TEST_CERTIFICATE_UPDATE_MODEL_WITH_WRONG_OLD_CERT =
- new CertificateUpdateModelBuilder()
- .setEncodedCsr(TEST_ENCODED_CSR)
- .setEncodedPrivateKey(TEST_ENCODED_PRIVATE_KEY)
- .setEncodedOldCert(WRONG_OLD_CERT)
- .setEncodedOldPrivateKey(TEST_ENCODED_OLD_PRIVATE_KEY)
- .setCaName(TEST_CA)
- .build();
+ static final OldCertificateModel createCorrectOldCertificateModel() throws CertificateDecryptionException {
+ return createOldCertificateModel(TEST_ENCODED_OLD_CERT, TEST_ENCODED_OLD_PRIVATE_KEY);
+ }
- public static final CertificateUpdateModel TEST_CERTIFICATE_UPDATE_MODEL_WITH_WRONG_PRIVATE_KEY =
- new CertificateUpdateModelBuilder()
- .setEncodedCsr(TEST_ENCODED_CSR)
- .setEncodedPrivateKey(TEST_ENCODED_PRIVATE_KEY)
- .setEncodedOldCert(TEST_ENCODED_OLD_CERT)
- .setEncodedOldPrivateKey(WRONG_OLD_PRIVATE_KEY)
- .setCaName(TEST_CA)
- .build();
+ static final OldCertificateModel createOldCertificateModelWithWrongCert() throws CertificateDecryptionException {
+ return createOldCertificateModel(WRONG_OLD_CERT, TEST_ENCODED_OLD_PRIVATE_KEY);
+ }
- static final CertificateUpdateModel TEST_CERTIFICATE_UPDATE_MODEL = new CertificateUpdateModelBuilder()
- .setEncodedCsr(TEST_ENCODED_CSR)
- .setEncodedPrivateKey(TEST_ENCODED_PRIVATE_KEY)
- .setEncodedOldCert(TEST_ENCODED_OLD_CERT)
- .setEncodedOldPrivateKey(TEST_ENCODED_OLD_PRIVATE_KEY)
- .setCaName(TEST_CA)
- .build();
+ static final OldCertificateModel createOldCertificateModelWithWrongPrivateKey() throws CertificateDecryptionException {
+ return createOldCertificateModel(TEST_ENCODED_OLD_CERT, WRONG_OLD_PRIVATE_KEY);
+ }
+
+ private static final OldCertificateModel createOldCertificateModel(String certificate, String privateKey) throws CertificateDecryptionException {
+ StringBase64 base64EncodedCertificate = new StringBase64(certificate);
+ return factory.createCertificateModel(base64EncodedCertificate, privateKey);
+ }
private ClientTestData() {
}
diff --git a/certService/src/test/java/org/onap/oom/certservice/cmpv2client/Cmpv2ClientTest.java b/certService/src/test/java/org/onap/oom/certservice/cmpv2client/Cmpv2ClientTest.java
index de0a100c..b44d6447 100644
--- a/certService/src/test/java/org/onap/oom/certservice/cmpv2client/Cmpv2ClientTest.java
+++ b/certService/src/test/java/org/onap/oom/certservice/cmpv2client/Cmpv2ClientTest.java
@@ -76,6 +76,7 @@ import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.onap.oom.certservice.certification.configuration.model.Authentication;
import org.onap.oom.certservice.certification.configuration.model.Cmpv2Server;
+import org.onap.oom.certservice.certification.exception.CertificateDecryptionException;
import org.onap.oom.certservice.certification.model.CsrModel;
import org.onap.oom.certservice.cmpv2client.exceptions.CmpClientException;
import org.onap.oom.certservice.cmpv2client.exceptions.CmpServerException;
@@ -141,7 +142,7 @@ class Cmpv2ClientTest {
}
@Test
- void shouldReturnCorrectCmpCertificateForCorrectKeyUpdateResponse() throws CmpClientException, IOException {
+ void shouldReturnCorrectCmpCertificateForCorrectKeyUpdateResponse() throws CmpClientException, IOException, CertificateDecryptionException {
// given
setCsrModelAndServerTestDefaultValues();
@@ -160,7 +161,7 @@ class Cmpv2ClientTest {
// when
Cmpv2CertificationModel cmpClientResult =
- cmpClient.updateCertificate(csrModel, server, ClientTestData.TEST_CERTIFICATE_UPDATE_MODEL);
+ cmpClient.executeKeyUpdateRequest(csrModel, server, ClientTestData.createCorrectOldCertificateModel());
// then
assertNotNull(cmpClientResult);
@@ -189,7 +190,7 @@ class Cmpv2ClientTest {
// when
Cmpv2CertificationModel cmpClientResult =
- cmpClient.certificationRequest(csrModel, server);
+ cmpClient.executeCertificationRequest(csrModel, server);
// then
assertNotNull(cmpClientResult);
@@ -203,9 +204,9 @@ class Cmpv2ClientTest {
setCsrModelAndServerTestDefaultValues();
CmpClientImpl cmpClient = new CmpClientImpl(httpClient);
- assertThatExceptionOfType(CmpClientException.class)
- .isThrownBy(() -> cmpClient.updateCertificate(csrModel, server, ClientTestData.TEST_CERTIFICATE_UPDATE_MODEL_WITH_WRONG_PRIVATE_KEY))
- .withMessageContaining("Cannot parse old private key");
+ assertThatExceptionOfType(CertificateDecryptionException.class)
+ .isThrownBy(() -> cmpClient.executeKeyUpdateRequest(csrModel, server, ClientTestData.createOldCertificateModelWithWrongPrivateKey()))
+ .withMessageContaining("Cannot convert certificate or key");
}
@@ -217,9 +218,9 @@ class Cmpv2ClientTest {
CmpClientImpl cmpClient = new CmpClientImpl(httpClient);
// When // Then
- assertThatExceptionOfType(CmpClientException.class)
- .isThrownBy(() -> cmpClient.updateCertificate(csrModel, server, ClientTestData.TEST_CERTIFICATE_UPDATE_MODEL_WITH_WRONG_OLD_CERT))
- .withMessageContaining("Cannot parse old certificate");
+ assertThatExceptionOfType(CertificateDecryptionException.class)
+ .isThrownBy(() -> cmpClient.executeKeyUpdateRequest(csrModel, server, ClientTestData.createOldCertificateModelWithWrongCert()))
+ .withMessageContaining("Incorrect certificate, decryption failed");
}
@@ -255,7 +256,7 @@ class Cmpv2ClientTest {
CmpClientImpl cmpClient = spy(new CmpClientImpl(httpClient));
// when
Cmpv2CertificationModel cmpClientResult =
- cmpClient.createCertificate(csrModel, server, notBefore, notAfter);
+ cmpClient.executeInitializationRequest(csrModel, server, notBefore, notAfter);
// then
assertNotNull(cmpClientResult);
}
@@ -294,7 +295,7 @@ class Cmpv2ClientTest {
// then
Assertions.assertThrows(
CmpClientException.class,
- () -> cmpClient.createCertificate(csrModel, server, notBefore, notAfter));
+ () -> cmpClient.executeInitializationRequest(csrModel, server, notBefore, notAfter));
}
@Test
@@ -331,7 +332,7 @@ class Cmpv2ClientTest {
// then
Assertions.assertThrows(
CmpServerException.class,
- () -> cmpClient.createCertificate(csrModel, server, notBefore, notAfter));
+ () -> cmpClient.executeInitializationRequest(csrModel, server, notBefore, notAfter));
}
@@ -370,7 +371,7 @@ class Cmpv2ClientTest {
CmpClientImpl cmpClient = new CmpClientImpl(httpClient);
assertThatExceptionOfType(CmpClientException.class)
- .isThrownBy(() -> cmpClient.createCertificate(csrModel, server, notBefore, notAfter))
+ .isThrownBy(() -> cmpClient.executeInitializationRequest(csrModel, server, notBefore, notAfter))
.withMessageContaining("CMP response does not contain Protection Algorithm field");
}
@@ -391,7 +392,7 @@ class Cmpv2ClientTest {
// then
Assertions.assertThrows(
IllegalArgumentException.class,
- () -> cmpClient.createCertificate(csrModel, server, notBefore, notAfter));
+ () -> cmpClient.executeInitializationRequest(csrModel, server, notBefore, notAfter));
}
@Test
@@ -411,7 +412,7 @@ class Cmpv2ClientTest {
// then
Assertions.assertThrows(
CmpClientException.class,
- () -> cmpClient.createCertificate(csrModel, server, notBefore, notAfter));
+ () -> cmpClient.executeInitializationRequest(csrModel, server, notBefore, notAfter));
}
private void setCsrModelAndServerValues(String iak, String rv, String externalCaUrl, Date notBefore, Date notAfter) {