summaryrefslogtreecommitdiffstats
path: root/prh-app-server
diff options
context:
space:
mode:
authorJoanna Jeremicz <joanna.jeremicz@nokia.com>2020-03-05 08:28:31 +0100
committerJoanna Jeremicz <joanna.jeremicz@nokia.com>2020-03-05 08:28:31 +0100
commitb3d3b52b0734196e73268e44be00e65d4926aa5a (patch)
tree26ceb1f6ca957c1d04b0513377a2f3174cb465d1 /prh-app-server
parent8d6fec35a2c710105da6ea8f0b732b786b4ff1e3 (diff)
PRH error after PNF relocation
Path should be encoded before it is used as URL Change-Id: I408064245d9f56ea7925bc5a882ed42d8c84f191 Issue-ID: DCAEGEN2-2088 Signed-off-by: Joanna Jeremicz <joanna.jeremicz@nokia.com>
Diffstat (limited to 'prh-app-server')
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java3
-rw-r--r--prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java8
-rw-r--r--prh-app-server/src/test/resources/BbsActionsTaskTestFiles/logicalLinkBodyWithSpace.json1
3 files changed, 8 insertions, 4 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java
index 201f1bc0..c949b774 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskImpl.java
@@ -26,6 +26,7 @@ import static org.apache.http.HttpHeaders.CONTENT_TYPE;
import static org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpMethod.DELETE;
import static org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpMethod.GET;
import static org.onap.dcaegen2.services.sdk.rest.services.adapters.http.HttpMethod.PUT;
+import static org.springframework.web.util.UriUtils.encodeFragment;
import com.google.gson.JsonObject;
import io.vavr.collection.HashMap;
@@ -202,7 +203,7 @@ public class BbsActionsTaskImpl implements BbsActionsTask {
}
private String buildUri(String path) {
- return config.getAaiClientConfiguration().pnfUrl().replace(PNF_URI, path);
+ return config.getAaiClientConfiguration().pnfUrl().replace(PNF_URI, encodeFragment(path, UTF_8));
}
}
diff --git a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java
index bc754bf8..f060ac7b 100644
--- a/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java
+++ b/prh-app-server/src/test/java/org/onap/dcaegen2/services/prh/tasks/BbsActionsTaskTest.java
@@ -66,6 +66,7 @@ class BbsActionsTaskTest {
private static final String PNF_WITH_LINK_JSON = "BbsActionsTaskTestFiles/pnfWithLogicalLink.json";
private static final String LOGICAL_LINK_JSON = "BbsActionsTaskTestFiles/oldLogicalLink.json";
private static final String LOGICAL_LINK_BODY = "BbsActionsTaskTestFiles/logicalLinkBody.json";
+ private static final String LOGICAL_LINK_BODY_WITH_SPACE = "BbsActionsTaskTestFiles/logicalLinkBodyWithSpace.json";
private CbsConfiguration cbsConfiguration = mock(CbsConfiguration.class);
@@ -111,7 +112,8 @@ class BbsActionsTaskTest {
given(cbsConfiguration.getAaiClientConfiguration()).willReturn(aaiClientConfiguration);
JsonObject additionalFields = new JsonObject();
- String linkName = "some-link";
+ String linkName = "some link";
+ String encodedLinkName = "some%20link";
additionalFields.addProperty(ATTACHMENT_POINT, linkName);
ConsumerDmaapModel consumerDmaapModel = buildConsumerDmaapModel(additionalFields);
@@ -136,9 +138,9 @@ class BbsActionsTaskTest {
assertEquals(AAI_URL + PNF_URL + "/Nokia123", pnfGet.url());
assertEquals(GET, pnfGet.method());
- assertEquals(AAI_URL + LOGICAL_LINK_URL + "/" + linkName, linkPut.url());
+ assertEquals(AAI_URL + LOGICAL_LINK_URL + "/" + encodedLinkName, linkPut.url());
assertEquals(PUT, linkPut.method());
- assertEquals(getBodyJson(LOGICAL_LINK_BODY), extractBodyFromRequest(linkPut));
+ assertEquals(getBodyJson(LOGICAL_LINK_BODY_WITH_SPACE), extractBodyFromRequest(linkPut));
}
@Test
diff --git a/prh-app-server/src/test/resources/BbsActionsTaskTestFiles/logicalLinkBodyWithSpace.json b/prh-app-server/src/test/resources/BbsActionsTaskTestFiles/logicalLinkBodyWithSpace.json
new file mode 100644
index 00000000..9cdd7010
--- /dev/null
+++ b/prh-app-server/src/test/resources/BbsActionsTaskTestFiles/logicalLinkBodyWithSpace.json
@@ -0,0 +1 @@
+{"link-name":"some link","link-type":"attachment-point","relationship-list":{"relationship":[{"related-link":"/network/pnfs/pnf/Nokia123","relationship-data":[]}]}} \ No newline at end of file