summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-service/src
diff options
context:
space:
mode:
authordanielhanrahan <daniel.hanrahan@est.tech>2024-02-29 15:52:46 +0000
committerdanielhanrahan <daniel.hanrahan@est.tech>2024-02-29 15:52:46 +0000
commit0a1b4b12b6c2809d30c4bb1f3e862c855f21a316 (patch)
treedcfa113dc816940d8fee30ec88d553372b2e875a /cps-ncmp-service/src
parentc5222a72ef11bd440f5c2bd017e820922ff6735a (diff)
Add bearer token to NCMP async batch data passthrough (CPS-2126 #4)
Async processing was not passing bearer token. Issue-ID: CPS-2128 Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech> Change-Id: I75da35cce555c49cca638b68f106a9daba79c24a
Diffstat (limited to 'cps-ncmp-service/src')
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java5
-rwxr-xr-xcps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java9
-rw-r--r--cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java18
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy4
-rw-r--r--cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy2
5 files changed, 24 insertions, 14 deletions
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
index dbfeca1804..4230140d26 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/NetworkCmProxyDataService.java
@@ -89,10 +89,13 @@ public interface NetworkCmProxyDataService {
*
* @param topicParamInQuery topic name for (triggering) async responses
* @param dataOperationRequest contains a list of operation definitions(multiple operations)
+ * @param requestId request ID
+ * @param authorization contents of Authorization header, or null if not present
*/
void executeDataOperationForCmHandles(String topicParamInQuery,
DataOperationRequest dataOperationRequest,
- String requestId);
+ String requestId,
+ String authorization);
/**
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
index 3e304a4fd0..8c02106f4c 100755
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImpl.java
@@ -154,10 +154,11 @@ public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService
@Override
public void executeDataOperationForCmHandles(final String topicParamInQuery,
- final DataOperationRequest
- dataOperationRequest,
- final String requestId) {
- dmiDataOperations.requestResourceDataFromDmi(topicParamInQuery, dataOperationRequest, requestId);
+ final DataOperationRequest dataOperationRequest,
+ final String requestId,
+ final String authorization) {
+ dmiDataOperations.requestResourceDataFromDmi(topicParamInQuery, dataOperationRequest, requestId,
+ authorization);
}
@Override
diff --git a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java
index 05b6ec3001..a77e78a2e2 100644
--- a/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java
+++ b/cps-ncmp-service/src/main/java/org/onap/cps/ncmp/api/impl/operations/DmiDataOperations.java
@@ -132,10 +132,12 @@ public class DmiDataOperations extends DmiOperations {
* @param topicParamInQuery topic name for (triggering) async responses
* @param dataOperationRequest data operation request to execute operations
* @param requestId requestId for as a response
+ * @param authorization contents of Authorization header, or null if not present
*/
public void requestResourceDataFromDmi(final String topicParamInQuery,
final DataOperationRequest dataOperationRequest,
- final String requestId) {
+ final String requestId,
+ final String authorization) {
final Set<String> cmHandlesIds
= getDistinctCmHandleIdsFromDataOperationRequest(dataOperationRequest);
@@ -147,7 +149,8 @@ public class DmiDataOperations extends DmiOperations {
= ResourceDataOperationRequestUtils.processPerDefinitionInDataOperationsRequest(topicParamInQuery,
requestId, dataOperationRequest, yangModelCmHandles);
- buildDataOperationRequestUrlAndSendToDmiService(topicParamInQuery, requestId, operationsOutPerDmiServiceName);
+ buildDataOperationRequestUrlAndSendToDmiService(topicParamInQuery, requestId, operationsOutPerDmiServiceName,
+ authorization);
}
/**
@@ -238,23 +241,26 @@ public class DmiDataOperations extends DmiOperations {
private void buildDataOperationRequestUrlAndSendToDmiService(final String topicParamInQuery,
final String requestId,
final Map<String, List<DmiDataOperation>>
- groupsOutPerDmiServiceName) {
+ groupsOutPerDmiServiceName,
+ final String authorization) {
groupsOutPerDmiServiceName.forEach((dmiServiceName, dmiDataOperationRequestBodies) -> {
final String dmiDataOperationResourceUrl =
getDmiServiceDataOperationRequestUrl(dmiServiceName, topicParamInQuery, requestId);
- sendDataOperationRequestToDmiService(dmiDataOperationResourceUrl, dmiDataOperationRequestBodies);
+ sendDataOperationRequestToDmiService(dmiDataOperationResourceUrl, dmiDataOperationRequestBodies,
+ authorization);
});
}
private void sendDataOperationRequestToDmiService(final String dataOperationResourceUrl,
- final List<DmiDataOperation> dmiDataOperationRequestBodies) {
+ final List<DmiDataOperation> dmiDataOperationRequestBodies,
+ final String authorization) {
final DmiDataOperationRequest dmiDataOperationRequest = DmiDataOperationRequest.builder()
.operations(dmiDataOperationRequestBodies).build();
final String dmiDataOperationRequestAsJsonString =
jsonObjectMapper.asJsonString(dmiDataOperationRequest);
TaskExecutor.executeTask(() -> dmiRestClient.postOperationWithJsonData(dataOperationResourceUrl,
- dmiDataOperationRequestAsJsonString, READ, null),
+ dmiDataOperationRequestAsJsonString, READ, authorization),
DEFAULT_ASYNC_TASK_EXECUTOR_TIMEOUT_IN_MILLISECONDS)
.whenCompleteAsync((response, throwable) -> handleTaskCompletionException(throwable,
dataOperationResourceUrl, dmiDataOperationRequestBodies));
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy
index 71380d46a6..5e837ac6b0 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/NetworkCmProxyDataServiceImplSpec.groovy
@@ -158,9 +158,9 @@ class NetworkCmProxyDataServiceImplSpec extends Specification {
given: 'cpsDataService returns valid data node'
def dataOperationRequest = getDataOperationRequest(datastoreName)
when: 'request resource data for data operation is called'
- objectUnderTest.executeDataOperationForCmHandles('some topic', dataOperationRequest, 'requestId')
+ objectUnderTest.executeDataOperationForCmHandles('some topic', dataOperationRequest, 'requestId', NO_AUTH_HEADER)
then: 'request resource data for data operation returns expected response'
- 1 * mockDmiDataOperations.requestResourceDataFromDmi('some topic', dataOperationRequest, 'requestId')
+ 1 * mockDmiDataOperations.requestResourceDataFromDmi('some topic', dataOperationRequest, 'requestId', NO_AUTH_HEADER)
where: 'the following data stores are used'
datastoreName << [PASSTHROUGH_RUNNING.datastoreName, PASSTHROUGH_OPERATIONAL.datastoreName]
}
diff --git a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy
index 26d44f28b3..7d8ac7485b 100644
--- a/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy
+++ b/cps-ncmp-service/src/test/groovy/org/onap/cps/ncmp/api/impl/operations/DmiDataOperationsSpec.groovy
@@ -114,7 +114,7 @@ class DmiDataOperationsSpec extends DmiOperationsBaseSpec {
postOperationWithJsonDataMethodCalled = true
}
when: 'get resource data for group of cm handles are invoked'
- objectUnderTest.requestResourceDataFromDmi('my-topic-name', dataOperationRequest, 'requestId')
+ objectUnderTest.requestResourceDataFromDmi('my-topic-name', dataOperationRequest, 'requestId', NO_AUTH_HEADER)
then: 'validate the post operation was called and ncmp generated dmi request body json args'
new PollingConditions().within(1) {
assert postOperationWithJsonDataMethodCalled == true