Add forwarding support for policy-pap 96/132096/2
authorliamfallon <liam.fallon@est.tech>
Wed, 9 Nov 2022 11:50:59 +0000 (11:50 +0000)
committerliamfallon <liam.fallon@est.tech>
Wed, 9 Nov 2022 13:51:27 +0000 (13:51 +0000)
The GUI server must forward calls to PAP to allow policies to be
deployed and undeployed.

Issue-ID: POLICY-4138
Change-Id: I10ef96a8154cf618c3a22be1e06ec969729db54e
Signed-off-by: liamfallon <liam.fallon@est.tech>
20 files changed:
gui-server/src/main/java/org/onap/policy/gui/server/config/FilterRegistrationConfig.java
gui-server/src/main/java/org/onap/policy/gui/server/config/PolicyApiRestTemplateConfig.java
gui-server/src/main/java/org/onap/policy/gui/server/config/PolicyPapRestTemplateConfig.java [new file with mode: 0644]
gui-server/src/main/java/org/onap/policy/gui/server/rest/PolicyApiRestController.java
gui-server/src/main/java/org/onap/policy/gui/server/rest/PolicyPapRestController.java [new file with mode: 0644]
gui-server/src/test/java/org/onap/policy/gui/server/GuiServerAppMainTest.java
gui-server/src/test/java/org/onap/policy/gui/server/SpringContextTest.java
gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig.java [moved from gui-server/src/test/java/org/onap/policy/gui/server/test/util/RestTemplateConfig.java with 87% similarity]
gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig1Test.java
gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig2Test.java
gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig3Test.java
gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig4Test.java
gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig5Test.java
gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateTrustStoreUnsetTest.java
gui-server/src/test/java/org/onap/policy/gui/server/rest/AcmRuntimeRestControllerTest.java
gui-server/src/test/java/org/onap/policy/gui/server/rest/DesigntimeRestControllerTest.java
gui-server/src/test/java/org/onap/policy/gui/server/rest/PolicyApiRestControllerTest.java
gui-server/src/test/java/org/onap/policy/gui/server/rest/PolicyPapRestControllerTest.java [new file with mode: 0644]
gui-server/src/test/resources/application_http.yaml
gui-server/src/test/resources/application_https.yaml

index 179a3aa..c7a3aa4 100644 (file)
@@ -29,9 +29,12 @@ import org.springframework.context.annotation.Configuration;
 
 @Configuration
 public class FilterRegistrationConfig {
-    @Value("${runtime-ui.policy.mapping-path}")
+    @Value("${runtime-ui.policy-api.mapping-path}")
     private String policyApiMappingPath;
 
+    @Value("${runtime-ui.policy-pap.mapping-path}")
+    private String policyPapMappingPath;
+
     @Value("${runtime-ui.acm.mapping-path}")
     private String acmRuntimeMappingPath;
 
@@ -44,6 +47,7 @@ public class FilterRegistrationConfig {
         registrationBean.setFilter(new ClientSslHeaderFilter());
         registrationBean.addUrlPatterns(
             StringUtils.stripEnd(policyApiMappingPath, "/")  + "/*",
+            StringUtils.stripEnd(policyPapMappingPath, "/")  + "/*",
             StringUtils.stripEnd(acmRuntimeMappingPath, "/")  + "/*"
         );
         return registrationBean;
index e88b0a5..b3bcb24 100644 (file)
@@ -36,10 +36,10 @@ public class PolicyApiRestTemplateConfig extends BaseRestTemplateConfig {
      * @param disableSslValidation Turn off SSL altogether on this REST interface
      * @param disableSslHostnameCheck Turn off SSL host name checking
      */
-    @Value("{runtime-ui.policy}")
+    @Value("{runtime-ui.policy-api}")
     public void setSslFlags(
-        @Value("${runtime-ui.policy.disable-ssl-validation:false}") boolean disableSslValidation,
-        @Value("${runtime-ui.policy.disable-ssl-hostname-check:false}") boolean disableSslHostnameCheck) {
+        @Value("${runtime-ui.policy-api.disable-ssl-validation:false}") boolean disableSslValidation,
+        @Value("${runtime-ui.policy-api.disable-ssl-hostname-check:false}") boolean disableSslHostnameCheck) {
         super.setDisableSslValidation(disableSslValidation);
         super.setDisableSslHostnameCheck(disableSslHostnameCheck);
     }
diff --git a/gui-server/src/main/java/org/onap/policy/gui/server/config/PolicyPapRestTemplateConfig.java b/gui-server/src/main/java/org/onap/policy/gui/server/config/PolicyPapRestTemplateConfig.java
new file mode 100644 (file)
index 0000000..3d7731b
--- /dev/null
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ *  Copyright (C) 2022 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.gui.server.config;
+
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.client.RestTemplate;
+
+@Configuration
+public class PolicyPapRestTemplateConfig extends BaseRestTemplateConfig {
+
+    /**
+     * Set the SSL validation flags on the template.
+     *
+     * @param disableSslValidation Turn off SSL altogether on this REST interface
+     * @param disableSslHostnameCheck Turn off SSL host name checking
+     */
+    @Value("{runtime-ui.policy-pap}")
+    public void setSslFlags(
+        @Value("${runtime-ui.policy-pap.disable-ssl-validation:false}") boolean disableSslValidation,
+        @Value("${runtime-ui.policy-pap.disable-ssl-hostname-check:false}") boolean disableSslHostnameCheck) {
+        super.setDisableSslValidation(disableSslValidation);
+        super.setDisableSslHostnameCheck(disableSslHostnameCheck);
+    }
+
+    /**
+     * Returns a RestTemplate, optionally disabling SSL host name check or disabling SSL validation entirely.
+     */
+    @Bean
+    public RestTemplate policyPapRestTemplate() throws GeneralSecurityException, IOException {
+        return super.getRestTemplate();
+    }
+}
index 2be3417..5e3f5d3 100644 (file)
@@ -35,7 +35,7 @@ import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.client.RestTemplate;
 
 @RestController
-@RequestMapping("${runtime-ui.policy.mapping-path}")
+@RequestMapping("${runtime-ui.policy-api.mapping-path}")
 public class PolicyApiRestController extends BaseRestController {
     /**
      * Set the mapping parameters for the REST controller.
@@ -43,10 +43,10 @@ public class PolicyApiRestController extends BaseRestController {
      * @param mappingPath The mapping path to map from
      * @param url The URL path to map to
      */
-    @Value("{runtime-ui.policy}")
+    @Value("{runtime-ui.policy-api}")
     public void setSslFlags(
-        @Value("${runtime-ui.policy.mapping-path}") String mappingPath,
-        @Value("${runtime-ui.policy.url}") URI url) {
+        @Value("${runtime-ui.policy-api.mapping-path}") String mappingPath,
+        @Value("${runtime-ui.policy-api.url}") URI url) {
         super.setMappingPath(mappingPath);
         super.setUrl(url);
     }
diff --git a/gui-server/src/main/java/org/onap/policy/gui/server/rest/PolicyPapRestController.java b/gui-server/src/main/java/org/onap/policy/gui/server/rest/PolicyPapRestController.java
new file mode 100644 (file)
index 0000000..c837b03
--- /dev/null
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ *  Copyright (C) 2022 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.gui.server.rest;
+
+import java.net.URI;
+import javax.servlet.http.HttpServletRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.client.RestTemplate;
+
+@RestController
+@RequestMapping("${runtime-ui.policy-pap.mapping-path}")
+public class PolicyPapRestController extends BaseRestController {
+    /**
+     * Set the mapping parameters for the REST controller.
+     *
+     * @param mappingPath The mapping path to map from
+     * @param url The URL path to map to
+     */
+    @Value("{runtime-ui.policy-pap}")
+    public void setSslFlags(
+        @Value("${runtime-ui.policy-pap.mapping-path}") String mappingPath,
+        @Value("${runtime-ui.policy-pap.url}") URI url) {
+        super.setMappingPath(mappingPath);
+        super.setUrl(url);
+    }
+
+    /**
+     * Set the REST template for the REST controller.
+     *
+     * @param restTemplate The REST template
+     */
+    @Autowired
+    public void setControllerRestTemplate(
+        @Qualifier("policyPapRestTemplate") RestTemplate restTemplate) {
+        super.setRestTemplate(restTemplate);
+    }
+
+    /**
+     * Proxy rest calls to ACM runtime.
+     */
+    @Override
+    @RequestMapping("/**")
+    public ResponseEntity<String> mirrorRest(@RequestBody(required = false) String body,
+                                             @RequestHeader HttpHeaders headers,
+                                             HttpMethod method,
+                                             HttpServletRequest request) {
+        return super.mirrorRest(body, headers, method, request);
+    }
+}
index 870eaaf..b8e73c3 100644 (file)
@@ -34,9 +34,12 @@ class GuiServerAppMainTest {
         String[] args = {
             "--server.port=0",
             "--server.ssl.enabled=false",
-            "--runtime-ui.policy.disable-ssl-validation=true",
-            "--runtime-ui.policy.mapping-path=/policy-api",
-            "--runtime-ui.policy.url=http://policyapi:9876/",
+            "--runtime-ui.policy-api.disable-ssl-validation=true",
+            "--runtime-ui.policy-api.mapping-path=/policy-api",
+            "--runtime-ui.policy-api.url=http://policyapi:9876/",
+            "--runtime-ui.policy-pap.disable-ssl-validation=true",
+            "--runtime-ui.policy-pap.mapping-path=/policy-pap",
+            "--runtime-ui.policy-pap.url=http://policypap:9876/",
             "--runtime-ui.acm.disable-ssl-validation=true",
             "--runtime-ui.acm.mapping-path=/acm-runtime",
             "--runtime-ui.acm.url=http://acmruntime:9876/"
index 1623ea7..cacde1b 100644 (file)
@@ -25,9 +25,12 @@ import org.springframework.boot.test.context.SpringBootTest;
 
 @SpringBootTest(
     properties = {
-        "runtime-ui.policy.disable-ssl-validation=true",
-        "runtime-ui.policy.mapping-path=policy-api",
-        "runtime-ui.policy.url=http://policyapi:9876/",
+        "runtime-ui.policy-api.disable-ssl-validation=true",
+        "runtime-ui.policy-api.mapping-path=policy-api",
+        "runtime-ui.policy-api.url=http://policyapi:9876/",
+        "runtime-ui.policy-pap.disable-ssl-validation=true",
+        "runtime-ui.policy-pap.mapping-path=policy-pap",
+        "runtime-ui.policy-pap.url=http://policypap:9876/",
         "runtime-ui.acm.disable-ssl-validation=true",
         "runtime-ui.acm.mapping-path=acm-runtime",
         "runtime-ui.acm.url=http://acmruntime:9876/"
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.onap.policy.gui.server.test.util;
+package org.onap.policy.gui.server.config;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -45,12 +45,20 @@ public class RestTemplateConfig {
     @Qualifier("policyApiRestTemplate")
     private RestTemplate policyApiRestTemplate;
 
+    @Autowired
+    @Qualifier("policyPapRestTemplate")
+    private RestTemplate policyPapRestTemplate;
+
     @Getter
     List<RestTemplate> restTemplateList = new ArrayList<>();
 
+    /**
+     * Add the REST templates for each REST interface.
+     */
     @PostConstruct
     public void setupRestTemplateList() {
         restTemplateList.add(acmRuntimeRestTemplate);
         restTemplateList.add(policyApiRestTemplate);
+        restTemplateList.add(policyPapRestTemplate);
     }
 }
index e982db5..b1a72ac 100644 (file)
@@ -25,7 +25,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import javax.net.ssl.SSLPeerUnverifiedException;
 import org.junit.jupiter.api.Test;
-import org.onap.policy.gui.server.test.util.RestTemplateConfig;
 import org.onap.policy.gui.server.test.util.hello.HelloWorldApplication;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.web.client.RestClientException;
@@ -40,7 +39,8 @@ import org.springframework.web.client.RestClientException;
     classes = {
         HelloWorldApplication.class,
         AcmRuntimeRestTemplateConfig.class,
-        PolicyApiRestTemplateConfig.class
+        PolicyApiRestTemplateConfig.class,
+        PolicyPapRestTemplateConfig.class
     },
     properties = {
         "server.ssl.enabled=true",
@@ -50,8 +50,10 @@ import org.springframework.web.client.RestClientException;
         "server.ssl.trust-store-password=changeit",
         "runtime-ui.acm.disable-ssl-validation=false",
         "runtime-ui.acm.disable-ssl-hostname-check=false",
-        "runtime-ui.policy.disable-ssl-validation=false",
-        "runtime-ui.policy.disable-ssl-hostname-check=false"
+        "runtime-ui.policy-api.disable-ssl-validation=false",
+        "runtime-ui.policy-api.disable-ssl-hostname-check=false",
+        "runtime-ui.policy-pap.disable-ssl-validation=false",
+        "runtime-ui.policy-pap.disable-ssl-hostname-check=false"
     },
     webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
 class RestTemplateConfig1Test {
index f59eeaf..ce97320 100644 (file)
@@ -24,7 +24,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.onap.policy.gui.server.test.util.hello.HelloWorldRestController.HELLO_WORLD_STRING;
 
 import org.junit.jupiter.api.Test;
-import org.onap.policy.gui.server.test.util.RestTemplateConfig;
 import org.onap.policy.gui.server.test.util.hello.HelloWorldApplication;
 import org.springframework.boot.test.context.SpringBootTest;
 
@@ -37,13 +36,15 @@ import org.springframework.boot.test.context.SpringBootTest;
         HelloWorldApplication.class,
         AcmRuntimeRestTemplateConfig.class,
         PolicyApiRestTemplateConfig.class,
+        PolicyPapRestTemplateConfig.class
     },
     properties = {
         "server.ssl.enabled=true",
         "server.ssl.key-store=file:src/test/resources/helloworld-keystore.jks",
         "server.ssl.key-store-password=changeit",
         "runtime-ui.acm.disable-ssl-validation=true",
-        "runtime-ui.policy.disable-ssl-validation=true"
+        "runtime-ui.policy-api.disable-ssl-validation=true",
+        "runtime-ui.policy-pap.disable-ssl-validation=true"
     },
     webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
 class RestTemplateConfig2Test {
index 60ae9ac..b249721 100644 (file)
@@ -24,7 +24,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.onap.policy.gui.server.test.util.hello.HelloWorldRestController.HELLO_WORLD_STRING;
 
 import org.junit.jupiter.api.Test;
-import org.onap.policy.gui.server.test.util.RestTemplateConfig;
 import org.onap.policy.gui.server.test.util.hello.HelloWorldApplication;
 import org.springframework.boot.test.context.SpringBootTest;
 
@@ -38,7 +37,8 @@ import org.springframework.boot.test.context.SpringBootTest;
     classes = {
         HelloWorldApplication.class,
         AcmRuntimeRestTemplateConfig.class,
-        PolicyApiRestTemplateConfig.class
+        PolicyApiRestTemplateConfig.class,
+        PolicyPapRestTemplateConfig.class
     },
     properties = {
         "server.ssl.enabled=true",
@@ -48,8 +48,10 @@ import org.springframework.boot.test.context.SpringBootTest;
         "server.ssl.trust-store-password=changeit",
         "runtime-ui.acm.disable-ssl-validation=false",
         "runtime-ui.acm.disable-ssl-hostname-check=true",
-        "runtime-ui.policy.disable-ssl-validation=false",
-        "runtime-ui.policy.disable-ssl-hostname-check=true"
+        "runtime-ui.policy-api.disable-ssl-validation=false",
+        "runtime-ui.policy-api.disable-ssl-hostname-check=true",
+        "runtime-ui.policy-pap.disable-ssl-validation=false",
+        "runtime-ui.policy-pap.disable-ssl-hostname-check=true"
     },
     webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
 class RestTemplateConfig3Test {
index e85cdd0..eed7d14 100644 (file)
@@ -24,7 +24,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.onap.policy.gui.server.test.util.hello.HelloWorldRestController.HELLO_WORLD_STRING;
 
 import org.junit.jupiter.api.Test;
-import org.onap.policy.gui.server.test.util.RestTemplateConfig;
 import org.onap.policy.gui.server.test.util.hello.HelloWorldApplication;
 import org.springframework.boot.test.context.SpringBootTest;
 
@@ -39,7 +38,8 @@ import org.springframework.boot.test.context.SpringBootTest;
     classes = {
         HelloWorldApplication.class,
         AcmRuntimeRestTemplateConfig.class,
-        PolicyApiRestTemplateConfig.class
+        PolicyApiRestTemplateConfig.class,
+        PolicyPapRestTemplateConfig.class
     },
     properties = {
         "server.ssl.enabled=true",
@@ -49,8 +49,10 @@ import org.springframework.boot.test.context.SpringBootTest;
         "server.ssl.trust-store-password=changeit",
         "runtime-ui.acm.disable-ssl-validation=true",
         "runtime-ui.acm.disable-ssl-hostname-check=false",
-        "runtime-ui.policy.disable-ssl-validation=true",
-        "runtime-ui.policy.disable-ssl-hostname-check=false"
+        "runtime-ui.policy-api.disable-ssl-validation=true",
+        "runtime-ui.policy-api.disable-ssl-hostname-check=false",
+        "runtime-ui.policy-pap.disable-ssl-validation=true",
+        "runtime-ui.policy-pap.disable-ssl-hostname-check=false"
     },
     webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
 class RestTemplateConfig4Test {
index 5905ebc..5461d89 100644 (file)
@@ -25,7 +25,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import javax.net.ssl.SSLPeerUnverifiedException;
 import org.junit.jupiter.api.Test;
-import org.onap.policy.gui.server.test.util.RestTemplateConfig;
 import org.onap.policy.gui.server.test.util.hello.HelloWorldApplication;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.web.client.RestClientException;
@@ -42,7 +41,8 @@ import org.springframework.web.client.RestClientException;
     classes = {
         HelloWorldApplication.class,
         AcmRuntimeRestTemplateConfig.class,
-        PolicyApiRestTemplateConfig.class
+        PolicyApiRestTemplateConfig.class,
+        PolicyPapRestTemplateConfig.class
     },
     properties = {
         "server.ssl.enabled=true",
index 5edda12..f51d390 100644 (file)
@@ -43,7 +43,8 @@ import org.springframework.test.util.ReflectionTestUtils;
 class RestTemplateTrustStoreUnsetTest {
     BaseRestTemplateConfig[] restTemplateConfigArray = {
         new AcmRuntimeRestTemplateConfig(),
-        new PolicyApiRestTemplateConfig()
+        new PolicyApiRestTemplateConfig(),
+        new PolicyPapRestTemplateConfig()
     };
 
     @Test
index 56368c2..6d15642 100644 (file)
@@ -31,9 +31,12 @@ import org.springframework.web.client.RestTemplate;
 
 @SpringBootTest(
     properties = {
-        "runtime-ui.policy.mapping-path=/runtime-ui/policy/restservices/",
-        "runtime-ui.policy.url=http://policy-api:9876/",
-        "runtime-ui.policy.disable-ssl-validation=true",
+        "runtime-ui.policy-api.mapping-path=/runtime-ui/policy-api/restservices/",
+        "runtime-ui.policy-api.url=http://policy-api:9876/",
+        "runtime-ui.policy-api.disable-ssl-validation=true",
+        "runtime-ui.policy-pap.mapping-path=/runtime-ui/policy-pap/restservices/",
+        "runtime-ui.policy-pap.url=http://policy-pap:9876/",
+        "runtime-ui.policy-pap.disable-ssl-validation=true",
         "runtime-ui.acm.mapping-path=/runtime-ui/acm/restservices/",
         "runtime-ui.acm.url=https://runtime-acm:8443/",
         "runtime-ui.acm.disable-ssl-validation=true"
index 92f75d5..abacbc9 100644 (file)
@@ -33,9 +33,12 @@ import org.springframework.test.web.servlet.MockMvc;
 
 @SpringBootTest(
     properties = {
-        "runtime-ui.policy.disable-ssl-validation=true",
-        "runtime-ui.policy.mapping-path=policy-api",
-        "runtime-ui.policy.url=http://policyapi:9876/",
+        "runtime-ui.policy-api.disable-ssl-validation=true",
+        "runtime-ui.policy-api.mapping-path=policy-api",
+        "runtime-ui.policy-api.url=http://policyapi:9876/",
+        "runtime-ui.policy-pap.disable-ssl-validation=true",
+        "runtime-ui.policy-pap.mapping-path=policy-pap",
+        "runtime-ui.policy-pap.url=http://policypap:9876/",
         "runtime-ui.acm.disable-ssl-validation=true",
         "runtime-ui.acm.mapping-path=acm-runtime",
         "runtime-ui.acm.url=http://acmruntime:9876/"
index a862dc8..0b52022 100644 (file)
@@ -31,9 +31,12 @@ import org.springframework.web.client.RestTemplate;
 
 @SpringBootTest(
     properties = {
-        "runtime-ui.policy.mapping-path=/runtime-ui/policy/restservices/",
-        "runtime-ui.policy.url=https://policy-api:9876/",
-        "runtime-ui.policy.disable-ssl-validation=true",
+        "runtime-ui.policy-api.mapping-path=/runtime-ui/policy-api/restservices/",
+        "runtime-ui.policy-api.url=https://policy-api:9876/",
+        "runtime-ui.policy-api.disable-ssl-validation=true",
+        "runtime-ui.policy-pap.mapping-path=/runtime-ui/policy-pap/restservices/",
+        "runtime-ui.policy-pap.url=https://policy-pap:9876/",
+        "runtime-ui.policy-pap.disable-ssl-validation=true",
         "runtime-ui.acm.mapping-path=/runtime-ui/acm/restservices/",
         "runtime-ui.acm.url=https://runtime-acm:8443/",
         "runtime-ui.acm.disable-ssl-validation=true"
@@ -47,8 +50,8 @@ class PolicyApiRestControllerTest extends BaseRestControllerTest {
 
     @Autowired
     public void setBaseMapping(
-        @Value("${runtime-ui.policy.mapping-path}") String mappingPath,
-        @Value("${runtime-ui.policy.url}") URI url) {
+        @Value("${runtime-ui.policy-api.mapping-path}") String mappingPath,
+        @Value("${runtime-ui.policy-api.url}") URI url) {
         super.setMappingPath(mappingPath);
         super.setUrl(url);
     }
diff --git a/gui-server/src/test/java/org/onap/policy/gui/server/rest/PolicyPapRestControllerTest.java b/gui-server/src/test/java/org/onap/policy/gui/server/rest/PolicyPapRestControllerTest.java
new file mode 100644 (file)
index 0000000..ff174e0
--- /dev/null
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ *  Copyright (C) 2022 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.gui.server.rest;
+
+import java.net.URI;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.web.client.MockRestServiceServer;
+import org.springframework.web.client.RestTemplate;
+
+@SpringBootTest(
+    properties = {
+        "runtime-ui.policy-api.mapping-path=/runtime-ui/policy-api/restservices/",
+        "runtime-ui.policy-api.url=https://policy-api:9876/",
+        "runtime-ui.policy-api.disable-ssl-validation=true",
+        "runtime-ui.policy-pap.mapping-path=/runtime-ui/policy-pap/restservices/",
+        "runtime-ui.policy-pap.url=https://policy-pap:9876/",
+        "runtime-ui.policy-pap.disable-ssl-validation=true",
+        "runtime-ui.acm.mapping-path=/runtime-ui/acm/restservices/",
+        "runtime-ui.acm.url=https://runtime-acm:8443/",
+        "runtime-ui.acm.disable-ssl-validation=true"
+    })
+@AutoConfigureMockMvc
+class PolicyPapRestControllerTest extends BaseRestControllerTest {
+    @Autowired
+    public void setBaseMockServer(@Qualifier("policyPapRestTemplate") RestTemplate restTemplate) {
+        super.setMockServer(MockRestServiceServer.createServer(restTemplate));
+    }
+
+    @Autowired
+    public void setBaseMapping(
+        @Value("${runtime-ui.policy-pap.mapping-path}") String mappingPath,
+        @Value("${runtime-ui.policy-pap.url}") URI url) {
+        super.setMappingPath(mappingPath);
+        super.setUrl(url);
+    }
+}
index cebdc09..934e933 100644 (file)
@@ -4,14 +4,20 @@ server:
     enabled: false
 
 runtime-ui:
-  policy:
-    mapping-path: "/runtime-ui/policy/restservices"
+  policy-api:
+    mapping-path: "/runtime-ui/policy-api/restservices/"
     url: http://localhost:30440
     disable-ssl-validation: true
     disable-ssl-hostname-check: true
 
+  policy-pap:
+    mapping-path: "/runtime-ui/policy-pap/restservices/"
+    url: http://localhost:30442
+    disable-ssl-validation: true
+    disable-ssl-hostname-check: true
+
   acm:
-    mapping-path: "/runtime-ui/acm/restservices"
+    mapping-path: "/runtime-ui/acm/restservices/"
     url: http://localhost:30258
     disable-ssl-validation: true
     disable-ssl-hostname-check: true
index 8882c29..e5a84c1 100644 (file)
@@ -10,14 +10,20 @@ server:
     trust-store-password: changeit
 
 runtime-ui:
-  policy:
-    mapping-path: "/runtime-ui/policy/restservices"
+  policy-api:
+    mapping-path: "/runtime-ui/policy-api/restservices/"
     url: http://localhost:30440
     disable-ssl-validation: true
     disable-ssl-hostname-check: true
 
+  policy-pap:
+    mapping-path: "/runtime-ui/policy-pap/restservices/"
+    url: http://localhost:30442
+    disable-ssl-validation: true
+    disable-ssl-hostname-check: true
+
   acm:
-    mapping-path: "/runtime-ui/acm/restservices"
+    mapping-path: "/runtime-ui/acm/restservices/"
     url: http://localhost:30258
     disable-ssl-validation: true
     disable-ssl-hostname-check: true