http-port: 8081
shutdown: "graceful"
ssl:
+ enabled: true
key-store-type: JKS
key-store-password: policy_agent
key-store: /opt/app/policy-agent/etc/cert/keystore.jks
* ONAP : ccsdk oran
* ======================================================================
* Copyright (C) 2019-2020 Nordix Foundation. All rights reserved.
- * Copyright (C) 2023-2024 OpenInfra Foundation Europe. All rights reserved.
+ * 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.
@Configuration
public class BeanFactory {
- @Value("${server.http-port}")
+ @Value("${server.http-port:0}")
private int httpPort = 0;
@Bean
* ONAP : ccsdk oran
* ======================================================================
* Copyright (C) 2019-2022 Nordix Foundation. All rights reserved.
+ * Modifications Copyright (C) 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.
public AsyncRestClientFactory(WebClientConfig clientConfig, SecurityContext securityContext) {
if (clientConfig != null) {
- this.sslContextFactory = new CachingSslContextFactory(clientConfig);
+ if (clientConfig.isSslEnabled()) {
+ this.sslContextFactory = new CachingSslContextFactory(clientConfig);
+ } else {
+ this.sslContextFactory = null;
+ logger.debug("SSL is turned OFF for the web client");
+ }
this.httpProxyConfig = clientConfig.getHttpProxyConfig();
} else {
logger.warn("No configuration for web client defined, HTTPS will not work");
* ONAP : ccsdk oran
* ======================================================================
* Copyright (C) 2019-2020 Nordix Foundation. All rights reserved.
- * Modifications Copyright (C) 2023-2025 OpenInfra Foundation Europe. All rights reserved.
+ * 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.
public class ApplicationConfig {
@Getter
- @Value("${app.filepath}")
+ @Value("${app.filepath:null}")
private String localConfigurationFilePath;
@Getter
- @Value("${app.config-file-schema-path:}")
+ @Value("${app.config-file-schema-path:null}")
private String configurationFileSchemaPath;
@Getter
@Value("${app.vardata-directory:null}")
private String vardataDirectory;
- @Value("${server.ssl.key-store-type}")
+ @Getter
+ @Value("${server.ssl.enabled:true}")
+ private boolean sslEnabled;
+
+ @Value("${server.ssl.key-store-type:null}")
private String sslKeyStoreType = "";
- @Value("${server.ssl.key-store-password}")
+ @Value("${server.ssl.key-store-password:null}")
private String sslKeyStorePassword = "";
- @Value("${server.ssl.key-store}")
+ @Value("${server.ssl.key-store:null}")
private String sslKeyStore = "";
- @Value("${server.ssl.key-password}")
+ @Value("${server.ssl.key-password:null}")
private String sslKeyPassword = "";
- @Value("${app.webclient.trust-store-used}")
+ @Value("${app.webclient.trust-store-used:false}")
private boolean sslTrustStoreUsed = false;
- @Value("${app.webclient.trust-store-password}")
+ @Value("${app.webclient.trust-store-password:null}")
private String sslTrustStorePassword = "";
- @Value("${app.webclient.trust-store}")
+ @Value("${app.webclient.trust-store:null}")
private String sslTrustStore = "";
@Value("${app.webclient.http.proxy-host:}")
.httpProxyPort(this.httpProxyPort) //
.httpProxyType(ProxyProvider.Proxy.valueOf(this.httpProxyType)) //
.build();
+ if (sslEnabled) {
+ this.webClientConfig = WebClientConfig.builder() //
+ .sslEnabled(true)
+ .keyStoreType(this.sslKeyStoreType) //
+ .keyStorePassword(this.sslKeyStorePassword) //
+ .keyStore(this.sslKeyStore) //
+ .keyPassword(this.sslKeyPassword) //
+ .isTrustStoreUsed(this.sslTrustStoreUsed) //
+ .trustStore(this.sslTrustStore) //
+ .trustStorePassword(this.sslTrustStorePassword) //
+ .httpProxyConfig(httpProxyConfig) //
+ .build();
+ } else {
+ this.webClientConfig = WebClientConfig.builder() //
+ .sslEnabled(false)
+ .isTrustStoreUsed(false)
+ .httpProxyConfig(httpProxyConfig) //
+ .build();
+ }
- this.webClientConfig = WebClientConfig.builder() //
- .keyStoreType(this.sslKeyStoreType) //
- .keyStorePassword(this.sslKeyStorePassword) //
- .keyStore(this.sslKeyStore) //
- .keyPassword(this.sslKeyPassword) //
- .isTrustStoreUsed(this.sslTrustStoreUsed) //
- .trustStore(this.sslTrustStore) //
- .trustStorePassword(this.sslTrustStorePassword) //
- .httpProxyConfig(httpProxyConfig) //
- .build();
}
return this.webClientConfig;
}
* ONAP : ccsdk oran
* ======================================================================
* Copyright (C) 2020-2023 Nordix Foundation. All rights reserved.
+ * Modifications Copyright (C) 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.
import lombok.Builder;
import lombok.Getter;
import lombok.ToString;
-
import reactor.netty.transport.ProxyProvider;
@Builder
@Getter
@ToString
public class WebClientConfig {
+
+ private boolean sslEnabled;
+
private String keyStoreType;
private String keyStorePassword;
* ONAP : ccsdk oran
* ======================================================================
* Copyright (C) 2019-2023 Nordix Foundation. All rights reserved.
+ * Modifications Copyright (C) 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.
private AsyncRestClient restClient(String baseUrl, boolean useTrustValidation) {
WebClientConfig config = this.applicationConfig.getWebClientConfig();
config = WebClientConfig.builder()
+ .sslEnabled(config.isSslEnabled())
.keyStoreType(config.getKeyStoreType())
.keyStorePassword(config.getKeyStorePassword())
.keyStore(config.getKeyStore())
}
- private String baseUrl() {
- return "https://localhost:" + port;
+ public String baseUrl() {
+ if (applicationConfig.isSslEnabled()) {
+ return "https://localhost:" + port;
+ } else {
+ return "http://localhost:" + port;
+ }
}
private AsyncRestClient restClient(boolean useTrustValidation) {
/*-
* ========================LICENSE_START=================================
* Copyright (C) 2020-2023 Nordix Foundation. All rights reserved.
+ * Modifications Copyright (C) 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.
"app.config-file-schema-path=/application_configuration_schema.json" //
})
class ConfigurationControllerTest {
- @Autowired
- ApplicationContext context;
@Autowired
ApplicationConfig applicationConfig;
private AsyncRestClient restClient() {
WebClientConfig config = this.applicationConfig.getWebClientConfig();
- config = WebClientConfig.builder() //
- .keyStoreType(config.getKeyStoreType()) //
- .keyStorePassword(config.getKeyStorePassword()) //
- .keyStore(config.getKeyStore()) //
- .keyPassword(config.getKeyPassword()) //
- .isTrustStoreUsed(false) //
- .trustStore(config.getTrustStore()) //
- .trustStorePassword(config.getTrustStorePassword()) //
- .httpProxyConfig(config.getHttpProxyConfig()) //
- .build();
-
- AsyncRestClientFactory f = new AsyncRestClientFactory(config, new SecurityContext(""));
- return f.createRestClientNoHttpProxy("https://localhost:" + port);
+ if (applicationConfig.isSslEnabled()) {
+ config = WebClientConfig.builder() //
+ .sslEnabled(applicationConfig.isSslEnabled())
+ .keyStoreType(config.getKeyStoreType()) //
+ .keyStorePassword(config.getKeyStorePassword()) //
+ .keyStore(config.getKeyStore()) //
+ .keyPassword(config.getKeyPassword()) //
+ .isTrustStoreUsed(config.isTrustStoreUsed()) //
+ .trustStore(config.getTrustStore()) //
+ .trustStorePassword(config.getTrustStorePassword()) //
+ .httpProxyConfig(config.getHttpProxyConfig()) //
+ .build();
+
+ AsyncRestClientFactory f = new AsyncRestClientFactory(config, new SecurityContext(""));
+ return f.createRestClientNoHttpProxy("https://localhost:" + port);
+ } else {
+ config = WebClientConfig.builder()
+ .httpProxyConfig(config.getHttpProxyConfig())
+ .build();
+ AsyncRestClientFactory f = new AsyncRestClientFactory(config, new SecurityContext(""));
+ return f.createRestClientNoHttpProxy("http://localhost:" + port);
+ }
}
}
Mono<ResponseEntity<String>> responseMono = testHelperTest.restClientV3().postForEntity(url, policyBody);
testHelperTest.testSuccessResponse(responseMono, HttpStatus.CREATED, responseBody ->
responseBody.contains("{\"scope\":{\"ueId\":\"ue5100\",\"qosId\":\"qos5100\"},\"qosObjectives\":{\"priorityLevel\":5100.0}}"));
- testHelperTest.testSuccessHeader(responseMono, "location", headerValue -> headerValue.contains("https://localhost:" + port + "/a1-policy-management/v1/policies/"));
+ testHelperTest.testSuccessHeader(responseMono, "location", headerValue -> headerValue.contains(testHelperTest.baseUrl() + "/a1-policy-management/v1/policies/"));
}
Mono<ResponseEntity<String>> responseMono = testHelperTest.restClientV3().postForEntity(url, policyBody);
testHelperTest.testSuccessResponse(responseMono, HttpStatus.CREATED, responseBody ->
responseBody.contains("{\"scope\":{\"ueId\":\"ue5100\",\"qosId\":\"qos5100\"},\"qosObjectives\":{\"priorityLevel\":5100.0}}"));
- testHelperTest.testSuccessHeader(responseMono, "location", headerValue -> headerValue.contains("https://localhost:" + port + "/a1-policy-management/v1/policies/"));
+ testHelperTest.testSuccessHeader(responseMono, "location", headerValue -> headerValue.contains(testHelperTest.baseUrl() + "/a1-policy-management/v1/policies/"));
}
Mono<ResponseEntity<String>> responseMono = testHelperTest.restClientV3().postForEntity(url, policyBody);
testHelperTest.testSuccessResponse(responseMono, HttpStatus.CREATED, responseBody ->
responseBody.contains("{\"scope\":{\"ueId\":\"ue5100\",\"qosId\":\"qos5100\"},\"qosObjectives\":{\"priorityLevel\":5100.0}}"));
- testHelperTest.testSuccessHeader(responseMono, "location", headerValue -> headerValue.contains("https://localhost:" + port + "/a1-policy-management/v1/policies/"));
+ testHelperTest.testSuccessHeader(responseMono, "location", headerValue -> headerValue.contains(testHelperTest.baseUrl() + "/a1-policy-management/v1/policies/"));
}
Mono<ResponseEntity<String>> responseMono = testHelperTest.restClientV3().postForEntity(url, policyBody);
testHelperTest.testSuccessResponse(responseMono, HttpStatus.CREATED, responseBody ->
responseBody.contains("{\"scope\":{\"ueId\":\"ue5100\",\"qosId\":\"qos5100\"},\"qosObjectives\":{\"priorityLevel\":5100.0}}"));
- testHelperTest.testSuccessHeader(responseMono, "location", headerValue -> headerValue.contains("https://localhost:" + port + "/a1-policy-management/v1/policies/"));
+ testHelperTest.testSuccessHeader(responseMono, "location", headerValue -> headerValue.contains(testHelperTest.baseUrl() + "/a1-policy-management/v1/policies/"));
}
@Test
testHelperTest.addPolicyType(policyTypeName, nonRtRicId);
String policyBody = testHelperTest.postBadPolicyBody(nonRtRicId, policyTypeName, "");
Mono<ResponseEntity<String>> responseMono = testHelperTest.restClientV3().postForEntity(url, policyBody);
- testHelperTest.testSuccessHeader(responseMono, "location", headerValue -> headerValue.contains("https://localhost:" + port + "/a1-policy-management/v1/policies/"));
+ testHelperTest.testSuccessHeader(responseMono, "location", headerValue -> headerValue.contains(testHelperTest.baseUrl() + "/a1-policy-management/v1/policies/"));
}
@Test
testHelperTest.addPolicyType(policyTypeName, nonRtRicId);
String policyBody = testHelperTest.postBadPolicyBody(nonRtRicId, policyTypeName, "");
Mono<ResponseEntity<String>> responseMono = testHelperTest.restClientV3().postForEntity(url, policyBody);
- testHelperTest.testSuccessHeader(responseMono, "location", headerValue -> headerValue.contains("https://localhost:" + port + "/a1-policy-management/v1/policies/"));
+ testHelperTest.testSuccessHeader(responseMono, "location", headerValue -> headerValue.contains(testHelperTest.baseUrl() + "/a1-policy-management/v1/policies/"));
}
@Test
testHelperTest.addPolicyType(policyTypeName, nonRtRicId);
String policyBody = testHelperTest.postPolicyBody(nonRtRicId, policyTypeName, "1");
Mono<ResponseEntity<String>> responseMono = testHelperTest.restClientV3().postForEntity(url, policyBody);
- testHelperTest.testSuccessHeader(responseMono, "location", headerValue -> headerValue.contains("https://localhost:" + port + "/a1-policy-management/v1/policies/1"));
+ testHelperTest.testSuccessHeader(responseMono, "location", headerValue -> headerValue.contains(testHelperTest.baseUrl() + "/a1-policy-management/v1/policies/1"));
}
@Test
+/*-
+ * ========================LICENSE_START=================================
+ * ONAP : ccsdk oran
+ * ======================================================================
+ * Copyright (C) 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.
+ * 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.ccsdk.oran.a1policymanagementservice.utils.v3;
import org.junit.jupiter.api.AfterAll;
import java.nio.file.Path;
import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ExtendWith({OutputCaptureExtension.class})
Mono<ResponseEntity<String>> responseMono = testHelperTest.restClientV3().postForEntity(url, policyBody);
testHelperTest.testSuccessResponse(responseMono, HttpStatus.CREATED, responseBody ->
responseBody.contains("{\"scope\":{\"ueId\":\"ue5100\",\"qosId\":\"qos5100\"},\"qosObjectives\":{\"priorityLevel\":5100.0}}"));
- testHelperTest.testSuccessHeader(responseMono, "location", headerValue -> headerValue.contains("https://localhost:" + port + "/a1-policy-management/v1/policies/"));
+ testHelperTest.testSuccessHeader(responseMono, "location", headerValue -> headerValue.contains(testHelperTest.baseUrl() + "/a1-policy-management/v1/policies/"));
assertFalse(capturedOutput.getOut().contains("Request received with path: /a1-policy-management/v1/policies"));
assertFalse(capturedOutput.getOut().contains("the Status code of the response: 201 CREATED"));
assertFalse(capturedOutput.getOut().contains("the response is:"));
+/*-
+ * ========================LICENSE_START=================================
+ * ONAP : ccsdk oran
+ * ======================================================================
+ * Copyright (C) 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.
+ * 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.ccsdk.oran.a1policymanagementservice.utils.v3;
import org.junit.jupiter.api.AfterAll;
Mono<ResponseEntity<String>> responseMono = testHelperTest.restClientV3().postForEntity(url, policyBody);
testHelperTest.testSuccessResponse(responseMono, HttpStatus.CREATED, responseBody ->
responseBody.contains("{\"scope\":{\"ueId\":\"ue5100\",\"qosId\":\"qos5100\"},\"qosObjectives\":{\"priorityLevel\":5100.0}}"));
- testHelperTest.testSuccessHeader(responseMono, "location", headerValue -> headerValue.contains("https://localhost:" + port + "/a1-policy-management/v1/policies/"));
+ testHelperTest.testSuccessHeader(responseMono, "location", headerValue -> headerValue.contains(testHelperTest.baseUrl() + "/a1-policy-management/v1/policies/"));
assertTrue(capturedOutput.getOut().contains("Request received with path: /a1-policy-management/v1/policies"));
assertTrue(capturedOutput.getOut().contains("the Status code of the response: 201 CREATED"));
assertTrue(capturedOutput.getOut().contains("the response is:"));
public AsyncRestClient restClient(String baseUrl, boolean useTrustValidation) {
WebClientConfig config = this.applicationConfig.getWebClientConfig();
config = WebClientConfig.builder()
+ .sslEnabled(config.isSslEnabled())
.keyStoreType(config.getKeyStoreType())
.keyStorePassword(config.getKeyStorePassword())
.keyStore(config.getKeyStore())
}
public String baseUrl() {
- return "https://localhost:" + port;
+ if (applicationConfig.isSslEnabled()) {
+ return "https://localhost:" + port;
+ } else {
+ return "http://localhost:" + port;
+ }
}
public AsyncRestClient restClientV3(boolean useTrustValidation) {