summaryrefslogtreecommitdiffstats
path: root/cadi
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2018-11-28 10:54:32 -0600
committerInstrumental <jonathan.gathman@att.com>2018-11-28 10:57:01 -0600
commit5a357d6354eeca5999fd56437b5b492cd8bbc310 (patch)
tree6e82b6d3c9287cfe268a8071985ec5e256588a8f /cadi
parentdfe29e3ea4028ff04f73606f46404baf63f81f5b (diff)
Add more Path Wildcard
Issue-ID: AAF-649 Change-Id: I3eb81782dc899fb66d170c2ee7f3bfadccb01f22 Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'cadi')
-rw-r--r--cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/PermEval.java15
-rw-r--r--cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/test/JU_PermEval.java19
2 files changed, 32 insertions, 2 deletions
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/PermEval.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/PermEval.java
index 2c7aa12b..7c843dbd 100644
--- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/PermEval.java
+++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/PermEval.java
@@ -66,11 +66,22 @@ public class PermEval {
if (sInst.charAt(0)==startChar) { // To compare key-to-key, both strings must be keys
String[] skeys=Split.split(startChar,sInst);
String[] pkeys=Split.split(startChar,pInst);
- if (skeys.length!=pkeys.length) return false;
+ if (pkeys.length<skeys.length) {
+ return false;
+ } else if(pkeys.length > skeys.length &&
+ (skeys.length==0 || !ASTERIX.equals(skeys[skeys.length-1]))) {
+ return false;
+ }
boolean pass = true;
for (int i=1;pass && i<skeys.length;++i) { // We start at 1, because the first one, being ":" is always ""
- if (ASTERIX.equals(skeys[i]))continue; // Server data accepts all for this key spot
+ if (ASTERIX.equals(skeys[i])) {
+ if(i==skeys.length-1) {
+ // accept all after
+ return true;
+ }
+ continue; // Server data accepts all for this key spot
+ }
pass = false;
for (String sItem : Split.split(LIST_SEP,skeys[i])) { // allow for "," definition in Action
if (pkeys[i].length()==0) {
diff --git a/cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/test/JU_PermEval.java b/cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/test/JU_PermEval.java
index 3e137c25..5d242005 100644
--- a/cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/test/JU_PermEval.java
+++ b/cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/test/JU_PermEval.java
@@ -211,5 +211,24 @@ public class JU_PermEval {
@SuppressWarnings("unused")
PermEval pe = new PermEval();
}
+
+ @Test
+ public void pathTest() {
+ assertTrue(PermEval.evalInstance("/","/"));
+ assertFalse(PermEval.evalInstance("/","/hello"));
+ assertTrue(PermEval.evalInstance("/","/"));
+ assertTrue(PermEval.evalInstance("/onap/so/infra/*/*/*","/onap/so/infra/a/b/c"));
+ assertFalse(PermEval.evalInstance("/onap/so/infra/*","/onap/so/infra"));
+ assertTrue(PermEval.evalInstance("/onap/so/infra/*","/onap/so/infra/a/b/c"));
+ assertTrue(PermEval.evalInstance("/onap/so/infra*","/onap/so/infra"));
+ assertFalse(PermEval.evalInstance("/onap/so/infra*/hello","/onap/so/infra"));
+ assertFalse(PermEval.evalInstance("/onap/so/infra*/hello","/onap/so/infra23"));
+ assertTrue(PermEval.evalInstance("/onap/so/infra*/hello","/onap/so/infra23/hello"));
+ assertFalse(PermEval.evalInstance("/onap/so/*/hello","/onap/so/infra23"));
+ assertFalse(PermEval.evalInstance("/onap/so/*/","/onap/so/infra23"));
+ assertTrue(PermEval.evalInstance("/onap/so/*/","/onap/so/infra23/"));
+ }
+
+
}