aboutsummaryrefslogtreecommitdiffstats
path: root/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/Cmpv2ServerConfigurationValidatorTest.java
diff options
context:
space:
mode:
authorawudzins <adam.wudzinski@nokia.com>2020-03-03 14:51:21 +0100
committerawudzins <adam.wudzinski@nokia.com>2020-03-04 13:44:52 +0100
commit09128196b16368651e8fa2a20140216e086700f2 (patch)
treef66c560d95b2140448b7414c1a34b7d0594cd9a5 /certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/Cmpv2ServerConfigurationValidatorTest.java
parent552f87238fbc04b63a992645217dcfded40cb122 (diff)
Fix reload endpoint to return status
Signed-off-by: Adam Wudzinski <adam.wudzinski@nokia.com> Issue-ID: AAF-997 wChange-Id: I4563428ef407b4dc8c84c3efc8ec213145806b32 Change-Id: Iee33a26feb5cc1acd39d91ee9f34a49183040e06
Diffstat (limited to 'certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/Cmpv2ServerConfigurationValidatorTest.java')
-rw-r--r--certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/Cmpv2ServerConfigurationValidatorTest.java124
1 files changed, 97 insertions, 27 deletions
diff --git a/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/Cmpv2ServerConfigurationValidatorTest.java b/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/Cmpv2ServerConfigurationValidatorTest.java
index 18097608..10a7ba46 100644
--- a/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/Cmpv2ServerConfigurationValidatorTest.java
+++ b/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/Cmpv2ServerConfigurationValidatorTest.java
@@ -20,6 +20,9 @@
package org.onap.aaf.certservice.certification.configuration.validation;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
import org.bouncycastle.asn1.x500.X500Name;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -32,13 +35,12 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = CertServiceApplication.class)
class Cmpv2ServerConfigurationValidatorTest {
+ private static final String EMPTY_STRING = "";
+
@Autowired
private Cmpv2ServerConfigurationValidator validator;
@@ -52,53 +54,121 @@ class Cmpv2ServerConfigurationValidatorTest {
}
@Test
- public void givenValidServerDetailsWhenValidatingShouldNotThrowAnyException() {
- //then
+ public void shouldNotThrowExceptionWhenServerConfigurationIsValid() {
+ // Then
assertDoesNotThrow(() -> validator.validate(server));
}
@Test
- public void givenWrongProtocolInURLServerDetailsWhenValidatingShouldThrowException() {
- //given
+ public void shouldThrowExceptionWhenWrongProtocolInURL() {
+ // Given
server.setUrl("https://test.test.test:60000/");
- //then
- assertThrows(IllegalArgumentException.class, () -> {validator.validate(server);});
+ // Then
+ assertExceptionIsThrown();
}
@Test
- public void givenWrongPortInURLServerDetailsWhenValidatingShouldThrowException() {
- //given
+ public void shouldThrowExceptionWhenWrongPortInURL() {
+ // Given
server.setUrl("http://test.test.test:70000/");
- //then
- assertThrows(IllegalArgumentException.class, () -> validator.validate(server));
+ // Then
+ assertExceptionIsThrown();
}
@Test
- public void givenWrongCANameLengthInURLServerDetailsWhenValidatingShouldThrowException() {
- //given
- server.setCaName("");
+ public void shouldThrowExceptionWhenWrongCANameLength() {
+ // Given
+ server.setCaName(EMPTY_STRING);
- //then
- assertThrows(IllegalArgumentException.class, () -> validator.validate(server));
+ // Then
+ assertExceptionIsThrown();
}
@Test
- public void givenWrongRVLengthInURLServerDetailsWhenValidatingShouldThrowException() {
- //given
- authentication.setRv("");
+ public void shouldThrowExceptionWhenWrongRVLength() {
+ // Given
+ authentication.setRv(EMPTY_STRING);
- //then
- assertThrows(IllegalArgumentException.class, () -> validator.validate(server));
+ // Then
+ assertExceptionIsThrown();
}
+
@Test
- public void givenWrongIAKLengthInURLServerDetailsWhenValidatingShouldThrowException() {
- //given
- authentication.setIak("");
+ public void shouldThrowExceptionWhenWrongIAKLength() {
+ // Given
+ authentication.setIak(EMPTY_STRING);
+
+ // Then
+ assertExceptionIsThrown();
+ }
+
+ @Test
+ public void shouldThrowExceptionWhenCaNameIsNull() {
+ // Given
+ server.setCaName(null);
+
+ // Then
+ assertExceptionIsThrown();
+ }
+
+ @Test
+ public void shouldThrowExceptionWhenIssuerDnIsNull() {
+ // Given
+ server.setIssuerDN(null);
+
+ // Then
+ assertExceptionIsThrown();
+ }
+
+ @Test
+ public void shouldThrowExceptionWhenCaModeIsNull() {
+ // Given
+ server.setCaMode(null);
+
+ // Then
+ assertExceptionIsThrown();
+ }
+
+ @Test
+ public void shouldThrowExceptionWhenUrlIsNull() {
+ // Given
+ server.setUrl(null);
+
+ // Then
+ assertExceptionIsThrown();
+ }
+
+ @Test
+ public void shouldThrowExceptionWhenAuthenticationIsNull() {
+ // Given
+ server.setAuthentication(null);
+
+ // Then
+ assertExceptionIsThrown();
+ }
+
+ @Test
+ public void shouldThrowExceptionWhenIakIsNull() {
+ // Given
+ authentication.setIak(null);
+
+ // Then
+ assertExceptionIsThrown();
+ }
+
+ @Test
+ public void shouldThrowExceptionWhenRvIsNull() {
+ // Given
+ authentication.setRv(null);
+
+ // Then
+ assertExceptionIsThrown();
+ }
- //then
+ private void assertExceptionIsThrown() {
assertThrows(IllegalArgumentException.class, () -> validator.validate(server));
}