* ONAP
* ================================================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2025 OpenInfra Foundation Europe.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* writing them out to the temporary folder.
*/
@BeforeAll
- public static void setUp() {
+ static void setUp() {
assertThatCode(() -> {
//
// Load our test property object
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2023-2025 OpenInfra Foundation Europe.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class StdMatchableTranslatorTest {
+class StdMatchableTranslatorTest {
private static final Logger logger = LoggerFactory.getLogger(StdMatchableTranslatorTest.class);
private static final String CLIENT_NAME = "policy-api";
private static final StandardYamlCoder yamlCoder = new StandardYamlCoder();
- private static int port;
private static RestClientParameters clientParams;
private static ToscaServiceTemplate testTemplate;
private static HttpClient apiClient;
//
// Setup our api server simulator
//
- port = NetworkUtil.allocPort();
clientParams = mock(RestClientParameters.class);
when(clientParams.getClientName()).thenReturn("apiClient");
when(clientParams.getHostname()).thenReturn("localhost");
- when(clientParams.getPort()).thenReturn(port);
+ when(clientParams.getPort()).thenReturn(NetworkUtil.allocPort());
Properties props = getProperties();
}
@AfterAll
- public static void tearDownAfterClass() {
+ static void tearDownAfterClass() {
HttpServletServerFactoryInstance.getServerFactory().destroy();
}
//
List<AttributeAssignment> listAttributes = new ArrayList<>();
ObligationExpressionType xacmlObligation = translatedPolicy.getObligationExpressions()
- .getObligationExpression().get(0);
+ .getObligationExpression().getFirst();
assertThat(xacmlObligation.getAttributeAssignmentExpression()).hasSize(4);
//
// Copy into the list
//
xacmlObligation.getAttributeAssignmentExpression().forEach(assignment -> {
- Object value = ((AttributeValueType) assignment.getExpression().getValue()).getContent().get(0);
+ Object value = ((AttributeValueType) assignment.getExpression().getValue()).getContent().getFirst();
listAttributes.add(TestUtilsCommon.createAttributeAssignment(assignment.getAttributeId(),
assignment.getCategory(), value));
});
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2024 Nordix Foundation.
+ * Modifications Copyright (C) 2024-2025 OpenInfra Foundation Europe.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* @throws PIPException if an error occurs
*/
@BeforeEach
- public void setUp() throws PIPException {
+ void setUp() throws PIPException {
resp = new StdMutablePIPResponse();
lenient().when(request.getIssuer()).thenReturn(ISSUER);
* ONAP
* ================================================================================
* Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019, 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 2023-2025 OpenInfra Foundation Europe.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.security.SecureRandom;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
-import javax.net.ssl.SSLContext;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.common.utils.resources.ResourceUtils;
-import org.onap.policy.common.utils.security.SelfSignedKeyStore;
import org.onap.policy.pdpx.main.rest.XacmlPdpStatisticsManager;
import org.onap.policy.pdpx.main.startstop.Main;
import org.onap.policy.pdpx.main.startstop.XacmlPdpActivator;
* @throws Exception if an error occurs
*/
@BeforeAll
- public static void setUpBeforeClass() throws Exception {
- System.setProperty("javax.net.ssl.keyStore", new SelfSignedKeyStore().getKeystoreName());
- System.setProperty("javax.net.ssl.keyStorePassword", SelfSignedKeyStore.KEYSTORE_PASSWORD);
+ public static void setUpBeforeClass() throws Exception { // NOSONAR - class is extended
System.setProperty("org.eclipse.jetty.util.log.class", "org.eclipse.jetty.util.log.StdErrLog");
System.setProperty("org.eclipse.jetty.LEVEL", "OFF");
* Stops the "Main".
*/
@AfterAll
- public static void tearDownAfterClass() {
+ static void tearDownAfterClass() {
stopMain();
}
* Resets the statistics.
*/
@BeforeEach
- public void setUp() {
+ void setUp() {
activatorWasAlive = XacmlPdpActivator.getCurrent().isAlive();
XacmlPdpStatisticsManager.getCurrent().resetAllStatistics();
}
* Restores the "alive" status of the activator.
*/
@AfterEach
- public void tearDown() {
+ public void tearDown() { // NOSONAR - class is extended
markActivator(activatorWasAlive);
}
}
/**
- * Sends an HTTPS request to an endpoint of the PDP's REST API.
+ * Sends an HTTP request to an endpoint of the PDP's REST API.
*
* @param endpoint target endpoint
* @return a request builder
- * @throws Exception if an error occurs
*/
- protected Invocation.Builder sendHttpsRequest(final String endpoint) throws Exception {
- // always trust the certificate
- final SSLContext sc = SSLContext.getInstance("TLSv1.2");
- sc.init(null, NetworkUtil.getAlwaysTrustingManager(), new SecureRandom());
-
- // always trust the host name
- final ClientBuilder clientBuilder =
- ClientBuilder.newBuilder().sslContext(sc).hostnameVerifier((host, session) -> true);
-
- final Client client = clientBuilder.build();
+ protected Invocation.Builder sendHttpsRequest(final String endpoint) {
+ final Client client = ClientBuilder.newBuilder().build();
final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
client.register(feature);
- final WebTarget webTarget = client.target("https://localhost:" + port + "/policy/pdpx/v1/" + endpoint);
+ final WebTarget webTarget = client.target("http://localhost:" + port + "/policy/pdpx/v1/" + endpoint);
return webTarget.request(MediaType.APPLICATION_JSON);
}
/**
- * Mark the activator as dead, but leave its REST server running.
+ * Mark the activator as dead but leave its REST server running.
*/
protected void markActivatorDead() {
markActivator(false);
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019, 2024 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 2024-2025 OpenInfra Foundation Europe.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* @throws Exception if an error occurs
*/
@BeforeAll
- public static void setUpBeforeClass() throws Exception {
+ public static void setUpBeforeClass() throws Exception { // NOSONAR - class is extended
ParameterService.clear();
CommonRest.setUpBeforeClass();
CommonRest.stopMain();
}
- @Override
@BeforeEach
- public void setUp() {
+ void setUp() {
main = null;
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019, 2023-2024 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 2023-2025 OpenInfra Foundation Europe.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* Class to perform unit test of XacmlPdpActivator.
*/
-public class TestXacmlPdpActivator extends CommonRest {
+class TestXacmlPdpActivator extends CommonRest {
private static final String PROBE_FIELD_NAME = "probeHeartbeatTopicSec";
private static XacmlPdpParameterGroup parGroup;
* Loads properties.
*/
@BeforeAll
- public static void setUpBeforeClass() throws Exception {
+ public static void setUpBeforeClass() throws Exception { // NOSONAR - class is extended
ParameterService.clear();
CommonRest.setUpBeforeClass();
/**
* Creates the activator.
*/
- @Override
@BeforeEach
- public void setUp() {
+ void setUp() {
ReflectionTestUtils.setField(parGroup, PROBE_FIELD_NAME, 4);
activator = new XacmlPdpActivator(parGroup);
}
* Teardown tests.
*/
@AfterEach
- public void teardown() {
+ void teardown() {
if (activator != null && activator.isAlive()) {
activator.stop();
}
"port":${port},
"userName":"healthcheck",
"password":"zb!XztG34",
- "https":true
+ "https":false
},
"policyApiParameters": {
"hostname": "0.0.0.0",