You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polaris.apache.org by di...@apache.org on 2026/04/24 13:18:32 UTC

(polaris) branch main updated: Added Integration Tests to validate auto-upgrade of Graalvm version by Renovate-bot (#4275) (#4277)

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

dimas-b pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git


The following commit(s) were added to refs/heads/main by this push:
     new 43c0cee2e3 Added Integration Tests to validate auto-upgrade of Graalvm version by Renovate-bot (#4275) (#4277)
43c0cee2e3 is described below

commit 43c0cee2e3ccfadfa5bcb46b53d33d26f942fce5
Author: Selvamohan Neethiraj <sn...@apache.org>
AuthorDate: Fri Apr 24 09:18:26 2026 -0400

    Added Integration Tests to validate auto-upgrade of Graalvm version by Renovate-bot (#4275) (#4277)
    
    * Ranger IT for Policy Conditions that invokes GraalVM script engine (#4275)
    
    * modified method names for the integration test for PolicyCondition (#4275)
    
    * modified policy name associated with the integration tests for PolicyCondition (#4275)
    
    * Updated IT to validate graalvm script execution with attribute-based access control policies (#4275)
    
    * Updated code based on spotlessApply (#4275)
---
 .../ranger/test/RangerIntegrationTestBase.java     | 12 +++++
 .../auth/ranger/test/RangerPolicyConditionIT.java  | 53 ++++++++++++++++++++++
 .../auth/ranger/test/RangerTestProfiles.java       |  2 +
 .../resources/authz_it_tests/dev_polaris.json      | 38 +++++++++++++++-
 .../authz_it_tests/dev_polaris_userstore.json      |  7 +++
 5 files changed, 111 insertions(+), 1 deletion(-)

diff --git a/extensions/auth/ranger/tests/src/intTest/java/org/apache/polaris/extension/auth/ranger/test/RangerIntegrationTestBase.java b/extensions/auth/ranger/tests/src/intTest/java/org/apache/polaris/extension/auth/ranger/test/RangerIntegrationTestBase.java
index 2123e451f7..89403eea08 100644
--- a/extensions/auth/ranger/tests/src/intTest/java/org/apache/polaris/extension/auth/ranger/test/RangerIntegrationTestBase.java
+++ b/extensions/auth/ranger/tests/src/intTest/java/org/apache/polaris/extension/auth/ranger/test/RangerIntegrationTestBase.java
@@ -27,6 +27,7 @@ import io.restassured.http.ContentType;
 import java.io.UncheckedIOException;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import org.junit.jupiter.api.AfterEach;
@@ -40,6 +41,8 @@ public abstract class RangerIntegrationTestBase {
   private static final JsonMapper mapper = JsonMapper.builder().build();
   private final List<String> catalogsToCleanup = new ArrayList<>();
 
+  protected Map<String, String> user2Token = new HashMap<>();
+
   protected String toJson(Object value) {
     try {
       return mapper.writeValueAsString(value);
@@ -71,6 +74,15 @@ public abstract class RangerIntegrationTestBase {
     return accessToken;
   }
 
+  protected String getUserToken(String userName) {
+    String token = user2Token.get(userName);
+    if (token == null) {
+      token = createPrincipalAndGetToken(userName);
+      user2Token.put(userName, token);
+    }
+    return token;
+  }
+
   protected String createPrincipalAndGetToken(String principalName) {
     String rootToken = getRootToken();
 
diff --git a/extensions/auth/ranger/tests/src/intTest/java/org/apache/polaris/extension/auth/ranger/test/RangerPolicyConditionIT.java b/extensions/auth/ranger/tests/src/intTest/java/org/apache/polaris/extension/auth/ranger/test/RangerPolicyConditionIT.java
new file mode 100644
index 0000000000..2cdb05af41
--- /dev/null
+++ b/extensions/auth/ranger/tests/src/intTest/java/org/apache/polaris/extension/auth/ranger/test/RangerPolicyConditionIT.java
@@ -0,0 +1,53 @@
+/*
+ * 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.polaris.extension.auth.ranger.test;
+
+import static io.restassured.RestAssured.given;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.quarkus.test.junit.TestProfile;
+import io.restassured.http.ContentType;
+import org.junit.jupiter.api.Test;
+
+@QuarkusTest
+@TestProfile(RangerTestProfiles.EmbeddedPolicy.class)
+public class RangerPolicyConditionIT extends RangerIntegrationTestBase {
+
+  @Test
+  void getCatalogListsWithoutAuthorization() {
+    String polcondu1Token = getUserToken("polcondu1");
+    given()
+        .contentType(ContentType.JSON)
+        .header("Authorization", "Bearer " + polcondu1Token)
+        .get("/api/management/v1/catalogs")
+        .then()
+        .statusCode(403);
+  }
+
+  @Test
+  void getCatalogListsWithAuthorization() {
+    String polcondu2Token = getUserToken("polcondu2");
+    given()
+        .contentType(ContentType.JSON)
+        .header("Authorization", "Bearer " + polcondu2Token)
+        .get("/api/management/v1/catalogs")
+        .then()
+        .statusCode(200);
+  }
+}
diff --git a/extensions/auth/ranger/tests/src/intTest/java/org/apache/polaris/extension/auth/ranger/test/RangerTestProfiles.java b/extensions/auth/ranger/tests/src/intTest/java/org/apache/polaris/extension/auth/ranger/test/RangerTestProfiles.java
index 1535a0b3a0..d91b6d4f17 100644
--- a/extensions/auth/ranger/tests/src/intTest/java/org/apache/polaris/extension/auth/ranger/test/RangerTestProfiles.java
+++ b/extensions/auth/ranger/tests/src/intTest/java/org/apache/polaris/extension/auth/ranger/test/RangerTestProfiles.java
@@ -37,6 +37,8 @@ public final class RangerTestProfiles {
       config.put(
           "polaris.authorization.ranger.authz.default.policy.source.impl",
           "org.apache.ranger.admin.client.EmbeddedResourcePolicySource");
+      config.put(
+          "polaris.authorization.ranger.authz.default.enable.implicit.userstore.enricher", "true");
       config.put(
           "polaris.authorization.ranger.authz.default.policy.source.embedded_resource.path",
           "/authz_it_tests");
diff --git a/extensions/auth/ranger/tests/src/intTest/resources/authz_it_tests/dev_polaris.json b/extensions/auth/ranger/tests/src/intTest/resources/authz_it_tests/dev_polaris.json
index 9d082a5497..701746f589 100644
--- a/extensions/auth/ranger/tests/src/intTest/resources/authz_it_tests/dev_polaris.json
+++ b/extensions/auth/ranger/tests/src/intTest/resources/authz_it_tests/dev_polaris.json
@@ -439,6 +439,16 @@
       { "itemId": 67, "name": "policy-attach",        "label": "Policy Attach",        "category": "MANAGE" },
       { "itemId": 68, "name": "policy-detach",        "label": "Policy Detach",        "category": "MANAGE" },
       { "itemId": 69, "name": "policy-metadata-full", "label": "Policy Metadata Full", "category": "MANAGE", "impliedGrants": [ "policy-create", "policy-drop", "policy-list", "policy-read", "policy-write" ] }
+    ],
+    "policyConditions": [
+      {
+        "itemId":1,
+        "name":"_expression",
+        "evaluator": "org.apache.ranger.plugin.conditionevaluator.RangerScriptConditionEvaluator",
+        "evaluatorOptions" : {"engineName":"JavaScript"},
+        "label":"Enter boolean expression",
+        "description": "Boolean expression"
+      }
     ]
   },
   "policies": [
@@ -689,6 +699,32 @@
           ],
           "users": [ "root" ] }
       ]
+    },
+    {
+      "id": 12, "name": "Realm:POLARIS",
+      "resources": {
+        "root":      { "values": [ "POLARIS" ] }
+      },
+      "policyItems": [
+        {
+          "accesses": [
+            {
+              "type": "catalog-list"
+            }
+          ],
+          "users": [
+            "polcondu1", "polcondu2"
+          ],
+          "conditions": [
+            {
+              "type": "_expression",
+              "values": [
+                "USER.allowedSensitiveLevel > 5"
+              ]
+            }
+          ]
+        }
+      ]
     }
   ]
-}
+}
\ No newline at end of file
diff --git a/extensions/auth/ranger/tests/src/intTest/resources/authz_it_tests/dev_polaris_userstore.json b/extensions/auth/ranger/tests/src/intTest/resources/authz_it_tests/dev_polaris_userstore.json
new file mode 100644
index 0000000000..11240429fd
--- /dev/null
+++ b/extensions/auth/ranger/tests/src/intTest/resources/authz_it_tests/dev_polaris_userstore.json
@@ -0,0 +1,7 @@
+{
+  "userAttrMapping": {
+    "polcondu1": { "dept": "finance",   "allowedSensitiveLevel": "1" },
+    "polcondu2": { "dept": "audit",     "allowedSensitiveLevel": "10" }
+  },
+  "userStoreVersion": 1
+}
\ No newline at end of file