Fix sonar issues 55/141555/1
authoradheli.tavares <adheli.tavares@est.tech>
Mon, 21 Jul 2025 09:50:06 +0000 (10:50 +0100)
committeradheli.tavares <adheli.tavares@est.tech>
Mon, 21 Jul 2025 09:55:07 +0000 (10:55 +0100)
Issue-ID: POLICY-5421
Change-Id: I767787d7c0129aecc778292c5e8ae08eea256d14
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
main/src/test/java/org/onap/policy/api/main/rest/TestApiRestController.java
main/src/test/java/org/onap/policy/api/main/rest/TestNodeTemplateController.java
main/src/test/java/org/onap/policy/api/main/service/TestCommonToscaServiceTemplateService.java
main/src/test/java/org/onap/policy/api/main/service/TestNodeTemplateService.java
main/src/test/java/org/onap/policy/api/main/service/TestPdpGroupService.java
main/src/test/java/org/onap/policy/api/main/service/TestPolicyTypeService.java
packages/policy-api-docker/src/main/docker/policy-api.sh
packages/policy-api-tarball/src/main/resources/etc/ssl/policy-truststore [deleted file]

index a9a7cb8..1c9dd2c 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * Copyright (C) 2024 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2024-2025 OpenInfra Foundation Europe. 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.
@@ -43,10 +43,10 @@ import org.onap.policy.models.base.PfModelRuntimeException;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
-import org.springframework.boot.test.mock.mockito.MockBean;
 import org.springframework.http.MediaType;
 import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.bean.override.mockito.MockitoBean;
 import org.springframework.test.web.servlet.MockMvc;
 import org.springframework.test.web.servlet.setup.MockMvcBuilders;
 import org.springframework.web.context.WebApplicationContext;
@@ -59,10 +59,10 @@ class TestApiRestController {
     @Autowired
     private MockMvc mvc;
 
-    @MockBean
+    @MockitoBean
     private HealthCheckProvider healthCheckProvider;
 
-    @MockBean
+    @MockitoBean
     private ToscaServiceTemplateService toscaServiceTemplateService;
 
     AutoCloseable autoCloseable;
index 22c4346..06ff1f5 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy API
  * ================================================================================
- * Copyright (C) 2022-2024 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2022-2025 OpenInfra Foundation Europe. 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.
@@ -43,10 +43,10 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
-import org.springframework.boot.test.mock.mockito.MockBean;
 import org.springframework.http.MediaType;
 import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.bean.override.mockito.MockitoBean;
 import org.springframework.test.web.servlet.MockMvc;
 import org.springframework.test.web.servlet.setup.MockMvcBuilders;
 import org.springframework.web.context.WebApplicationContext;
@@ -59,7 +59,7 @@ class TestNodeTemplateController {
     @Autowired
     private MockMvc mvc;
 
-    @MockBean
+    @MockitoBean
     private ToscaServiceTemplateService toscaServiceTemplateService;
 
     AutoCloseable autoCloseable;
index fcdb928..924ed1e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  ============LICENSE_START=======================================================
  *  Copyright (C) 2022 Bell Canada. All rights reserved.
- *  Modifications Copyright (C) 2023-2024 Nordix Foundation.
+ *  Modifications Copyright (C) 2023-2025 OpenInfra Foundation Europe. 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.
@@ -35,7 +35,7 @@ import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
 /**
  * This class offers common mock utility methods for uni testing {@link ToscaServiceTemplateService}.
  */
-public class TestCommonToscaServiceTemplateService {
+class TestCommonToscaServiceTemplateService {
 
     protected enum Operation {
         CREATE_POLICY_TYPE,
@@ -93,14 +93,14 @@ public class TestCommonToscaServiceTemplateService {
      * Setup to return empty DB service template.
      */
     @BeforeEach
-    public void setUp() {
+    void setUp() {
         autoCloseable = MockitoAnnotations.openMocks(this);
         Mockito.when(toscaServiceTemplateRepository.findById(new PfConceptKey(JpaToscaServiceTemplate.DEFAULT_NAME,
             JpaToscaServiceTemplate.DEFAULT_VERSION))).thenReturn(Optional.of(new JpaToscaServiceTemplate()));
     }
 
     @AfterEach
-    public void tearDown() throws Exception {
+    void tearDown() throws Exception {
         autoCloseable.close();
     }
 }
\ No newline at end of file
index b48306f..a1fea21 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy API
  * ================================================================================
- * Copyright (C) 2022-2024 Nordix Foundation. All rights reserved.
+ * Copyright (C) 2022-2025 OpenInfra Foundation Europe. 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.
@@ -74,7 +74,7 @@ class TestNodeTemplateService {
      * @throws CoderException if error in json parsing
      */
     @BeforeEach
-    public void setUp() throws CoderException {
+    void setUp() throws CoderException {
         closeable = MockitoAnnotations.openMocks(this);
         StandardCoder standardCoder = new StandardCoder();
         policyServiceTemplate =
index d46592f..da37ff0 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  ============LICENSE_START=======================================================
  *  Copyright (C) 2022 Bell Canada. All rights reserved.
- *  Modifications Copyright (C) 2023 Nordix Foundation.
+ *  Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. 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.
@@ -56,7 +56,7 @@ class TestPdpGroupService {
      * @throws CoderException decode errors
      */
     @BeforeEach
-    public void setUp() throws CoderException {
+    void setUp() throws CoderException {
         closeable = MockitoAnnotations.openMocks(this);
         var pdpGroups = new StandardCoder().decode(ResourceUtils.getResourceAsString("pdpgroups/PdpGroups.json"),
             PdpGroups.class).getGroups();
index 278d597..cc31149 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  ============LICENSE_START=======================================================
  *  Copyright (C) 2022 Bell Canada. All rights reserved.
- *  Modifications Copyright (C) 2023 Nordix Foundation.
+ *  Modifications Copyright (C) 2023, 2025 OpenInfra Foundation Europe. 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.
@@ -44,7 +44,7 @@ class TestPolicyTypeService {
     AutoCloseable closeable;
 
     @BeforeEach
-    public void setUp() {
+    void setUp() {
         closeable = MockitoAnnotations.openMocks(this);
     }
 
index e638ceb..b4c0fef 100644 (file)
@@ -2,7 +2,7 @@
 #
 # ============LICENSE_START=======================================================
 #  Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
-#  Modifications Copyright (C) 2019-2022 Nordix Foundation.
+#  Modifications Copyright (C) 2019-2022, 2025 OpenInfra Foundation Europe. All rights reserved.
 #  Modifications Copyright (C) 2022 Bell Canada. All rights reserved.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # ============LICENSE_END=========================================================
 #
 
-KEYSTORE="${KEYSTORE:-$POLICY_HOME/etc/ssl/policy-keystore}"
-TRUSTSTORE="${TRUSTSTORE:-$POLICY_HOME/etc/ssl/policy-truststore}"
-KEYSTORE_PASSWD="${KEYSTORE_PASSWD:-Pol1cy_0nap}"
-TRUSTSTORE_PASSWD="${TRUSTSTORE_PASSWD:-Pol1cy_0nap}"
-
 if [ "$#" -eq 1 ]; then
     CONFIG_FILE=$1
 else
+    # shellcheck disable=SC2269
     CONFIG_FILE=${CONFIG_FILE}
 fi
 
@@ -38,26 +34,12 @@ fi
 
 echo "Policy api config file: $CONFIG_FILE"
 
-if [ -f "${POLICY_HOME}/etc/mounted/policy-truststore" ]; then
-    echo "overriding policy-truststore"
-    cp -f "${POLICY_HOME}"/etc/mounted/policy-truststore "${TRUSTSTORE}"
-fi
-
-if [ -f "${POLICY_HOME}/etc/mounted/policy-keystore" ]; then
-    echo "overriding policy-keystore"
-    cp -f "${POLICY_HOME}"/etc/mounted/policy-keystore "${KEYSTORE}"
-fi
-
 if [ -f "${POLICY_HOME}/etc/mounted/logback.xml" ]; then
     echo "overriding logback.xml"
     cp -f "${POLICY_HOME}"/etc/mounted/logback.xml "${POLICY_HOME}"/etc/
 fi
 
-$JAVA_HOME/bin/java \
+"$JAVA_HOME"/bin/java \
     -Dlogging.config="${POLICY_HOME}/etc/logback.xml" \
-    -Dserver.ssl.key-store="${KEYSTORE}" \
-    -Dserver.ssl.key-store-password="${KEYSTORE_PASSWD}" \
-    -Djavax.net.ssl.trustStore="${TRUSTSTORE}" \
-    -Djavax.net.ssl.trustStorePassword="${TRUSTSTORE_PASSWD}" \
     -jar /app/api.jar \
     --spring.config.location="${CONFIG_FILE}"
diff --git a/packages/policy-api-tarball/src/main/resources/etc/ssl/policy-truststore b/packages/policy-api-tarball/src/main/resources/etc/ssl/policy-truststore
deleted file mode 100644 (file)
index 8834ac2..0000000
Binary files a/packages/policy-api-tarball/src/main/resources/etc/ssl/policy-truststore and /dev/null differ