summaryrefslogtreecommitdiffstats
path: root/certService/src/test/java/org/onap/aaf/certservice/certification/configuration/validation/Cmpv2ServerConfigurationValidatorTest.java
diff options
context:
space:
mode:
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));
}