From 34981c30a78e8bbd7791131059a9210f9928b62c Mon Sep 17 00:00:00 2001
From: 刘光辉 <347230014@qq.com>
Date: 星期四, 17 九月 2026 09:24:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master' into master

---
 jnpf-dms/jnpf-dms-biz/src/test/java/jnpf/dmsPermission/DmsFileCenterCursorCodecTest.java |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/jnpf-dms/jnpf-dms-biz/src/test/java/jnpf/dmsPermission/DmsFileCenterCursorCodecTest.java b/jnpf-dms/jnpf-dms-biz/src/test/java/jnpf/dmsPermission/DmsFileCenterCursorCodecTest.java
new file mode 100644
index 0000000..03e6067
--- /dev/null
+++ b/jnpf-dms/jnpf-dms-biz/src/test/java/jnpf/dmsPermission/DmsFileCenterCursorCodecTest.java
@@ -0,0 +1,49 @@
+package jnpf.dmsPermission;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.UUID;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+class DmsFileCenterCursorCodecTest {
+    private final DmsPermissionProperties properties = properties();
+    private final DmsFileCenterCursorCodec codec = new DmsFileCenterCursorCodec(properties);
+    private final UUID parentId = UUID.fromString("018f0000-0000-7000-8000-000000000101");
+    private final UUID documentId = UUID.fromString("018f0000-0000-7000-8000-000000000102");
+    private final UUID id = UUID.fromString("018f0000-0000-7000-8000-000000000103");
+
+    @Test
+    void roundTripsBoundCursor() {
+        String fingerprint = codec.fingerprint("璐ㄩ噺");
+        String value = codec.encode("HISTORICAL_FOLDER", "tenant-1", "user-1", parentId,
+                fingerprint, new DmsFileCenterCursorCodec.Cursor("鏂囦欢A", documentId, 9L, id));
+
+        DmsFileCenterCursorCodec.Cursor decoded = codec.decode(value, "HISTORICAL_FOLDER",
+                "tenant-1", "user-1", parentId, fingerprint);
+
+        assertEquals("鏂囦欢A", decoded.getName());
+        assertEquals(documentId, decoded.getDocumentId());
+        assertEquals(9L, decoded.getVersionNo());
+        assertEquals(id, decoded.getId());
+    }
+
+    @Test
+    void rejectsTamperingAndCrossUserReplay() {
+        String fingerprint = codec.fingerprint(null);
+        String value = codec.encode("FOLDER", "tenant-1", "user-1", parentId, fingerprint,
+                new DmsFileCenterCursorCodec.Cursor("A", null, null, id));
+
+        assertThrows(DmsPermissionException.class,
+                () -> codec.decode(value + "x", "FOLDER", "tenant-1", "user-1", parentId, fingerprint));
+        assertThrows(DmsPermissionException.class,
+                () -> codec.decode(value, "FOLDER", "tenant-1", "user-2", parentId, fingerprint));
+    }
+
+    private DmsPermissionProperties properties() {
+        DmsPermissionProperties value = new DmsPermissionProperties();
+        value.setCursorSigningSecret("0123456789abcdef0123456789abcdef");
+        return value;
+    }
+}

--
Gitblit v1.8.0