summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDominic Lunanuova <dgl@research.att.com>2019-05-14 13:08:13 +0000
committerGerrit Code Review <gerrit@onap.org>2019-05-14 13:08:13 +0000
commit7dd1b8a4b7a3e87d555721b8d234f50e2305bcd0 (patch)
tree19191ce35df660fe1c0bf7de244ebef2465df146 /src
parentc81973deba0c2eeaaa424b398bed50c5cc8faece (diff)
parent715872f016751eb1ba7fb0045a7fc3fc34bf2327 (diff)
Merge "Problem in building AAF permission - fix"
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/util/PermissionBuilder.java7
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/util/PermissionBuilderTest.java16
2 files changed, 17 insertions, 6 deletions
diff --git a/src/main/java/org/onap/dmaap/dbcapi/util/PermissionBuilder.java b/src/main/java/org/onap/dmaap/dbcapi/util/PermissionBuilder.java
index 44c94af..d1f6b2b 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/util/PermissionBuilder.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/util/PermissionBuilder.java
@@ -73,11 +73,8 @@ public class PermissionBuilder {
private String getPermissionType(String pathInfo) {
char pathSeparator = '/';
- String relativePath = (pathInfo.charAt(pathInfo.length()-1) == pathSeparator) ?
- pathInfo.substring(0,pathInfo.length()-1) : pathInfo;
-
- String[] pathSlices = relativePath.split(String.valueOf(pathSeparator));
- return pathSlices[pathSlices.length-1];
+ String[] pathSlices = pathInfo.split(String.valueOf(pathSeparator));
+ return pathSlices[1];
}
String getInstance() {
diff --git a/src/test/java/org/onap/dmaap/dbcapi/util/PermissionBuilderTest.java b/src/test/java/org/onap/dmaap/dbcapi/util/PermissionBuilderTest.java
index 61bb4b6..8db9d2e 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/util/PermissionBuilderTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/util/PermissionBuilderTest.java
@@ -116,7 +116,21 @@ public class PermissionBuilderTest {
@Test
public void buildPermission_shouldBuildPermissionWithRealInstance() {
//given
- String path = "/subpath/topics/";
+ String path = "/dmaap";
+ String method = "GET";
+ initPermissionBuilder(path, method, provideRealInstance(DMAAP_NAME));
+
+ //when
+ String permission = permissionBuilder.buildPermission(request);
+
+ //then
+ assertEquals("org.onap.dmaap-bc.api.dmaap|mr|GET", permission);
+ }
+
+ @Test
+ public void buildPermission_shouldBuildPermissionWhenUrlContainsId() {
+ //given
+ String path = "/topics/topic_id_123";
String method = "GET";
initPermissionBuilder(path, method, provideRealInstance(DMAAP_NAME));