diff options
author | liamfallon <liam.fallon@est.tech> | 2022-11-09 11:50:59 +0000 |
---|---|---|
committer | liamfallon <liam.fallon@est.tech> | 2022-11-09 13:51:27 +0000 |
commit | 6e4582e760f0f63f8938a64b1317658dcde119cd (patch) | |
tree | 550714f06791eb489ad57a4ff7079a9472ca2dc0 | |
parent | b972ede6f59bb057505e000178364c24fa85f77c (diff) |
Add forwarding support for policy-pap
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, 284 insertions, 49 deletions
diff --git a/gui-server/src/main/java/org/onap/policy/gui/server/config/FilterRegistrationConfig.java b/gui-server/src/main/java/org/onap/policy/gui/server/config/FilterRegistrationConfig.java index 179a3aa..c7a3aa4 100644 --- a/gui-server/src/main/java/org/onap/policy/gui/server/config/FilterRegistrationConfig.java +++ b/gui-server/src/main/java/org/onap/policy/gui/server/config/FilterRegistrationConfig.java @@ -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; diff --git a/gui-server/src/main/java/org/onap/policy/gui/server/config/PolicyApiRestTemplateConfig.java b/gui-server/src/main/java/org/onap/policy/gui/server/config/PolicyApiRestTemplateConfig.java index e88b0a5..b3bcb24 100644 --- a/gui-server/src/main/java/org/onap/policy/gui/server/config/PolicyApiRestTemplateConfig.java +++ b/gui-server/src/main/java/org/onap/policy/gui/server/config/PolicyApiRestTemplateConfig.java @@ -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 index 0000000..3d7731b --- /dev/null +++ b/gui-server/src/main/java/org/onap/policy/gui/server/config/PolicyPapRestTemplateConfig.java @@ -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(); + } +} diff --git a/gui-server/src/main/java/org/onap/policy/gui/server/rest/PolicyApiRestController.java b/gui-server/src/main/java/org/onap/policy/gui/server/rest/PolicyApiRestController.java index 2be3417..5e3f5d3 100644 --- a/gui-server/src/main/java/org/onap/policy/gui/server/rest/PolicyApiRestController.java +++ b/gui-server/src/main/java/org/onap/policy/gui/server/rest/PolicyApiRestController.java @@ -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 index 0000000..c837b03 --- /dev/null +++ b/gui-server/src/main/java/org/onap/policy/gui/server/rest/PolicyPapRestController.java @@ -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); + } +} diff --git a/gui-server/src/test/java/org/onap/policy/gui/server/GuiServerAppMainTest.java b/gui-server/src/test/java/org/onap/policy/gui/server/GuiServerAppMainTest.java index 870eaaf..b8e73c3 100644 --- a/gui-server/src/test/java/org/onap/policy/gui/server/GuiServerAppMainTest.java +++ b/gui-server/src/test/java/org/onap/policy/gui/server/GuiServerAppMainTest.java @@ -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/" diff --git a/gui-server/src/test/java/org/onap/policy/gui/server/SpringContextTest.java b/gui-server/src/test/java/org/onap/policy/gui/server/SpringContextTest.java index 1623ea7..cacde1b 100644 --- a/gui-server/src/test/java/org/onap/policy/gui/server/SpringContextTest.java +++ b/gui-server/src/test/java/org/onap/policy/gui/server/SpringContextTest.java @@ -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/" diff --git a/gui-server/src/test/java/org/onap/policy/gui/server/test/util/RestTemplateConfig.java b/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig.java index 0d11eb7..4ffce3b 100644 --- a/gui-server/src/test/java/org/onap/policy/gui/server/test/util/RestTemplateConfig.java +++ b/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig.java @@ -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); } } diff --git a/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig1Test.java b/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig1Test.java index e982db5..b1a72ac 100644 --- a/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig1Test.java +++ b/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig1Test.java @@ -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 { diff --git a/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig2Test.java b/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig2Test.java index f59eeaf..ce97320 100644 --- a/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig2Test.java +++ b/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig2Test.java @@ -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 { diff --git a/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig3Test.java b/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig3Test.java index 60ae9ac..b249721 100644 --- a/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig3Test.java +++ b/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig3Test.java @@ -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 { diff --git a/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig4Test.java b/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig4Test.java index e85cdd0..eed7d14 100644 --- a/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig4Test.java +++ b/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig4Test.java @@ -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 { diff --git a/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig5Test.java b/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig5Test.java index 5905ebc..5461d89 100644 --- a/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig5Test.java +++ b/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateConfig5Test.java @@ -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", diff --git a/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateTrustStoreUnsetTest.java b/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateTrustStoreUnsetTest.java index 5edda12..f51d390 100644 --- a/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateTrustStoreUnsetTest.java +++ b/gui-server/src/test/java/org/onap/policy/gui/server/config/RestTemplateTrustStoreUnsetTest.java @@ -43,7 +43,8 @@ import org.springframework.test.util.ReflectionTestUtils; class RestTemplateTrustStoreUnsetTest { BaseRestTemplateConfig[] restTemplateConfigArray = { new AcmRuntimeRestTemplateConfig(), - new PolicyApiRestTemplateConfig() + new PolicyApiRestTemplateConfig(), + new PolicyPapRestTemplateConfig() }; @Test diff --git a/gui-server/src/test/java/org/onap/policy/gui/server/rest/AcmRuntimeRestControllerTest.java b/gui-server/src/test/java/org/onap/policy/gui/server/rest/AcmRuntimeRestControllerTest.java index 56368c2..6d15642 100644 --- a/gui-server/src/test/java/org/onap/policy/gui/server/rest/AcmRuntimeRestControllerTest.java +++ b/gui-server/src/test/java/org/onap/policy/gui/server/rest/AcmRuntimeRestControllerTest.java @@ -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" diff --git a/gui-server/src/test/java/org/onap/policy/gui/server/rest/DesigntimeRestControllerTest.java b/gui-server/src/test/java/org/onap/policy/gui/server/rest/DesigntimeRestControllerTest.java index 92f75d5..abacbc9 100644 --- a/gui-server/src/test/java/org/onap/policy/gui/server/rest/DesigntimeRestControllerTest.java +++ b/gui-server/src/test/java/org/onap/policy/gui/server/rest/DesigntimeRestControllerTest.java @@ -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/" diff --git a/gui-server/src/test/java/org/onap/policy/gui/server/rest/PolicyApiRestControllerTest.java b/gui-server/src/test/java/org/onap/policy/gui/server/rest/PolicyApiRestControllerTest.java index a862dc8..0b52022 100644 --- a/gui-server/src/test/java/org/onap/policy/gui/server/rest/PolicyApiRestControllerTest.java +++ b/gui-server/src/test/java/org/onap/policy/gui/server/rest/PolicyApiRestControllerTest.java @@ -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 index 0000000..ff174e0 --- /dev/null +++ b/gui-server/src/test/java/org/onap/policy/gui/server/rest/PolicyPapRestControllerTest.java @@ -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); + } +} diff --git a/gui-server/src/test/resources/application_http.yaml b/gui-server/src/test/resources/application_http.yaml index cebdc09..934e933 100644 --- a/gui-server/src/test/resources/application_http.yaml +++ b/gui-server/src/test/resources/application_http.yaml @@ -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 diff --git a/gui-server/src/test/resources/application_https.yaml b/gui-server/src/test/resources/application_https.yaml index 8882c29..e5a84c1 100644 --- a/gui-server/src/test/resources/application_https.yaml +++ b/gui-server/src/test/resources/application_https.yaml @@ -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 |