vaijosh commented on code in PR #3273:
URL: https://github.com/apache/hugegraph/pull/3273#discussion_r4559832474


##########
docker/hgRangerIntegration/README.md:
##########
@@ -0,0 +1,841 @@
+# HugeGraph Ranger Plugin — Integration Test Guide
+
+## Prerequisites
+
+- Docker and Docker Compose installed
+- Maven 3.5+ and Java 17
+- HugeGraph source cloned, on branch `RangerPlugin`
+
+---
+
+## Step 1 — No manual build needed
+
+`docker-compose.yml` builds the `hugegraph` image straight from source via
+`Dockerfile.hugegraph`, which runs:
+
+```bash
+mvn package -pl hugegraph-server/hugegraph-dist -am -DskipTests 
-Dwith-ranger-plugin
+```
+
+`-Dwith-ranger-plugin` bundles the shaded 
`hugegraph-ranger-plugin-<version>-plugin.jar`
+(the one with Ranger's runtime deps, not the ~44 KB thin jar) directly into the
+distribution's `lib/`. There's nothing to build or mount by hand — `docker 
compose up`
+(Step 2 below) does it all.
+
+That one property gates the plugin in two places, both opt-in:
+
+- `hugegraph-server/pom.xml` — declares `hugegraph-ranger-plugin` as a module, 
so
+  without the flag it is not in the reactor and is never compiled. This is 
also what
+  keeps Ranger's dependency tree out of
+  `install-dist/scripts/dependency/known-dependencies.txt` and 
`release-docs/LICENSE`.
+- `hugegraph-server/hugegraph-dist/pom.xml` — adds the shaded jar to the 
distribution.
+
+So a plain `mvn package` omits the plugin entirely and standalone HugeGraph 
builds are
+unaffected. The flip side: any command that selects the module with `-pl` 
**must** pass
+the flag too, or Maven fails with `Could not find the selected project in the 
reactor`.
+
+If you want to build the distribution standalone (outside Docker) — e.g. to 
inspect
+`lib/` or run HugeGraph directly on the host — use the same command from the 
repo root:
+
+```bash
+mvn clean package -pl hugegraph-server/hugegraph-dist -am -DskipTests 
-Dwith-ranger-plugin
+```
+
+This produces `hugegraph-server/apache-hugegraph-server-<version>/` with the 
plugin already
+in `lib/`.
+
+---
+
+## Step 2 — Docker Compose Stack
+
+The `docker-compose.yml` defines the stack with 4 services:
+
+**Services:**
+- `ranger-db` — PostgreSQL 14 (Ranger Admin metadata store)
+- `ranger-solr` — Solr 8.11 (audit backend for Ranger Admin)
+- `ranger` — Apache Ranger 2.9.0 on Java 17 (policy server), built from 
`Dockerfile.ranger`
+- `hugegraph` — HugeGraph built from this checkout (graph database with Ranger 
plugin)
+
+**Key files:**
+- `Dockerfile.hugegraph` — builds HugeGraph with Ranger plugin, audit directory
+- `Dockerfile.ranger` — Ranger Admin on Java 17 with the thin plugin jar baked 
onto its classpath
+- `ranger-hugegraph-security.xml` — plugin-side Ranger config
+- `rest-server.properties` — HugeGraph REST server config
+- `solr-init.sh` — creates the `ranger_audits` Solr core on startup
+
+The Ranger Admin password is `rangerR0cks!`: the `apache/ranger:2.9.0` image 
uses
+`RANGER_DB_PASSWORD` from `docker-compose.yml` for the `admin` login as well 
as the DB user.
+
+> **Test stack only:** `Dockerfile.ranger` sets
+> `ranger.admin.allow.unauthenticated.download.access=true`, so the HugeGraph 
plugin can
+> download policies without Ranger credentials. Ranger 2.9 rejects that by 
default
+> (`Unauthenticated access not allowed` in the HugeGraph log). Production 
deployments must
+> authenticate the plugin to Ranger Admin (Kerberos or JWT) instead.
+
+---
+
+## Step 3 — Start the Stack
+
+```bash
+# Start the full stack (builds the hugegraph and ranger images from source on 
first run)
+docker compose -f docker/hgRangerIntegration/docker-compose.yml up -d
+```
+
+The Solr and Ranger Admin containers take a few minutes to initialise. Check 
status:
+
+```bash
+docker compose -f docker/hgRangerIntegration/docker-compose.yml ps
+# ranger-db    - healthy
+# ranger-solr  - healthy (Solr core created, audit backend ready)
+# ranger       - healthy (Ranger Admin with Solr audit enabled)
+# hugegraph    - healthy (with Ranger plugin)
+```
+
+**What happens during startup:**
+1. PostgreSQL starts and initializes the Ranger Admin database
+2. Solr starts and `solr-init.sh` creates the `ranger_audits` core
+3. Ranger Admin starts and configures Solr as the audit backend
+4. HugeGraph starts and loads the Ranger plugin
+
+If any container fails, check logs with `docker compose logs <service>`.
+
+---
+
+## Step 4 — Register the HugeGraph Service in Ranger Admin
+
+These steps are one-time setup. Run them after Ranger Admin is healthy.
+
+**Ranger Admin credentials: `admin` / `rangerR0cks!`**
+
+### 4a. Register the service definition
+
+```bash
+curl -s -u admin:rangerR0cks! \
+  -X POST http://localhost:6080/service/plugins/definitions \
+  -H "Content-Type: application/json" \
+  -d 
@hugegraph-server/hugegraph-ranger-plugin/src/main/resources/ranger-servicedef-hugegraph.json
+```
+
+Expected: HTTP 200 with a JSON body containing `"name": "hugegraph"`.
+
+If you see `service def with the name[hugegraph] already exists` the 
definition is already registered — continue with 4b.
+
+### 4b. Create a HugeGraph service instance
+
+```bash
+curl -s -u admin:rangerR0cks! \
+  -X POST http://localhost:6080/service/plugins/services \
+  -H "Content-Type: application/json" \
+  -d '{
+    "name": "hugegraph",
+    "displayName": "HugeGraph",
+    "description": "Local HugeGraph test instance",
+    "type": "hugegraph",
+    "isEnabled": true,
+    "configs": {
+      "username": "admin",
+      "password": "admin",
+      "hugegraph.url": "http://hugegraph:8080";
+    }
+  }'
+```
+
+Expected: HTTP 200 with a JSON body containing `"id"`. Confirm:
+```bash
+curl -s -u admin:rangerR0cks! \
+  http://localhost:6080/service/plugins/services/name/hugegraph | python3 -m 
json.tool | grep '"id"'
+```
+
+### 4c. Verify Ranger Admin can load the plugin class
+
+Nothing to deploy. `Dockerfile.ranger` bakes the thin 
`hugegraph-ranger-plugin` jar into
+the Ranger image under
+`ews/webapp/WEB-INF/classes/ranger-plugins/hugegraph/`, which is where Ranger 
Admin
+looks for a service definition's `implClass`. That class, 
`RangerHugeGraphService`,
+backs both the **Test Connection** button and the policy editor's **resource
+autocomplete** (Graph Space -> Graph -> Resource Type -> Label). Both log in 
to HugeGraph
+with the service's `username`/`password`; **Test Connection** lists the graphs 
of the
+`DEFAULT` graphspace and fails if HugeGraph rejects those credentials (HTTP 
401/403).
+
+Confirm it with the exact call the autocomplete makes. 
`lookupResource/hugegraph` takes
+the service *instance* name from step 4b, so run that step first:
+
+```bash
+curl -s -u admin:rangerR0cks! \
+  -X POST 
http://localhost:6080/service/plugins/services/lookupResource/hugegraph \
+  -H "Content-Type: application/json" \
+  -d 
'{"userInput":"","resourceName":"graph","resources":{"graphspace":["DEFAULT"]}}'
+```
+
+Expected: `["hugegraph"]`.
+
+If it returns `"service" is null`, the `hugegraph` service instance does not 
exist yet —
+run step 4b.
+
+If it returns `[]`:
+
+```bash
+# is the jar in the image?
+docker exec ranger ls \
+  /opt/ranger/admin/ews/webapp/WEB-INF/classes/ranger-plugins/hugegraph/
+
+# did the class fail to load?
+docker logs ranger 2>&1 | grep -iE "hugegraph|ClassNotFound"
+
+# is implClass still set on the service definition?
+curl -s -u admin:rangerR0cks! \
+  http://localhost:6080/service/plugins/definitions/name/hugegraph \
+  | grep -o '"implClass":"[^"]*"'
+```
+
+A stack created before the jar was baked in still runs the stock image — 
rebuild it:
+
+```bash
+docker compose -f docker/hgRangerIntegration/docker-compose.yml up -d --build 
ranger
+```
+
+Resource fields are plain text inputs, so an empty autocomplete never blocks 
policy
+creation: you can always type `DEFAULT`, `hugegraph`, `vertex` and so on by 
hand.
+
+---
+
+## Step 5 — Create Test Users in HugeGraph
+
+```bash
+# Create user "bob" with password "bobpass"
+curl -u admin:admin \
+-X POST http://localhost:8080/graphspaces/DEFAULT/auth/users \
+-H "Content-Type: application/json" \
+-d '{"user_name": "bob", "user_password": "bobpass"}'
+
+# Create user "alice" with password "alicepass"
+curl -u admin:admin \
+-X POST http://localhost:8080/graphspaces/DEFAULT/auth/users \
+-H "Content-Type: application/json" \
+-d '{"user_name": "alice", "user_password": "alicepass"}'
+```
+
+---
+
+## Step 6 — Create Ranger Policies
+
+Ranger only accepts policies for users it knows about. Without this, the 
policy below
+is rejected with `User name: bob specified in policy does not exist in ranger 
admin`,
+and every login by `bob` or `alice` then fails with `Authentication failed` 
because
+Ranger grants them nothing. Register both users in Ranger Admin first:
+
+```bash
+for u in bob alice; do
+  curl -s -u admin:rangerR0cks! \
+    -X POST http://localhost:6080/service/xusers/secure/users \
+    -H "Content-Type: application/json" \
+    -d "{\"name\": \"$u\", \"firstName\": \"$u\", \"password\": 
\"${u}Ranger1\",
+         \"userRoleList\": [\"ROLE_USER\"], \"status\": 1}" | grep -o 
'"name":"[^"]*"'
+done
+```
+
+Expected: `"name":"bob"` and `"name":"alice"`. These Ranger-side passwords 
only satisfy
+Ranger's password rules and are never used; HugeGraph still checks `bobpass` 
and
+`alicepass` from Step 5.
+
+> **Important:** Ranger rejects two separate policies with overlapping 
resource patterns
+> (`graphspace/*`, `graph/*`, etc. match the same space). Bob, Alice, and 
HugeGraph's
+> `admin` user must all be in a **single combined policy** with separate 
`policyItems`
+> entries.
+
+> **Why `resource-type: ["*"]`?** The Ranger plugin checks permissions using
+> `ResourceType.ALL` at login time to build the user's role. The policy must 
cover `"*"`
+> (wildcard) so that `"all"` matches. Using `["vertex"]` would not match and 
the user
+> would be denied everything.
+
+> **Why include `admin`?** `HugeGraphAuthProxy` still calls into the Ranger 
authorizer
+> for the `admin` role so that admin's actions land in Ranger's audit log — 
but it
+> discards the verdict, so admin is never actually denied regardless of 
policy. Without
+> a matching policy, admin's actions are audited as `Result: Denied` 
(harmless, but
+> confusing to read). Add `admin` to this policy so Ranger's own verdict is 
`Allowed`
+> and the audit trail reflects that admin genuinely has access, not just that 
it was
+> let through unconditionally.
+
+```bash
+curl -s -u admin:rangerR0cks! \
+  -X POST http://localhost:6080/service/plugins/policies \
+  -H "Content-Type: application/json" \
+  -d '{
+    "name": "hugegraph-access",
+    "service": "hugegraph",
+    "isEnabled": true,
+    "isAuditEnabled": true,
+    "resources": {
+      "graphspace":     {"values": ["*"], "isExcludes": false, "isRecursive": 
false},
+      "graph":          {"values": ["*"], "isExcludes": false, "isRecursive": 
false},
+      "resource-type":  {"values": ["*"], "isExcludes": false, "isRecursive": 
false},
+      "label":          {"values": ["*"], "isExcludes": false, "isRecursive": 
false}
+    },
+    "policyItems": [
+      {
+        "users":      ["bob"],
+        "groups":     [],
+        "accesses":   [{"type": "read", "isAllowed": true}],
+        "conditions": [],
+        "delegateAdmin": false
+      },
+      {
+        "users":      ["alice"],
+        "groups":     [],
+        "accesses":   [{"type": "admin", "isAllowed": true}],
+        "conditions": [],
+        "delegateAdmin": false
+      },
+      {
+        "users":      ["admin"],
+        "groups":     [],
+        "accesses":   [
+          {"type": "read", "isAllowed": true},
+          {"type": "write", "isAllowed": true},
+          {"type": "delete", "isAllowed": true},
+          {"type": "execute", "isAllowed": true},
+          {"type": "admin", "isAllowed": true}
+        ],
+        "conditions": [],
+        "delegateAdmin": false
+      }
+    ]
+  }'
+```
+
+Expected: HTTP 200 with `"id"` in the response.
+
+Wait ~30 seconds for HugeGraph to pull the new policies from Ranger Admin.
+
+Confirm admin's actions are now audited as allowed, not just let through:
+
+```bash
+curl -s -o /dev/null -w "%{http_code}\n" -u admin:admin \
+  
http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/propertykeys
+# Expected: 200
+
+curl -s -u admin:rangerR0cks! \
+  
"http://localhost:6080/service/assets/accessAudit?requestUser=admin&sortBy=eventTime&descending=true&pageSize=5";
 \
+  | python3 -m json.tool | grep -E '"eventTime"|"accessResult"'
+# Expected: accessResult 1 (Allowed) for the most recent entries
+```
+
+---
+
+## Step 7 — Run the Smoke Tests
+
+All tests use the REST API (`/graphspaces/DEFAULT/graphs/hugegraph/...`) 
rather than the
+Gremlin endpoint, which has serialization issues in this deployment.
+
+### Setup — create schema and real graph data
+
+The read tests below (Test 1, Test 3) only exercise the per-request Ranger 
check
+(`checkResourceAuthorizer`) if there is actual data to iterate — an empty 
result set never
+reaches the authorizer for a real element. Create schema and a couple of 
elements as
+**alice** (admin) before running the read tests, using fixed 
(`CUSTOMIZE_STRING`) vertex
+IDs so later tests can address them directly.
+
+```bash
+# Vertex labels — CUSTOMIZE_STRING lets us assign ids explicitly below
+curl -s -o /dev/null -w "%{http_code}\n" -u alice:alicepass \
+  -X POST 
http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabels \
+  -H "Content-Type: application/json" \
+  -d '{"name":"person","id_strategy":"CUSTOMIZE_STRING"}'
+# Expected: 201
+
+curl -s -o /dev/null -w "%{http_code}\n" -u alice:alicepass \
+  -X POST 
http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabels \
+  -H "Content-Type: application/json" \
+  -d '{"name":"software","id_strategy":"CUSTOMIZE_STRING"}'
+# Expected: 201
+
+# Edge label "likes" from person -> software
+curl -s -o /dev/null -w "%{http_code}\n" -u alice:alicepass \
+  -X POST 
http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/edgelabels \
+  -H "Content-Type: application/json" \
+  -d '{"name":"likes","source_label":"person","target_label":"software"}'
+# Expected: 201
+
+# Vertices with fixed ids "p1" (person) and "s1" (software)
+curl -s -o /dev/null -w "%{http_code}\n" -u alice:alicepass \
+  -X POST 
http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices \
+  -H "Content-Type: application/json" \
+  -d '{"label":"person","id":"p1","properties":{}}'
+# Expected: 201
+
+curl -s -o /dev/null -w "%{http_code}\n" -u alice:alicepass \
+  -X POST 
http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices \
+  -H "Content-Type: application/json" \
+  -d '{"label":"software","id":"s1","properties":{}}'
+# Expected: 201
+
+# Edge "p1 -likes-> s1"
+curl -s -o /dev/null -w "%{http_code}\n" -u alice:alicepass \
+  -X POST 
http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges \
+  -H "Content-Type: application/json" \
+  -d 
'{"label":"likes","outV":"p1","outVLabel":"person","inV":"s1","inVLabel":"software","properties":{}}'
+# Expected: 201
+```
+
+### Test 1 — Bob can read vertices ✅
+
+```bash
+curl -s --compressed -u bob:bobpass \
+  http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices
+```
+
+Expected: a `vertices` array containing `p1` (label `person`) and `s1` (label 
`software`).
+Because these are now real elements, the underlying `FilterIterator` in
+`HugeGraphAuthProxy.verifyElemPermission` calls `checkResourceAuthorizer()` 
per element,
+consulting Ranger with the real `graphspace/graph/resource-type/label` — see 
the audit
+verification at the end of this step.
+
+### Test 2 — Bob cannot create a schema ❌
+
+```bash
+curl -s -o /dev/null -w "%{http_code}\n" -u bob:bobpass \
+  -X POST 
http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabels \
+  -H "Content-Type: application/json" \
+  -d '{"name":"nope","id_strategy":"DEFAULT"}'
+```
+
+Expected: `403`
+
+This does **not** exercise the Ranger per-request check — it demonstrates the 
local
+`RolePerm.match()` gate. Bob's HugeGraph role only grants `READ`, so
+`HugeGraphAuthProxy.verifyResPermission()` (`HugeGraphAuthProxy.java:1197`) 
rejects the
+`WRITE` attempt before `matched` is ever `true`, and the code at
+`HugeGraphAuthProxy.java:1213-1216` (`if (matched && RESOURCE_AUTHORIZER != 
null && ...)`)
+short-circuits — Ranger is never consulted at all for this call. Confirm this 
by checking
+the audit log after this request: there should be **no** new entry for it, 
since
+`RangerHugeGraphPlugin.isAllowed()` was never invoked.
+
+### Test 3 — Bob can also read edges ✅
+
+Bob's policy covers `resource-type: ["*"]` which includes edges, so this 
succeeds either
+way. Because the `likes` edge created in Setup is a real element, this request 
is also
+checked against Ranger with the *real* resource-type/label being accessed 
(`edge`/`likes`
+here), not just the coarse `ResourceType.ALL` grant fetched once at login — 
see Test 3b
+below for a case that actually depends on this distinction, since this test 
would pass
+either way.
+
+```bash
+curl -s -o /dev/null -w "%{http_code}\n" -u bob:bobpass \
+  http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/edges
+```
+
+Expected: `200`, with the `likes` edge from `p1` to `s1` in the `edges` array.
+
+### Test 3b — Fine-grained per-label denial ❌ (regression test for real 
enforcement)
+
+Keep bob's wildcard `label: ["*"]` read grant in place — it is what lets him 
pass the
+coarse `ResourceType.ALL`/`*` role check done once at login
+(`RangerAuthManager.mergeRangerRole`). Ranger policies are 
additive/allow-list: a policy
+that grants read on `label: ["person"]` only adds a grant, it never implies 
"deny read on
+every other label." So **narrowing** bob's grant to `person` only (replacing 
the wildcard)
+does not produce a person/software split — it makes Ranger deny read for 
*every* label,
+including `person`, because bob then has no grant at all that matches the 
coarse
+`ResourceType.ALL` check, and `HugeGraphAuthProxy.verifyResPermission()` 
rejects him at the
+local `RolePerm.match()` gate before the per-element Ranger check is ever 
consulted.
+
+To get an actual split, add a second, higher-priority policy with an explicit
+**`denyPolicyItems`** entry scoped to `label: ["software"]`, while leaving 
bob's wildcard
+allow grant untouched. Ranger evaluates deny policies with priority over allow 
policies for
+a matching resource, so: the coarse per-login check still grants bob `READ` 
(nothing denies
+`resource-type: ALL`/`*`), and the per-element check on the real label then 
denies
+`software` specifically while `person` still matches only the allow.
+
+```bash
+# 1. Get the combined policy id (created in Step 6)
+POLICY_ID=$(curl -s -u admin:rangerR0cks! \
+  
"http://localhost:6080/service/plugins/policies?serviceName=hugegraph&policyName=hugegraph-access";
 \
+  | python3 -m json.tool | grep '"id"' | head -1 | grep -o '[0-9]*')
+echo "Policy id: $POLICY_ID"
+
+# 2. Add a deny policy for bob's read on label "software" only. Bob's wildcard 
read
+#    grant in hugegraph-access (id=$POLICY_ID) is left untouched — this is 
additive.
+curl -s -u admin:rangerR0cks! \
+  -X POST http://localhost:6080/service/plugins/policies \
+  -H "Content-Type: application/json" \
+  -d '{
+    "name": "hugegraph-bob-deny-software",
+    "service": "hugegraph",
+    "isEnabled": true,
+    "isAuditEnabled": true,
+    "policyPriority": 1,
+    "resources": {
+      "graphspace":    {"values": ["*"], "isExcludes": false, "isRecursive": 
false},
+      "graph":         {"values": ["*"], "isExcludes": false, "isRecursive": 
false},
+      "resource-type": {"values": ["*"], "isExcludes": false, "isRecursive": 
false},
+      "label":         {"values": ["software"], "isExcludes": false, 
"isRecursive": false}
+    },
+    "policyItems": [
+      {
+        "users":      ["admin"],
+        "groups":     [],
+        "accesses":   [
+          {"type": "read", "isAllowed": true},
+          {"type": "write", "isAllowed": true},
+          {"type": "delete", "isAllowed": true},
+          {"type": "execute", "isAllowed": true},
+          {"type": "admin", "isAllowed": true}
+        ],
+        "conditions": [],
+        "delegateAdmin": false
+      }
+    ],
+    "denyPolicyItems": [
+      {
+        "users":      ["bob"],
+        "groups":     [],
+        "accesses":   [{"type": "read", "isAllowed": true}],
+        "conditions": [],
+        "delegateAdmin": false
+      }
+    ]
+  }'
+# Expected: 200 with "id" in the response
+
+# 3. Wait for policy refresh (default poll interval: 30s)
+sleep 35
+
+# 4. Bob reading vertex "p1" (label "person") — still allowed. Note the vertex 
id must be
+#    URL-encoded (%22p1%22) — a literal quote in the path 500s with a 
URISyntaxException
+#    rather than exercising the permission check at all.
+curl -s -o /dev/null -w "%{http_code}\n" -u bob:bobpass \
+  
http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/%22p1%22
+# Expected: 200
+
+# 5. Bob reading vertex "s1" (label "software") — now denied
+curl -s -o /dev/null -w "%{http_code}\n" -u bob:bobpass \
+  
http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices/%22s1%22
+# Expected: 403
+```
+
+Confirm the denial reached the real per-request check (not a local-role 
rejection, since
+bob's base role still grants `READ` generally) by checking the audit log for a 
`result: 0`
+entry with `resource` containing `.../vertex/software` and `reqUser: bob`:
+
+```bash
+docker exec hugegraph tail -n 20 
/var/log/ranger/audit/hugegraph_ranger_audit.log
+```
+
+**Cleanup:** delete the `hugegraph-bob-deny-software` policy before continuing 
to Test 4,
+so later steps that expect bob to read any label are not affected by this deny 
rule.
+
+```bash
+DENY_POLICY_ID=$(curl -s -u admin:rangerR0cks! \
+  
"http://localhost:6080/service/plugins/policies?serviceName=hugegraph&policyName=hugegraph-bob-deny-software";
 \
+  | python3 -m json.tool | grep '"id"' | head -1 | grep -o '[0-9]*')
+curl -s -u admin:rangerR0cks! -X DELETE \
+  "http://localhost:6080/service/plugins/policies/$DENY_POLICY_ID"; -o 
/dev/null -w "%{http_code}\n"
+# Expected: 204
+sleep 35
+```
+
+### Test 4 — Alice can do everything ✅
+
+```bash
+# Create a new vertex label as alice — "person2", not "person" (that name was
+# already taken by the Setup step above; reusing it 400s with ExistedException,
+# a schema-validation error unrelated to Ranger)
+curl -s -o /dev/null -w "%{http_code}\n" -u alice:alicepass \
+  -X POST 
http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/schema/vertexlabels \
+  -H "Content-Type: application/json" \
+  -d '{"name":"person2","id_strategy":"DEFAULT"}'
+```
+
+Expected: `201`
+
+```bash
+# Alice can also read vertices
+curl -s --compressed -u alice:alicepass \
+  http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices
+```
+
+Expected: `{"vertices":[]}`
+
+### Test 5 — Unknown user is rejected ❌
+
+Use a protected endpoint — `/versions` is public and always returns 200.
+
+```bash
+curl -s -o /dev/null -w "%{http_code}\n" -u nobody:wrongpass \
+  http://localhost:8080/graphspaces/DEFAULT/graphs/hugegraph/graph/vertices
+```
+
+Expected: `401`
+
+### Verify audit entries reflect the real request (do this after Tests 1-4)
+
+After running the smoke tests above, check the audit log and confirm each 
entry's
+`resource`/`access`/`action` fields (see [Audit logs](#audit-logs) below) 
match the operation
+that was actually performed, not a generic placeholder:
+
+```bash
+docker exec hugegraph tail -n 20 
/var/log/ranger/audit/hugegraph_ranger_audit.log
+```
+
+For example, after Test 1 (bob reading vertices), look for an entry with
+`"reqUser":"bob"`, `"access":"read"`, `"action":"read"`, and `"resource"` 
containing
+`hugegraph/vertex` (not the stale `*/*/all/*` / null-access-type values). Test 
2's denial
+(bob's schema create) does **not** produce a corresponding audit entry at all 
— as noted
+in Test 2, that request never reaches `RangerHugeGraphPlugin.isAllowed()`. For 
a denial
+that *does* reach Ranger, see Test 3b, which confirms a `"result":0` entry for 
the
+per-label deny.
+
+---
+
+## Step 8 — Verify Policy Caching
+
+Test that HugeGraph continues to serve Ranger policies even if Ranger Admin 
goes down (uses local cache).
+
+```bash
+# Stop Ranger Admin
+docker compose -f docker/ranger-integration/docker-compose.yml stop ranger

Review Comment:
   Addressed in recent commit



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to