aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/apex-pdp-package-full/src/main/resources/ssl/policy-keystorebin4431 -> 0 bytes
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java47
-rw-r--r--services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java8
-rw-r--r--services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/rest/CommonApexStarterRestServer.java8
-rw-r--r--services/services-onappf/src/test/resources/ssl/policy-keystorebin4431 -> 0 bytes
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java40
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/DummyApexEventConsumer.java4
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/TaskFetchHttpCode.js7
-rw-r--r--testsuites/integration/integration-uservice-test/src/test/resources/testdata/executionproperties/RESTHttpCodeFilterSetToTagUrlOK.json58
9 files changed, 33 insertions, 139 deletions
diff --git a/packages/apex-pdp-package-full/src/main/resources/ssl/policy-keystore b/packages/apex-pdp-package-full/src/main/resources/ssl/policy-keystore
deleted file mode 100644
index b95e01031..000000000
--- a/packages/apex-pdp-package-full/src/main/resources/ssl/policy-keystore
+++ /dev/null
Binary files differ
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java
index 54dba7a7c..d7ee0a5ee 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/main/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/ApexRestRequestorConsumer.java
@@ -99,8 +99,6 @@ public class ApexRestRequestorConsumer extends ApexPluginsEventConsumer {
// The number of the next request runner thread
private static long nextRequestRunnerThreadNo = 0;
- private String untaggedUrl = null;
-
// The pattern for filtering status code
private Pattern httpCodeFilterPattern = null;
@@ -207,22 +205,6 @@ public class ApexRestRequestorConsumer extends ApexPluginsEventConsumer {
continue;
}
- Properties inputExecutionProperties = restRequest.getExecutionProperties();
- untaggedUrl = restConsumerProperties.getUrl();
- if (inputExecutionProperties != null) {
- Set<String> names = restConsumerProperties.getKeysFromUrl();
- Set<String> inputProperty = inputExecutionProperties.stringPropertyNames();
-
- names.stream().map(Optional::of)
- .forEach(op -> op.filter(inputProperty::contains)
- .orElseThrow(() -> new ApexEventRuntimeException(
- "key\"" + op.get() + "\"specified on url \"" + restConsumerProperties.getUrl()
- + "\"not found in execution properties passed by the current policy")));
-
- untaggedUrl = names.stream().reduce(untaggedUrl,
- (acc, str) -> acc.replace("{" + str + "}", (String) inputExecutionProperties.get(str)));
- }
-
// Set the time stamp of the REST request
restRequest.setTimestamp(System.currentTimeMillis());
@@ -311,18 +293,31 @@ public class ApexRestRequestorConsumer extends ApexPluginsEventConsumer {
public void run() {
// Get the thread for the request
restRequestThread = Thread.currentThread();
-
+ Properties inputExecutionProperties = request.getExecutionProperties();
+ String url = restConsumerProperties.getUrl();
+ Set<String> names = restConsumerProperties.getKeysFromUrl();
+ if (!names.isEmpty() && inputExecutionProperties != null) {
+ Set<String> inputProperty = inputExecutionProperties.stringPropertyNames();
+
+ names.stream().map(Optional::of)
+ .forEach(op -> op.filter(inputProperty::contains)
+ .orElseThrow(() -> new ApexEventRuntimeException(
+ "key\"" + op.get() + "\"specified on url \"" + restConsumerProperties.getUrl()
+ + "\"not found in execution properties passed by the current policy")));
+
+ url = names.stream().reduce(url,
+ (acc, str) -> acc.replace("{" + str + "}", (String) inputExecutionProperties.get(str)));
+ }
try {
if (restConsumerProperties.getHttpMethod().equals(HttpMethod.PUT)
|| restConsumerProperties.getHttpMethod().equals(HttpMethod.POST)) {
- NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, untaggedUrl,
- request.getEvent().toString());
+ NetLoggerUtil.log(EventType.OUT, CommInfrastructure.REST, url, request.getEvent().toString());
}
// Execute the REST request
- final Response response = sendEventAsRestRequest(untaggedUrl);
+ final Response response = sendEventAsRestRequest(url);
// Get the event we received
final String eventJsonString = response.readEntity(String.class);
- NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, untaggedUrl, eventJsonString);
+ NetLoggerUtil.log(EventType.IN, CommInfrastructure.REST, url, eventJsonString);
// Match the return code
Matcher isPass = httpCodeFilterPattern.matcher(String.valueOf(response.getStatus()));
@@ -336,7 +331,7 @@ public class ApexRestRequestorConsumer extends ApexPluginsEventConsumer {
// Check there is content
if (StringUtils.isBlank(eventJsonString)) {
final String errorMessage =
- "received an empty response to \"" + request + "\" from URL \"" + untaggedUrl + "\"";
+ "received an empty response to \"" + request + "\" from URL \"" + url + "\"";
throw new ApexEventRuntimeException(errorMessage);
}
@@ -371,8 +366,8 @@ public class ApexRestRequestorConsumer extends ApexPluginsEventConsumer {
*
* @return the response to the REST request
*/
- public Response sendEventAsRestRequest(String untaggedUrl) {
- Builder headers = client.target(untaggedUrl).request(APPLICATION_JSON)
+ public Response sendEventAsRestRequest(String url) {
+ Builder headers = client.target(url).request(APPLICATION_JSON)
.headers(restConsumerProperties.getHttpHeadersAsMultivaluedMap());
switch (restConsumerProperties.getHttpMethod()) {
case GET:
diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java
index fdc404c67..d31940aa0 100644
--- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java
+++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexEventUnmarshaller.java
@@ -226,13 +226,13 @@ public class ApexEventUnmarshaller implements ApexEventReceiver, Runnable {
// Ignore this event
continue;
}
-
if (!generateExecutionId) {
apexEvent.setExecutionId(executionId);
+ apexEvent.setExecutionProperties(executionProperties);
+ } else {
+ // Clean up executionProperties in case if it is not a response event to a request made from APEX
+ apexEvent.setExecutionProperties(new Properties(executionProperties));
}
-
- apexEvent.setExecutionProperties(executionProperties);
-
// Cache synchronized events that are sent
if (consumerParameters.isPeeredMode(EventHandlerPeeredMode.SYNCHRONOUS)) {
final SynchronousEventCache synchronousEventCache =
diff --git a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/rest/CommonApexStarterRestServer.java b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/rest/CommonApexStarterRestServer.java
index bf5bf485d..283134087 100644
--- a/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/rest/CommonApexStarterRestServer.java
+++ b/services/services-onappf/src/test/java/org/onap/policy/apex/services/onappf/rest/CommonApexStarterRestServer.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -50,6 +51,7 @@ import org.onap.policy.common.gson.GsonMessageBodyHandler;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.network.NetworkUtil;
+import org.onap.policy.common.utils.security.SelfSignedKeyStore;
import org.onap.policy.common.utils.services.Registry;
import org.powermock.reflect.Whitebox;
import org.slf4j.Logger;
@@ -64,8 +66,6 @@ public class CommonApexStarterRestServer {
private static final Logger LOGGER = LoggerFactory.getLogger(CommonApexStarterRestServer.class);
- private static String KEYSTORE = System.getProperty("user.dir") + "/src/test/resources/ssl/policy-keystore";
-
private static Coder coder = new StandardCoder();
public static final String NOT_ALIVE = "not alive";
@@ -180,8 +180,8 @@ public class CommonApexStarterRestServer {
}
final Properties systemProps = System.getProperties();
- systemProps.put("javax.net.ssl.keyStore", KEYSTORE);
- systemProps.put("javax.net.ssl.keyStorePassword", "Pol1cy_0nap");
+ systemProps.put("javax.net.ssl.keyStore", new SelfSignedKeyStore().getKeystoreName());
+ systemProps.put("javax.net.ssl.keyStorePassword", SelfSignedKeyStore.KEYSTORE_PASSWORD);
System.setProperties(systemProps);
final String[] apexStarterConfigParameters = { "-c", "src/test/resources/TestConfigParams.json" };
diff --git a/services/services-onappf/src/test/resources/ssl/policy-keystore b/services/services-onappf/src/test/resources/ssl/policy-keystore
deleted file mode 100644
index b95e01031..000000000
--- a/services/services-onappf/src/test/resources/ssl/policy-keystore
+++ /dev/null
Binary files differ
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java
index 0cf7dc652..b3f27c52e 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java
@@ -239,46 +239,6 @@ public class TestExecutionPropertyRest {
}
/**
- * Test Http code filter set and tag Url are transformed correctly.
- */
- @Test
- public void testReplaceUrlTag() throws Exception {
- final Client client = ClientBuilder.newClient();
- // @formatter:off
- final String[] cliArgs = new String[] {
- "-c",
- "src/test/resources/policies/executionproperties/policy/ExecutionPropertiesRestTestPolicyModel.apex",
- "-o",
- "target/ExecutionPropertiesRestTestPolicyModel.json",
- "-ac",
- "src/test/resources/testdata/executionproperties/RESTHttpCodeFilterSetToTagUrlOK.json",
- "-t",
- "src/test/resources/tosca/ToscaTemplate.json",
- "-ot",
- "target/classes/APEXPolicy.json"
- };
- // @formatter:on
-
- new ApexCliToscaEditorMain(cliArgs);
-
- // @formatter:off
- final String[] args = {
- "-p",
- "target/classes/APEXPolicy.json"
- };
- // @formatter:on
- apexMain = new ApexMain(args);
-
- await().atMost(5, TimeUnit.SECONDS).until(() -> {
- Response response = client.target("http://localhost:32801/TestExecutionRest/apex/event/GetProperUrl")
- .request("application/json").get();
- return response.readEntity(String.class).contains("\"PostProperUrl\": 1");
- });
- assertTrue(apexMain.isAlive());
- LOGGER.info("testReplaceUrlTag-OUTSTRING=\n" + outContent.toString() + "\nEnd-TagUrl");
- }
-
- /**
* Test Http code filter set and multi-tag Url are transformed correctly.
*/
@Test
diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/DummyApexEventConsumer.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/DummyApexEventConsumer.java
index c4b93b002..1dc6f13a2 100644
--- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/DummyApexEventConsumer.java
+++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/executionproperties/DummyApexEventConsumer.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -125,7 +125,7 @@ public class DummyApexEventConsumer implements ApexEventConsumer {
RunTestEvent event = new RunTestEvent();
event.setTestToRun(dummyConsumerProperties.getTestToRun());
try {
- eventReceiver.receiveEvent(executionProperties, event.toJson());
+ eventReceiver.receiveEvent(1, executionProperties, event.toJson());
} catch (Exception e) {
String message = "event processing for executor properties testing failed: " + e.getMessage();
LOGGER.warn(message, e);
diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/TaskFetchHttpCode.js b/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/TaskFetchHttpCode.js
index b60e2acee..f4d979d1f 100644
--- a/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/TaskFetchHttpCode.js
+++ b/testsuites/integration/integration-uservice-test/src/test/resources/policies/executionproperties/logic/TaskFetchHttpCode.js
@@ -1,6 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 Bell Canada. 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.
@@ -22,11 +23,7 @@ executor.logger.debug(executor.getSubject().getId());
executor.logger.debug("executionProperties: " + executor.getExecutionProperties());
-if (executor.getExecutionProperties().get("HTTP_CODE_STATUS") == "500")
- executor.outFields.put("testToRun", "CodeFilterSet");
-else
- executor.outFields.put("testToRun", "CodeFilterDefault");
-
+executor.outFields.put("testToRun", "CodeFilterSet");
executor.logger.debug("testToRun: " + executor.outFields.get("testToRun"));
true;
diff --git a/testsuites/integration/integration-uservice-test/src/test/resources/testdata/executionproperties/RESTHttpCodeFilterSetToTagUrlOK.json b/testsuites/integration/integration-uservice-test/src/test/resources/testdata/executionproperties/RESTHttpCodeFilterSetToTagUrlOK.json
deleted file mode 100644
index 22ab9e3bb..000000000
--- a/testsuites/integration/integration-uservice-test/src/test/resources/testdata/executionproperties/RESTHttpCodeFilterSetToTagUrlOK.json
+++ /dev/null
@@ -1,58 +0,0 @@
-{
- "engineServiceParameters": {
- "name": "MyApexEngine",
- "version": "0.0.1",
- "id": 45,
- "instanceCount": 4,
- "deploymentPort": 12561,
- "engineParameters": {
- "executorParameters": {
- "JAVASCRIPT": {
- "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
- }
- }
- }
- },
- "eventInputParameters": {
- "GetCodeConsumer": {
- "carrierTechnologyParameters": {
- "carrierTechnology": "RESTCLIENT",
- "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
- "parameters": {
- "url": "http://localhost:32801/TestExecutionRest/apex/event/FetchHttpCode",
- "httpMethod": "GET",
- "httpHeaders" : [
- ],
- "httpCodeFilter" : "[1-5][0][0-5]"
- }
- },
- "eventProtocolParameters": {
- "eventProtocol": "JSON",
- "parameters": {
- "testToRun": "FetchHttpCode"
- }
- },
- "eventName": "Event0200"
- }
- },
- "eventOutputParameters": {
- "FirstProducer": {
- "carrierTechnologyParameters": {
- "carrierTechnology": "RESTCLIENT",
- "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
- "parameters": {
- "url": "http://localhost:32801/TestExecutionRest/apex/event/{tagId}",
- "httpMethod": "PUT",
- "httpHeaders" : [
- ["Content-Type", "application/json"],
- ["Date", "Tue, 24 Jul 2019 14:57:12 GMT"]
- ]
- }
- },
- "eventProtocolParameters": {
- "eventProtocol": "JSON"
- },
- "eventName": "Event0201"
- }
- }
-}