From 5e9a59b327528f9ff1ed1bfe0c412186de814901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=87=AA=E8=BE=BE?= <980324341@qq.com> Date: Thu, 17 Sep 2026 00:13:27 +0800 Subject: [PATCH] =?UTF-8?q?test(=E9=89=B4=E6=9D=83):=20=E5=85=9C=E5=BA=95?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E5=99=A8=E7=94=A8=E4=BE=8B=E6=94=B9=E7=94=A8?= =?UTF-8?q?=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=9A=84=E6=A0=B7=E4=BE=8B=E8=B1=81?= =?UTF-8?q?=E5=85=8D=E5=89=8D=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit exemptPrefixes 是配置化操作出口(aiimage.security.admin-guard-exempt-prefixes, 默认空、生产未配置任何值),原用例拿已下线的 /api/admin/shop-credential-checks 当样例路径,容易被误读成「该端点已配好豁免」——那条路径是 2026-09-04 引入 豁免机制时随手取的,并非真的配过。换成显然不存在的 /api/admin/example-exempt, 并注明不要改成真实业务端点。 --- .../com/nanri/aiimage/config/AdminApiGuardFilterTest.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend-java/src/test/java/com/nanri/aiimage/config/AdminApiGuardFilterTest.java b/backend-java/src/test/java/com/nanri/aiimage/config/AdminApiGuardFilterTest.java index f3682a8f..8b8b9f23 100644 --- a/backend-java/src/test/java/com/nanri/aiimage/config/AdminApiGuardFilterTest.java +++ b/backend-java/src/test/java/com/nanri/aiimage/config/AdminApiGuardFilterTest.java @@ -142,10 +142,13 @@ class AdminApiGuardFilterTest { @Test void exemptPrefixPassesThrough() throws Exception { + // 豁免前缀是配置项 aiimage.security.admin-guard-exempt-prefixes 留的操作出口,默认空、 + // 生产未配置任何值。故此处取一个显然不存在的样例前缀——不要换成某个真实业务端点, + // 否则会被误读成"该端点已配好豁免"(此前这里是已下线的 shop-credential-checks)。 AdminAuthSupport authSupport = mock(AdminAuthSupport.class); - AdminApiGuardFilter filter = newFilter(authSupport, true, "/api/admin/shop-credential-checks"); + AdminApiGuardFilter filter = newFilter(authSupport, true, "/api/admin/example-exempt"); MockHttpServletRequest request = - new MockHttpServletRequest("GET", "/api/admin/shop-credential-checks/poll"); + new MockHttpServletRequest("GET", "/api/admin/example-exempt/poll"); MockHttpServletResponse response = new MockHttpServletResponse(); MockFilterChain chain = new MockFilterChain();