aboutsummaryrefslogtreecommitdiffstats
path: root/aai-schema-service/src
diff options
context:
space:
mode:
Diffstat (limited to 'aai-schema-service/src')
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/SchemaServiceApp.java2
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/JettyPasswordDecoder.java34
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/PasswordDecoder.java26
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/PropertyPasswordConfiguration.java142
-rw-r--r--aai-schema-service/src/main/resources/application.properties9
-rw-r--r--aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java5
-rw-r--r--aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTestConfiguration.java36
-rw-r--r--aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/AAIContainerFilterTest.java61
-rw-r--r--aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/post/InvalidResponseStatusTest.java124
-rw-r--r--aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/post/ResponseHeaderManipulationTest.java96
-rw-r--r--aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/pre/HeaderValidationTest.java315
-rw-r--r--aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/pre/HttpHeaderInterceptorTest.java80
-rw-r--r--aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/pre/OneWaySslAuthorizationTest.java166
-rw-r--r--aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/pre/RequestTransactionLoggingTest.java141
-rw-r--r--aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/validation/FailFastStrategyTest.java56
-rw-r--r--aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/validation/NodeValidatorTest.java101
-rw-r--r--aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/validation/VersionValidatorTest.java76
-rw-r--r--aai-schema-service/src/test/resources/application.properties11
-rw-r--r--aai-schema-service/src/test/resources/error.properties198
19 files changed, 1419 insertions, 260 deletions
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/SchemaServiceApp.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/SchemaServiceApp.java
index 5c36ed8..65232be 100644
--- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/SchemaServiceApp.java
+++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/SchemaServiceApp.java
@@ -25,7 +25,6 @@ import javax.annotation.PreDestroy;
import org.onap.aai.aailog.logs.AaiDebugLog;
import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.schemaservice.config.PropertyPasswordConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -68,7 +67,6 @@ public class SchemaServiceApp {
SpringApplication app = new SpringApplication(SchemaServiceApp.class);
app.setLogStartupInfo(false);
app.setRegisterShutdownHook(true);
- app.addInitializers(new PropertyPasswordConfiguration());
Environment env = app.run(args).getEnvironment();
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/JettyPasswordDecoder.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/JettyPasswordDecoder.java
deleted file mode 100644
index f1576b0..0000000
--- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/JettyPasswordDecoder.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. 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.aai.schemaservice.config;
-
-import org.eclipse.jetty.util.security.Password;
-
-public class JettyPasswordDecoder implements PasswordDecoder {
-
- @Override
- public String decode(String input) {
- if (input.startsWith("OBF:")) {
- return Password.deobfuscate(input);
- }
- return Password.deobfuscate("OBF:" + input);
- }
-}
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/PasswordDecoder.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/PasswordDecoder.java
deleted file mode 100644
index 9ebd684..0000000
--- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/PasswordDecoder.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. 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.aai.schemaservice.config;
-
-public interface PasswordDecoder {
-
- String decode(String input);
-}
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/PropertyPasswordConfiguration.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/PropertyPasswordConfiguration.java
deleted file mode 100644
index bd8ce6e..0000000
--- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/PropertyPasswordConfiguration.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. 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
- * <p>
- * http://www.apache.org/licenses/LICENSE-2.0
- * <p>
- * 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.aai.schemaservice.config;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.commons.io.IOUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.ApplicationContextInitializer;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.core.env.ConfigurableEnvironment;
-import org.springframework.core.env.EnumerablePropertySource;
-import org.springframework.core.env.MapPropertySource;
-import org.springframework.core.env.PropertySource;
-
-public class PropertyPasswordConfiguration
- implements ApplicationContextInitializer<ConfigurableApplicationContext> {
-
- private static final Pattern decodePasswordPattern = Pattern.compile("password\\((.*?)\\)");
- private PasswordDecoder passwordDecoder = new JettyPasswordDecoder();
- private static final Logger logger =
- LoggerFactory.getLogger(PropertyPasswordConfiguration.class.getName());
-
- @Override
- public void initialize(ConfigurableApplicationContext applicationContext) {
-
- ConfigurableEnvironment environment = applicationContext.getEnvironment();
- String certPath = environment.getProperty("server.certs.location");
- Map<String, Object> sslProps = new LinkedHashMap<>();
-
- // Override the passwords from application.properties if we find AAF certman files
- if (certPath != null) {
- File passwordFile = new File(certPath + ".password");
- try (InputStream passwordStream = new FileInputStream(passwordFile)) {
- String keystorePassword = null;
-
- keystorePassword = IOUtils.toString(passwordStream, Charset.defaultCharset());
- if (keystorePassword != null) {
- keystorePassword = keystorePassword.trim();
- sslProps.put("server.ssl.key-store-password", keystorePassword);
- } else {
- logger.warn("Keystore password is null in AAF Certman password file");
- }
- } catch (IOException e) {
- logger.warn("Not using AAF Certman password file " + passwordFile.getName() + " e="
- + e.getMessage());
- }
-
- File passphrasesFile = new File(certPath + ".passphrases");
- try (InputStream passphrasesStream = new FileInputStream(passphrasesFile)) {
- String truststorePassword = null;
- Properties passphrasesProps = new Properties();
- passphrasesProps.load(passphrasesStream);
- truststorePassword = passphrasesProps.getProperty("cadi_truststore_password");
- if (truststorePassword != null) {
- truststorePassword = truststorePassword.trim();
- sslProps.put("server.ssl.trust-store-password", truststorePassword);
- } else {
- logger.warn("Truststore password is null in AAF Certman passphrases file");
- }
- } catch (IOException e) {
- logger.warn("Not using AAF Certman passphrases file " + passphrasesFile.getName()
- + " e=" + e.getMessage());
- }
- }
- for (PropertySource<?> propertySource : environment.getPropertySources()) {
- Map<String, Object> propertyOverrides = new LinkedHashMap<>();
- decodePasswords(propertySource, propertyOverrides);
- if (!propertyOverrides.isEmpty()) {
- PropertySource<?> decodedProperties =
- new MapPropertySource("decoded " + propertySource.getName(), propertyOverrides);
- environment.getPropertySources().addBefore(propertySource.getName(),
- decodedProperties);
- }
-
- }
- if (!sslProps.isEmpty()) {
- logger.info("Using AAF Certman files");
- PropertySource<?> additionalProperties =
- new MapPropertySource("additionalProperties", sslProps);
- environment.getPropertySources().addFirst(additionalProperties);
- }
-
- }
-
- private void decodePasswords(PropertySource<?> source, Map<String, Object> propertyOverrides) {
- if (source instanceof EnumerablePropertySource) {
- EnumerablePropertySource<?> enumerablePropertySource =
- (EnumerablePropertySource<?>) source;
- for (String key : enumerablePropertySource.getPropertyNames()) {
- Object rawValue = source.getProperty(key);
- if (rawValue instanceof String) {
- String decodedValue = decodePasswordsInString((String) rawValue);
- propertyOverrides.put(key, decodedValue);
- }
- }
- }
- }
-
- private String decodePasswordsInString(String input) {
- if (input == null) {
- return null;
- }
- StringBuffer output = new StringBuffer();
- Matcher matcher = decodePasswordPattern.matcher(input);
- while (matcher.find()) {
- String replacement = passwordDecoder.decode(matcher.group(1));
- matcher.appendReplacement(output, replacement);
- }
- matcher.appendTail(output);
- return output.toString();
- }
-
-}
diff --git a/aai-schema-service/src/main/resources/application.properties b/aai-schema-service/src/main/resources/application.properties
index 8581348..bcdc887 100644
--- a/aai-schema-service/src/main/resources/application.properties
+++ b/aai-schema-service/src/main/resources/application.properties
@@ -32,17 +32,8 @@ server.tomcat.max-idle-time=60000
# If you get an application startup failure that the port is already taken
# If thats not it, please check if the key-store file path makes sense
server.local.startpath=aai-schema-service/src/main/resources/
-server.basic.auth.location=${server.local.startpath}etc/auth/realm.properties
server.port=8452
-# Server SSL Related Attributes
-server.ssl.enabled-protocols=TLSv1.1,TLSv1.2
-server.ssl.key-store=${server.local.startpath}etc/auth/aai_keystore
-server.ssl.key-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
-server.ssl.trust-store=${server.local.startpath}etc/auth/aai_keystore
-server.ssl.trust-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
-server.ssl.client-auth=want
-server.ssl.key-store-type=JKS
# Schema related attributes for the oxm and edges
# Any additional schema related attributes should start with prefix schema
diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java
index f2f91cb..7450d14 100644
--- a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java
+++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java
@@ -31,7 +31,6 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.schemaservice.config.PropertyPasswordConfiguration;
import org.onap.aai.util.AAIConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -42,15 +41,11 @@ import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.TestPropertySource;
import org.springframework.web.client.RestTemplate;
@SpringBootTest(
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes = SchemaServiceApp.class)
-// @TestPropertySource(locations = "classpath:application-test.properties")
-@ContextConfiguration(initializers = PropertyPasswordConfiguration.class)
@Import(SchemaServiceTestConfiguration.class)
public class SchemaServiceTest {
diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTestConfiguration.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTestConfiguration.java
index e5a8632..a45696e 100644
--- a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTestConfiguration.java
+++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTestConfiguration.java
@@ -20,11 +20,7 @@
package org.onap.aai.schemaservice;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
-import java.io.InputStream;
-import java.security.KeyStore;
import javax.net.ssl.SSLContext;
@@ -65,25 +61,12 @@ public class SchemaServiceTestConfiguration {
RestTemplate restTemplate = null;
if (env.acceptsProfiles(Profiles.of("one-way-ssl", "two-way-ssl"))) {
- char[] trustStorePassword =
- env.getProperty("server.ssl.trust-store-password").toCharArray();
- char[] keyStorePassword =
- env.getProperty("server.ssl.key-store-password").toCharArray();
-
- String keyStore = env.getProperty("server.ssl.key-store");
- String trustStore = env.getProperty("server.ssl.trust-store");
- SSLContextBuilder sslContextBuilder = SSLContextBuilder.create();
-
- if (env.acceptsProfiles(Profiles.of("two-way-ssl"))) {
- sslContextBuilder = sslContextBuilder
- .loadKeyMaterial(loadPfx(keyStore, keyStorePassword), keyStorePassword);
- }
-
- SSLContext sslContext = sslContextBuilder
- .loadTrustMaterial(ResourceUtils.getFile(trustStore), trustStorePassword).build();
+ SSLContext sslContext = SSLContextBuilder.create().build();
- HttpClient client = HttpClients.custom().setSSLContext(sslContext)
- .setSSLHostnameVerifier((s, sslSession) -> true).build();
+ HttpClient client = HttpClients.custom()
+ .setSSLContext(sslContext)
+ .setSSLHostnameVerifier((s, sslSession) -> true)
+ .build();
restTemplate = builder
.requestFactory(() -> new HttpComponentsClientHttpRequestFactory(client)).build();
@@ -119,13 +102,4 @@ public class SchemaServiceTestConfiguration {
return restTemplate;
}
-
- private KeyStore loadPfx(String file, char[] password) throws Exception {
- KeyStore keyStore = KeyStore.getInstance("PKCS12");
- File key = ResourceUtils.getFile(file);
- try (InputStream in = new FileInputStream(key)) {
- keyStore.load(in, password);
- }
- return keyStore;
- }
}
diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/AAIContainerFilterTest.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/AAIContainerFilterTest.java
new file mode 100644
index 0000000..b549c5f
--- /dev/null
+++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/AAIContainerFilterTest.java
@@ -0,0 +1,61 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2025 Deutsche Telekom. 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.aai.schemaservice.interceptors;
+
+import java.util.UUID;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
+public class AAIContainerFilterTest {
+ private class TestAAIContainerFilter extends AAIContainerFilter {
+ // This subclass allows us to test the protected methods
+ }
+
+ @Test
+ public void testGenDate() {
+ TestAAIContainerFilter filter = new TestAAIContainerFilter();
+
+ // Get the generated date-time string
+ String generatedDate = filter.genDate();
+
+ // Assert that the generated date matches the expected format
+ assertNotNull(generatedDate);
+ assertTrue(generatedDate.matches("\\d{6}-\\d{2}:\\d{2}:\\d{2}:\\d{3}"));
+ }
+
+ @Test
+ public void testIsValidUUID_ValidUUID() {
+ TestAAIContainerFilter filter = new TestAAIContainerFilter();
+
+ // Test with a valid UUID
+ String validUUID = UUID.randomUUID().toString();
+ assertTrue(filter.isValidUUID(validUUID));
+ }
+
+ @Test
+ public void testIsValidUUID_InvalidUUID() {
+ TestAAIContainerFilter filter = new TestAAIContainerFilter();
+
+ // Test with an invalid UUID (not a valid UUID string)
+ String invalidUUID = "invalid-uuid-string";
+ assertFalse(filter.isValidUUID(invalidUUID));
+ }
+
+}
diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/post/InvalidResponseStatusTest.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/post/InvalidResponseStatusTest.java
new file mode 100644
index 0000000..2bc7e34
--- /dev/null
+++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/post/InvalidResponseStatusTest.java
@@ -0,0 +1,124 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2025 Deutsche Telekom. 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.aai.schemaservice.interceptors.post;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerResponseContext;
+import java.io.IOException;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.*;
+
+@ExtendWith(MockitoExtension.class)
+public class InvalidResponseStatusTest {
+
+ @InjectMocks
+ private InvalidResponseStatus invalidResponseStatus;
+
+ @Mock
+ private ContainerRequestContext mockRequestContext;
+
+ @Mock
+ private ContainerResponseContext mockResponseContext;
+
+
+ @Test
+ public void testFilter_ResponseStatus405_ShouldChangeTo400() throws IOException {
+ when(mockResponseContext.getStatus()).thenReturn(405);
+
+ invalidResponseStatus.filter(mockRequestContext, mockResponseContext);
+
+ verify(mockResponseContext).setStatus(400);
+
+ verify(mockResponseContext).setEntity(anyString());
+ }
+
+ @Test
+ public void testFilter_ResponseStatus405_ShouldHandleContentType() throws IOException {
+ String contentType = "application/json";
+ when(mockResponseContext.getStatus()).thenReturn(405);
+ when(mockResponseContext.getHeaderString("Content-Type")).thenReturn(contentType);
+
+ invalidResponseStatus.filter(mockRequestContext, mockResponseContext);
+
+ verify(mockResponseContext).setStatus(400);
+
+ verify(mockResponseContext).setEntity(anyString());
+ assertEquals("application/json",mockResponseContext.getHeaderString("Content-Type"));
+ }
+
+ @Test
+ public void testFilter_ContentTypeSetToNull_ShouldSetXmlContentType() throws IOException {
+ // Setup: Simulate 405 status and no Content-Type header
+ when(mockResponseContext.getStatus()).thenReturn(405);
+ when(mockResponseContext.getHeaderString("Content-Type")).thenReturn(null);
+
+ invalidResponseStatus.filter(mockRequestContext, mockResponseContext);
+
+ verify(mockResponseContext).setEntity(anyString());
+ Assertions.assertNull(mockResponseContext.getHeaderString("Content-Type"));
+ }
+
+ @Test
+ public void testFilter_ResponseStatus406_ContentTypeXml_ShouldSetXmlMessage() throws IOException {
+ when(mockResponseContext.getStatus()).thenReturn(406);
+ when(mockResponseContext.getHeaderString("Content-Type")).thenReturn("application/xml");
+
+ invalidResponseStatus.filter(mockRequestContext, mockResponseContext);
+
+ verify(mockResponseContext).setStatus(406);
+
+ verify(mockResponseContext).setEntity(anyString());
+ assertEquals("application/xml",mockResponseContext.getHeaderString("Content-Type"));
+ }
+
+ @Test
+ public void testFilter_ResponseStatus406_ContentTypeJson_ShouldSetJsonMessage() throws IOException {
+ // Setup: Simulate a 406 status and Content-Type header as "application/json"
+ when(mockResponseContext.getStatus()).thenReturn(406);
+ when(mockResponseContext.getHeaderString("Content-Type")).thenReturn("application/json");
+
+ invalidResponseStatus.filter(mockRequestContext, mockResponseContext);
+
+ verify(mockResponseContext).setStatus(406);
+
+ verify(mockResponseContext).setEntity(anyString());
+ assertEquals("application/json",mockResponseContext.getHeaderString("Content-Type"));
+ }
+
+ @Test
+ public void testFilter_ResponseStatus406_ContentTypeUnsupported_ShouldReturnErrorMessage() throws IOException {
+ when(mockResponseContext.getStatus()).thenReturn(406);
+ when(mockResponseContext.getHeaderString("Content-Type")).thenReturn("application/unsupported");
+
+ invalidResponseStatus.filter(mockRequestContext, mockResponseContext);
+
+ verify(mockResponseContext).setStatus(406);
+
+ verify(mockResponseContext).setEntity(anyString());
+ assertEquals("application/unsupported",mockResponseContext.getHeaderString("Content-Type"));
+
+ }
+}
diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/post/ResponseHeaderManipulationTest.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/post/ResponseHeaderManipulationTest.java
new file mode 100644
index 0000000..7aae84e
--- /dev/null
+++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/post/ResponseHeaderManipulationTest.java
@@ -0,0 +1,96 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2025 Deutsche Telekom. 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.aai.schemaservice.interceptors.post;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerResponseContext;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import java.io.IOException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
+public class ResponseHeaderManipulationTest {
+
+ @InjectMocks
+ private ResponseHeaderManipulation responseHeaderManipulation;
+
+ @Mock
+ private ContainerRequestContext mockRequestContext;
+
+ @Mock
+ private ContainerResponseContext mockResponseContext;
+
+ @Mock
+ private MultivaluedMap<String, Object> mockResponseHeaders;
+
+ @BeforeEach
+ public void setUp() {
+ when(mockResponseContext.getHeaders()).thenReturn(mockResponseHeaders);
+ }
+
+ @Test
+ public void testFilterWithContentType() throws IOException {
+ when(mockResponseContext.getHeaderString("Content-Type")).thenReturn(MediaType.APPLICATION_JSON);
+ responseHeaderManipulation.filter(mockRequestContext, mockResponseContext);
+
+ assertEquals("application/json",mockResponseContext.getHeaderString("Content-Type"));
+ }
+
+ @Test
+ public void testFilterWithNoContentType() throws IOException {
+ // Arrange: Simulate Accept header with "*/*" and no Content-Type set
+ when(mockRequestContext.getHeaderString("Accept")).thenReturn("*/*");
+
+ responseHeaderManipulation.filter(mockRequestContext, mockResponseContext);
+
+ assertEquals("*/*",mockRequestContext.getHeaderString("Accept"));
+ }
+
+ @Test
+ public void testFilterWithNullAcceptHeader() throws IOException {
+ // Arrange: Simulate null Accept header
+ when(mockRequestContext.getHeaderString("Accept")).thenReturn(null);
+ responseHeaderManipulation.filter(mockRequestContext, mockResponseContext);
+
+ assertNull(mockRequestContext.getHeaderString("Accept"));
+ }
+
+ @Test
+ public void testFilterWithEmptyAcceptHeader() throws IOException {
+ // Arrange: Simulate empty Accept header and no Content-Type set
+ when(mockRequestContext.getHeaderString("Accept")).thenReturn("");
+ when(mockResponseContext.getHeaderString("Content-Type")).thenReturn(null);
+
+ responseHeaderManipulation.filter(mockRequestContext, mockResponseContext);
+ assertEquals("", mockRequestContext.getHeaderString("Accept"));
+ }
+
+}
diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/pre/HeaderValidationTest.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/pre/HeaderValidationTest.java
new file mode 100644
index 0000000..684fdc1
--- /dev/null
+++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/pre/HeaderValidationTest.java
@@ -0,0 +1,315 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2025 Deutsche Telekom. 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.aai.schemaservice.interceptors.pre;
+
+import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.*;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
+import org.onap.aai.restcore.MediaType;
+import org.onap.aai.schemaservice.interceptors.AAIHeaderProperties;
+import org.onap.logging.filter.base.Constants;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.LENIENT)
+public class HeaderValidationTest {
+
+ @InjectMocks
+ private HeaderValidation headerValidation;
+
+ @Mock
+ private ContainerRequestContext requestContext;
+
+ private MultivaluedMap<String, String> headers;
+
+ @BeforeEach
+ public void setUp() {
+ headers = new MultivaluedHashMap<>();
+ when(requestContext.getHeaders()).thenReturn(headers);
+ }
+
+ @Test
+ public void testGetPartnerName_withEmptyPartnerName() {
+ when(requestContext.getHeaderString("X-ONAP-PartnerName")).thenReturn("");
+ when(requestContext.getHeaderString("X-FromAppId")).thenReturn("testAppId");
+
+ String partnerName = headerValidation.getPartnerName(requestContext);
+
+ assertEquals("testAppId", partnerName);
+ }
+
+ @Test
+ public void testGetPartnerName_withNullPartnerNameAndFromAppId() {
+ // Mock behavior of getHeaderString to return null for both PARTNER_NAME and FROM_APP_ID
+ when(requestContext.getHeaderString("X-ONAP-PartnerName")).thenReturn(null);
+ when(requestContext.getHeaderString("X-FromAppId")).thenReturn("testAppId");
+
+ String partnerName = headerValidation.getPartnerName(requestContext);
+
+ assertEquals("testAppId", partnerName);
+ }
+
+ @Test
+ public void testGetPartnerName_withMissingPartnerNameAndFromAppId() {
+ // Mock behavior of getHeaderString to return null for both PARTNER_NAME and FROM_APP_ID
+ when(requestContext.getHeaderString("X-ONAP-PartnerName")).thenReturn(null);
+
+ String partnerName = headerValidation.getPartnerName(requestContext);
+
+ assertNull(partnerName);
+ }
+
+ @Test
+ public void testGetRequestId_withValidRequestId() {
+ // Mock behavior of getHeaderString to return a valid request ID
+ when(requestContext.getHeaderString("X-ONAP-RequestID")).thenReturn("testRequestId");
+
+ String requestId = headerValidation.getRequestId(requestContext);
+
+ assertEquals("testRequestId", requestId);
+ }
+
+ @Test
+ public void testFilter_withMissingPartnerName() throws IOException {
+ // Mock behavior for missing PartnerName header
+ when(requestContext.getHeaderString("X-ONAP-PartnerName")).thenReturn("");
+ when(requestContext.getHeaderString("X-FromAppId")).thenReturn("testAppId");
+ when(requestContext.getHeaderString("X-ONAP-RequestId")).thenReturn("testRequestId");
+
+ headerValidation.filter(requestContext);
+
+ // Verify that the method calls abortWith due to the missing partner name
+ verify(requestContext).abortWith(argThat(response -> response.getStatus() == 400));
+ }
+
+ @Test
+ void testGetRequestId_ClearsExistingHeaders() {
+ // Arrange
+ String expectedRequestId = "test-request-id";
+ headers.put(ONAPLogConstants.Headers.REQUEST_ID, new ArrayList<>());
+ headers.put(Constants.HttpHeaders.TRANSACTION_ID, new ArrayList<>());
+ headers.put(Constants.HttpHeaders.HEADER_REQUEST_ID, new ArrayList<>());
+ headers.put(Constants.HttpHeaders.ECOMP_REQUEST_ID, new ArrayList<>());
+
+ when(requestContext.getHeaderString(ONAPLogConstants.Headers.REQUEST_ID))
+ .thenReturn(expectedRequestId);
+
+ String actualRequestId = headerValidation.getRequestId(requestContext);
+
+ assertEquals(expectedRequestId, actualRequestId);
+ verify(requestContext, atLeastOnce()).getHeaders();
+ assertTrue(headers.get(ONAPLogConstants.Headers.REQUEST_ID).isEmpty());
+ assertTrue(headers.get(Constants.HttpHeaders.TRANSACTION_ID).contains(expectedRequestId));
+ assertTrue(headers.get(Constants.HttpHeaders.HEADER_REQUEST_ID).isEmpty());
+ assertTrue(headers.get(Constants.HttpHeaders.ECOMP_REQUEST_ID).isEmpty());
+ }
+
+ @Test
+ void testGetRequestId_WhenEcompRequestIdExists() {
+ String expectedRequestId = "ecomp-123";
+ when(requestContext.getHeaderString(ONAPLogConstants.Headers.REQUEST_ID))
+ .thenReturn(null);
+ when(requestContext.getHeaderString(Constants.HttpHeaders.HEADER_REQUEST_ID))
+ .thenReturn(null);
+ when(requestContext.getHeaderString(Constants.HttpHeaders.TRANSACTION_ID))
+ .thenReturn(null);
+ when(requestContext.getHeaderString(Constants.HttpHeaders.ECOMP_REQUEST_ID))
+ .thenReturn(expectedRequestId);
+
+ String result = headerValidation.getRequestId(requestContext);
+
+ assertEquals(expectedRequestId, result);
+ }
+
+ @Test
+ void whenPartnerNameHasValidComponents_shouldReturnFirstComponent() {
+ when(requestContext.getHeaderString(ONAPLogConstants.Headers.PARTNER_NAME)).thenReturn("TEST.COMPONENT");
+
+ String result = headerValidation.getPartnerName(requestContext);
+
+ assertEquals("TEST.COMPONENT", result);
+ }
+
+ @Test
+ void whenPartnerNameStartsWithAAI_shouldUseFromAppId() {
+ when(requestContext.getHeaderString(ONAPLogConstants.Headers.PARTNER_NAME)).thenReturn("AAI.COMPONENT");
+
+ String result = headerValidation.getPartnerName(requestContext);
+
+ assertEquals("AAI.COMPONENT", result);
+ }
+
+ @Test
+ void shouldClearAndUpdateHeaders() {
+ List<String> oldValues = new ArrayList<>();
+ oldValues.add("OLD-VALUE");
+ headers.put(ONAPLogConstants.Headers.PARTNER_NAME, oldValues);
+ headers.put(AAIHeaderProperties.FROM_APP_ID, oldValues);
+
+ when(requestContext.getHeaderString(ONAPLogConstants.Headers.PARTNER_NAME)).thenReturn("NEW-SOT");
+
+ String result = headerValidation.getPartnerName(requestContext);
+
+ assertEquals("NEW-SOT", result);
+ assertEquals("NEW-SOT", headers.getFirst(AAIHeaderProperties.FROM_APP_ID));
+ }
+
+
+ @Test
+ public void testGetRequestId_withValidHeaderRequestId() {
+ when(requestContext.getHeaderString(ONAPLogConstants.Headers.REQUEST_ID)).thenReturn("");
+ when(requestContext.getHeaderString(Constants.HttpHeaders.HEADER_REQUEST_ID)).thenReturn("validHeaderRequestId");
+
+ String result = headerValidation.getRequestId(requestContext);
+
+ assertEquals("validHeaderRequestId",result);
+ }
+
+ @Test
+ public void testGetRequestIdNull_withValidTransactionId() {
+ when(requestContext.getHeaderString(ONAPLogConstants.Headers.REQUEST_ID)).thenReturn(null);
+ when(requestContext.getHeaderString(Constants.HttpHeaders.HEADER_REQUEST_ID)).thenReturn(null);
+ when(requestContext.getHeaderString(Constants.HttpHeaders.TRANSACTION_ID)).thenReturn("validTransactionId");
+
+ String result = headerValidation.getRequestId(requestContext);
+
+ assertEquals("validTransactionId",result);
+ }
+
+ @Test
+ public void testGetRequestIdEmpty_withValidTransactionId() {
+ when(requestContext.getHeaderString(ONAPLogConstants.Headers.REQUEST_ID)).thenReturn("");
+ when(requestContext.getHeaderString(Constants.HttpHeaders.HEADER_REQUEST_ID)).thenReturn("");
+ when(requestContext.getHeaderString(Constants.HttpHeaders.TRANSACTION_ID)).thenReturn("validTransactionId");
+
+ String result = headerValidation.getRequestId(requestContext);
+
+ assertEquals("validTransactionId",result);
+ }
+
+ @Test
+ public void testGetRequestId_withValidEcompRequestId() {
+
+ when(requestContext.getHeaderString(ONAPLogConstants.Headers.REQUEST_ID)).thenReturn(null);
+ when(requestContext.getHeaderString(Constants.HttpHeaders.HEADER_REQUEST_ID)).thenReturn(null);
+ when(requestContext.getHeaderString(Constants.HttpHeaders.TRANSACTION_ID)).thenReturn(null);
+ when(requestContext.getHeaderString(Constants.HttpHeaders.ECOMP_REQUEST_ID)).thenReturn("validEcompRequestId");
+
+ String result = headerValidation.getRequestId(requestContext);
+
+ assertEquals("validEcompRequestId",result);
+ }
+
+ @Test
+ public void testGetRequestId_withValidEcompRequestIdAfterEmptyTransactionId() {
+ when(requestContext.getHeaderString(ONAPLogConstants.Headers.REQUEST_ID)).thenReturn(null);
+ when(requestContext.getHeaderString(Constants.HttpHeaders.HEADER_REQUEST_ID)).thenReturn(null);
+ when(requestContext.getHeaderString(Constants.HttpHeaders.TRANSACTION_ID)).thenReturn("");
+ when(requestContext.getHeaderString(Constants.HttpHeaders.ECOMP_REQUEST_ID)).thenReturn("validEcompRequestId");
+
+ String result = headerValidation.getRequestId(requestContext);
+
+ assertEquals("validEcompRequestId",result);
+ }
+
+ @Test
+ public void testGetRequestId_withMultipleHeadersValid() {
+ when(requestContext.getHeaderString(ONAPLogConstants.Headers.REQUEST_ID)).thenReturn("validRequestId");
+ when(requestContext.getHeaderString(Constants.HttpHeaders.HEADER_REQUEST_ID)).thenReturn("anotherRequestId");
+
+ String result = headerValidation.getRequestId(requestContext);
+ assertEquals("validRequestId", result, "Expected validRequestId to be returned as it's the first non-null value");
+
+ }
+ @Test
+ public void testGetPartnerName_withNullPartnerNameAndNullFromAppId() {
+ when(requestContext.getHeaderString(ONAPLogConstants.Headers.PARTNER_NAME)).thenReturn(null);
+ when(requestContext.getHeaderString(AAIHeaderProperties.FROM_APP_ID)).thenReturn(null);
+
+ String partnerName = headerValidation.getPartnerName(requestContext);
+ assertNull(partnerName, "Expected null partner name when both PARTNER_NAME and FROM_APP_ID are null");
+ }
+
+ @Test
+ public void testGetPartnerName_withNonEmptyPartnerName() {
+ when(requestContext.getHeaderString(ONAPLogConstants.Headers.PARTNER_NAME)).thenReturn("partnerName");
+ when(requestContext.getHeaderString(AAIHeaderProperties.FROM_APP_ID)).thenReturn("testAppId");
+ String partnerName = headerValidation.getPartnerName(requestContext);
+
+ assertEquals("partnerName", partnerName, "Expected partner name to be used directly when PARTNER_NAME is not empty");
+ }
+
+ @Test
+ public void testGetPartnerName_withNullPartnerNameAndNonEmptyFromAppId() {
+ when(requestContext.getHeaderString(ONAPLogConstants.Headers.PARTNER_NAME)).thenReturn(null);
+ when(requestContext.getHeaderString(AAIHeaderProperties.FROM_APP_ID)).thenReturn("testAppId");
+
+ String partnerName = headerValidation.getPartnerName(requestContext);
+ assertEquals("testAppId", partnerName, "Expected partner name to fall back to FROM_APP_ID when PARTNER_NAME is null");
+ }
+
+ @Test
+ public void testGetPartnerName_withEmptyFromAppId() {
+ when(requestContext.getHeaderString(ONAPLogConstants.Headers.PARTNER_NAME)).thenReturn("validPartnerName");
+ when(requestContext.getHeaderString(AAIHeaderProperties.FROM_APP_ID)).thenReturn("");
+ String partnerName = headerValidation.getPartnerName(requestContext);
+
+ assertEquals("validPartnerName", partnerName, "Expected valid PARTNER_NAME to be used even when FROM_APP_ID is empty");
+ }
+
+ @Test
+ public void testGetPartnerName_withValidPartnerNameWithDot() {
+ when(requestContext.getHeaderString(ONAPLogConstants.Headers.PARTNER_NAME)).thenReturn("TEST.COMPONENT");
+ when(requestContext.getHeaderString(AAIHeaderProperties.FROM_APP_ID)).thenReturn("testAppId");
+
+ String partnerName = headerValidation.getPartnerName(requestContext);
+
+ assertEquals("TEST.COMPONENT", partnerName, "Expected partner name to return 'TEST.COMPONENT' when PARTNER_NAME is valid");
+ }
+ @Test
+ public void testValidateHeaderValuePresence_usingReflection() throws Exception {
+
+ Method method = HeaderValidation.class.getDeclaredMethod("validateHeaderValuePresence", String.class, String.class, List.class);
+ method.setAccessible(true);
+ String value = "testValue";
+ String errorCode = "AAI_4009";
+ List<MediaType> acceptHeaderValues = List.of(MediaType.APPLICATION_JSON_TYPE);
+ Optional<Response> result = (Optional<Response>) method.invoke(headerValidation, value, errorCode, acceptHeaderValues);
+ assertNotNull(result);
+ }
+
+
+}
diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/pre/HttpHeaderInterceptorTest.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/pre/HttpHeaderInterceptorTest.java
new file mode 100644
index 0000000..4570443
--- /dev/null
+++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/pre/HttpHeaderInterceptorTest.java
@@ -0,0 +1,80 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2025 Deutsche Telekom. 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.aai.schemaservice.interceptors.pre;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.onap.aai.schemaservice.interceptors.AAIHeaderProperties;
+import javax.ws.rs.container.ContainerRequestContext;
+import java.io.IOException;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.*;
+
+class HttpHeaderInterceptorTest {
+
+ private HttpHeaderInterceptor httpHeaderInterceptor;
+
+ @Mock
+ private ContainerRequestContext mockRequestContext;
+
+ @BeforeEach
+ void setUp() {
+ MockitoAnnotations.openMocks(this);
+ httpHeaderInterceptor = new HttpHeaderInterceptor();
+ }
+
+ @Test
+ void testFilter_WithPostMethodAndPatchOverride_ShouldSetMethodToPatch() throws IOException {
+ // Setup: Mock the method to POST and the HTTP_METHOD_OVERRIDE header to PATCH
+ when(mockRequestContext.getHeaderString(AAIHeaderProperties.HTTP_METHOD_OVERRIDE)).thenReturn("PATCH");
+ when(mockRequestContext.getMethod()).thenReturn("POST");
+
+ httpHeaderInterceptor.filter(mockRequestContext);
+
+ verify(mockRequestContext).setMethod("PATCH");
+ }
+
+ @Test
+ void testFilter_WithPostMethodAndNoOverride_ShouldNotChangeMethod() throws IOException {
+ // Setup: Mock the method to POST and no HTTP_METHOD_OVERRIDE header (null or empty)
+ when(mockRequestContext.getMethod()).thenReturn("POST");
+ when(mockRequestContext.getHeaderString(AAIHeaderProperties.HTTP_METHOD_OVERRIDE)).thenReturn(null);
+
+ httpHeaderInterceptor.filter(mockRequestContext);
+
+ verify(mockRequestContext, never()).setMethod(anyString());
+ assertEquals("POST", mockRequestContext.getMethod());
+ }
+
+ @Test
+ void testFilter_WithPatchMethodAndNoOverride_ShouldNotChangeMethod() throws IOException {
+ // Setup: Mock the method to PATCH and no override header
+ when(mockRequestContext.getMethod()).thenReturn("PATCH");
+ when(mockRequestContext.getHeaderString(AAIHeaderProperties.HTTP_METHOD_OVERRIDE)).thenReturn(null);
+
+ httpHeaderInterceptor.filter(mockRequestContext);
+
+ verify(mockRequestContext, never()).setMethod(anyString());
+ assertEquals("PATCH", mockRequestContext.getMethod());
+
+ }
+}
diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/pre/OneWaySslAuthorizationTest.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/pre/OneWaySslAuthorizationTest.java
new file mode 100644
index 0000000..9696e69
--- /dev/null
+++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/pre/OneWaySslAuthorizationTest.java
@@ -0,0 +1,166 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2025 Deutsche Telekom. 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.aai.schemaservice.interceptors.pre;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.mockito.junit.jupiter.MockitoSettings;
+import org.mockito.quality.Strictness;
+import org.onap.aai.schemaservice.service.AuthorizationService;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@ExtendWith(MockitoExtension.class)
+@MockitoSettings(strictness = Strictness.LENIENT)
+public class OneWaySslAuthorizationTest {
+
+ @Mock
+ private AuthorizationService authorizationService;
+
+ @Mock
+ private ContainerRequestContext containerRequestContext;
+
+ @InjectMocks
+ private OneWaySslAuthorization oneWaySslAuthorization;
+
+ @BeforeEach
+ public void setUp() {
+ lenient().when(authorizationService.checkIfUserAuthorized(anyString())).thenReturn(true);
+ }
+
+ @Test
+ public void testFilterWithValidBasicAuth() throws Exception {
+ String basicAuth = "Basic validToken";
+ List<MediaType> acceptHeaderValues = Arrays.asList(MediaType.APPLICATION_JSON_TYPE);
+
+ when(containerRequestContext.getHeaderString("Authorization")).thenReturn(basicAuth);
+ when(containerRequestContext.getAcceptableMediaTypes()).thenReturn(acceptHeaderValues);
+
+ UriInfo uriInfoMock = mock(UriInfo.class);
+ when(containerRequestContext.getUriInfo()).thenReturn(uriInfoMock);
+ when(uriInfoMock.getRequestUri()).thenReturn(URI.create("http://localhost/some/other/path"));
+ when(uriInfoMock.getPath()).thenReturn("/some/other/path");
+
+ oneWaySslAuthorization.filter(containerRequestContext);
+
+ verify(containerRequestContext, times(0)).abortWith(any());
+ }
+
+ @Test
+ public void testFilterWithInvalidBasicAuth() throws Exception {
+ String basicAuth = "Basic invalidToken";
+ List<MediaType> acceptHeaderValues = Arrays.asList(MediaType.APPLICATION_JSON_TYPE);
+
+ UriInfo uriInfoMock = mock(UriInfo.class);
+ when(containerRequestContext.getUriInfo()).thenReturn(uriInfoMock);
+ when(uriInfoMock.getRequestUri()).thenReturn(URI.create("http://localhost/some/other/path"));
+ when(uriInfoMock.getPath()).thenReturn("/some/other/path");
+
+ when(containerRequestContext.getHeaderString("Authorization")).thenReturn(basicAuth);
+ when(containerRequestContext.getAcceptableMediaTypes()).thenReturn(acceptHeaderValues);
+
+ when(authorizationService.checkIfUserAuthorized("invalidToken")).thenReturn(false);
+
+ oneWaySslAuthorization.filter(containerRequestContext);
+
+ verify(containerRequestContext, times(1)).abortWith(any(Response.class));
+ }
+
+ @Test
+ public void testFilterWithNoAuthorizationHeader() throws Exception {
+ String basicAuth = null;
+ List<MediaType> acceptHeaderValues = Arrays.asList(MediaType.APPLICATION_JSON_TYPE);
+
+ when(containerRequestContext.getHeaderString("Authorization")).thenReturn(basicAuth);
+ when(containerRequestContext.getAcceptableMediaTypes()).thenReturn(acceptHeaderValues);
+
+ UriInfo uriInfoMock = mock(UriInfo.class);
+ when(containerRequestContext.getUriInfo()).thenReturn(uriInfoMock);
+ when(uriInfoMock.getRequestUri()).thenReturn(URI.create("http://localhost/some/other/path"));
+ when(uriInfoMock.getPath()).thenReturn("/some/other/path");
+
+ oneWaySslAuthorization.filter(containerRequestContext);
+
+ verify(containerRequestContext, times(1)).abortWith(any(Response.class));
+ }
+
+ @Test
+ public void testFilterWithInvalidAuthorizationHeaderFormat() throws Exception {
+ String basicAuth = "Bearer invalidToken"; // Header doesn't start with "Basic "
+ List<MediaType> acceptHeaderValues = Arrays.asList(MediaType.APPLICATION_JSON_TYPE);
+
+ when(containerRequestContext.getHeaderString("Authorization")).thenReturn(basicAuth);
+ when(containerRequestContext.getAcceptableMediaTypes()).thenReturn(acceptHeaderValues);
+
+ UriInfo uriInfoMock = mock(UriInfo.class);
+ when(containerRequestContext.getUriInfo()).thenReturn(uriInfoMock);
+ when(uriInfoMock.getRequestUri()).thenReturn(URI.create("http://localhost/some/other/path"));
+ when(uriInfoMock.getPath()).thenReturn("/some/other/path");
+
+ oneWaySslAuthorization.filter(containerRequestContext);
+
+ verify(containerRequestContext, times(1)).abortWith(any(Response.class));
+ }
+
+ @Test
+ public void testFilterForEchoPath() throws Exception {
+ String path = "/util/echo";
+
+ UriInfo uriInfoMock = mock(UriInfo.class);
+ when(containerRequestContext.getUriInfo()).thenReturn(uriInfoMock);
+ when(uriInfoMock.getRequestUri()).thenReturn(URI.create("http://localhost" + path));
+ when(uriInfoMock.getPath()).thenReturn(path);
+
+ oneWaySslAuthorization.filter(containerRequestContext);
+
+ verify(containerRequestContext, times(0)).abortWith(any());
+ }
+
+ @Test
+ public void testErrorResponse() throws Exception {
+ Method errorResponseMethod = OneWaySslAuthorization.class.getDeclaredMethod("errorResponse", String.class, List.class);
+ errorResponseMethod.setAccessible(true);
+
+ String errorCode = "AAI_3300";
+ List<MediaType> acceptHeaderValues = Arrays.asList(MediaType.APPLICATION_JSON_TYPE);
+
+ Object result = errorResponseMethod.invoke(oneWaySslAuthorization, errorCode, acceptHeaderValues);
+
+ assertTrue(result instanceof Optional);
+ Optional<Response> responseOptional = (Optional<Response>) result;
+ assertTrue(responseOptional.isPresent());
+ assertEquals(Response.Status.FORBIDDEN.getStatusCode(), responseOptional.get().getStatus());
+ }
+}
+
diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/pre/RequestTransactionLoggingTest.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/pre/RequestTransactionLoggingTest.java
new file mode 100644
index 0000000..0c701cd
--- /dev/null
+++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/interceptors/pre/RequestTransactionLoggingTest.java
@@ -0,0 +1,141 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2025 Deutsche Telekom. 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.aai.schemaservice.interceptors.pre;
+
+import org.glassfish.jersey.server.ContainerException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.onap.aai.schemaservice.interceptors.AAIHeaderProperties;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.UriInfo;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.List;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.Mockito.*;
+
+class RequestTransactionLoggingTest {
+
+ @InjectMocks
+ RequestTransactionLogging requestTransactionLogging;
+
+ @Mock
+ ContainerRequestContext containerRequestContext;
+
+ @Mock
+ UriInfo uriInfoMock;
+
+ @Mock
+ private MultivaluedMap<String, String> mockHeaders;
+
+ @BeforeEach
+ void setUp() {
+ // Initialize mocks
+ MockitoAnnotations.openMocks(this);
+ }
+
+ @Test
+ public void testFilterMethod() throws UnsupportedEncodingException {
+
+ String contentType = "application/json";
+ String expectedTxId = "12345";
+ String request ="request_id";
+ String aaiRequestTs="aaiRequestId";
+ String payload = "{\"key\":\"value\"}";
+
+ List<MediaType> acceptHeaderValues = Arrays.asList(MediaType.APPLICATION_JSON_TYPE);
+
+ when(containerRequestContext.getHeaderString("Content-Type")).thenReturn(contentType);
+ when(containerRequestContext.getAcceptableMediaTypes()).thenReturn(acceptHeaderValues);
+ when(containerRequestContext.getProperty(AAIHeaderProperties.AAI_TX_ID)).thenReturn(expectedTxId);
+ when(containerRequestContext.getProperty(AAIHeaderProperties.AAI_REQUEST)).thenReturn(request);
+ when(containerRequestContext.getProperty(AAIHeaderProperties.AAI_REQUEST_TS)).thenReturn(aaiRequestTs);
+
+ when(containerRequestContext.getHeaders()).thenReturn(mockHeaders);
+
+ when(mockHeaders.containsKey("Content-Type")).thenReturn(false);
+ when(mockHeaders.containsKey("Accept")).thenReturn(true);
+
+ // Mocking UriInfo methods
+ when(containerRequestContext.getUriInfo()).thenReturn(uriInfoMock);
+ when(uriInfoMock.getRequestUri()).thenReturn(URI.create("http://localhost/some/other/path"));
+ when(uriInfoMock.getPath()).thenReturn("/some/other/path");
+
+ InputStream inputStream = new ByteArrayInputStream(payload.getBytes("UTF-8"));
+ when(containerRequestContext.getEntityStream()).thenReturn(inputStream);
+
+ requestTransactionLogging.filter(containerRequestContext);
+
+ // Assertions for headers
+ assertNotNull(mockHeaders, "Headers should not be null.");
+ assertNull(mockHeaders.getFirst("Content-Type"), "Content-Type should initially be null.");
+ }
+
+ @Test
+ public void testFilterMethodWithIOException() throws IOException {
+
+ String contentType = "application/json";
+ String expectedTxId = "12345";
+ String request = "request_id";
+ String aaiRequestTs = "aaiRequestId";
+ String payload = "{\"key\":\"value\"}";
+
+ List<MediaType> acceptHeaderValues = Arrays.asList(MediaType.APPLICATION_JSON_TYPE);
+
+ // Mocking containerRequestContext methods
+ when(containerRequestContext.getHeaderString("Content-Type")).thenReturn(contentType);
+ when(containerRequestContext.getAcceptableMediaTypes()).thenReturn(acceptHeaderValues);
+ when(containerRequestContext.getProperty(AAIHeaderProperties.AAI_TX_ID)).thenReturn(expectedTxId);
+ when(containerRequestContext.getProperty(AAIHeaderProperties.AAI_REQUEST)).thenReturn(request);
+ when(containerRequestContext.getProperty(AAIHeaderProperties.AAI_REQUEST_TS)).thenReturn(aaiRequestTs);
+
+ // Mocking the getHeaders() method to return a non-null headers object
+ when(containerRequestContext.getHeaders()).thenReturn(mockHeaders);
+ when(mockHeaders.getFirst("Content-Type")).thenReturn(null); // This is to simulate the header being absent
+ when(mockHeaders.getFirst("Accept")).thenReturn("application/xml");
+
+ doNothing().when(mockHeaders).putSingle(anyString(), anyString());
+ when(mockHeaders.containsKey("Content-Type")).thenReturn(false);
+ when(mockHeaders.containsKey("Accept")).thenReturn(true);
+
+ // Mocking UriInfo methods
+ when(containerRequestContext.getUriInfo()).thenReturn(uriInfoMock);
+ when(uriInfoMock.getRequestUri()).thenReturn(URI.create("http://localhost/some/other/path"));
+ when(uriInfoMock.getPath()).thenReturn("/some/other/path");
+
+ // Mocking getEntityStream to throw an IOException
+ InputStream inputStream = mock(InputStream.class);
+ when(inputStream.available()).thenThrow(new IOException("Test IOException"));
+ when(containerRequestContext.getEntityStream()).thenReturn(inputStream);
+
+ assertThrows(ContainerException.class, () -> {
+ requestTransactionLogging.filter(containerRequestContext);
+ });
+ }
+}
diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/validation/FailFastStrategyTest.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/validation/FailFastStrategyTest.java
new file mode 100644
index 0000000..9c75a59
--- /dev/null
+++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/validation/FailFastStrategyTest.java
@@ -0,0 +1,56 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2025 Deutsche Telekom. 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.aai.schemaservice.nodeschema.validation;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
+class FailFastStrategyTest {
+
+ private FailFastStrategy failFastStrategy;
+
+ @BeforeEach
+ void setUp() {
+ failFastStrategy = new FailFastStrategy();
+ }
+
+ @Test
+ void testIsOK_WhenNoErrorOccurred() {
+ assertTrue(failFastStrategy.isOK());
+ }
+
+ @Test
+ void testGetErrorMsg_WhenNoErrorOccurred() {
+ assertEquals("No errors found.", failFastStrategy.getErrorMsg());
+ }
+
+ @Test
+ void testNotifyOnError_ShouldSetErrorState() {
+ String errorMessage = "Validation failed!";
+ AAISchemaValidationException exception = assertThrows(AAISchemaValidationException.class, () -> {
+ failFastStrategy.notifyOnError(errorMessage);
+ });
+
+ assertEquals(errorMessage, exception.getMessage());
+ assertFalse(failFastStrategy.isOK());
+ assertEquals(errorMessage, failFastStrategy.getErrorMsg());
+ }
+}
diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/validation/NodeValidatorTest.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/validation/NodeValidatorTest.java
new file mode 100644
index 0000000..2e2b48b
--- /dev/null
+++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/validation/NodeValidatorTest.java
@@ -0,0 +1,101 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2025 Deutsche Telekom. 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.aai.schemaservice.nodeschema.validation;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.*;
+import org.onap.aai.schemaservice.config.ConfigTranslator;
+import org.onap.aai.schemaservice.nodeschema.SchemaVersion;
+import java.util.*;
+import static org.mockito.Mockito.*;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class NodeValidatorTest {
+
+ @Mock
+ private ConfigTranslator mockTranslator;
+
+ @Mock
+ private SchemaErrorStrategy mockErrorStrategy;
+
+ @Mock
+ private DuplicateNodeDefinitionValidationModule mockDupChecker;
+
+ private NodeValidator nodeValidator;
+
+ @BeforeEach
+ void setUp() {
+ MockitoAnnotations.openMocks(this);
+ nodeValidator = new NodeValidator(mockTranslator, mockErrorStrategy, mockDupChecker);
+ }
+
+ @Test
+ void testValidate_NoDuplicates_ShouldReturnTrue() {
+ SchemaVersion schemaVersion = mock(SchemaVersion.class);
+ List<String> nodeFiles = Arrays.asList("file1", "file2", "file3");
+
+ Map<SchemaVersion, List<String>> mockNodeFiles = new HashMap<>();
+ mockNodeFiles.put(schemaVersion, nodeFiles);
+
+ when(mockTranslator.getNodeFiles()).thenReturn(mockNodeFiles);
+ when(mockDupChecker.findDuplicates(nodeFiles, schemaVersion)).thenReturn("");
+
+ boolean result = nodeValidator.validate();
+ assertFalse(result);
+
+ verify(mockErrorStrategy, never()).notifyOnError(anyString());
+ }
+
+ @Test
+ void testValidate_WithDuplicates_ShouldReturnFalse() {
+ SchemaVersion schemaVersion = mock(SchemaVersion.class);
+ List<String> nodeFiles = Arrays.asList("file1", "file2", "file3");
+
+ Map<SchemaVersion, List<String>> mockNodeFiles = new HashMap<>();
+ mockNodeFiles.put(schemaVersion, nodeFiles);
+
+ when(mockTranslator.getNodeFiles()).thenReturn(mockNodeFiles);
+ when(mockDupChecker.findDuplicates(nodeFiles, schemaVersion)).thenReturn("Duplicate found!");
+ boolean result = nodeValidator.validate();
+
+ assertFalse(result);
+ verify(mockErrorStrategy).notifyOnError("Duplicate found!");
+ }
+
+ @Test
+ void testGetErrorMsg_WithoutError_ShouldReturnEmptyString() {
+ when(mockErrorStrategy.getErrorMsg()).thenReturn("");
+
+ String errorMsg = nodeValidator.getErrorMsg();
+
+ assertEquals("", errorMsg);
+ }
+
+ @Test
+ void testGetErrorMsg_WithError_ShouldReturnErrorMessage() {
+ when(mockErrorStrategy.getErrorMsg()).thenReturn("Some error occurred");
+
+ String errorMsg = nodeValidator.getErrorMsg();
+
+ assertEquals("Some error occurred", errorMsg);
+ }
+}
diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/validation/VersionValidatorTest.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/validation/VersionValidatorTest.java
new file mode 100644
index 0000000..5db1a26
--- /dev/null
+++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/validation/VersionValidatorTest.java
@@ -0,0 +1,76 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2025 Deutsche Telekom. 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.aai.schemaservice.nodeschema.validation;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.*;
+import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.*;
+
+class VersionValidatorTest {
+
+ @Mock
+ private SchemaErrorStrategy mockErrorStrategy;
+
+ @Mock
+ private VersionValidationModule mockVersionValidationModule;
+
+ private VersionValidator versionValidator;
+
+ @BeforeEach
+ void setUp() {
+ MockitoAnnotations.openMocks(this);
+ versionValidator = new VersionValidator(mockErrorStrategy, mockVersionValidationModule);
+ }
+
+ @Test
+ void testValidate_NoError_ShouldReturnTrue() {
+ when(mockVersionValidationModule.validate()).thenReturn("");
+ when(mockErrorStrategy.isOK()).thenReturn(true);
+
+ boolean result = versionValidator.validate();
+
+ assertTrue(result);
+ verify(mockErrorStrategy, never()).notifyOnError(anyString());
+ }
+
+ @Test
+ void testValidate_WithError_ShouldReturnFalse() {
+ String errorMessage = "Version validation failed";
+ when(mockVersionValidationModule.validate()).thenReturn(errorMessage);
+ when(mockErrorStrategy.isOK()).thenReturn(false);
+
+ boolean result = versionValidator.validate();
+
+ assertFalse(result);
+ verify(mockErrorStrategy).notifyOnError(errorMessage);
+ }
+
+ @Test
+ void testGetErrorMsg() {
+ String errorMessage = "Error in version validation";
+ when(mockErrorStrategy.getErrorMsg()).thenReturn(errorMessage);
+
+ String errorMsg = versionValidator.getErrorMsg();
+
+ assertEquals(errorMessage, errorMsg);
+ }
+}
diff --git a/aai-schema-service/src/test/resources/application.properties b/aai-schema-service/src/test/resources/application.properties
index a711688..9235392 100644
--- a/aai-schema-service/src/test/resources/application.properties
+++ b/aai-schema-service/src/test/resources/application.properties
@@ -18,19 +18,8 @@ server.tomcat.max-idle-time=60000
# If you get an application startup failure that the port is already taken
# If thats not it, please check if the key-store file path makes sense
server.local.startpath=src/main/resources/
-server.basic.auth.location=${server.local.startpath}etc/auth/realm.properties
server.port=8452
-security.require-ssl=false
-server.ssl.enabled=false
-# Server SSL Related Attributes
-#server.ssl.enabled-protocols=TLSv1.1,TLSv1.2
-#server.ssl.key-store=${server.local.startpath}etc/auth/aai_keystore
-#server.ssl.key-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
-#server.ssl.trust-store=${server.local.startpath}etc/auth/aai_keystore
-#server.ssl.trust-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
-#server.ssl.client-auth=want
-#server.ssl.key-store-type=JKS
# Schema related attributes for the oxm and edges
# Any additional schema related attributes should start with prefix schema
diff --git a/aai-schema-service/src/test/resources/error.properties b/aai-schema-service/src/test/resources/error.properties
new file mode 100644
index 0000000..52a44bc
--- /dev/null
+++ b/aai-schema-service/src/test/resources/error.properties
@@ -0,0 +1,198 @@
+# Adding comment trying to trigger a build
+#------------------------------------------------------------------------------- ----------
+#Key=Disposition:Category:Severity:Error Code:HTTP ResponseCode:RESTError Code:Error Message
+#------------------------------------------------------------------------------- ----------
+# testing code, please don't change unless error utility source code changes
+AAI_TESTING=5:2:WARN:0000:400:0001:Error code for testing:0
+
+# General success
+AAI_0000=0:0:INFO:0000:200:0000:Success:0
+
+# health check success
+AAI_0001=0:0:INFO:0001:200:0001:Success X-FromAppId=%1 X-TransactionId=%2 :0
+AAI_0002=0:0:INFO:0002:200:0001:Successful health check:0
+
+# Success with additional info
+AAI_0003=0:3:INFO:0003:202:0003:Success with additional info performing %1 on %2. Added %3 with key %4:0
+AAI_0004=0:3:INFO:0004:202:0003:Added prerequisite object to db:0
+
+#--- aairest: 3000-3299
+# svc errors
+AAI_3000=5:2:INFO:3000:400:3000:Invalid input performing %1 on %2:300
+AAI_3001=5:6:INFO:3001:404:3001:Resource not found for %1 using id %2:300
+AAI_3002=5:1:WARN:3002:400:3002:Error writing output performing %1 on %2:300
+AAI_3003=5:1:WARN:3003:400:3003:Failed to make edge to missing target node of type %3 with keys %4 performing %1 on %2:400
+AAI_3005=5:6:WARN:3005:404:3001:Node cannot be directly accessed for read, must be accessed via ancestor(s):100
+AAI_3006=5:6:WARN:3006:404:3001:Node cannot be directly accessed for write, must be accessed via ancestor(s)100
+AAI_3007=5:6:INFO:3007:410:3007:This version (%1) of the API is retired, please migrate to %2:500
+AAI_3008=5:6:WARN:3008:400:3008:URI is not encoded in UTF-8:300
+AAI_3009=5:6:WARN:3009:400:3002:Malformed URL:300
+AAI_3010=5:6:WARN:3010:400:3002:Cannot write via this URL:100
+AAI_3011=5:6:WARN:3011:400:3000:Unknown XML namespace used in payload:300
+AAI_3012=5:6:WARN:3012:400:3012:Unrecognized AAI function:300
+AAI_3013=5:6:WARN:3013:400:3013:Query payload missing required parameters %1:300
+AAI_3014=5:6:WARN:3014:400:3014:Query payload is invalid %1:300
+AAI_3016=5:6:INFO:3007:400:3016:Request uri is not valid, please check the version %1:500
+AAI_3017=5:6:INFO:3007:400:3016:Request uri is not valid, please check the uri %1:500
+AAI_3018=5:6:WARN:3018:400:3018:Query URI missing required parameters:300
+AAI_3019=5:6:WARN:3019:400:3019:Query URI sending conflicting parameters:300
+AAI_3020=5:6:WARN:3020:400:3020:Query URI parameters outside bounds:300
+AAI_3021=5:6:WARN:3021:400:3021:Invalid parameters to Recents API:300
+AAI_3022=5:6:WARN:3022:400:3022:Query payload includes extra/unrecognized parameters %1:300
+AAI_3025=5:4:FATAL:3025:500:3025:Error connecting to Schema Service:400
+AAI_3026=5:4:FATAL:3026:500:3026:Error reading OXM from Schema Service:400
+AAI_3027=5:4:FATAL:3026:500:3026:Error reading EdgeRules from Schema Service:400
+AAI_3028=5:4:FATAL:3026:500:3026:Error reading stored-queries from Schema Service:400
+
+# pol errors
+AAI_3100=5:1:WARN:3100:400:3100:Unsupported operation %1:300
+AAI_3101=5:1:WARN:3101:403:3101:Attempt by client %1 to execute API %2:100
+AAI_3102=5:1:WARN:3102:400:3102:Error parsing input performing %1 on %2:300
+AAI_3300=5:1:WARN:3300:403:3300:Unauthorized:100
+AAI_3301=5:1:WARN:3301:401:3301:Stale credentials:100
+AAI_3302=5:1:WARN:3302:401:3301:Not authenticated:100
+AAI_3303=5:1:WARN:3303:403:3300:Too many objects would be returned by this request, please refine your request and retry:500
+
+#--- aaigen: 4000-4099
+AAI_4000=5:4:ERROR:4000:500:3002:Internal Error:500
+AAI_4001=5:4:FATAL:4001:500:3002:Configuration file not found:500
+AAI_4002=5:4:FATAL:4002:500:3002:Error reading Configuration file:500
+AAI_4003=5:4:ERROR:4003:500:3002:Error writing to log file:500
+AAI_4004=5:4:FATAL:4004:500:3002:Error reading/parsing the error properties file:500
+AAI_4005=5:4:FATAL:4005:500:3002:Missing or invalid configuration parameter:500
+AAI_4006=5:4:FATAL:4006:500:3002:Unexpected error in service:500
+AAI_4007=5:4:WARN:4007:500:3102:Input parsing error:500
+AAI_4008=5:4:ERROR:4008:500:3002:Output parsing error:500
+AAI_4009=4:0:WARN:4009:400:3000:Invalid X-FromAppId in header:300
+AAI_4010=4:0:WARN:4010:400:3000:Invalid X-TransactionId in header:300
+AAI_4011=5:4:ERROR:4011:500:3002:Missing data for REST error response:500
+AAI_4014=4:0:WARN:4014:400:3000:Invalid Accept header:300
+AAI_4015=4:0:WARN:4015:400:3000:You must provide at least one indexed property:400
+AAI_4016=4:0:WARN:4016:400:3000:The depth parameter must be a number or the string "all":300
+AAI_4017=5:2:INFO:4017:400:3000:Could not set property:300
+AAI_4018=5:2:WARN:4018:400:3000:Unable to convert the string to integer:300
+AAI_4019=5:4:ERROR:4018:400:3000:Invalid start time sent to history formats:300
+AAI_4020=5:4:ERROR:4020:400:3002:Unexpected data type for property key:400
+
+#--- aaidbmap: 5102-5199
+AAI_5102=5:4:FATAL:5102:500:3002:Graph database is null after open:400
+AAI_5105=5:4:ERROR:5105:500:3002:Unexpected error reading/updating database:300
+AAI_5106=5:4:WARN:5106:404:3001:Node not found:300
+AAI_5107=5:2:WARN:5107:400:3000:Required information missing:300
+AAI_5108=5:2:WARN:5108:200:0:Unexpected information in request being ignored:300
+
+#--- aaidbgen: 6101-6199
+AAI_6101=5:4:ERROR:6101:500:3002:null JanusGraph object passed:400
+AAI_6102=5:4:WARN:6102:400:3000:Passed-in property is not valid for this nodeType:400
+AAI_6103=5:4:WARN:6103:400:3000:Required Node-property not found in input data:400
+AAI_6104=5:4:WARN:6104:400:3000:Required Node-property was passed with no data:400
+AAI_6105=5:4:WARN:6105:400:3000:Node-Key-Property not defined in DbMaps:400
+AAI_6106=5:4:WARN:6106:400:3000:Passed-in property is not valid for this edgeType:400
+AAI_6107=5:4:WARN:6107:400:3000:Required Edge-property not found in input data:400
+AAI_6108=5:4:WARN:6108:400:3000:Required Edge-property was passed with no data:400
+AAI_6109=5:4:WARN:6109:400:3000:Bad dependent Node value:400
+AAI_6110=5:4:ERROR:6110:400:3100:Node cannot be deleted:500
+AAI_6111=5:4:WARN:6111:400:3000:JSON processing error:300
+AAI_6112=5:4:ERROR:6112:400:3000:More than one node found by getUniqueNode():400
+AAI_6114=5:4:WARN:6114:404:3001:Node Not Found:300
+AAI_6115=5:4:ERROR:6115:400:3000:Unrecognized NodeType:400
+AAI_6116=5:4:ERROR:6116:400:3000:Unrecognized Property:400
+AAI_6117=5:4:ERROR:6117:400:3000:Uniqueness constraint violated:400
+AAI_6118=5:4:WARN:6118:400:3000:Required Field not passed.:400
+AAI_6120=5:4:WARN:6120:400:3000:Bad Parameter Passed:300
+AAI_6121=5:4:ERROR:6121:400:3000:Problem with internal AAI reference data:400
+AAI_6122=5:4:ERROR:6122:400:3000:Data Set not complete in DB for this request:400
+AAI_6123=5:4:ERROR:6123:500:3000:Bad Data found by DataGrooming Tool - Investigate:300
+AAI_6124=5:4:ERROR:6124:500:3000:File read/write error:500
+AAI_6125=5:4:WARN:6125:500:3000:Problem Pulling Data Set:500
+AAI_6126=5:4:ERROR:6126:400:3000:Edge cannot be deleted:400
+AAI_6127=5:4:INFO:6127:404:3001:Edge Not Found:400
+AAI_6128=5:4:INFO:6128:500:3000:Unexpected error:900
+AAI_6129=5:4:INFO:6129:404:3003:Error making edge to target node:400
+AAI_6130=5:4:WARN:6130:412:3000:Precondition Required:300
+AAI_6131=5:4:WARN:6131:412:3000:Precondition Failed:300
+AAI_6132=5:4:WARN:6132:400:3000:Bad Model Definition:500
+AAI_6133=5:4:WARN:6133:400:3000:Bad Named Query Definition:500
+AAI_6134=5:4:ERROR:6134:500:6134:Could not persist transaction to storage back end. Exhausted retry amount:500
+AAI_6135=5:4:WARN:6135:412:3000:Resource version specified on create:300
+AAI_6136=5:4:ERROR:6136:400:3000:Object cannot hold multiple items:400
+AAI_6137=5:4:ERROR:6137:400:3000:Cannot perform writes on multiple vertices:400
+AAI_6138=5:4:ERROR:6138:400:3000:Cannot delete multiple vertices:400
+AAI_6139=5:4:ERROR:6139:404:3000:Attempted to add edge to vertex that does not exist:400
+AAI_6140=5:4:ERROR:6140:400:3000:Edge multiplicity violated:400
+AAI_6141=5:4:WARN:6141:400:3000:Please Refine Query:400
+AAI_6142=5:4:INFO:6142:400:3000:Retrying transaction:900
+AAI_6143=5:4:INFO:6143:400:3000:Ghost vertex found:400
+AAI_6144=5:4:WARN:6144:400:3000:Cycle found in graph:400
+AAI_6145=5:4:ERROR:6145:400:3000:Cannot create a nested/containment edge via relationship:400
+AAI_6146=5:4:ERROR:6146:400:3000:Ambiguous identity map found, use a URI instead:300
+AAI_6147=5:4:ERROR:6147:400:3000:Payload Limit Reached, reduce payload:300
+AAI_6148=5:4:INFO:6148:404:3001:Node Not Found. Start URI returned no vertexes, please check the start URI:400
+AAI_6149=5:4:INFO:6149:400:6149:DSL Query/Schema Error:400
+AAI_6150=5:4:INFO:6150:404:6150:Pagination Error:500
+AAI_6151=5:4:INFO:6151:400:6151:DSL Validation Error:500
+AAI_6152=5:4:INFO:6152:400:6152:DSL Generic Error:900
+AAI_6153=5:4:INFO:6153:400:6153:DSL Syntax Error:300
+AAI_6154=5:4:WARN:6134:500:3000:Delete Error:300
+
+#--- aaicsvp: 7101-7199
+AAI_7101=5:4:ERROR:7101:500:3002:Unexpected error in CSV file processing:900
+AAI_7102=5:4:ERROR:7102:500:3002:Error in cleanup temporary directory:500
+#AAI_7103=4:2:ERROR:7103:500:3002:Unsupported user:100
+AAI_7104=5:4:ERROR:7104:500:3002:Failed to create directory:500
+AAI_7105=5:4:ERROR:7105:500:3002:Temporary directory exists:500
+AAI_7106=5:4:ERROR:7106:500:3002:Cannot delete:500
+AAI_7107=5:4:ERROR:7107:500:3002:Input file does not exist:500
+AAI_7108=5:4:ERROR:7108:500:3002:Output file does not exist:500
+AAI_7109=5:4:ERROR:7109:500:3002:Error closing file:500
+AAI_7110=5:4:ERROR:7110:500:3002:Error loading/reading properties file:500
+AAI_7111=5:4:ERROR:7111:500:3002:Error executing shell script:900
+AAI_7112=5:4:ERROR:7112:500:3002:Error creating output file:500
+AAI_7113=5:4:ERROR:7113:500:3002:Trailer record error:300
+AAI_7114=5:4:ERROR:7114:500:3002:Input file error:300
+AAI_7115=5:4:ERROR:7115:500:3002:Unexpected error:900
+AAI_7116=5:4:ERROR:7116:500:3002:Request error:900
+AAI_7117=5:4:ERROR:7117:500:3002:Error in get http client object:500
+AAI_7118=5:4:ERROR:7118:500:3002:Script Error:900
+AAI_7119=5:4:ERROR:7119:500:3002:Unknown host:900
+
+#--- aaisdnc: 7201-7299
+AAI_7202=5:4:ERROR:7202:500:3002:Error getting connection to odl:200
+AAI_7203=5:4:ERROR:7203:500:3002:Unexpected error calling DataChangeNotification API:900
+AAI_7204=5:4:ERROR:7204:500:3002:Error returned by DataChangeNotification API:200
+#AAI_7206=5:4:ERROR:7206:500:3002:Invalid data returned from ODL:300
+
+#--- NotificationEvent, using UEB space
+AAI_7304=4:5:ERROR:7304:500:3002:Error reaching DMaaP to send event:200
+AAI_7350=5:4:ERROR:7305:500:3002:Notification event creation failed:500
+
+#--- aairestctlr: 7401-7499
+AAI_7401=5:4:ERROR:7401:500:3002:Error connecting to AAI REST API:200
+AAI_7402=5:4:ERROR:7402:500:3002:Unexpected error:900
+AAI_7403=5:4:WARN:7403:400:3001:Request error:900
+AAI_7404=5:4:INFO:7404:404:3001:Node not found:300
+AAI_7405=5:4:WARN:7405:200:0:UUID not formatted correctly, generating UUID:300
+AAI_7406=5:4:ERROR:7406:400:7406:Request Timed Out:200
+
+#--- aaicsiovals: 7501-7599
+#AAI_7501=5:4:WARN:7501:500:3002:Error getting connection to CSI-OVALS:200
+AAI_7502=5:4:WARN:7502:500:3002:Bad parameter when trying to build request for CSI-OVALS:300
+AAI_7503=5:4:WARN:7503:500:3002:Error returned by CSI-OVALS:500
+
+#--- aaiauth: 9101-9199
+AAI_9101=5:0:WARN:9101:403:3300:User is not authorized to perform function:100
+#AAI_9102=5:0:WARN:9102:401:3301:Refresh credentials from source
+#AAI_9103=5:0:WARN:9103:403:3300:User not found
+#AAI_9104=5:0:WARN:9104:401:3302:Authentication error
+#AAI_9105=5:0:WARN:9105:403:3300:Authorization error
+#AAI_9106=5:0:WARN:9106:403:3300:Invalid AppId
+#AAI_9107=5:0:WARN:9107:403:3300:No Username in Request
+AAI_9107=5:0:WARN:9107:403:3300:SSL is not provided in request, please contact admin:100
+
+#--- aaiinstar: 9201-9299
+#AAI_9201=5:4:ERROR:9201:500:3002:Unable to send notification
+AAI_9202=5:4:ERROR:9202:500:3002:Unable to start a thread:500
+#--- GRM DME2: 9501-9599
+AAI_9501=5:4:WARN:9501:500:3002:Unable to register with GRM retrying:200
+AAI_9502=5:4:ERROR:9502:500:3002:Unable to register with GRM after exhausting all retries:200
+AAI_9503=5:4:WARN:9503:500:3002:Unable to successfully unpublish with GRM, recommend manual cleanup but not necessary:200