修复权限:纠正培训管理员住宿编辑权限并加固住宿删除权限隔离

This commit is contained in:
wangzhibiao committed 2026-09-24 01:22:03 +08:00
1 parent 6bdf84974b
commit 3a81cb3f0c
2 files changed
+52 -7

No files matched your search

@@ -1,6 +1,7 @@
package com.ruoyi.web.controller.train;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.nio.charset.StandardCharsets;
@@ -44,6 +45,42 @@ public class DmsAccessSafetyPackageAMigrationContractTest
assertFalse("must not contain remote unlock", sql.contains("remoteunlock") || sql.contains("remote-unlock"));
}
@Test
public void migration015PreservesAccommodationEditForTrainAdmin() throws Exception
{
Path migration015Path = null;
for (Path path = Paths.get("").toAbsolutePath(); path != null; path = path.getParent())
{
Path candidate = path.resolve("sql/system/kingbase/015_dms_package_a_hardening.sql");
if (Files.isRegularFile(candidate)) {
migration015Path = candidate;
break;
}
}
if (migration015Path == null) {
for (Path path = Paths.get("").toAbsolutePath(); path != null; path = path.getParent())
{
Path candidate = path.resolve("RuoYi-Vue/sql/system/kingbase/015_dms_package_a_hardening.sql");
if (Files.isRegularFile(candidate)) {
migration015Path = candidate;
break;
}
}
}
assertNotNull("015_dms_package_a_hardening.sql migration not found", migration015Path);
String sql = new String(Files.readAllBytes(migration015Path), StandardCharsets.UTF_8).toLowerCase();
// 必须确保授予或保留 2263 (train:accommodation:edit)
assertContains(sql, "select 3, 2263");
// 绝不得包含对 2263 的 delete 语句
assertFalse("015 严禁删除 train_admin 的 2263 权限",
java.util.regex.Pattern.compile("delete\\s+from\\s+public\\.sys_role_menu[^;]*?menu_id\\s*=\\s*2263").matcher(sql).find());
// 必须断言 role 3 拥有 2263
assertContains(sql, "where role_id = 3 and menu_id = 2263) <> 1");
// 必须断言 role 3 严禁拥有 train:accommodation:remove
assertContains(sql, "perms = 'train:accommodation:remove') <> 0");
}
private Path findMigration()
{
for (Path path = Paths.get("").toAbsolutePath(); path != null; path = path.getParent())