This is an automated email from the ASF dual-hosted git repository.

madhan pushed a commit to branch ranger-2.8
in repository https://gitbox.apache.org/repos/asf/ranger.git


The following commit(s) were added to refs/heads/ranger-2.8 by this push:
     new aa3fc640b RANGER-5324: replace iterations with streams in 
RangerRequestScriptEvaluator - #2
aa3fc640b is described below

commit aa3fc640b252d21c081e227abd52044556a4dc7d
Author: Madhan Neethiraj <[email protected]>
AuthorDate: Thu Sep 18 08:28:09 2025 -0700

    RANGER-5324: replace iterations with streams in 
RangerRequestScriptEvaluator - #2
    
    (cherry picked from commit b34f856715b01abd77ee226386009c5d1104e910)
---
 .../policyengine/RangerRequestScriptEvaluator.java |  43 ++-
 .../ranger/authorization/utils/TestStringUtil.java |  61 +++-
 .../RangerRequestScriptEvaluatorTest.java          | 380 ++++++++++++---------
 3 files changed, 293 insertions(+), 191 deletions(-)

diff --git 
a/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerRequestScriptEvaluator.java
 
b/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerRequestScriptEvaluator.java
index 4b9ff23d1..f94df27e6 100644
--- 
a/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerRequestScriptEvaluator.java
+++ 
b/agents-common/src/main/java/org/apache/ranger/plugin/policyengine/RangerRequestScriptEvaluator.java
@@ -432,9 +432,7 @@ public String getCurrentTagType() {
     }
 
     public Set<String> getAllTagTypes() {
-        Set<RangerTagForEval> tags = getAllTags();
-
-        return CollectionUtils.isEmpty(tags) ? null : 
tags.stream().map(RangerTagForEval::getType).collect(Collectors.toSet());
+        return Collections.unmodifiableSet(tags.keySet());
     }
 
     public Map<String, String> getTagAttributes(final String tagType) {
@@ -445,8 +443,9 @@ public Map<String, String> getTagAttributes(final String 
tagType) {
         return CollectionUtils.isEmpty(tags) ? null :
                 tags.stream()
                         .filter(tag -> tagType.equals(tag.getType()))
-                        .findFirst()
                         .map(RangerTagForEval::getAttributes)
+                        .filter(MapUtils::isNotEmpty)
+                        .findFirst()
                         .orElse(null);
     }
 
@@ -474,10 +473,17 @@ public String getAttributeValue(final String tagType, 
final String attributeName
     }
 
     public List<String> getAttributeValueForAllMatchingTags(final String 
tagType, final String attributeName) {
-        List<Map<String, String>> attributes = (StringUtils.isBlank(tagType) 
|| StringUtils.isBlank(attributeName)) ? null : 
getTagAttributesForAllMatchingTags(tagType);
+        Set<RangerTagForEval> tags = StringUtils.isBlank(tagType) || 
StringUtils.isBlank(attributeName) ? null : getAllTags();
 
-        return attributes == null ? null :
-                attributes.stream().map(tagAttrs -> 
tagAttrs.get(attributeName)).filter(Objects::nonNull).collect(Collectors.toList());
+        return CollectionUtils.isEmpty(tags) ? null :
+                tags.stream()
+                        .filter(tag -> tagType.equals(tag.getType()))
+                        .map(RangerTagForEval::getAttributes)
+                        .filter(MapUtils::isNotEmpty)
+                        .map(tagAttrs -> tagAttrs.get(attributeName))
+                        .filter(Objects::nonNull)
+                        .sorted()
+                        .collect(Collectors.toList());
     }
 
     public String getAttributeValue(final String attributeName) {
@@ -1039,19 +1045,26 @@ private List<Object> getUgAttr(String attrName) {
     }
 
     private List<Object> getTagAttr(String attrName) {
-        return tagNames.stream()
-                .map(tags::get)
+        Set<RangerTagForEval> tags = StringUtils.isBlank(attrName) ? null : 
getAllTags();
+
+        return tags == null ? Collections.emptyList() : tags.stream()
+                .map(RangerTagForEval::getAttributes)
                 .filter(Objects::nonNull)
                 .map(attrs -> attrs.get(attrName))
                 .filter(Objects::nonNull)
+                .sorted()
                 .collect(Collectors.toList());
     }
 
     private Collection<String> getUserAttrNames() {
         Collection<String> ret = getSorted(userAttrs.keySet());
 
-        if (ret.contains(SCRIPT_FIELD__NAME)) { // this is needed to avoid 
calling remove() on unmodifiable collection
-            ret.remove(SCRIPT_FIELD__NAME);
+        if (ret.contains(SCRIPT_FIELD__NAME)) {
+            if (ret.size() == 1) { // SCRIPT_FIELD__NAME is the only entry; 
return empty list
+                ret = Collections.emptyList();
+            } else { // ret is safe to mutate when size > 1 - see getSorted()
+                ret.remove(SCRIPT_FIELD__NAME);
+            }
         }
 
         return ret;
@@ -1066,8 +1079,12 @@ private Collection<String> getUgAttrNames() {
     }
 
     private Collection<String> getTagAttrNames() {
-        return getSorted(
-                tags.values().stream()
+        Set<RangerTagForEval> tags = getAllTags();
+
+        return tags == null ? Collections.emptySet() : getSorted(
+                tags.stream()
+                        .map(RangerTagForEval::getAttributes)
+                        .filter(Objects::nonNull)
                         .flatMap(attrs -> attrs.keySet().stream())
                         .filter(attr -> !SCRIPT_FIELD__TYPE.equals(attr) && 
!SCRIPT_FIELD__MATCH_TYPE.equals(attr))
                         .collect(Collectors.toSet()));
diff --git 
a/agents-common/src/test/java/org/apache/ranger/authorization/utils/TestStringUtil.java
 
b/agents-common/src/test/java/org/apache/ranger/authorization/utils/TestStringUtil.java
index 2f3caea9d..dd21e9dc2 100644
--- 
a/agents-common/src/test/java/org/apache/ranger/authorization/utils/TestStringUtil.java
+++ 
b/agents-common/src/test/java/org/apache/ranger/authorization/utils/TestStringUtil.java
@@ -29,6 +29,7 @@
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -38,6 +39,36 @@
 import java.util.Set;
 
 public class TestStringUtil {
+    public static Map<String, String> mapFromStrings(String...args) {
+        Map<String, String> ret = new HashMap<>();
+
+        if (args != null) {
+            for (int i = 0; i < args.length; i += 2) {
+                String key = args[i];
+                String val = (args.length > (i + 1)) ? args[i + 1] : null;
+
+                ret.put(key, val);
+            }
+        }
+
+        return ret;
+    }
+
+    public static HashMap<String, List<String>> 
mapFromStringStringList(Object...args) {
+        HashMap<String, List<String>> ret = new HashMap<>();
+
+        if (args != null) {
+            for (int i = 0; i < args.length; i += 2) {
+                String       key = (String) args[i];
+                List<String> val = (args.length > (i + 1)) ? ((List<String>) 
args[i + 1]) : null;
+
+                ret.put(key, val);
+            }
+        }
+
+        return ret;
+    }
+
     @Test
     public void testDedupString() {
         Map<String, String> strTbl = new HashMap<>();
@@ -67,13 +98,13 @@ public void testDedupStringsList() {
         l1 = new ArrayList<>();
         Assert.assertSame("empty list - dedupStringsList() should return the 
same list", l1, StringUtil.dedupStringsList(l1, strTbl));
 
-        l1 = new ArrayList<String>() {{ add(getString("*")); }};
+        l1 = new ArrayList<>(Collections.singletonList("*"));
         Assert.assertNotSame("non-empty list - dedupStringsList() should 
return a new list", l1, StringUtil.dedupStringsList(l1, strTbl));
 
-        l1 = new ArrayList<String>() {{ add(getString("*")); 
add(getString("db1")); }};
+        l1 = new ArrayList<>(Arrays.asList(getString("*"), getString("db1")));
         Assert.assertNotSame("non-empty list - dedupStringsList() should 
return a new list", l1, StringUtil.dedupStringsList(l1, strTbl));
 
-        List<String> l2 = new ArrayList<String>() {{ add(getString("*")); 
add(getString("db1")); }};
+        List<String> l2 = new ArrayList<>(Arrays.asList(getString("*"), 
getString("db1")));
 
         for (int i = 0; i < l1.size(); i++) {
             Assert.assertNotSame("Before dedupStringsList(): l1[" + i + "] == 
l2[" + i + "]", l1.get(i), l2.get(i));
@@ -100,13 +131,13 @@ public void testDedupStringsSet() {
         s1 = new HashSet<>();
         Assert.assertSame("empty set - dedupStringsSet() should return the 
same set", s1, StringUtil.dedupStringsSet(s1, strTbl));
 
-        s1 = new HashSet<String>() {{ add(getString("*")); }};
+        s1 = new HashSet<>(Collections.singletonList(getString("*")));
         Assert.assertNotSame("non-empty set - dedupStringsSet() should return 
a new set", s1, StringUtil.dedupStringsSet(s1, strTbl));
 
-        s1 = new HashSet<String>() {{ add(getString("*")); 
add(getString("db1")); }};
+        s1 = new HashSet<>(Arrays.asList(getString("*"), getString("db1")));
         Assert.assertNotSame("non-empty set - dedupStringsSet() should return 
a new set", s1, StringUtil.dedupStringsSet(s1, strTbl));
 
-        Set<String> s2 = new HashSet<String>() {{ add(getString("*")); 
add(getString("db1")); }};
+        Set<String> s2 = new HashSet<>(Arrays.asList(getString("*"), 
getString("db1")));
 
         for (String elem : s1) {
             Assert.assertFalse("Before dedupStringsSet(): s1[" + elem + "] == 
s2[" + elem + "]", containsInstance(s2, elem));
@@ -133,10 +164,12 @@ public void testDedupStringsMap() {
         m1 = new HashMap<>();
         Assert.assertSame("empty map - dedupStringsMap() should return the 
same map", m1, StringUtil.dedupStringsMap(m1, strTbl));
 
-        m1 = new HashMap<String, String>() {{ put(getString("database"), 
getString("*")); }};
+        m1 = new HashMap<>();
+        m1.put(getString("database"), getString("*"));
         Assert.assertNotSame("non-empty map - dedupStringsMap() should return 
a new map", m1, StringUtil.dedupStringsMap(m1, strTbl));
 
-        Map<String, String> m2 = new HashMap<String, String>() {{ 
put(getString("database"), getString("*")); }};
+        Map<String, String> m2 = new HashMap<>();
+        m2.put(getString("database"), getString("*"));
 
         for (Map.Entry<String, String> entry : m1.entrySet()) {
             String key = entry.getKey();
@@ -169,10 +202,14 @@ public void testDedupMapOfPolicyResource() {
         m1 = new HashMap<>();
         Assert.assertSame("empty map - dedupStringsMapOfPolicyResource() 
should return the same map", m1, StringUtil.dedupStringsMapOfPolicyResource(m1, 
strTbl));
 
-        m1 = new HashMap<String, RangerPolicyResource>() {{ 
put(getString("database"), new RangerPolicyResource(getString("db1"))); 
put(getString("table"), new RangerPolicyResource(getString("*"))); }};
+        m1 = new HashMap<>();
+        m1.put(getString("database"), new 
RangerPolicyResource(getString("db1")));
+        m1.put(getString("table"), new RangerPolicyResource(getString("*")));
         Assert.assertNotSame("non-empty map - 
dedupStringsMapOfPolicyResource() should return a new map", m1, 
StringUtil.dedupStringsMapOfPolicyResource(m1, strTbl));
 
-        Map<String, RangerPolicyResource> m2 = new HashMap<String, 
RangerPolicyResource>() {{ put(getString("database"), new 
RangerPolicyResource(getString("db1"))); put(getString("table"), new 
RangerPolicyResource(getString("*"))); }};
+        Map<String, RangerPolicyResource> m2 = new HashMap<>();
+        m2.put(getString("database"), new 
RangerPolicyResource(getString("db1")));
+        m2.put(getString("table"), new RangerPolicyResource(getString("*")));
 
         for (Map.Entry<String, RangerPolicyResource> entry : m1.entrySet()) {
             String               key    = entry.getKey();
@@ -204,7 +241,7 @@ public void testDedupMapOfPolicyResource() {
 
     @Test
     public void testJsonCompression() throws IOException {
-        int[] sizeFactors = new int[] { 1, 10, 50, 100, 250, 300, 400, 500 };
+        int[] sizeFactors = new int[] {1, 10, 50, 100, 250, 300, 400, 500};
 
         for (int sizeFactor : sizeFactors) {
             RangerSecurityZone zone         = 
generateLargeSecurityZone(sizeFactor);
@@ -212,7 +249,7 @@ public void testJsonCompression() throws IOException {
             String             compressed   = StringUtil.compressString(json);
             String             deCompressed = 
StringUtil.decompressString(compressed);
 
-            System.out.println(String.format("%d: resourceCount=%d: 
len(json)=%,d, len(compressed)=%,d, savings=(%,d == %.03f%%)", sizeFactor, 
getResourceCount(zone), json.length(), compressed.length(), (json.length() - 
compressed.length()), ((json.length() - compressed.length()) / (float) 
json.length()) * 100));
+            System.out.printf("%d: resourceCount=%d: len(json)=%,d, 
len(compressed)=%,d, savings=(%,d == %.03f%%)%n", sizeFactor, 
getResourceCount(zone), json.length(), compressed.length(), (json.length() - 
compressed.length()), ((json.length() - compressed.length()) / (float) 
json.length()) * 100);
 
             Assert.assertTrue(compressed.length() < deCompressed.length());
 
diff --git 
a/agents-common/src/test/java/org/apache/ranger/plugin/conditionevaluator/RangerRequestScriptEvaluatorTest.java
 
b/agents-common/src/test/java/org/apache/ranger/plugin/conditionevaluator/RangerRequestScriptEvaluatorTest.java
index 0059bef88..35e32496c 100644
--- 
a/agents-common/src/test/java/org/apache/ranger/plugin/conditionevaluator/RangerRequestScriptEvaluatorTest.java
+++ 
b/agents-common/src/test/java/org/apache/ranger/plugin/conditionevaluator/RangerRequestScriptEvaluatorTest.java
@@ -19,6 +19,7 @@
 
 package org.apache.ranger.plugin.conditionevaluator;
 
+import org.apache.ranger.authorization.utils.TestStringUtil;
 import org.apache.ranger.plugin.contextenricher.RangerTagForEval;
 import org.apache.ranger.plugin.model.RangerTag;
 import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
@@ -33,6 +34,8 @@
 import org.junit.Test;
 
 import javax.script.ScriptEngine;
+
+import java.io.File;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
@@ -75,16 +78,16 @@ public void testRequestAttributes() {
         Assert.assertEquals("test: GET_TAG_ATTR_Q_CSV('attr1')", 
"'PCI_value','PII_value'", 
evaluator.evaluateScript("GET_TAG_ATTR_Q_CSV('attr1')"));
 
         Assert.assertTrue("test: USER._name is 'test-user'", (Boolean) 
evaluator.evaluateScript("USER._name == 'test-user'"));
-        Assert.assertTrue("test: HAS_USER_ATTR(state)", 
(Boolean)evaluator.evaluateScript("HAS_USER_ATTR('state')"));
-        Assert.assertFalse("test: HAS_USER_ATTR(notExists)", 
(Boolean)evaluator.evaluateScript("HAS_USER_ATTR('notExists')"));
+        Assert.assertTrue("test: HAS_USER_ATTR(state)", (Boolean) 
evaluator.evaluateScript("HAS_USER_ATTR('state')"));
+        Assert.assertFalse("test: HAS_USER_ATTR(notExists)", (Boolean) 
evaluator.evaluateScript("HAS_USER_ATTR('notExists')"));
         Assert.assertTrue("test: USER['state'] is 'CA'", (Boolean) 
evaluator.evaluateScript("USER['state'] == 'CA'"));
         Assert.assertTrue("test: USER.state is 'CA'", (Boolean) 
evaluator.evaluateScript("USER.state == 'CA'"));
 
-        Assert.assertTrue("test: IS_IN_GROUP(test-group1)", 
(Boolean)evaluator.evaluateScript("IS_IN_GROUP('test-group1')"));
-        Assert.assertTrue("test: IS_IN_GROUP(test-group2)", 
(Boolean)evaluator.evaluateScript("IS_IN_GROUP('test-group2')"));
-        Assert.assertFalse("test: IS_IN_GROUP(notExists)", 
(Boolean)evaluator.evaluateScript("IS_IN_GROUP('notExists')"));
-        Assert.assertTrue("test: IS_IN_ANY_GROUP", 
(Boolean)evaluator.evaluateScript("IS_IN_ANY_GROUP"));
-        Assert.assertFalse("test: IS_NOT_IN_ANY_GROUP", 
(Boolean)evaluator.evaluateScript("IS_NOT_IN_ANY_GROUP"));
+        Assert.assertTrue("test: IS_IN_GROUP(test-group1)", (Boolean) 
evaluator.evaluateScript("IS_IN_GROUP('test-group1')"));
+        Assert.assertTrue("test: IS_IN_GROUP(test-group2)", (Boolean) 
evaluator.evaluateScript("IS_IN_GROUP('test-group2')"));
+        Assert.assertFalse("test: IS_IN_GROUP(notExists)", (Boolean) 
evaluator.evaluateScript("IS_IN_GROUP('notExists')"));
+        Assert.assertTrue("test: IS_IN_ANY_GROUP", (Boolean) 
evaluator.evaluateScript("IS_IN_ANY_GROUP"));
+        Assert.assertFalse("test: IS_NOT_IN_ANY_GROUP", (Boolean) 
evaluator.evaluateScript("IS_NOT_IN_ANY_GROUP"));
 
         Assert.assertTrue("test: UG['test-group1'].dept is 'ENGG'", (Boolean) 
evaluator.evaluateScript("UG['test-group1'].dept == 'ENGG'"));
         Assert.assertTrue("test: UG['test-group1'].site is 10", (Boolean) 
evaluator.evaluateScript("UG['test-group1'].site == 10"));
@@ -93,13 +96,13 @@ public void testRequestAttributes() {
         Assert.assertTrue("test: UG['test-group3'] is null", (Boolean) 
evaluator.evaluateScript("UG['test-group3'] == null"));
         Assert.assertTrue("test: UG['test-group1'].notExists is null", 
(Boolean) evaluator.evaluateScript("UG['test-group1'].notExists == null"));
 
-        Assert.assertTrue("test: IS_IN_ROLE(test-role1)", 
(Boolean)evaluator.evaluateScript("IS_IN_ROLE('test-role1')"));
-        Assert.assertTrue("test: IS_IN_ROLE(test-role2)", 
(Boolean)evaluator.evaluateScript("IS_IN_ROLE('test-role2')"));
-        Assert.assertFalse("test: IS_IN_ROLE(notExists)", 
(Boolean)evaluator.evaluateScript("IS_IN_ROLE('notExists')"));
-        Assert.assertTrue("test: IS_IN_ANY_ROLE", 
(Boolean)evaluator.evaluateScript("IS_IN_ANY_ROLE"));
-        Assert.assertFalse("test: IS_NOT_IN_ANY_ROLE", 
(Boolean)evaluator.evaluateScript("IS_NOT_IN_ANY_ROLE"));
+        Assert.assertTrue("test: IS_IN_ROLE(test-role1)", (Boolean) 
evaluator.evaluateScript("IS_IN_ROLE('test-role1')"));
+        Assert.assertTrue("test: IS_IN_ROLE(test-role2)", (Boolean) 
evaluator.evaluateScript("IS_IN_ROLE('test-role2')"));
+        Assert.assertFalse("test: IS_IN_ROLE(notExists)", (Boolean) 
evaluator.evaluateScript("IS_IN_ROLE('notExists')"));
+        Assert.assertTrue("test: IS_IN_ANY_ROLE", (Boolean) 
evaluator.evaluateScript("IS_IN_ANY_ROLE"));
+        Assert.assertFalse("test: IS_NOT_IN_ANY_ROLE", (Boolean) 
evaluator.evaluateScript("IS_NOT_IN_ANY_ROLE"));
 
-        Assert.assertTrue("test: UGA.sVal['dept'] is 'ENGG'", 
(Boolean)evaluator.evaluateScript("UGA.sVal['dept'] == 'ENGG'"));
+        Assert.assertTrue("test: UGA.sVal['dept'] is 'ENGG'", (Boolean) 
evaluator.evaluateScript("UGA.sVal['dept'] == 'ENGG'"));
         Assert.assertTrue("test: UGA.sVal['site'] is 10", (Boolean) 
evaluator.evaluateScript("UGA.sVal['site'] == 10"));
         Assert.assertTrue("test: UGA.sVal['notExists'] is null", (Boolean) 
evaluator.evaluateScript("UGA.sVal['notExists'] == null"));
         Assert.assertTrue("test: UGA.mVal['dept'] is [\"ENGG\", \"PROD\"]", 
(Boolean) evaluator.evaluateScript("J(UGA.mVal['dept']) == 
'[\"ENGG\",\"PROD\"]'"));
@@ -108,9 +111,9 @@ public void testRequestAttributes() {
         Assert.assertTrue("test: UGA.mVal['dept'] has 'ENGG'", (Boolean) 
evaluator.evaluateScript("UGA.mVal['dept'].indexOf('ENGG') != -1"));
         Assert.assertTrue("test: UGA.mVal['dept'] has 'PROD'", (Boolean) 
evaluator.evaluateScript("UGA.mVal['dept'].indexOf('PROD') != -1"));
         Assert.assertTrue("test: UGA.mVal['dept'] doesn't have 'EXEC'", 
(Boolean) evaluator.evaluateScript("UGA.mVal['dept'].indexOf('EXEC') == -1"));
-        Assert.assertTrue("test: HAS_UG_ATTR(dept)", 
(Boolean)evaluator.evaluateScript("HAS_UG_ATTR('dept')"));
-        Assert.assertTrue("test: HAS_UG_ATTR(site)", 
(Boolean)evaluator.evaluateScript("HAS_UG_ATTR('site')"));
-        Assert.assertFalse("test: HAS_UG_ATTR(notExists)", 
(Boolean)evaluator.evaluateScript("HAS_UG_ATTR('notExists')"));
+        Assert.assertTrue("test: HAS_UG_ATTR(dept)", (Boolean) 
evaluator.evaluateScript("HAS_UG_ATTR('dept')"));
+        Assert.assertTrue("test: HAS_UG_ATTR(site)", (Boolean) 
evaluator.evaluateScript("HAS_UG_ATTR('site')"));
+        Assert.assertFalse("test: HAS_UG_ATTR(notExists)", (Boolean) 
evaluator.evaluateScript("HAS_UG_ATTR('notExists')"));
 
         Assert.assertTrue("test: REQ.accessTyp is 'select'", (Boolean) 
evaluator.evaluateScript("REQ.accessType == 'select'"));
         Assert.assertTrue("test: REQ.action is 'query'", (Boolean) 
evaluator.evaluateScript("REQ.action == 'query'"));
@@ -136,124 +139,124 @@ public void testRequestAttributes() {
         Assert.assertTrue("test: HAS_ANY_TAG", (Boolean) 
evaluator.evaluateScript("HAS_ANY_TAG"));
         Assert.assertFalse("test: HAS_NO_TAG", (Boolean) 
evaluator.evaluateScript("HAS_NO_TAG"));
 
-        Assert.assertEquals("GET_TAG_NAMES()",           "PCI,PII", 
evaluator.evaluateScript("GET_TAG_NAMES()"));
-        Assert.assertEquals("GET_TAG_NAMES(null)",       "PCI,PII", 
evaluator.evaluateScript("GET_TAG_NAMES(null)"));
-        Assert.assertEquals("GET_TAG_NAMES(null, '|')",  "PCI|PII", 
evaluator.evaluateScript("GET_TAG_NAMES(null, '|')"));
+        Assert.assertEquals("GET_TAG_NAMES()", "PCI,PII", 
evaluator.evaluateScript("GET_TAG_NAMES()"));
+        Assert.assertEquals("GET_TAG_NAMES(null)", "PCI,PII", 
evaluator.evaluateScript("GET_TAG_NAMES(null)"));
+        Assert.assertEquals("GET_TAG_NAMES(null, '|')", "PCI|PII", 
evaluator.evaluateScript("GET_TAG_NAMES(null, '|')"));
         Assert.assertEquals("GET_TAG_NAMES(null, null)", "PCIPII", 
evaluator.evaluateScript("GET_TAG_NAMES(null, null)"));
 
-        Assert.assertEquals("GET_TAG_NAMES_Q()",                    
"'PCI','PII'", evaluator.evaluateScript("GET_TAG_NAMES_Q()"));
-        Assert.assertEquals("GET_TAG_NAMES_Q(null)",                
"'PCI','PII'", evaluator.evaluateScript("GET_TAG_NAMES_Q(null)"));
-        Assert.assertEquals("GET_TAG_NAMES_Q(null, '|')",           
"'PCI'|'PII'", evaluator.evaluateScript("GET_TAG_NAMES_Q(null, '|')"));
-        Assert.assertEquals("GET_TAG_NAMES_Q(null, null)",          
"'PCI''PII'",  evaluator.evaluateScript("GET_TAG_NAMES_Q(null, null)"));
-        Assert.assertEquals("GET_TAG_NAMES_Q(null, '|', null)",     "PCI|PII", 
    evaluator.evaluateScript("GET_TAG_NAMES_Q(null, '|', null)"));
+        Assert.assertEquals("GET_TAG_NAMES_Q()", "'PCI','PII'", 
evaluator.evaluateScript("GET_TAG_NAMES_Q()"));
+        Assert.assertEquals("GET_TAG_NAMES_Q(null)", "'PCI','PII'", 
evaluator.evaluateScript("GET_TAG_NAMES_Q(null)"));
+        Assert.assertEquals("GET_TAG_NAMES_Q(null, '|')", "'PCI'|'PII'", 
evaluator.evaluateScript("GET_TAG_NAMES_Q(null, '|')"));
+        Assert.assertEquals("GET_TAG_NAMES_Q(null, null)", "'PCI''PII'", 
evaluator.evaluateScript("GET_TAG_NAMES_Q(null, null)"));
+        Assert.assertEquals("GET_TAG_NAMES_Q(null, '|', null)", "PCI|PII", 
evaluator.evaluateScript("GET_TAG_NAMES_Q(null, '|', null)"));
         Assert.assertEquals("GET_TAG_NAMES_Q(null, ',', '{', '}')", 
"{PCI},{PII}", evaluator.evaluateScript("GET_TAG_NAMES_Q(null, ',', '{', 
'}')"));
 
-        Assert.assertEquals("GET_TAG_ATTR_NAMES()",           "attr1", 
evaluator.evaluateScript("GET_TAG_ATTR_NAMES()"));
-        Assert.assertEquals("GET_TAG_ATTR_NAMES(null)",       "attr1", 
evaluator.evaluateScript("GET_TAG_ATTR_NAMES(null)"));
+        Assert.assertEquals("GET_TAG_ATTR_NAMES()", "attr1", 
evaluator.evaluateScript("GET_TAG_ATTR_NAMES()"));
+        Assert.assertEquals("GET_TAG_ATTR_NAMES(null)", "attr1", 
evaluator.evaluateScript("GET_TAG_ATTR_NAMES(null)"));
         Assert.assertEquals("GET_TAG_ATTR_NAMES(null, '|',)", "attr1", 
evaluator.evaluateScript("GET_TAG_ATTR_NAMES(null, '|')"));
         Assert.assertEquals("GET_TAG_ATTR_NAMES(null, null)", "attr1", 
evaluator.evaluateScript("GET_TAG_ATTR_NAMES(null, null)"));
 
-        Assert.assertEquals("GET_TAG_ATTR_NAMES_Q()",                    
"'attr1'", evaluator.evaluateScript("GET_TAG_ATTR_NAMES_Q()"));
-        Assert.assertEquals("GET_TAG_ATTR_NAMES_Q(null)",                
"'attr1'", evaluator.evaluateScript("GET_TAG_ATTR_NAMES_Q(null)"));
-        Assert.assertEquals("GET_TAG_ATTR_NAMES_Q(null, '|')",           
"'attr1'", evaluator.evaluateScript("GET_TAG_ATTR_NAMES_Q(null, '|')"));
-        Assert.assertEquals("GET_TAG_ATTR_NAMES_Q(null, null)",          
"'attr1'",   evaluator.evaluateScript("GET_TAG_ATTR_NAMES_Q(null, null)"));
-        Assert.assertEquals("GET_TAG_ATTR_NAMES_Q(null, '|', null)",     
"attr1",   evaluator.evaluateScript("GET_TAG_ATTR_NAMES_Q(null, '|', null)"));
+        Assert.assertEquals("GET_TAG_ATTR_NAMES_Q()", "'attr1'", 
evaluator.evaluateScript("GET_TAG_ATTR_NAMES_Q()"));
+        Assert.assertEquals("GET_TAG_ATTR_NAMES_Q(null)", "'attr1'", 
evaluator.evaluateScript("GET_TAG_ATTR_NAMES_Q(null)"));
+        Assert.assertEquals("GET_TAG_ATTR_NAMES_Q(null, '|')", "'attr1'", 
evaluator.evaluateScript("GET_TAG_ATTR_NAMES_Q(null, '|')"));
+        Assert.assertEquals("GET_TAG_ATTR_NAMES_Q(null, null)", "'attr1'", 
evaluator.evaluateScript("GET_TAG_ATTR_NAMES_Q(null, null)"));
+        Assert.assertEquals("GET_TAG_ATTR_NAMES_Q(null, '|', null)", "attr1", 
evaluator.evaluateScript("GET_TAG_ATTR_NAMES_Q(null, '|', null)"));
         Assert.assertEquals("GET_TAG_ATTR_NAMES_Q(null, ',', '{', '}')", 
"{attr1}", evaluator.evaluateScript("GET_TAG_ATTR_NAMES_Q(null, ',', '{', 
'}')"));
 
-        Assert.assertEquals("GET_TAG_ATTR('attr1')",            
"PCI_value,PII_value", evaluator.evaluateScript("GET_TAG_ATTR('attr1')"));
-        Assert.assertEquals("GET_TAG_ATTR('attr1', null)",      
"PCI_value,PII_value", evaluator.evaluateScript("GET_TAG_ATTR('attr1', null)"));
+        Assert.assertEquals("GET_TAG_ATTR('attr1')", "PCI_value,PII_value", 
evaluator.evaluateScript("GET_TAG_ATTR('attr1')"));
+        Assert.assertEquals("GET_TAG_ATTR('attr1', null)", 
"PCI_value,PII_value", evaluator.evaluateScript("GET_TAG_ATTR('attr1', null)"));
         Assert.assertEquals("GET_TAG_ATTR('attr1', null, '|')", 
"PCI_value|PII_value", evaluator.evaluateScript("GET_TAG_ATTR('attr1', null, 
'|')"));
         Assert.assertEquals("GET_TAG_ATTR('attr1', null, null)", 
"PCI_valuePII_value", evaluator.evaluateScript("GET_TAG_ATTR('attr1', null, 
null)"));
 
-        Assert.assertEquals("GET_TAG_ATTR_Q('attr1')",                      
"'PCI_value','PII_value'", evaluator.evaluateScript("GET_TAG_ATTR_Q('attr1')"));
-        Assert.assertEquals("GET_TAG_ATTR_Q('attr1', null)",                
"'PCI_value','PII_value'", evaluator.evaluateScript("GET_TAG_ATTR_Q('attr1', 
null)"));
-        Assert.assertEquals("GET_TAG_ATTR_Q('attr1', null, null)",          
"'PCI_value''PII_value'",  evaluator.evaluateScript("GET_TAG_ATTR_Q('attr1', 
null, null)"));
-        Assert.assertEquals("GET_TAG_ATTR_Q('attr1', null, '|')",           
"'PCI_value'|'PII_value'", evaluator.evaluateScript("GET_TAG_ATTR_Q('attr1', 
null, '|')"));
-        Assert.assertEquals("GET_TAG_ATTR_Q('attr1', null, ',', null)",     
"PCI_value,PII_value",     evaluator.evaluateScript("GET_TAG_ATTR_Q('attr1', 
null, ',', null)"));
+        Assert.assertEquals("GET_TAG_ATTR_Q('attr1')", 
"'PCI_value','PII_value'", evaluator.evaluateScript("GET_TAG_ATTR_Q('attr1')"));
+        Assert.assertEquals("GET_TAG_ATTR_Q('attr1', null)", 
"'PCI_value','PII_value'", evaluator.evaluateScript("GET_TAG_ATTR_Q('attr1', 
null)"));
+        Assert.assertEquals("GET_TAG_ATTR_Q('attr1', null, null)", 
"'PCI_value''PII_value'", evaluator.evaluateScript("GET_TAG_ATTR_Q('attr1', 
null, null)"));
+        Assert.assertEquals("GET_TAG_ATTR_Q('attr1', null, '|')", 
"'PCI_value'|'PII_value'", evaluator.evaluateScript("GET_TAG_ATTR_Q('attr1', 
null, '|')"));
+        Assert.assertEquals("GET_TAG_ATTR_Q('attr1', null, ',', null)", 
"PCI_value,PII_value", evaluator.evaluateScript("GET_TAG_ATTR_Q('attr1', null, 
',', null)"));
         Assert.assertEquals("GET_TAG_ATTR_Q('attr1', null, ',', '{', '}')", 
"{PCI_value},{PII_value}", evaluator.evaluateScript("GET_TAG_ATTR_Q('attr1', 
null, ',', '{', '}')"));
 
-        Assert.assertEquals("GET_UG_NAMES()",           
"test-group1,test-group2", evaluator.evaluateScript("GET_UG_NAMES()"));
-        Assert.assertEquals("GET_UG_NAMES(null)",       
"test-group1,test-group2", evaluator.evaluateScript("GET_UG_NAMES(null)"));
-        Assert.assertEquals("GET_UG_NAMES(null, '|')",  
"test-group1|test-group2", evaluator.evaluateScript("GET_UG_NAMES(null, '|')"));
-        Assert.assertEquals("GET_UG_NAMES(null, null)", 
"test-group1test-group2",  evaluator.evaluateScript("GET_UG_NAMES(null, 
null)"));
+        Assert.assertEquals("GET_UG_NAMES()", "test-group1,test-group2", 
evaluator.evaluateScript("GET_UG_NAMES()"));
+        Assert.assertEquals("GET_UG_NAMES(null)", "test-group1,test-group2", 
evaluator.evaluateScript("GET_UG_NAMES(null)"));
+        Assert.assertEquals("GET_UG_NAMES(null, '|')", 
"test-group1|test-group2", evaluator.evaluateScript("GET_UG_NAMES(null, '|')"));
+        Assert.assertEquals("GET_UG_NAMES(null, null)", 
"test-group1test-group2", evaluator.evaluateScript("GET_UG_NAMES(null, null)"));
 
-        Assert.assertEquals("GET_UG_NAMES_Q()",                    
"'test-group1','test-group2'", evaluator.evaluateScript("GET_UG_NAMES_Q()"));
-        Assert.assertEquals("GET_UG_NAMES_Q(null)",                
"'test-group1','test-group2'", 
evaluator.evaluateScript("GET_UG_NAMES_Q(null)"));
-        Assert.assertEquals("GET_UG_NAMES_Q(null, null)",          
"'test-group1''test-group2'", evaluator.evaluateScript("GET_UG_NAMES_Q(null, 
null)"));
-        Assert.assertEquals("GET_UG_NAMES_Q(null, '|')",           
"'test-group1'|'test-group2'", evaluator.evaluateScript("GET_UG_NAMES_Q(null, 
'|')"));
-        Assert.assertEquals("GET_UG_NAMES_Q(null, ',', null)",     
"test-group1,test-group2",     evaluator.evaluateScript("GET_UG_NAMES_Q(null, 
',', null)"));
+        Assert.assertEquals("GET_UG_NAMES_Q()", "'test-group1','test-group2'", 
evaluator.evaluateScript("GET_UG_NAMES_Q()"));
+        Assert.assertEquals("GET_UG_NAMES_Q(null)", 
"'test-group1','test-group2'", 
evaluator.evaluateScript("GET_UG_NAMES_Q(null)"));
+        Assert.assertEquals("GET_UG_NAMES_Q(null, null)", 
"'test-group1''test-group2'", evaluator.evaluateScript("GET_UG_NAMES_Q(null, 
null)"));
+        Assert.assertEquals("GET_UG_NAMES_Q(null, '|')", 
"'test-group1'|'test-group2'", evaluator.evaluateScript("GET_UG_NAMES_Q(null, 
'|')"));
+        Assert.assertEquals("GET_UG_NAMES_Q(null, ',', null)", 
"test-group1,test-group2", evaluator.evaluateScript("GET_UG_NAMES_Q(null, ',', 
null)"));
         Assert.assertEquals("GET_UG_NAMES_Q(null, ',', '{', '}')", 
"{test-group1},{test-group2}", evaluator.evaluateScript("GET_UG_NAMES_Q(null, 
',', '{', '}')"));
 
-        Assert.assertEquals("GET_UG_ATTR_NAMES()",           "dept,site", 
evaluator.evaluateScript("GET_UG_ATTR_NAMES()"));
-        Assert.assertEquals("GET_UG_ATTR_NAMES(null)",       "dept,site", 
evaluator.evaluateScript("GET_UG_ATTR_NAMES(null)"));
-        Assert.assertEquals("GET_UG_ATTR_NAMES(null, '|')",  "dept|site", 
evaluator.evaluateScript("GET_UG_ATTR_NAMES(null, '|')"));
-        Assert.assertEquals("GET_UG_ATTR_NAMES(null, null)", "deptsite",  
evaluator.evaluateScript("GET_UG_ATTR_NAMES(null, null)"));
+        Assert.assertEquals("GET_UG_ATTR_NAMES()", "dept,site", 
evaluator.evaluateScript("GET_UG_ATTR_NAMES()"));
+        Assert.assertEquals("GET_UG_ATTR_NAMES(null)", "dept,site", 
evaluator.evaluateScript("GET_UG_ATTR_NAMES(null)"));
+        Assert.assertEquals("GET_UG_ATTR_NAMES(null, '|')", "dept|site", 
evaluator.evaluateScript("GET_UG_ATTR_NAMES(null, '|')"));
+        Assert.assertEquals("GET_UG_ATTR_NAMES(null, null)", "deptsite", 
evaluator.evaluateScript("GET_UG_ATTR_NAMES(null, null)"));
 
-        Assert.assertEquals("GET_UG_ATTR_NAMES_Q()",                    
"'dept','site'", evaluator.evaluateScript("GET_UG_ATTR_NAMES_Q()"));
-        Assert.assertEquals("GET_UG_ATTR_NAMES_Q(null)",                
"'dept','site'", evaluator.evaluateScript("GET_UG_ATTR_NAMES_Q(null)"));
-        Assert.assertEquals("GET_UG_ATTR_NAMES_Q(null, null)",          
"'dept''site'", evaluator.evaluateScript("GET_UG_ATTR_NAMES_Q(null, null)"));
-        Assert.assertEquals("GET_UG_ATTR_NAMES_Q(null, '|')",           
"'dept'|'site'", evaluator.evaluateScript("GET_UG_ATTR_NAMES_Q(null, '|')"));
-        Assert.assertEquals("GET_UG_ATTR_NAMES_Q(null, ',', null)",     
"dept,site",     evaluator.evaluateScript("GET_UG_ATTR_NAMES_Q(null, ',', 
null)"));
+        Assert.assertEquals("GET_UG_ATTR_NAMES_Q()", "'dept','site'", 
evaluator.evaluateScript("GET_UG_ATTR_NAMES_Q()"));
+        Assert.assertEquals("GET_UG_ATTR_NAMES_Q(null)", "'dept','site'", 
evaluator.evaluateScript("GET_UG_ATTR_NAMES_Q(null)"));
+        Assert.assertEquals("GET_UG_ATTR_NAMES_Q(null, null)", "'dept''site'", 
evaluator.evaluateScript("GET_UG_ATTR_NAMES_Q(null, null)"));
+        Assert.assertEquals("GET_UG_ATTR_NAMES_Q(null, '|')", "'dept'|'site'", 
evaluator.evaluateScript("GET_UG_ATTR_NAMES_Q(null, '|')"));
+        Assert.assertEquals("GET_UG_ATTR_NAMES_Q(null, ',', null)", 
"dept,site", evaluator.evaluateScript("GET_UG_ATTR_NAMES_Q(null, ',', null)"));
         Assert.assertEquals("GET_UG_ATTR_NAMES_Q(null, ',', '{', '}')", 
"{dept},{site}", evaluator.evaluateScript("GET_UG_ATTR_NAMES_Q(null, ',', '{', 
'}')"));
 
-        Assert.assertEquals("GET_UG_ATTR('dept')",             "ENGG,PROD", 
evaluator.evaluateScript("GET_UG_ATTR('dept')"));
-        Assert.assertEquals("GET_UG_ATTR('dept', null)",       "ENGG,PROD", 
evaluator.evaluateScript("GET_UG_ATTR('dept', null)"));
-        Assert.assertEquals("GET_UG_ATTR('dept', null, '|')",  "ENGG|PROD", 
evaluator.evaluateScript("GET_UG_ATTR('dept', null, '|')"));
-        Assert.assertEquals("GET_UG_ATTR('dept', null, null)", "ENGGPROD",  
evaluator.evaluateScript("GET_UG_ATTR('dept', null, null)"));
+        Assert.assertEquals("GET_UG_ATTR('dept')", "ENGG,PROD", 
evaluator.evaluateScript("GET_UG_ATTR('dept')"));
+        Assert.assertEquals("GET_UG_ATTR('dept', null)", "ENGG,PROD", 
evaluator.evaluateScript("GET_UG_ATTR('dept', null)"));
+        Assert.assertEquals("GET_UG_ATTR('dept', null, '|')", "ENGG|PROD", 
evaluator.evaluateScript("GET_UG_ATTR('dept', null, '|')"));
+        Assert.assertEquals("GET_UG_ATTR('dept', null, null)", "ENGGPROD", 
evaluator.evaluateScript("GET_UG_ATTR('dept', null, null)"));
 
-        Assert.assertEquals("GET_UG_ATTR_Q('dept')",                      
"'ENGG','PROD'", evaluator.evaluateScript("GET_UG_ATTR_Q('dept')"));
-        Assert.assertEquals("GET_UG_ATTR_Q('dept', null)",                
"'ENGG','PROD'", evaluator.evaluateScript("GET_UG_ATTR_Q('dept', null)"));
-        Assert.assertEquals("GET_UG_ATTR_Q('dept', null, null)",          
"'ENGG''PROD'",  evaluator.evaluateScript("GET_UG_ATTR_Q('dept', null, null)"));
-        Assert.assertEquals("GET_UG_ATTR_Q('dept', null, '|')",           
"'ENGG'|'PROD'", evaluator.evaluateScript("GET_UG_ATTR_Q('dept', null, '|')"));
-        Assert.assertEquals("GET_UG_ATTR_Q('dept', null, ',', null)",     
"ENGG,PROD",     evaluator.evaluateScript("GET_UG_ATTR_Q('dept', null, ',', 
null)"));
+        Assert.assertEquals("GET_UG_ATTR_Q('dept')", "'ENGG','PROD'", 
evaluator.evaluateScript("GET_UG_ATTR_Q('dept')"));
+        Assert.assertEquals("GET_UG_ATTR_Q('dept', null)", "'ENGG','PROD'", 
evaluator.evaluateScript("GET_UG_ATTR_Q('dept', null)"));
+        Assert.assertEquals("GET_UG_ATTR_Q('dept', null, null)", 
"'ENGG''PROD'", evaluator.evaluateScript("GET_UG_ATTR_Q('dept', null, null)"));
+        Assert.assertEquals("GET_UG_ATTR_Q('dept', null, '|')", 
"'ENGG'|'PROD'", evaluator.evaluateScript("GET_UG_ATTR_Q('dept', null, '|')"));
+        Assert.assertEquals("GET_UG_ATTR_Q('dept', null, ',', null)", 
"ENGG,PROD", evaluator.evaluateScript("GET_UG_ATTR_Q('dept', null, ',', 
null)"));
         Assert.assertEquals("GET_UG_ATTR_Q('dept', null, ',', '{', '}')", 
"{ENGG},{PROD}", evaluator.evaluateScript("GET_UG_ATTR_Q('dept', null, ',', 
'{', '}')"));
 
-        Assert.assertEquals("GET_UG_ATTR('site')",             "10,20", 
evaluator.evaluateScript("GET_UG_ATTR('site')"));
-        Assert.assertEquals("GET_UG_ATTR('site', null)",       "10,20", 
evaluator.evaluateScript("GET_UG_ATTR('site', null)"));
-        Assert.assertEquals("GET_UG_ATTR('site', null, '|')",  "10|20", 
evaluator.evaluateScript("GET_UG_ATTR('site', null, '|')"));
-        Assert.assertEquals("GET_UG_ATTR('site', null, null)", "1020",  
evaluator.evaluateScript("GET_UG_ATTR('site', null, null)"));
+        Assert.assertEquals("GET_UG_ATTR('site')", "10,20", 
evaluator.evaluateScript("GET_UG_ATTR('site')"));
+        Assert.assertEquals("GET_UG_ATTR('site', null)", "10,20", 
evaluator.evaluateScript("GET_UG_ATTR('site', null)"));
+        Assert.assertEquals("GET_UG_ATTR('site', null, '|')", "10|20", 
evaluator.evaluateScript("GET_UG_ATTR('site', null, '|')"));
+        Assert.assertEquals("GET_UG_ATTR('site', null, null)", "1020", 
evaluator.evaluateScript("GET_UG_ATTR('site', null, null)"));
 
-        Assert.assertEquals("GET_UG_ATTR_Q('site')",                      
"'10','20'", evaluator.evaluateScript("GET_UG_ATTR_Q('site')"));
-        Assert.assertEquals("GET_UG_ATTR_Q('site', null)",                
"'10','20'", evaluator.evaluateScript("GET_UG_ATTR_Q('site', null)"));
-        Assert.assertEquals("GET_UG_ATTR_Q('site', null, null)",          
"'10''20'",  evaluator.evaluateScript("GET_UG_ATTR_Q('site', null, null)"));
-        Assert.assertEquals("GET_UG_ATTR_Q('site', null, '|')",           
"'10'|'20'", evaluator.evaluateScript("GET_UG_ATTR_Q('site', null, '|')"));
-        Assert.assertEquals("GET_UG_ATTR_Q('site', null, ',', null)",     
"10,20",     evaluator.evaluateScript("GET_UG_ATTR_Q('site', null, ',', 
null)"));
+        Assert.assertEquals("GET_UG_ATTR_Q('site')", "'10','20'", 
evaluator.evaluateScript("GET_UG_ATTR_Q('site')"));
+        Assert.assertEquals("GET_UG_ATTR_Q('site', null)", "'10','20'", 
evaluator.evaluateScript("GET_UG_ATTR_Q('site', null)"));
+        Assert.assertEquals("GET_UG_ATTR_Q('site', null, null)", "'10''20'", 
evaluator.evaluateScript("GET_UG_ATTR_Q('site', null, null)"));
+        Assert.assertEquals("GET_UG_ATTR_Q('site', null, '|')", "'10'|'20'", 
evaluator.evaluateScript("GET_UG_ATTR_Q('site', null, '|')"));
+        Assert.assertEquals("GET_UG_ATTR_Q('site', null, ',', null)", "10,20", 
evaluator.evaluateScript("GET_UG_ATTR_Q('site', null, ',', null)"));
         Assert.assertEquals("GET_UG_ATTR_Q('site', null, ',', '{', '}')", 
"{10},{20}", evaluator.evaluateScript("GET_UG_ATTR_Q('site', null, ',', '{', 
'}')"));
 
-        Assert.assertEquals("GET_UR_NAMES()",           
"test-role1,test-role2", evaluator.evaluateScript("GET_UR_NAMES()"));
-        Assert.assertEquals("GET_UR_NAMES(null)",       
"test-role1,test-role2", evaluator.evaluateScript("GET_UR_NAMES(null)"));
-        Assert.assertEquals("GET_UR_NAMES(null, '|')",  
"test-role1|test-role2", evaluator.evaluateScript("GET_UR_NAMES(null, '|')"));
-        Assert.assertEquals("GET_UR_NAMES(null, null)", 
"test-role1test-role2",  evaluator.evaluateScript("GET_UR_NAMES(null, null)"));
+        Assert.assertEquals("GET_UR_NAMES()", "test-role1,test-role2", 
evaluator.evaluateScript("GET_UR_NAMES()"));
+        Assert.assertEquals("GET_UR_NAMES(null)", "test-role1,test-role2", 
evaluator.evaluateScript("GET_UR_NAMES(null)"));
+        Assert.assertEquals("GET_UR_NAMES(null, '|')", 
"test-role1|test-role2", evaluator.evaluateScript("GET_UR_NAMES(null, '|')"));
+        Assert.assertEquals("GET_UR_NAMES(null, null)", 
"test-role1test-role2", evaluator.evaluateScript("GET_UR_NAMES(null, null)"));
 
-        Assert.assertEquals("GET_UR_NAMES_Q()",                    
"'test-role1','test-role2'", evaluator.evaluateScript("GET_UR_NAMES_Q()"));
-        Assert.assertEquals("GET_UR_NAMES_Q(null)",                
"'test-role1','test-role2'", evaluator.evaluateScript("GET_UR_NAMES_Q(null)"));
-        Assert.assertEquals("GET_UR_NAMES_Q(null, null)",          
"'test-role1''test-role2'", evaluator.evaluateScript("GET_UR_NAMES_Q(null, 
null)"));
-        Assert.assertEquals("GET_UR_NAMES_Q(null, '|')",           
"'test-role1'|'test-role2'", evaluator.evaluateScript("GET_UR_NAMES_Q(null, 
'|')"));
-        Assert.assertEquals("GET_UR_NAMES_Q(null, ',', null)",     
"test-role1,test-role2",     evaluator.evaluateScript("GET_UR_NAMES_Q(null, 
',', null)"));
+        Assert.assertEquals("GET_UR_NAMES_Q()", "'test-role1','test-role2'", 
evaluator.evaluateScript("GET_UR_NAMES_Q()"));
+        Assert.assertEquals("GET_UR_NAMES_Q(null)", 
"'test-role1','test-role2'", evaluator.evaluateScript("GET_UR_NAMES_Q(null)"));
+        Assert.assertEquals("GET_UR_NAMES_Q(null, null)", 
"'test-role1''test-role2'", evaluator.evaluateScript("GET_UR_NAMES_Q(null, 
null)"));
+        Assert.assertEquals("GET_UR_NAMES_Q(null, '|')", 
"'test-role1'|'test-role2'", evaluator.evaluateScript("GET_UR_NAMES_Q(null, 
'|')"));
+        Assert.assertEquals("GET_UR_NAMES_Q(null, ',', null)", 
"test-role1,test-role2", evaluator.evaluateScript("GET_UR_NAMES_Q(null, ',', 
null)"));
         Assert.assertEquals("GET_UR_NAMES_Q(null, ',', '{', '}')", 
"{test-role1},{test-role2}", evaluator.evaluateScript("GET_UR_NAMES_Q(null, 
',', '{', '}')"));
 
-        Assert.assertEquals("GET_USER_ATTR_NAMES()",           "state", 
evaluator.evaluateScript("GET_USER_ATTR_NAMES()"));
-        Assert.assertEquals("GET_USER_ATTR_NAMES(null)",       "state", 
evaluator.evaluateScript("GET_USER_ATTR_NAMES(null)"));
-        Assert.assertEquals("GET_USER_ATTR_NAMES(null, '|')",  "state", 
evaluator.evaluateScript("GET_USER_ATTR_NAMES(null, '|')"));
-        Assert.assertEquals("GET_USER_ATTR_NAMES(null, null)", "state",  
evaluator.evaluateScript("GET_USER_ATTR_NAMES(null, null)"));
+        Assert.assertEquals("GET_USER_ATTR_NAMES()", "state", 
evaluator.evaluateScript("GET_USER_ATTR_NAMES()"));
+        Assert.assertEquals("GET_USER_ATTR_NAMES(null)", "state", 
evaluator.evaluateScript("GET_USER_ATTR_NAMES(null)"));
+        Assert.assertEquals("GET_USER_ATTR_NAMES(null, '|')", "state", 
evaluator.evaluateScript("GET_USER_ATTR_NAMES(null, '|')"));
+        Assert.assertEquals("GET_USER_ATTR_NAMES(null, null)", "state", 
evaluator.evaluateScript("GET_USER_ATTR_NAMES(null, null)"));
 
-        Assert.assertEquals("GET_USER_ATTR_NAMES_Q()",                    
"'state'", evaluator.evaluateScript("GET_USER_ATTR_NAMES_Q()"));
-        Assert.assertEquals("GET_USER_ATTR_NAMES_Q(null)",                
"'state'", evaluator.evaluateScript("GET_USER_ATTR_NAMES_Q(null)"));
-        Assert.assertEquals("GET_USER_ATTR_NAMES_Q(null, null)",          
"'state'", evaluator.evaluateScript("GET_USER_ATTR_NAMES_Q(null, null)"));
-        Assert.assertEquals("GET_USER_ATTR_NAMES_Q(null, '|')",           
"'state'", evaluator.evaluateScript("GET_USER_ATTR_NAMES_Q(null, '|')"));
-        Assert.assertEquals("GET_USER_ATTR_NAMES_Q(null, ',', null)",     
"state",   evaluator.evaluateScript("GET_USER_ATTR_NAMES_Q(null, ',', null)"));
+        Assert.assertEquals("GET_USER_ATTR_NAMES_Q()", "'state'", 
evaluator.evaluateScript("GET_USER_ATTR_NAMES_Q()"));
+        Assert.assertEquals("GET_USER_ATTR_NAMES_Q(null)", "'state'", 
evaluator.evaluateScript("GET_USER_ATTR_NAMES_Q(null)"));
+        Assert.assertEquals("GET_USER_ATTR_NAMES_Q(null, null)", "'state'", 
evaluator.evaluateScript("GET_USER_ATTR_NAMES_Q(null, null)"));
+        Assert.assertEquals("GET_USER_ATTR_NAMES_Q(null, '|')", "'state'", 
evaluator.evaluateScript("GET_USER_ATTR_NAMES_Q(null, '|')"));
+        Assert.assertEquals("GET_USER_ATTR_NAMES_Q(null, ',', null)", "state", 
evaluator.evaluateScript("GET_USER_ATTR_NAMES_Q(null, ',', null)"));
         Assert.assertEquals("GET_USER_ATTR_NAMES_Q(null, ',', '{', '}')", 
"{state}", evaluator.evaluateScript("GET_USER_ATTR_NAMES_Q(null, ',', '{', 
'}')"));
 
-        Assert.assertEquals("GET_USER_ATTR('state')",             "CA", 
evaluator.evaluateScript("GET_USER_ATTR('state')"));
-        Assert.assertEquals("GET_USER_ATTR('state', null)",       "CA", 
evaluator.evaluateScript("GET_USER_ATTR('state', null)"));
-        Assert.assertEquals("GET_USER_ATTR('state', null, '|')",  "CA", 
evaluator.evaluateScript("GET_USER_ATTR('state', null, '|')"));
-        Assert.assertEquals("GET_USER_ATTR('state', null, null)", "CA",  
evaluator.evaluateScript("GET_USER_ATTR('state', null, null)"));
+        Assert.assertEquals("GET_USER_ATTR('state')", "CA", 
evaluator.evaluateScript("GET_USER_ATTR('state')"));
+        Assert.assertEquals("GET_USER_ATTR('state', null)", "CA", 
evaluator.evaluateScript("GET_USER_ATTR('state', null)"));
+        Assert.assertEquals("GET_USER_ATTR('state', null, '|')", "CA", 
evaluator.evaluateScript("GET_USER_ATTR('state', null, '|')"));
+        Assert.assertEquals("GET_USER_ATTR('state', null, null)", "CA", 
evaluator.evaluateScript("GET_USER_ATTR('state', null, null)"));
 
-        Assert.assertEquals("GET_USER_ATTR_Q('state')",                      
"'CA'", evaluator.evaluateScript("GET_USER_ATTR_Q('state')"));
-        Assert.assertEquals("GET_USER_ATTR_Q('state', null)",                
"'CA'", evaluator.evaluateScript("GET_USER_ATTR_Q('state', null)"));
-        Assert.assertEquals("GET_USER_ATTR_Q('state', null, null)",          
"'CA'", evaluator.evaluateScript("GET_USER_ATTR_Q('state', null, null)"));
-        Assert.assertEquals("GET_USER_ATTR_Q('state', null, '|')",           
"'CA'", evaluator.evaluateScript("GET_USER_ATTR_Q('state', null, '|')"));
-        Assert.assertEquals("GET_USER_ATTR_Q('state', null, ',', null)",     
"CA",   evaluator.evaluateScript("GET_USER_ATTR_Q('state', null, ',', null)"));
+        Assert.assertEquals("GET_USER_ATTR_Q('state')", "'CA'", 
evaluator.evaluateScript("GET_USER_ATTR_Q('state')"));
+        Assert.assertEquals("GET_USER_ATTR_Q('state', null)", "'CA'", 
evaluator.evaluateScript("GET_USER_ATTR_Q('state', null)"));
+        Assert.assertEquals("GET_USER_ATTR_Q('state', null, null)", "'CA'", 
evaluator.evaluateScript("GET_USER_ATTR_Q('state', null, null)"));
+        Assert.assertEquals("GET_USER_ATTR_Q('state', null, '|')", "'CA'", 
evaluator.evaluateScript("GET_USER_ATTR_Q('state', null, '|')"));
+        Assert.assertEquals("GET_USER_ATTR_Q('state', null, ',', null)", "CA", 
evaluator.evaluateScript("GET_USER_ATTR_Q('state', null, ',', null)"));
         Assert.assertEquals("GET_USER_ATTR_Q('state', null, ',', '{', '}')", 
"{CA}", evaluator.evaluateScript("GET_USER_ATTR_Q('state', null, ',', '{', 
'}')"));
     }
 
@@ -263,91 +266,91 @@ public void testNonExistentValues() {
         RangerRequestScriptEvaluator evaluator = new 
RangerRequestScriptEvaluator(request, scriptEngine);
 
         // empty TAG names
-        Assert.assertEquals("GET_TAG_NAMES()",              "",      
evaluator.evaluateScript("GET_TAG_NAMES()"));
-        Assert.assertEquals("GET_TAG_NAMES(null)",          "",      
evaluator.evaluateScript("GET_TAG_NAMES(null)"));
-        Assert.assertEquals("GET_TAG_NAMES('empty')",       "empty", 
evaluator.evaluateScript("GET_TAG_NAMES('empty')"));
-        Assert.assertEquals("GET_TAG_NAMES('empty', '|')",  "empty", 
evaluator.evaluateScript("GET_TAG_NAMES('empty', '|')"));
+        Assert.assertEquals("GET_TAG_NAMES()", "", 
evaluator.evaluateScript("GET_TAG_NAMES()"));
+        Assert.assertEquals("GET_TAG_NAMES(null)", "", 
evaluator.evaluateScript("GET_TAG_NAMES(null)"));
+        Assert.assertEquals("GET_TAG_NAMES('empty')", "empty", 
evaluator.evaluateScript("GET_TAG_NAMES('empty')"));
+        Assert.assertEquals("GET_TAG_NAMES('empty', '|')", "empty", 
evaluator.evaluateScript("GET_TAG_NAMES('empty', '|')"));
         Assert.assertEquals("GET_TAG_NAMES('empty', null)", "empty", 
evaluator.evaluateScript("GET_TAG_NAMES('empty', null)"));
 
         // empty TAG names
-        Assert.assertEquals("GET_TAG_NAMES_Q()",                       "",     
   evaluator.evaluateScript("GET_TAG_NAMES_Q()"));
-        Assert.assertEquals("GET_TAG_NAMES_Q(null)",                   "",     
   evaluator.evaluateScript("GET_TAG_NAMES_Q(null)"));
-        Assert.assertEquals("GET_TAG_NAMES_Q('empty')",                
"'empty'", evaluator.evaluateScript("GET_TAG_NAMES_Q('empty')"));
-        Assert.assertEquals("GET_TAG_NAMES_Q('empty', ',')",           
"'empty'", evaluator.evaluateScript("GET_TAG_NAMES_Q('empty', ',')"));
-        Assert.assertEquals("GET_TAG_NAMES_Q('empty', '|', null)",     
"'empty'", evaluator.evaluateScript("GET_TAG_NAMES_Q('empty', '|')"));
+        Assert.assertEquals("GET_TAG_NAMES_Q()", "", 
evaluator.evaluateScript("GET_TAG_NAMES_Q()"));
+        Assert.assertEquals("GET_TAG_NAMES_Q(null)", "", 
evaluator.evaluateScript("GET_TAG_NAMES_Q(null)"));
+        Assert.assertEquals("GET_TAG_NAMES_Q('empty')", "'empty'", 
evaluator.evaluateScript("GET_TAG_NAMES_Q('empty')"));
+        Assert.assertEquals("GET_TAG_NAMES_Q('empty', ',')", "'empty'", 
evaluator.evaluateScript("GET_TAG_NAMES_Q('empty', ',')"));
+        Assert.assertEquals("GET_TAG_NAMES_Q('empty', '|', null)", "'empty'", 
evaluator.evaluateScript("GET_TAG_NAMES_Q('empty', '|')"));
         Assert.assertEquals("GET_TAG_NAMES_Q('empty', ',', '{', '}')", 
"{empty}", evaluator.evaluateScript("GET_TAG_NAMES_Q('empty', ',', '{', '}')"));
 
         // empty UG names
-        Assert.assertEquals("GET_UG_NAMES()",              "",      
evaluator.evaluateScript("GET_UG_NAMES()"));
-        Assert.assertEquals("GET_UG_NAMES(null)",          "",      
evaluator.evaluateScript("GET_UG_NAMES(null)"));
-        Assert.assertEquals("GET_UG_NAMES('empty')",       "empty", 
evaluator.evaluateScript("GET_UG_NAMES('empty')"));
-        Assert.assertEquals("GET_UG_NAMES('empty', '|')",  "empty", 
evaluator.evaluateScript("GET_UG_NAMES('empty', '|')"));
+        Assert.assertEquals("GET_UG_NAMES()", "", 
evaluator.evaluateScript("GET_UG_NAMES()"));
+        Assert.assertEquals("GET_UG_NAMES(null)", "", 
evaluator.evaluateScript("GET_UG_NAMES(null)"));
+        Assert.assertEquals("GET_UG_NAMES('empty')", "empty", 
evaluator.evaluateScript("GET_UG_NAMES('empty')"));
+        Assert.assertEquals("GET_UG_NAMES('empty', '|')", "empty", 
evaluator.evaluateScript("GET_UG_NAMES('empty', '|')"));
         Assert.assertEquals("GET_UG_NAMES('empty', null)", "empty", 
evaluator.evaluateScript("GET_UG_NAMES('empty', null)"));
 
         // empty UG names
-        Assert.assertEquals("GET_UG_NAMES_Q()",                       "",      
  evaluator.evaluateScript("GET_UG_NAMES_Q()"));
-        Assert.assertEquals("GET_UG_NAMES_Q(null)",                   "",      
  evaluator.evaluateScript("GET_UG_NAMES_Q(null)"));
-        Assert.assertEquals("GET_UG_NAMES_Q('empty')",                
"'empty'", evaluator.evaluateScript("GET_UG_NAMES_Q('empty')"));
-        Assert.assertEquals("GET_UG_NAMES_Q('empty', ',')",           
"'empty'", evaluator.evaluateScript("GET_UG_NAMES_Q('empty', ',')"));
-        Assert.assertEquals("GET_UG_NAMES_Q('empty', '|', null)",     
"'empty'", evaluator.evaluateScript("GET_UG_NAMES_Q('empty', '|')"));
+        Assert.assertEquals("GET_UG_NAMES_Q()", "", 
evaluator.evaluateScript("GET_UG_NAMES_Q()"));
+        Assert.assertEquals("GET_UG_NAMES_Q(null)", "", 
evaluator.evaluateScript("GET_UG_NAMES_Q(null)"));
+        Assert.assertEquals("GET_UG_NAMES_Q('empty')", "'empty'", 
evaluator.evaluateScript("GET_UG_NAMES_Q('empty')"));
+        Assert.assertEquals("GET_UG_NAMES_Q('empty', ',')", "'empty'", 
evaluator.evaluateScript("GET_UG_NAMES_Q('empty', ',')"));
+        Assert.assertEquals("GET_UG_NAMES_Q('empty', '|', null)", "'empty'", 
evaluator.evaluateScript("GET_UG_NAMES_Q('empty', '|')"));
         Assert.assertEquals("GET_UG_NAMES_Q('empty', ',', '{', '}')", 
"{empty}", evaluator.evaluateScript("GET_UG_NAMES_Q('empty', ',', '{', '}')"));
 
         // empty UR names
-        Assert.assertEquals("GET_UR_NAMES()",              "",      
evaluator.evaluateScript("GET_UR_NAMES()"));
-        Assert.assertEquals("GET_UR_NAMES(null)",          "",      
evaluator.evaluateScript("GET_UR_NAMES(null)"));
-        Assert.assertEquals("GET_UR_NAMES('empty')",       "empty", 
evaluator.evaluateScript("GET_UR_NAMES('empty')"));
-        Assert.assertEquals("GET_UR_NAMES('empty', '|')",  "empty", 
evaluator.evaluateScript("GET_UR_NAMES('empty', '|')"));
+        Assert.assertEquals("GET_UR_NAMES()", "", 
evaluator.evaluateScript("GET_UR_NAMES()"));
+        Assert.assertEquals("GET_UR_NAMES(null)", "", 
evaluator.evaluateScript("GET_UR_NAMES(null)"));
+        Assert.assertEquals("GET_UR_NAMES('empty')", "empty", 
evaluator.evaluateScript("GET_UR_NAMES('empty')"));
+        Assert.assertEquals("GET_UR_NAMES('empty', '|')", "empty", 
evaluator.evaluateScript("GET_UR_NAMES('empty', '|')"));
         Assert.assertEquals("GET_UR_NAMES('empty', null)", "empty", 
evaluator.evaluateScript("GET_UR_NAMES('empty', null)"));
 
         // empty UR names
-        Assert.assertEquals("GET_UR_NAMES_Q()",                       "",      
  evaluator.evaluateScript("GET_UR_NAMES_Q()"));
-        Assert.assertEquals("GET_UR_NAMES_Q(null)",                   "",      
  evaluator.evaluateScript("GET_UR_NAMES_Q(null)"));
-        Assert.assertEquals("GET_UR_NAMES_Q('empty')",                
"'empty'", evaluator.evaluateScript("GET_UR_NAMES_Q('empty')"));
-        Assert.assertEquals("GET_UR_NAMES_Q('empty', ',')",           
"'empty'", evaluator.evaluateScript("GET_UR_NAMES_Q('empty', ',')"));
-        Assert.assertEquals("GET_UR_NAMES_Q('empty', '|', null)",     
"'empty'", evaluator.evaluateScript("GET_UR_NAMES_Q('empty', '|')"));
+        Assert.assertEquals("GET_UR_NAMES_Q()", "", 
evaluator.evaluateScript("GET_UR_NAMES_Q()"));
+        Assert.assertEquals("GET_UR_NAMES_Q(null)", "", 
evaluator.evaluateScript("GET_UR_NAMES_Q(null)"));
+        Assert.assertEquals("GET_UR_NAMES_Q('empty')", "'empty'", 
evaluator.evaluateScript("GET_UR_NAMES_Q('empty')"));
+        Assert.assertEquals("GET_UR_NAMES_Q('empty', ',')", "'empty'", 
evaluator.evaluateScript("GET_UR_NAMES_Q('empty', ',')"));
+        Assert.assertEquals("GET_UR_NAMES_Q('empty', '|', null)", "'empty'", 
evaluator.evaluateScript("GET_UR_NAMES_Q('empty', '|')"));
         Assert.assertEquals("GET_UR_NAMES_Q('empty', ',', '{', '}')", 
"{empty}", evaluator.evaluateScript("GET_UR_NAMES_Q('empty', ',', '{', '}')"));
 
         // non-existent attribute
-        Assert.assertEquals("GET_TAG_ATTR('noattr')",                "",      
evaluator.evaluateScript("GET_TAG_ATTR('noattr')"));
-        Assert.assertEquals("GET_TAG_ATTR('noattr', null)",          "",      
evaluator.evaluateScript("GET_TAG_ATTR('noattr', null)"));
-        Assert.assertEquals("GET_TAG_ATTR('noattr', 'empty')",       "empty", 
evaluator.evaluateScript("GET_TAG_ATTR('noattr', 'empty')"));
-        Assert.assertEquals("GET_TAG_ATTR('noattr', 'empty', '|')",  "empty", 
evaluator.evaluateScript("GET_TAG_ATTR('noattr', 'empty', '|')"));
+        Assert.assertEquals("GET_TAG_ATTR('noattr')", "", 
evaluator.evaluateScript("GET_TAG_ATTR('noattr')"));
+        Assert.assertEquals("GET_TAG_ATTR('noattr', null)", "", 
evaluator.evaluateScript("GET_TAG_ATTR('noattr', null)"));
+        Assert.assertEquals("GET_TAG_ATTR('noattr', 'empty')", "empty", 
evaluator.evaluateScript("GET_TAG_ATTR('noattr', 'empty')"));
+        Assert.assertEquals("GET_TAG_ATTR('noattr', 'empty', '|')", "empty", 
evaluator.evaluateScript("GET_TAG_ATTR('noattr', 'empty', '|')"));
         Assert.assertEquals("GET_TAG_ATTR('noattr', 'empty', null)", "empty", 
evaluator.evaluateScript("GET_TAG_ATTR('noattr', 'empty', null)"));
 
         // non-existent attribute
-        Assert.assertEquals("GET_TAG_ATTR_Q('noattr')",                        
 "",        evaluator.evaluateScript("GET_TAG_ATTR_Q('noattr')"));
-        Assert.assertEquals("GET_TAG_ATTR_Q('noattr', null)",                  
 "",        evaluator.evaluateScript("GET_TAG_ATTR_Q('noattr', null)"));
-        Assert.assertEquals("GET_TAG_ATTR_Q('noattr', 'empty')",               
 "'empty'", evaluator.evaluateScript("GET_TAG_ATTR_Q('noattr', 'empty')"));
-        Assert.assertEquals("GET_TAG_ATTR_Q('noattr', 'empty', ',')",          
 "'empty'", evaluator.evaluateScript("GET_TAG_ATTR_Q('noattr', 'empty', ',')"));
-        Assert.assertEquals("GET_TAG_ATTR_Q('noattr', 'empty', '|', null)",    
 "empty",   evaluator.evaluateScript("GET_TAG_ATTR_Q('noattr', 'empty', '|', 
null)"));
+        Assert.assertEquals("GET_TAG_ATTR_Q('noattr')", "", 
evaluator.evaluateScript("GET_TAG_ATTR_Q('noattr')"));
+        Assert.assertEquals("GET_TAG_ATTR_Q('noattr', null)", "", 
evaluator.evaluateScript("GET_TAG_ATTR_Q('noattr', null)"));
+        Assert.assertEquals("GET_TAG_ATTR_Q('noattr', 'empty')", "'empty'", 
evaluator.evaluateScript("GET_TAG_ATTR_Q('noattr', 'empty')"));
+        Assert.assertEquals("GET_TAG_ATTR_Q('noattr', 'empty', ',')", 
"'empty'", evaluator.evaluateScript("GET_TAG_ATTR_Q('noattr', 'empty', ',')"));
+        Assert.assertEquals("GET_TAG_ATTR_Q('noattr', 'empty', '|', null)", 
"empty", evaluator.evaluateScript("GET_TAG_ATTR_Q('noattr', 'empty', '|', 
null)"));
         Assert.assertEquals("GET_TAG_ATTR_Q('noattr', 'empty', ',', '{', 
'}')", "{empty}", evaluator.evaluateScript("GET_TAG_ATTR_Q('noattr', 'empty', 
',', '{', '}')"));
 
         // non-existent attribute
-        Assert.assertEquals("GET_UG_ATTR('noattr')",             "", 
evaluator.evaluateScript("GET_UG_ATTR('noattr')"));
-        Assert.assertEquals("GET_UG_ATTR('noattr', null)",       "", 
evaluator.evaluateScript("GET_UG_ATTR('noattr', null)"));
-        Assert.assertEquals("GET_UG_ATTR('noattr', 'empty', '|')",  "empty", 
evaluator.evaluateScript("GET_UG_ATTR('noattr', 'empty', '|')"));
-        Assert.assertEquals("GET_UG_ATTR('noattr', 'empty', null)", "empty",  
evaluator.evaluateScript("GET_UG_ATTR('noattr', 'empty', null)"));
+        Assert.assertEquals("GET_UG_ATTR('noattr')", "", 
evaluator.evaluateScript("GET_UG_ATTR('noattr')"));
+        Assert.assertEquals("GET_UG_ATTR('noattr', null)", "", 
evaluator.evaluateScript("GET_UG_ATTR('noattr', null)"));
+        Assert.assertEquals("GET_UG_ATTR('noattr', 'empty', '|')", "empty", 
evaluator.evaluateScript("GET_UG_ATTR('noattr', 'empty', '|')"));
+        Assert.assertEquals("GET_UG_ATTR('noattr', 'empty', null)", "empty", 
evaluator.evaluateScript("GET_UG_ATTR('noattr', 'empty', null)"));
 
         // non-existent attribute
-        Assert.assertEquals("GET_UG_ATTR_Q('noattr')",                         
"",        evaluator.evaluateScript("GET_UG_ATTR_Q('noattr')"));
-        Assert.assertEquals("GET_UG_ATTR_Q('noattr', null)",                   
"",        evaluator.evaluateScript("GET_UG_ATTR_Q('noattr', null)"));
-        Assert.assertEquals("GET_UG_ATTR_Q('noattr', 'empty', null)",          
"'empty'", evaluator.evaluateScript("GET_UG_ATTR_Q('noattr', 'empty', null)"));
-        Assert.assertEquals("GET_UG_ATTR_Q('noattr', 'empty', '|')",           
"'empty'", evaluator.evaluateScript("GET_UG_ATTR_Q('noattr', 'empty', '|')"));
-        Assert.assertEquals("GET_UG_ATTR_Q('noattr', 'empty', ',', null)",     
"empty",   evaluator.evaluateScript("GET_UG_ATTR_Q('noattr', 'empty', ',', 
null)"));
+        Assert.assertEquals("GET_UG_ATTR_Q('noattr')", "", 
evaluator.evaluateScript("GET_UG_ATTR_Q('noattr')"));
+        Assert.assertEquals("GET_UG_ATTR_Q('noattr', null)", "", 
evaluator.evaluateScript("GET_UG_ATTR_Q('noattr', null)"));
+        Assert.assertEquals("GET_UG_ATTR_Q('noattr', 'empty', null)", 
"'empty'", evaluator.evaluateScript("GET_UG_ATTR_Q('noattr', 'empty', null)"));
+        Assert.assertEquals("GET_UG_ATTR_Q('noattr', 'empty', '|')", 
"'empty'", evaluator.evaluateScript("GET_UG_ATTR_Q('noattr', 'empty', '|')"));
+        Assert.assertEquals("GET_UG_ATTR_Q('noattr', 'empty', ',', null)", 
"empty", evaluator.evaluateScript("GET_UG_ATTR_Q('noattr', 'empty', ',', 
null)"));
         Assert.assertEquals("GET_UG_ATTR_Q('noattr', 'empty', ',', '{', '}')", 
"{empty}", evaluator.evaluateScript("GET_UG_ATTR_Q('noattr', 'empty', ',', '{', 
'}')"));
 
         // non-existent attribute
-        Assert.assertEquals("GET_USER_ATTR('noattr')",                "",      
evaluator.evaluateScript("GET_USER_ATTR('noattr')"));
-        Assert.assertEquals("GET_USER_ATTR('noattr', null)",          "",      
evaluator.evaluateScript("GET_USER_ATTR('noattr', null)"));
-        Assert.assertEquals("GET_USER_ATTR('noattr', 'empty', '|')",  "empty", 
evaluator.evaluateScript("GET_USER_ATTR('noattr', 'empty', '|')"));
+        Assert.assertEquals("GET_USER_ATTR('noattr')", "", 
evaluator.evaluateScript("GET_USER_ATTR('noattr')"));
+        Assert.assertEquals("GET_USER_ATTR('noattr', null)", "", 
evaluator.evaluateScript("GET_USER_ATTR('noattr', null)"));
+        Assert.assertEquals("GET_USER_ATTR('noattr', 'empty', '|')", "empty", 
evaluator.evaluateScript("GET_USER_ATTR('noattr', 'empty', '|')"));
         Assert.assertEquals("GET_USER_ATTR('noattr', 'empty', null)", "empty", 
evaluator.evaluateScript("GET_USER_ATTR('noattr', 'empty', null)"));
 
         // non-existent attribute
-        Assert.assertEquals("GET_USER_ATTR_Q('noattr')",                       
  "",        evaluator.evaluateScript("GET_USER_ATTR_Q('noattr')"));
-        Assert.assertEquals("GET_USER_ATTR_Q('noattr', null)",                 
  "",        evaluator.evaluateScript("GET_USER_ATTR_Q('noattr', null)"));
-        Assert.assertEquals("GET_USER_ATTR_Q('noattr', 'empty', null)",        
  "'empty'", evaluator.evaluateScript("GET_USER_ATTR_Q('noattr', 'empty', 
null)"));
-        Assert.assertEquals("GET_USER_ATTR_Q('noattr', 'empty', '|')",         
  "'empty'", evaluator.evaluateScript("GET_USER_ATTR_Q('noattr', 'empty', 
'|')"));
-        Assert.assertEquals("GET_USER_ATTR_Q('noattr', 'empty', ',', null)",   
  "empty",   evaluator.evaluateScript("GET_USER_ATTR_Q('noattr', 'empty', ',', 
null)"));
+        Assert.assertEquals("GET_USER_ATTR_Q('noattr')", "", 
evaluator.evaluateScript("GET_USER_ATTR_Q('noattr')"));
+        Assert.assertEquals("GET_USER_ATTR_Q('noattr', null)", "", 
evaluator.evaluateScript("GET_USER_ATTR_Q('noattr', null)"));
+        Assert.assertEquals("GET_USER_ATTR_Q('noattr', 'empty', null)", 
"'empty'", evaluator.evaluateScript("GET_USER_ATTR_Q('noattr', 'empty', 
null)"));
+        Assert.assertEquals("GET_USER_ATTR_Q('noattr', 'empty', '|')", 
"'empty'", evaluator.evaluateScript("GET_USER_ATTR_Q('noattr', 'empty', '|')"));
+        Assert.assertEquals("GET_USER_ATTR_Q('noattr', 'empty', ',', null)", 
"empty", evaluator.evaluateScript("GET_USER_ATTR_Q('noattr', 'empty', ',', 
null)"));
         Assert.assertEquals("GET_USER_ATTR_Q('noattr', 'empty', ',', '{', 
'}')", "{empty}", evaluator.evaluateScript("GET_USER_ATTR_Q('noattr', 'empty', 
',', '{', '}')"));
     }
 
@@ -376,7 +379,6 @@ public void testIntersectsIncludes() {
          */
         Assert.assertTrue("test: 
TAGS.PARTNERS.names.split(',').intersects(USER.partners.split(','))", (Boolean) 
evaluator.evaluateScript("HAS_USER_ATTR('partners') && 
TAGS.PARTNERS.names.split(',').intersects(USER.partners.split(','))"));
 
-
         Assert.assertTrue("test: ['sales', 'mktg', 
'products'].includes('sales')", (Boolean) evaluator.evaluateScript("['sales', 
'mktg', 'products'].includes('sales')"));
         Assert.assertTrue("test: ['sales', 'mktg', 
'products'].includes('mktg')", (Boolean) evaluator.evaluateScript("['sales', 
'mktg', 'products'].includes('mktg')"));
         Assert.assertTrue("test: ['sales', 'mktg', 
'products'].includes('products')", (Boolean) 
evaluator.evaluateScript("['sales', 'mktg', 'products'].includes('products')"));
@@ -426,11 +428,26 @@ public void testIntersectsIncludes() {
 
     @Test
     public void testBlockJavaClassReferences() {
-        RangerAccessRequest          request   = createRequest("test-user", 
Collections.EMPTY_SET, Collections.EMPTY_SET, Collections.EMPTY_LIST);
+        RangerAccessRequest          request   = createRequest("test-user", 
Collections.emptySet(), Collections.emptySet(), Collections.emptyList());
         RangerRequestScriptEvaluator evaluator = new 
RangerRequestScriptEvaluator(request, scriptEngine, false);
 
         Assert.assertNull("test: java.lang.System.out.println(\"test\");", 
evaluator.evaluateScript("java.lang.System.out.println(\"test\");"));
         Assert.assertNull("test: 
java.lang.Runtime.getRuntime().exec(\"bash\");", 
evaluator.evaluateScript("java.lang.Runtime.getRuntime().exec(\"bash\");"));
+
+        String fileName = "/tmp/ctest1-" + System.currentTimeMillis();
+        String script   = "var file = new java.io.File('" + fileName +  "'); 
file.createNewFile()";
+
+        Assert.assertNull("test file access using: " + script, 
evaluator.evaluateScript(script));
+
+        File testFile = new File(fileName);
+        Assert.assertFalse(fileName + ": file should not have been created", 
testFile.exists());
+
+        script = "engine.eval('malicious code')";
+
+        Assert.assertNull("test engine access using: " + script, 
evaluator.evaluateScript(script));
+
+        script = "var str = new java.lang.String('test'); str.length()";
+        Assert.assertNull("test Java String class access using: " + script, 
evaluator.evaluateScript(script));
     }
 
     @Test
@@ -463,6 +480,39 @@ public void testIsTimeMacros() {
         Assert.assertTrue("test: IS_ACCESS_TIME_BETWEEN('2010/01/01 15:00:42', 
'2100/01/01 15:00:42', 'GMT')", (Boolean) 
evaluator.evaluateScript("IS_ACCESS_TIME_BETWEEN('2010/01/01 15:00:42', 
'2100/01/01 15:00:42', 'GMT')"));
     }
 
+    @Test
+    public void testMultipleTagInstancesOfType() {
+        List<RangerTag> tags = Arrays.asList(new RangerTag("PII", 
Collections.singletonMap("type", "email")),
+                new RangerTag("PII", Collections.singletonMap("type", 
"phone")),
+                new RangerTag("PII", Collections.emptyMap()),
+                new RangerTag("PCI", Collections.singletonMap("kind", "pan")),
+                new RangerTag("PCI", Collections.singletonMap("kind", "sad")),
+                new RangerTag("PCI", null));
+        RangerAccessRequest          request   = createRequest("test-user", 
Collections.emptySet(), Collections.emptySet(), tags);
+        RangerRequestScriptEvaluator evaluator = new 
RangerRequestScriptEvaluator(request, scriptEngine);
+
+        Object[][] tests = new Object[][] {
+                {"TAG_NAMES_CSV", "PCI,PII"},
+                {"TAG_ATTR_NAMES_CSV", "kind,type"},
+                {"ctx.getAttributeValueForAllMatchingTags('PII', 'type')", 
Arrays.asList("email", "phone")},
+                {"ctx.getAttributeValueForAllMatchingTags('PCI', 'kind')", 
Arrays.asList("pan", "sad")},
+                {"ctx.getAttributeValueForAllMatchingTags('PII', 'kind')", 
Collections.emptyList()},
+                {"ctx.getAttributeValueForAllMatchingTags('PCI', 'type')", 
Collections.emptyList()},
+                {"ctx.getAttributeValueForAllMatchingTags('notag', 'noattr')", 
Collections.emptyList()},
+                {"ctx.getAttributeValueForAllMatchingTags('notag', null)", 
null},
+                {"ctx.getAttributeValueForAllMatchingTags(null, 'noattr')", 
null},
+                {"ctx.getAttributeValueForAllMatchingTags(null, noull)", null}
+        };
+
+        for (Object[] test : tests) {
+            String script   = (String) test[0];
+            Object expected = test[1];
+            Object actual   = evaluator.evaluateScript(script);
+
+            Assert.assertEquals("test: " + script, expected, actual);
+        }
+    }
+
     RangerAccessRequest createRequest(String userName, Set<String> userGroups, 
Set<String> userRoles, List<RangerTag> resourceTags) {
         RangerAccessResource resource = mock(RangerAccessResource.class);
 
@@ -505,7 +555,7 @@ RangerAccessRequest createRequest(String userName, 
Set<String> userGroups, Set<S
 
             
RangerAccessRequestUtil.setRequestTagsInContext(request.getContext(), 
rangerTagForEvals);
             
RangerAccessRequestUtil.setCurrentTagInContext(request.getContext(), 
currentTag);
-        }  else {
+        } else {
             
RangerAccessRequestUtil.setRequestTagsInContext(request.getContext(), null);
         }
 
@@ -516,18 +566,16 @@ RangerAccessRequest createRequest(String userName, 
Set<String> userGroups, Set<S
         Map<String, Map<String, String>> userAttrMapping  = new HashMap<>();
         Map<String, Map<String, String>> groupAttrMapping = new HashMap<>();
 
-        userAttrMapping.put("test-user", Collections.singletonMap("state", 
"CA"));
-        userAttrMapping.put("test-user2", new HashMap<String, String>() {{ 
put("partners", "partner-1,partner-2,partner-3"); put("dept", "ENGG"); }});
-        userAttrMapping.put("test-user3", new HashMap<String, String>() {{ 
put("partners", "partner-3"); put("dept", "MKTG"); }});
-
-        groupAttrMapping.put("test-group1", new HashMap<String, String>() {{ 
put("dept", "ENGG"); put("site", "10"); }});
-        groupAttrMapping.put("test-group2", new HashMap<String, String>() {{ 
put("dept", "PROD"); put("site", "20"); }});
-        groupAttrMapping.put("test-group3", new HashMap<String, String>() {{ 
put("dept", "SALES"); put("site", "30"); }});
+        userAttrMapping.put("test-user", 
TestStringUtil.mapFromStrings("state", "CA"));
+        userAttrMapping.put("test-user2", 
TestStringUtil.mapFromStrings("partners", "partner-1,partner-2,partner-3", 
"dept", "ENGG"));
+        userAttrMapping.put("test-user3", 
TestStringUtil.mapFromStrings("partners", "partner-3", "dept", "MKTG"));
+        groupAttrMapping.put("test-group1", 
TestStringUtil.mapFromStrings("dept", "ENGG", "site", "10"));
+        groupAttrMapping.put("test-group2", 
TestStringUtil.mapFromStrings("dept", "PROD", "site", "20"));
+        groupAttrMapping.put("test-group3", 
TestStringUtil.mapFromStrings("dept", "SALES", "site", "30"));
 
         when(userStore.getUserAttrMapping()).thenReturn(userAttrMapping);
         when(userStore.getGroupAttrMapping()).thenReturn(groupAttrMapping);
 
         return request;
     }
-
-}
\ No newline at end of file
+}

Reply via email to