You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by ma...@apache.org on 2015/04/15 17:49:11 UTC
incubator-ranger git commit: RANGER-400: resource-matcher handling of
isRecursive updated to fix the issue
Repository: incubator-ranger
Updated Branches:
refs/heads/master d6cce39bb -> 0ee29405d
RANGER-400: resource-matcher handling of isRecursive updated to fix the issue
Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/0ee29405
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/0ee29405
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/0ee29405
Branch: refs/heads/master
Commit: 0ee29405da6e86b2683185ed68861a8f9e626ff0
Parents: d6cce39
Author: Madhan Neethiraj <ma...@apache.org>
Authored: Wed Apr 15 01:37:18 2015 -0700
Committer: Madhan Neethiraj <ma...@apache.org>
Committed: Wed Apr 15 08:48:09 2015 -0700
----------------------------------------------------------------------
.../RangerDefaultPolicyEvaluator.java | 2 +-
.../RangerAbstractResourceMatcher.java | 20 +-
.../RangerDefaultResourceMatcher.java | 13 +-
.../RangerPathResourceMatcher.java | 67 ++--
.../resourcematcher/RangerResourceMatcher.java | 9 +-
.../resourcematcher/TestResourceMatcher.java | 136 ++++++++
.../test_resourcematcher_default.json | 327 +++++++++++++++++++
.../test_resourcematcher_path.json | 290 ++++++++++++++++
8 files changed, 808 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/0ee29405/agents-common/src/main/java/org/apache/ranger/plugin/policyevaluator/RangerDefaultPolicyEvaluator.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/policyevaluator/RangerDefaultPolicyEvaluator.java b/agents-common/src/main/java/org/apache/ranger/plugin/policyevaluator/RangerDefaultPolicyEvaluator.java
index b6c98f7..3f9ab84 100644
--- a/agents-common/src/main/java/org/apache/ranger/plugin/policyevaluator/RangerDefaultPolicyEvaluator.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/policyevaluator/RangerDefaultPolicyEvaluator.java
@@ -649,7 +649,7 @@ public class RangerDefaultPolicyEvaluator extends RangerAbstractPolicyEvaluator
}
if (ret != null) {
- ret.init(resourceDef, resource);
+ ret.init(resourceDef.getMatcherOptions(), resource);
}
} else {
LOG.error("RangerDefaultPolicyEvaluator: RangerResourceDef is null");
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/0ee29405/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerAbstractResourceMatcher.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerAbstractResourceMatcher.java b/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerAbstractResourceMatcher.java
index 646cbc5..95dd214 100644
--- a/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerAbstractResourceMatcher.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerAbstractResourceMatcher.java
@@ -53,14 +53,12 @@ public abstract class RangerAbstractResourceMatcher implements RangerResourceMat
protected boolean isMatchAny = false;
@Override
- public void init(RangerResourceDef resourceDef, RangerPolicyResource policyResource) {
+ public void init(Map<String, String> options, RangerPolicyResource policyResource) {
if(LOG.isDebugEnabled()) {
LOG.debug("==> RangerAbstractResourceMatcher.init(" + resourceDef + ", " + policyResource + ")");
}
-
- this.options = resourceDef.getMatcherOptions();
- this.resourceDef = resourceDef;
+ this.options = options;
this.policyResource = policyResource;
optIgnoreCase = getBooleanOption(OPTION_IGNORE_CASE, true);
@@ -75,10 +73,6 @@ public abstract class RangerAbstractResourceMatcher implements RangerResourceMat
continue;
}
- if(optIgnoreCase) {
- policyValue = policyValue.toLowerCase();
- }
-
if(StringUtils.containsOnly(policyValue, WILDCARD_ASTERISK)) {
isMatchAny = true;
}
@@ -97,16 +91,6 @@ public abstract class RangerAbstractResourceMatcher implements RangerResourceMat
}
@Override
- public RangerResourceDef getResourceDef() {
- return resourceDef;
- }
-
- @Override
- public RangerPolicyResource getPolicyResource() {
- return policyResource;
- }
-
- @Override
public boolean isSingleAndExactMatch(String resource) {
if(LOG.isDebugEnabled()) {
LOG.debug("==> RangerAbstractResourceMatcher.isSingleAndExactMatch(" + resource + ")");
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/0ee29405/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerDefaultResourceMatcher.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerDefaultResourceMatcher.java b/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerDefaultResourceMatcher.java
index 007fc42..79c3885 100644
--- a/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerDefaultResourceMatcher.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerDefaultResourceMatcher.java
@@ -21,6 +21,7 @@ package org.apache.ranger.plugin.resourcematcher;
import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOCase;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -40,12 +41,14 @@ public class RangerDefaultResourceMatcher extends RangerAbstractResourceMatcher
if(resource == null || isMatchAny) {
ret = isMatchAny;
} else {
- if(optIgnoreCase) {
- resource = resource.toLowerCase();
- }
-
for(String policyValue : policyValues) {
- ret = optWildCard ? FilenameUtils.wildcardMatch(resource, policyValue) : StringUtils.equals(resource, policyValue);
+ if(optWildCard) {
+ ret = optIgnoreCase ? FilenameUtils.wildcardMatch(resource, policyValue, IOCase.INSENSITIVE)
+ : FilenameUtils.wildcardMatch(resource, policyValue, IOCase.SENSITIVE);
+ } else {
+ ret = optIgnoreCase ? StringUtils.equalsIgnoreCase(resource, policyValue)
+ : StringUtils.equals(resource, policyValue);
+ }
if(ret) {
break;
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/0ee29405/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerPathResourceMatcher.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerPathResourceMatcher.java b/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerPathResourceMatcher.java
index fffdbfc..6096c8d 100644
--- a/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerPathResourceMatcher.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerPathResourceMatcher.java
@@ -20,13 +20,17 @@
package org.apache.ranger.plugin.resourcematcher;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOCase;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyResource;
-import org.apache.ranger.plugin.model.RangerServiceDef.RangerResourceDef;
public class RangerPathResourceMatcher extends RangerAbstractResourceMatcher {
@@ -35,22 +39,37 @@ public class RangerPathResourceMatcher extends RangerAbstractResourceMatcher {
public static final String OPTION_PATH_SEPERATOR = "pathSeparatorChar";
public static final char DEFAULT_PATH_SEPERATOR_CHAR = org.apache.hadoop.fs.Path.SEPARATOR_CHAR;
- private boolean policyIsRecursive = false;
- private char pathSeparatorChar = DEFAULT_PATH_SEPERATOR_CHAR;
+ private boolean policyIsRecursive = false;
+ private char pathSeparatorChar = DEFAULT_PATH_SEPERATOR_CHAR;
+ private List<String> policyValuesForMatch = null;
@Override
- public void init(RangerResourceDef resourceDef, RangerPolicyResource policyResource) {
+ public void init(Map<String, String> options, RangerPolicyResource policyResource) {
if(LOG.isDebugEnabled()) {
- LOG.debug("==> RangerPathResourceMatcher.init(" + resourceDef + ", " + policyResource + ")");
+ LOG.debug("==> RangerPathResourceMatcher.init(" + options + ", " + policyResource + ")");
}
+ super.init(options, policyResource);
+
policyIsRecursive = policyResource == null ? false : policyResource.getIsRecursive();
pathSeparatorChar = getCharOption(OPTION_PATH_SEPERATOR, DEFAULT_PATH_SEPERATOR_CHAR);
- super.init(resourceDef, policyResource);
+ if(policyIsRecursive && optWildCard && !isMatchAny) {
+ policyValuesForMatch = new ArrayList<String>();
+
+ for(String policyValue : policyValues) {
+ if(policyValue.charAt(policyValue.length() - 1) == pathSeparatorChar) {
+ policyValuesForMatch.add(policyValue + WILDCARD_ASTERISK);
+ } else {
+ policyValuesForMatch.add(policyValue);
+ }
+ }
+ } else {
+ policyValuesForMatch = policyValues;
+ }
if(LOG.isDebugEnabled()) {
- LOG.debug("<== RangerPathResourceMatcher.init(" + resourceDef + ", " + policyResource + ")");
+ LOG.debug("<== RangerPathResourceMatcher.init(" + options + ", " + policyResource + ")");
}
}
@@ -65,23 +84,19 @@ public class RangerPathResourceMatcher extends RangerAbstractResourceMatcher {
if(resource == null || isMatchAny) {
ret = isMatchAny;
} else {
- if(optIgnoreCase) {
- resource = resource.toLowerCase();
- }
-
- for(String policyValue : policyValues) {
- if(policyIsRecursive) {
- if(optWildCard) {
- ret = isRecursiveWildCardMatch(resource, policyValue, pathSeparatorChar) ;
- } else {
- ret = StringUtils.startsWith(resource, policyValue);
- }
+ IOCase caseSensitivity = optIgnoreCase ? IOCase.INSENSITIVE : IOCase.SENSITIVE;
+
+ for(String policyValue : policyValuesForMatch) {
+ if(policyIsRecursive && optWildCard) {
+ ret = isRecursiveWildCardMatch(resource, policyValue, pathSeparatorChar, caseSensitivity);
+ } else if(policyIsRecursive) {
+ ret = optIgnoreCase ? StringUtils.startsWithIgnoreCase(resource, policyValue)
+ : StringUtils.startsWith(resource, policyValue);
+ } else if(optWildCard) {
+ ret = FilenameUtils.wildcardMatch(resource, policyValue, caseSensitivity);
} else {
- if(optWildCard) {
- ret = FilenameUtils.wildcardMatch(resource, policyValue);
- } else {
- ret = StringUtils.equals(resource, policyValue);
- }
+ ret = optIgnoreCase ? StringUtils.equalsIgnoreCase(resource, policyValue)
+ : StringUtils.equals(resource, policyValue);
}
if(ret) {
@@ -101,7 +116,7 @@ public class RangerPathResourceMatcher extends RangerAbstractResourceMatcher {
return ret;
}
- private boolean isRecursiveWildCardMatch(String pathToCheck, String wildcardPath, char pathSeparatorChar) {
+ private boolean isRecursiveWildCardMatch(String pathToCheck, String wildcardPath, char pathSeparatorChar, IOCase caseSensitivity) {
if(LOG.isDebugEnabled()) {
LOG.debug("==> RangerPathResourceMatcher.isRecursiveWildCardMatch(" + pathToCheck + ", " + wildcardPath + ", " + pathSeparatorChar + ")");
}
@@ -121,7 +136,7 @@ public class RangerPathResourceMatcher extends RangerAbstractResourceMatcher {
for(String p : pathElements) {
sb.append(p);
- ret = FilenameUtils.wildcardMatch(sb.toString(), wildcardPath) ;
+ ret = FilenameUtils.wildcardMatch(sb.toString(), wildcardPath, caseSensitivity) ;
if (ret) {
break;
@@ -132,7 +147,7 @@ public class RangerPathResourceMatcher extends RangerAbstractResourceMatcher {
sb = null;
} else { // pathToCheck consists of only pathSeparatorChar
- ret = FilenameUtils.wildcardMatch(pathToCheck, wildcardPath) ;
+ ret = FilenameUtils.wildcardMatch(pathToCheck, wildcardPath, caseSensitivity) ;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/0ee29405/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerResourceMatcher.java
----------------------------------------------------------------------
diff --git a/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerResourceMatcher.java b/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerResourceMatcher.java
index 4a846b5..3c4e99b 100644
--- a/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerResourceMatcher.java
+++ b/agents-common/src/main/java/org/apache/ranger/plugin/resourcematcher/RangerResourceMatcher.java
@@ -19,15 +19,12 @@
package org.apache.ranger.plugin.resourcematcher;
+import java.util.Map;
+
import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyResource;
-import org.apache.ranger.plugin.model.RangerServiceDef.RangerResourceDef;
public interface RangerResourceMatcher {
- void init(RangerResourceDef resourceDef, RangerPolicyResource policyResource);
-
- RangerResourceDef getResourceDef();
-
- RangerPolicyResource getPolicyResource();
+ void init(Map<String, String> options, RangerPolicyResource policyResource);
boolean isMatch(String resource);
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/0ee29405/agents-common/src/test/java/org/apache/ranger/plugin/resourcematcher/TestResourceMatcher.java
----------------------------------------------------------------------
diff --git a/agents-common/src/test/java/org/apache/ranger/plugin/resourcematcher/TestResourceMatcher.java b/agents-common/src/test/java/org/apache/ranger/plugin/resourcematcher/TestResourceMatcher.java
new file mode 100644
index 0000000..5775d0f
--- /dev/null
+++ b/agents-common/src/test/java/org/apache/ranger/plugin/resourcematcher/TestResourceMatcher.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ranger.plugin.resourcematcher;
+
+import static org.junit.Assert.*;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyResource;
+import org.apache.ranger.plugin.resourcematcher.TestResourceMatcher.ResourceMatcherTestCases.TestCase;
+import org.apache.ranger.plugin.resourcematcher.TestResourceMatcher.ResourceMatcherTestCases.TestCase.OneTest;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+public class TestResourceMatcher {
+ static Gson gsonBuilder = null;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ gsonBuilder = new GsonBuilder().setDateFormat("yyyyMMdd-HH:mm:ss.SSS-Z")
+ .setPrettyPrinting()
+ .create();
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void testResourceMatcher_default() throws Exception {
+ String[] tests = { "/resourcematcher/test_resourcematcher_default.json" };
+
+ runTestsFromResourceFiles(tests);
+ }
+
+ @Test
+ public void testResourceMatcher_path() throws Exception {
+ String[] tests = { "/resourcematcher/test_resourcematcher_path.json" };
+
+ runTestsFromResourceFiles(tests);
+ }
+
+ private void runTestsFromResourceFiles(String[] resourceNames) throws Exception {
+ for(String resourceName : resourceNames) {
+ InputStream inStream = this.getClass().getResourceAsStream(resourceName);
+ InputStreamReader reader = new InputStreamReader(inStream);
+
+ runTests(reader, resourceName);
+ }
+ }
+
+ private void runTests(InputStreamReader reader, String testName) throws Exception {
+ ResourceMatcherTestCases testCases = gsonBuilder.fromJson(reader, ResourceMatcherTestCases.class);
+
+ assertTrue("invalid input: " + testName, testCases != null && testCases.testCases != null);
+
+ for(TestCase testCase : testCases.testCases) {
+ RangerResourceMatcher matcher = createResourceMatcher(testCase.matcher, testCase.matcherOptions, testCase.policyResource);
+
+ for(OneTest oneTest : testCase.tests) {
+ if(oneTest == null) {
+ continue;
+ }
+
+ boolean expected = oneTest.result;
+ boolean result = matcher.isMatch(oneTest.input);
+
+ assertEquals("isMatch() failed! " + testCase.name + ":" + oneTest.name + ": input=" + oneTest.input, expected, result);
+ }
+ }
+ }
+
+ private RangerResourceMatcher createResourceMatcher(String className, Map<String, String> options, RangerPolicyResource policyResource) throws Exception {
+ RangerResourceMatcher ret = null;
+
+ @SuppressWarnings("unchecked")
+ Class<RangerResourceMatcher> matcherClass = (Class<RangerResourceMatcher>) Class.forName(className);
+
+ ret = matcherClass.newInstance();
+ ret.init(options, policyResource);
+
+ return ret;
+ }
+
+ static class ResourceMatcherTestCases {
+ public List<TestCase> testCases;
+
+ class TestCase {
+ public String name;
+ public String matcher;
+ public Map<String, String> matcherOptions;
+ public RangerPolicyResource policyResource;
+ public List<OneTest> tests;
+
+ class OneTest {
+ String name;
+ String input;
+ boolean result;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/0ee29405/agents-common/src/test/resources/resourcematcher/test_resourcematcher_default.json
----------------------------------------------------------------------
diff --git a/agents-common/src/test/resources/resourcematcher/test_resourcematcher_default.json b/agents-common/src/test/resources/resourcematcher/test_resourcematcher_default.json
new file mode 100644
index 0000000..24d1e4e
--- /dev/null
+++ b/agents-common/src/test/resources/resourcematcher/test_resourcematcher_default.json
@@ -0,0 +1,327 @@
+{
+ "testCases":[
+ {
+ "name":"value=simple; wildCard=true; ignoreCase=true",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerDefaultResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true},
+ "policyResource":{
+ "values": ["simple"]
+ },
+ "tests":[
+ { "name":"all-lower","input":"simple", "result":true},
+ { "name":"all-upper","input":"SIMPLE", "result":true},
+ { "name":"mixed-case","input":"SiMpLe", "result":true},
+ { "name":"invalid-all-lower-wild","input":"other-simple", "result":false},
+ { "name":"invalid-all-upper-wild","input":"OTHER-SIMPLE", "result":false},
+ { "name":"invalid-mixed-case-wild","input":"OtHeR-SiMpLe", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=simple; wildCard=true; ignoreCase=true; isExcludes=true",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerDefaultResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true},
+ "policyResource":{
+ "values": ["simple"],
+ "isExcludes":true
+ },
+ "tests":[
+ { "name":"all-lower","input":"simple", "result":false},
+ { "name":"all-upper","input":"SIMPLE", "result":false},
+ { "name":"mixed-case","input":"SiMpLe", "result":false},
+ { "name":"invalid-all-lower-wild","input":"other-simple", "result":true},
+ { "name":"invalid-all-upper-wild","input":"OTHER-SIMPLE", "result":true},
+ { "name":"invalid-mixed-case-wild","input":"OtHeR-SiMpLe", "result":true},
+ ]
+ }
+ ,
+ {
+ "name":"value=simple; wildCard=true; ignoreCase=false",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerDefaultResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":false},
+ "policyResource":{
+ "values": ["simple"]
+ },
+ "tests":[
+ { "name":"all-lower","input":"simple", "result":true},
+ { "name":"all-upper","input":"SIMPLE", "result":false},
+ { "name":"mixed-case","input":"SiMpLe", "result":false},
+ { "name":"invalid-all-lower","input":"other-string", "result":false},
+ { "name":"invalid-all-upper","input":"OTHER-STRING", "result":false},
+ { "name":"invalid-mixed-case","input":"oThEr-StRiNg", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=SiMpLe; wildCard=true; ignoreCase=false",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerDefaultResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":false},
+ "policyResource":{
+ "values": ["SiMpLe"]
+ },
+ "tests":[
+ { "name":"all-lower","input":"simple", "result":false},
+ { "name":"all-upper","input":"SIMPLE", "result":false},
+ { "name":"mixed-case","input":"SiMpLe", "result":true},
+ { "name":"invalid-all-lower","input":"other-string", "result":false},
+ { "name":"invalid-all-upper","input":"OTHER-STRING", "result":false},
+ { "name":"invalid-mixed-case","input":"oThEr-StRiNg", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=simple*; wildCard=true; ignoreCase=true",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerDefaultResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true},
+ "policyResource":{
+ "values": ["simple*"]
+ },
+ "tests":[
+ { "name":"all-lower","input":"simple", "result":true},
+ { "name":"all-upper","input":"SIMPLE", "result":true},
+ { "name":"mixed-case","input":"SiMpLe", "result":true},
+ { "name":"all-lower-wild-exact","input":"simple*", "result":true},
+ { "name":"all-upper-wild-exact","input":"SIMPLE*", "result":true},
+ { "name":"mixed-case-wild-exact","input":"SiMpLe*", "result":true},
+ { "name":"all-lower-wild","input":"simple-test-string", "result":true},
+ { "name":"all-upper-wild","input":"SIMPLE-TEST-STRING", "result":true},
+ { "name":"mixed-case-wild","input":"SiMpLe-TeSt-StRiNg", "result":true},
+ { "name":"invalid-all-lower","input":"other-string", "result":false},
+ { "name":"invalid-all-upper","input":"OTHER-STRING", "result":false},
+ { "name":"invalid-mixed-case","input":"oThEr-StRiNg", "result":false},
+ { "name":"invalid-lower-wild","input":"simpele-test-string", "result":false},
+ { "name":"invalid-upper-wild","input":"SIMPELE-TEST-STRING", "result":false},
+ { "name":"invalid-mixed-case-wild","input":"SiMpeLe-TeSt-StRiNg", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=simple*string; wildCard=true; ignoreCase=true",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerDefaultResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true},
+ "policyResource":{
+ "values": ["simple*string"]
+ },
+ "tests":[
+ { "name":"all-lower","input":"simplestring", "result":true},
+ { "name":"all-upper","input":"SIMPLESTRING", "result":true},
+ { "name":"mixed-case","input":"SiMpLeStRiNg", "result":true},
+ { "name":"all-lower-wild-exact","input":"simple*string", "result":true},
+ { "name":"all-upper-wild-exact","input":"SIMPLE*STRING", "result":true},
+ { "name":"mixed-case-wild-exact","input":"SiMpLe*StRiNg", "result":true},
+ { "name":"all-lower-wild","input":"simple-test-string", "result":true},
+ { "name":"all-upper-wild","input":"SIMPLE-TEST-STRING", "result":true},
+ { "name":"mixed-case-wild","input":"SiMpLe-TeSt-StRiNg", "result":true},
+ { "name":"invalid-all-lower","input":"other-simple-string", "result":false},
+ { "name":"invalid-all-upper","input":"OTHER-SIMPLE-STRING", "result":false},
+ { "name":"invalid-mixed-case","input":"oThEr-SiMpLe-StRiNg", "result":false},
+ { "name":"invalid-lower-wild","input":"simpele-test-string", "result":false},
+ { "name":"invalid-upper-wild","input":"SIMPELE-TEST-STRING", "result":false},
+ { "name":"invalid-mixed-case-wild","input":"SiMpeLe-TeSt-StRiNg", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=simple*test*string; wildCard=true; ignoreCase=true",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerDefaultResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true},
+ "policyResource":{
+ "values": ["simple*test*string"]
+ },
+ "tests":[
+ { "name":"all-lower","input":"simpleteststring", "result":true},
+ { "name":"all-upper","input":"SIMPLETESTSTRING", "result":true},
+ { "name":"mixed-case","input":"SiMpLeTeStStRiNg", "result":true},
+ { "name":"all-lower-wild-exact","input":"simple*test*string", "result":true},
+ { "name":"all-upper-wild-exact","input":"SIMPLE*TEST*STRING", "result":true},
+ { "name":"mixed-case-wild-exact","input":"SiMpLe*TeSt*StRiNg", "result":true},
+ { "name":"all-lower-wild","input":"simple-test-string", "result":true},
+ { "name":"all-upper-wild","input":"SIMPLE-TEST-STRING", "result":true},
+ { "name":"mixed-case-wild","input":"SiMpLe-TeSt-StRiNg", "result":true},
+ { "name":"all-lower-wild","input":"simple-long-test-cool-string", "result":true},
+ { "name":"all-upper-wild","input":"SIMPLE-LONG-TEST-COOL-STRING", "result":true},
+ { "name":"mixed-case-wild","input":"SiMpLe-LoNg-TeSt-CoOl-StRiNg", "result":true},
+ { "name":"invalid-all-lower","input":"other-simple-test-string", "result":false},
+ { "name":"invalid-all-upper","input":"OTHER-SIMPLE-TEST-STRING", "result":false},
+ { "name":"invalid-mixed-case","input":"oThEr-SiMpLe-TeSt-StRiNg", "result":false},
+ { "name":"invalid-lower-wild","input":"simpele-test-string", "result":false},
+ { "name":"invalid-upper-wild","input":"SIMPELE-TEST-STRING", "result":false},
+ { "name":"invalid-mixed-case-wild","input":"SiMpeLe-TeSt-StRiNg", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=*simple; wildCard=true; ignoreCase=true",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerDefaultResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true},
+ "policyResource":{
+ "values": ["*simple"]
+ },
+ "tests":[
+ { "name":"all-lower","input":"teststringsimple", "result":true},
+ { "name":"all-upper","input":"TESTSTRINGSIMPLE", "result":true},
+ { "name":"mixed-case","input":"TeStStRiNgSiMpLe", "result":true},
+ { "name":"all-lower","input":"simpleteststringsimple", "result":true},
+ { "name":"all-upper","input":"SIMPLETESTSTRINGSIMPLE", "result":true},
+ { "name":"mixed-case","input":"SiMpLeTeStStRiNgSiMpLe", "result":true},
+ { "name":"invalid-all-lower","input":"simpleteststring", "result":false},
+ { "name":"invalid-all-upper","input":"SIMPLETESTSTRING", "result":false},
+ { "name":"invalid-mixed-case","input":"SiMpLeTeStStRiNg", "result":false},
+ { "name":"invalid-all-lower-wild-exact","input":"simple*test*string", "result":false},
+ { "name":"invalid-all-upper-wild-exact","input":"SIMPLE*TEST*STRING", "result":false},
+ { "name":"invalid-mixed-case-wild-exact","input":"SiMpLeTeStStRiNg", "result":false},
+ { "name":"invalid-all-lower-wild","input":"simple-test-string", "result":false},
+ { "name":"invalid-all-upper-wild","input":"SIMPLE-TEST-STRING", "result":false},
+ { "name":"invalid-mixed-case-wild","input":"SiMpLe-TeSt-StRiNg", "result":false},
+ { "name":"invalid-all-lower","input":"other-simple-string", "result":false},
+ { "name":"invalid-all-upper","input":"OTHER-SIMPLE-STRING", "result":false},
+ { "name":"invalid-mixed-case","input":"oThEr-SiMpLe-StRiNg", "result":false},
+ { "name":"invalid-lower-wild","input":"simpele-test-string", "result":false},
+ { "name":"invalid-upper-wild","input":"SIMPELE-TEST-STRING", "result":false},
+ { "name":"invalid-mixed-case-wild","input":"SiMpeLe-TeSt-StRiNg", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=simple*; wildCard=true; ignoreCase=false",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerDefaultResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":false},
+ "policyResource":{
+ "values": ["simple*"]
+ },
+ "tests":[
+ { "name":"all-lower","input":"simple", "result":true},
+ { "name":"all-upper","input":"SIMPLE", "result":false},
+ { "name":"mixed-case","input":"SiMpLe", "result":false},
+ { "name":"all-lower-wild","input":"simple-test-string", "result":true},
+ { "name":"all-upper-wild","input":"SIMPLE-TEST-STRING", "result":false},
+ { "name":"mixed-case-wild","input":"SiMpLe-TeSt-StRiNg", "result":false},
+ { "name":"invalid-all-lower","input":"other-string", "result":false},
+ { "name":"invalid-all-upper","input":"OTHER-STRING", "result":false},
+ { "name":"invalid-mixed-case","input":"oThEr-StRiNg", "result":false},
+ { "name":"invalid-lower-wild","input":"simpele-test-string", "result":false},
+ { "name":"invalid-upper-wild","input":"SIMPELE-TEST-STRING", "result":false},
+ { "name":"invalidmixed-case-wild","input":"SiMpeLe-TeSt-StRiNg", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=simple?; wildCard=true; ignoreCase=true",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerDefaultResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true},
+ "policyResource":{
+ "values": ["simple?"]
+ },
+ "tests":[
+ { "name":"all-lower","input":"simple1", "result":true},
+ { "name":"all-upper","input":"SIMPLE1", "result":true},
+ { "name":"mixed-case","input":"SiMpLe1", "result":true},
+ { "name":"all-lower-wild-exact","input":"simple?", "result":true},
+ { "name":"all-upper-wild-exact","input":"SIMPLE?", "result":true},
+ { "name":"mixed-case-wild-exact","input":"SiMpLe?", "result":true},
+ { "name":"invalid-all-lower","input":"simple", "result":false},
+ { "name":"invalid-all-upper","input":"SIMPLE", "result":false},
+ { "name":"invalid-mixed-case","input":"SiMpLe", "result":false},
+ { "name":"invalid-all-lower","input":"simple11", "result":false},
+ { "name":"invalid-all-upper","input":"SIMPLE11", "result":false},
+ { "name":"invalid-mixed-case","input":"SiMpLe11", "result":false},
+ { "name":"invalid-all-lower-wild","input":"simple-test-string", "result":false},
+ { "name":"invalid-all-upper-wild","input":"SIMPLE-TEST-STRING", "result":false},
+ { "name":"invalid-mixed-case-wild","input":"SiMpLe-TeSt-StRiNg", "result":false},
+ { "name":"invalid-all-lower","input":"other-string", "result":false},
+ { "name":"invalid-all-upper","input":"OTHER-STRING", "result":false},
+ { "name":"invalid-mixed-case","input":"oThEr-StRiNg", "result":false},
+ { "name":"invalid-lower-wild","input":"simpele-test-string", "result":false},
+ { "name":"invalid-upper-wild","input":"SIMPELE-TEST-STRING", "result":false},
+ { "name":"invalid-mixed-case-wild","input":"SiMpeLe-TeSt-StRiNg", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=simple?string; wildCard=true; ignoreCase=true",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerDefaultResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true},
+ "policyResource":{
+ "values": ["simple?string"]
+ },
+ "tests":[
+ { "name":"all-lower","input":"simple1string", "result":true},
+ { "name":"all-upper","input":"SIMPLE1STRING", "result":true},
+ { "name":"mixed-case","input":"SiMpLe1StRiNg", "result":true},
+ { "name":"all-lower-wild-exact","input":"simple?string", "result":true},
+ { "name":"all-upper-wild-exact","input":"SIMPLE?STRING", "result":true},
+ { "name":"mixed-case-wild-exact","input":"SiMpLe?StRiNg", "result":true},
+ { "name":"all-lower-wild","input":"simple-test-string", "result":false},
+ { "name":"all-upper-wild","input":"SIMPLE-TEST-STRING", "result":false},
+ { "name":"mixed-case-wild","input":"SiMpLe-TeSt-StRiNg", "result":false},
+ { "name":"invalid-all-lower","input":"other-string-simple", "result":false},
+ { "name":"invalid-all-upper","input":"OTHER-STRING-simple", "result":false},
+ { "name":"invalid-mixed-case","input":"oThEr-StRiNg-simple", "result":false},
+ { "name":"invalid-lower-wild","input":"simpele-test-string", "result":false},
+ { "name":"invalid-upper-wild","input":"SIMPELE-TEST-STRING", "result":false},
+ { "name":"invalid-mixed-case-wild","input":"SiMpeLe-TeSt-StRiNg", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=simple?string?; wildCard=true; ignoreCase=true",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerDefaultResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true},
+ "policyResource":{
+ "values": ["simple?string?"]
+ },
+ "tests":[
+ { "name":"all-lower","input":"simple1string1", "result":true},
+ { "name":"all-upper","input":"SIMPLE1STRING1", "result":true},
+ { "name":"mixed-case","input":"SiMpLe1StRiNg1", "result":true},
+ { "name":"all-lower-wild-exact","input":"simple?string?", "result":true},
+ { "name":"all-upper-wild-exact","input":"SIMPLE?STRING?", "result":true},
+ { "name":"mixed-case-wild-exact","input":"SiMpLe*StRiNg?", "result":true},
+ { "name":"all-lower","input":"simple1string", "result":false},
+ { "name":"all-upper","input":"SIMPLE1STRING11", "result":false},
+ { "name":"mixed-case","input":"SiMpLe1StRiNg11", "result":false},
+ { "name":"all-lower-wild","input":"simple-test-string", "result":false},
+ { "name":"all-upper-wild","input":"SIMPLE-TEST-STRING", "result":false},
+ { "name":"mixed-case-wild","input":"SiMpLe-TeSt-StRiNg", "result":false},
+ { "name":"invalid-all-lower","input":"other-string", "result":false},
+ { "name":"invalid-all-upper","input":"OTHER-STRING", "result":false},
+ { "name":"invalid-mixed-case","input":"oThEr-StRiNg", "result":false},
+ { "name":"invalid-lower-wild","input":"simpele-test-string", "result":false},
+ { "name":"invalid-upper-wild","input":"SIMPELE-TEST-STRING", "result":false},
+ { "name":"invalid-mixed-case-wild","input":"SiMpeLe-TeSt-StRiNg", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=simple1,simple2,wild*,onechar?,star*onechar?; wildCard=true; ignoreCase=true",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerDefaultResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true},
+ "policyResource":{
+ "values": ["simple1","simple2","wild*","onechar?","star*onechar?"]
+ },
+ "tests":[
+ { "name":"val1-all-lower","input":"simple1", "result":true},
+ { "name":"val2-all-lower","input":"simple2", "result":true},
+ { "name":"val3-all-lower","input":"wild*", "result":true},
+ { "name":"val4-all-lower","input":"onechar?", "result":true},
+ { "name":"val5-all-lower","input":"star*onechar?", "result":true},
+ { "name":"val3-all-lower-wild","input":"wild", "result":true},
+ { "name":"val3-all-lower-wild","input":"wildstring", "result":true},
+ { "name":"val4-all-lower","input":"onechar1", "result":true},
+ { "name":"val5-all-lower","input":"star-studded-onechar1", "result":true},
+ { "name":"val1-captialize","input":"Simple1", "result":true},
+ { "name":"val1-all-upper","input":"SIMPLE1", "result":true},
+ { "name":"val3-captialize-wild","input":"Wild", "result":true},
+ { "name":"val3-mixed-case-wild","input":"WiLdStR", "result":true},
+ { "name":"val1-mixed-case","input":"SiMpLe1", "result":true},
+ { "name":"val1-mixed-case","input":"sImPlE1", "result":true},
+ { "name":"val1-extra-at-end","input":"simple11", "result":false},
+ { "name":"val1-extra-at-begin","input":"1simple1", "result":false},
+ { "name":"val3-extra-at-begin-wild","input":"mywildstring", "result":false},
+ { "name":"val3-extra-at-begin-wild","input":"mywildstring", "result":false},
+ { "name":"val4-all-lower","input":"onechar11", "result":false},
+ { "name":"val5-all-lower","input":"star-studded-onechar11", "result":false},
+ ]
+ }
+ ]
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/0ee29405/agents-common/src/test/resources/resourcematcher/test_resourcematcher_path.json
----------------------------------------------------------------------
diff --git a/agents-common/src/test/resources/resourcematcher/test_resourcematcher_path.json b/agents-common/src/test/resources/resourcematcher/test_resourcematcher_path.json
new file mode 100644
index 0000000..352ed52
--- /dev/null
+++ b/agents-common/src/test/resources/resourcematcher/test_resourcematcher_path.json
@@ -0,0 +1,290 @@
+{
+ "testCases":[
+ {
+ "name":"value=/; isRecursive=false; wildCard=true; ignoreCase=true",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerPathResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true},
+ "policyResource":{
+ "values": ["/"],
+ "isRecursive":false
+ },
+ "tests":[
+ { "name":"exact-path","input":"/", "result":true},
+ { "name":"child-path","input":"/path1", "result":false},
+ { "name":"grand-child-path","input":"/path1/path2", "result":false},
+ { "name":"invalid-path","input":"path1", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=/path1; isRecursive=false; wildCard=true; ignoreCase=true",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerPathResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true},
+ "policyResource":{
+ "values": ["/path1"],
+ "isRecursive":false
+ },
+ "tests":[
+ { "name":"parent-path","input":"/", "result":false},
+ { "name":"exact-path","input":"/path1", "result":true},
+ { "name":"child-path","input":"/path1/path2", "result":false},
+ { "name":"grand-child-path","input":"/path1/path2/path3", "result":false},
+ { "name":"invalid-path","input":"path1", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=/path1/*; isRecursive=false; wildCard=true; ignoreCase=true",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerPathResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true},
+ "policyResource":{
+ "values": ["/path1/*"],
+ "isRecursive":false
+ },
+ "tests":[
+ { "name":"parent-path","input":"/", "result":false},
+ { "name":"exact-path","input":"/path1/*", "result":true},
+ { "name":"child-path","input":"/path1/path2", "result":true},
+ { "name":"grand-child-path","input":"/path1/path2/path3", "result":true},
+ { "name":"sibling-path","input":"/path2/path3/path4", "result":false},
+ { "name":"invalid-path","input":"path1", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=/; isRecursive=true; wildCard=true; ignoreCase=true",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerPathResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true},
+ "policyResource":{
+ "values": ["/"],
+ "isRecursive":true
+ },
+ "tests":[
+ { "name":"exact-path","input":"/", "result":true},
+ { "name":"child-path","input":"/path1", "result":true},
+ { "name":"grand-child-path","input":"/path1/path2", "result":true},
+ { "name":"invalid-path","input":"path1", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=/path1; isRecursive=true; wildCard=true; ignoreCase=true",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerPathResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true},
+ "policyResource":{
+ "values": ["/path1"],
+ "isRecursive":true
+ },
+ "tests":[
+ { "name":"parent-path","input":"/", "result":false},
+ { "name":"exact-path","input":"/path1", "result":true},
+ { "name":"child-path","input":"/path1/path2", "result":true},
+ { "name":"grand-child-path","input":"/path1/path2/path3", "result":true},
+ { "name":"exact-path-upper-case","input":"/PATH1", "result":true},
+ { "name":"child-path-mixed-case","input":"/PaTh1/pAtH2", "result":true},
+ { "name":"grand-child-path-camel-case","input":"/Path1/Path2/Path3", "result":true},
+ { "name":"sibling-path","input":"/path2", "result":false},
+ { "name":"invalid-path","input":"path1", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=/path*; isRecursive=true; wildCard=true; ignoreCase=true",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerPathResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true},
+ "policyResource":{
+ "values": ["/path*"],
+ "isRecursive":true
+ },
+ "tests":[
+ { "name":"parent-path","input":"/", "result":false},
+ { "name":"exact-path","input":"/path*", "result":true},
+ { "name":"wild-path","input":"/path1", "result":true},
+ { "name":"wild-path","input":"/path-to-success", "result":true},
+ { "name":"child-path","input":"/path-to-success/is-slow", "result":true},
+ { "name":"grand-child-path","input":"/path-to-success/is-slow/and-fun", "result":true},
+ { "name":"wild-path-mixed-case","input":"/PaTh-To-SuCcEsS", "result":true},
+ { "name":"child-path-upper-case","input":"/PATH-TO-SUCCESS/IS-SLOW", "result":true},
+ { "name":"grand-child-path-camel-case","input":"/Path-To-Success/Is-Slow/And-Fun", "result":true},
+ { "name":"unmatched-path","input":"/pat1ha", "result":false},
+ { "name":"unmatched-child-path","input":"/pat1ha/path2b", "result":false},
+ { "name":"invalid-path","input":"path1", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=/path?; isRecursive=true; wildCard=true; ignoreCase=true",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerPathResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true},
+ "policyResource":{
+ "values": ["/path?"],
+ "isRecursive":true
+ },
+ "tests":[
+ { "name":"parent-path","input":"/", "result":false},
+ { "name":"exact-path","input":"/path?", "result":true},
+ { "name":"wild-path","input":"/path1", "result":true},
+ { "name":"child-path","input":"/path1/path2", "result":true},
+ { "name":"grand-child-path","input":"/path1/path2/path3", "result":true},
+ { "name":"wild-path-mixed-case","input":"/PaTh1", "result":true},
+ { "name":"child-path-upper-case","input":"/PATH1/PATH2", "result":true},
+ { "name":"grand-child-path-camel-case","input":"/Path1/Path2/Path3", "result":true},
+ { "name":"unmatched-path","input":"/path1a", "result":false},
+ { "name":"unmatched-child-path","input":"/path1a/path2b", "result":false},
+ { "name":"invalid-path","input":"path1", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=/public/*test; isRecursive=true; wildCard=true; ignoreCase=true",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerPathResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true},
+ "policyResource":{
+ "values": ["/public/*test"],
+ "isRecursive":true
+ },
+ "tests":[
+ { "name":"parent-path","input":"/", "result":false},
+ { "name":"exact-path","input":"/public/*test", "result":true},
+ { "name":"wild-path","input":"/public/first-test", "result":true},
+ { "name":"wild-path","input":"/public/second-test", "result":true},
+ { "name":"wild-path","input":"/public/last-test", "result":true},
+ { "name":"child-path","input":"/public/new/first-test", "result":true},
+ { "name":"grand-child-path","input":"/public/archive/2008/first-test", "result":true},
+ { "name":"unmatched-path","input":"/pat1ha", "result":false},
+ { "name":"unmatched-child-path","input":"/pat1ha/path2b", "result":false},
+ { "name":"invalid-path","input":"path1", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=/public/*test/*result; isRecursive=true; wildCard=true; ignoreCase=true",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerPathResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true},
+ "policyResource":{
+ "values": ["/public/*test/*result"],
+ "isRecursive":true
+ },
+ "tests":[
+ { "name":"parent-path","input":"/", "result":false},
+ { "name":"parent-path","input":"/public/*test", "result":false},
+ { "name":"parent-path","input":"/public/first-test", "result":false},
+ { "name":"parent-path","input":"/public/second-test", "result":false},
+ { "name":"parent-path","input":"/public/last-test", "result":false},
+ { "name":"grand-parent-branch-path","input":"/public/new/first-test", "result":false},
+ { "name":"grand-parent-branch-path","input":"/public/new/first-test/result", "result":true},
+ { "name":"grand-parent-branch-grand-child-path","input":"/public/archive/2008/first-test/result", "result":true},
+ { "name":"exact-path","input":"/public/*test/*result", "result":true},
+ { "name":"wild-path","input":"/public/first-test/good-result", "result":true},
+ { "name":"wild-path","input":"/public/second-test/better-result", "result":true},
+ { "name":"wild-path","input":"/public/last-test/best-result", "result":true},
+ { "name":"child-path","input":"/public/first-test/good-result/details", "result":true},
+ { "name":"grand-child-path","input":"/public/last-test/best-result/details", "result":true},
+ { "name":"unmatched-path","input":"/pat1ha", "result":false},
+ { "name":"unmatched-child-path","input":"/pat1ha/path2b", "result":false},
+ { "name":"invalid-path","input":"path1", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=/public/*test/*result; isRecursive=false; wildCard=true; ignoreCase=true",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerPathResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true},
+ "policyResource":{
+ "values": ["/public/*test/*result"],
+ "isRecursive":true
+ },
+ "tests":[
+ { "name":"parent-path","input":"/", "result":false},
+ { "name":"parent-path","input":"/public/*test", "result":false},
+ { "name":"parent-path","input":"/public/first-test", "result":false},
+ { "name":"parent-path","input":"/public/second-test", "result":false},
+ { "name":"parent-path","input":"/public/last-test", "result":false},
+ { "name":"grand-parent-branch-path","input":"/public/new/first-test", "result":false},
+ { "name":"grand-parent-branch-path","input":"/public/new/first-test/result", "result":true},
+ { "name":"grand-parent-branch-grand-child-path","input":"/public/archive/2008/first-test/result", "result":true},
+ { "name":"exact-path","input":"/public/*test/*result", "result":true},
+ { "name":"wild-path","input":"/public/first-test/good-result", "result":true},
+ { "name":"wild-path","input":"/public/second-test/better-result", "result":true},
+ { "name":"wild-path","input":"/public/last-test/best-result", "result":true},
+ { "name":"child-path","input":"/public/first-test/good-result/details", "result":true}, # TODO: should this be false since isRecursive=false?
+ { "name":"grand-child-path","input":"/public/last-test/best-result/details", "result":true}, # TODO: should this be false since isRecursive=false?
+ { "name":"unmatched-path","input":"/pat1ha", "result":false},
+ { "name":"unmatched-child-path","input":"/pat1ha/path2b", "result":false},
+ { "name":"invalid-path","input":"path1", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=root; isRecursive=false; wildCard=true; ignoreCase=true; pathSeparatorChar=.",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerPathResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true, "pathSeparatorChar":"."},
+ "policyResource":{
+ "values": ["root"],
+ "isRecursive":false
+ },
+ "tests":[
+ { "name":"exact-path","input":"root", "result":true},
+ { "name":"child-path","input":"root.default", "result":false},
+ { "name":"grand-child-path","input":"root.default.mycompany", "result":false},
+ { "name":"invalid-path","input":"path1", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=root.default.mycompany*; isRecursive=false; wildCard=true; ignoreCase=true; pathSeparatorChar=.",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerPathResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true, "pathSeparatorChar":"."},
+ "policyResource":{
+ "values": ["root.default.mycompany*"],
+ "isRecursive":false
+ },
+ "tests":[
+ { "name":"parent-path","input":"root", "result":false},
+ { "name":"parent-path","input":"root.default", "result":false},
+ { "name":"exact-path","input":"root.default.mycompany*", "result":true},
+ { "name":"wild-path","input":"root.default.mycompany1", "result":true},
+ { "name":"child-path","input":"root.default.mycompany1.test", "result":true}, # TODO: should this be false since isRecursive=false
+ { "name":"child-path","input":"root.default.mycompany1.dev", "result":true}, # TODO: should this be false since isRecursive=false
+ { "name":"sibling-path","input":"root.default.othercompany1.dev", "result":false},
+ { "name":"invalid-path","input":"path1", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=root; isRecursive=true; wildCard=true; ignoreCase=true; pathSeparatorChar=.",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerPathResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true, "pathSeparatorChar":"."},
+ "policyResource":{
+ "values": ["root"],
+ "isRecursive":true
+ },
+ "tests":[
+ { "name":"exact-path","input":"root", "result":true},
+ { "name":"child-path","input":"root.default", "result":true},
+ { "name":"grand-child-path","input":"root.default.mycompany", "result":true},
+ { "name":"invalid-path","input":"path1", "result":false},
+ ]
+ }
+ ,
+ {
+ "name":"value=root.default.mycompany*; isRecursive=true; wildCard=true; ignoreCase=true; pathSeparatorChar=.",
+ "matcher":"org.apache.ranger.plugin.resourcematcher.RangerPathResourceMatcher",
+ "matcherOptions":{"wildCard":true, "ignoreCase":true, "pathSeparatorChar":"."},
+ "policyResource":{
+ "values": ["root.default.mycompany*"],
+ "isRecursive":true
+ },
+ "tests":[
+ { "name":"parent-path","input":"root", "result":false},
+ { "name":"parent-path","input":"root.default", "result":false},
+ { "name":"exact-path","input":"root.default.mycompany*", "result":true},
+ { "name":"wild-path","input":"root.default.mycompany1", "result":true},
+ { "name":"child-path","input":"root.default.mycompany1.test", "result":true},
+ { "name":"child-path","input":"root.default.mycompany1.dev", "result":true},
+ { "name":"sibling-path","input":"root.default.othercompany1.dev", "result":false},
+ { "name":"invalid-path","input":"path1", "result":false},
+ ]
+ }
+ ]
+}
\ No newline at end of file