This is an automated email from the ASF dual-hosted git repository.
Aias00 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new 85cbda4d65 fix(admin): exclusion search drops plugins matching any
searchable field (#7690) (#7691)
85cbda4d65 is described below
commit 85cbda4d65fc5d434c8770a7fd3006c669f204f9
Author: konlue <[email protected]>
AuthorDate: Tue Oct 20 12:38:48 2026 +0800
fix(admin): exclusion search drops plugins matching any searchable field
(#7690) (#7691)
---
.../resources/mappers/namespace-plugin-rel-sqlmap.xml | 2 +-
.../src/main/resources/mappers/plugin-sqlmap.xml | 2 +-
.../admin/mapper/NamespacePluginRelMapperTest.java | 19 +++++++++++++++++++
.../apache/shenyu/admin/mapper/PluginMapperTest.java | 19 +++++++++++++++++++
4 files changed, 40 insertions(+), 2 deletions(-)
diff --git
a/shenyu-admin/src/main/resources/mappers/namespace-plugin-rel-sqlmap.xml
b/shenyu-admin/src/main/resources/mappers/namespace-plugin-rel-sqlmap.xml
index a300ea1af8..7bda794bac 100644
--- a/shenyu-admin/src/main/resources/mappers/namespace-plugin-rel-sqlmap.xml
+++ b/shenyu-admin/src/main/resources/mappers/namespace-plugin-rel-sqlmap.xml
@@ -180,7 +180,7 @@
<bind name="excluded" value="('%' + condition.excluded +
'%')"/>
AND (
p.name NOT LIKE #{excluded, jdbcType=VARCHAR}
- OR p.role NOT LIKE #{excluded, jdbcType=VARCHAR}
+ AND p.role NOT LIKE #{excluded, jdbcType=VARCHAR}
)
</if>
<if test="condition.switchStatus != null">
diff --git a/shenyu-admin/src/main/resources/mappers/plugin-sqlmap.xml
b/shenyu-admin/src/main/resources/mappers/plugin-sqlmap.xml
index 222c1e2082..cb01a5a759 100644
--- a/shenyu-admin/src/main/resources/mappers/plugin-sqlmap.xml
+++ b/shenyu-admin/src/main/resources/mappers/plugin-sqlmap.xml
@@ -256,7 +256,7 @@
<bind name="excluded" value="('%' + condition.excluded +
'%')"/>
AND (
name NOT LIKE #{excluded, jdbcType=VARCHAR}
- OR role NOT LIKE #{excluded, jdbcType=VARCHAR}
+ AND role NOT LIKE #{excluded, jdbcType=VARCHAR}
)
</if>
<if test="condition.switchStatus != null">
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/NamespacePluginRelMapperTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/NamespacePluginRelMapperTest.java
index cdfc8a11e0..08f213b492 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/NamespacePluginRelMapperTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/NamespacePluginRelMapperTest.java
@@ -99,6 +99,25 @@ class NamespacePluginRelMapperTest extends
AbstractSpringIntegrationTest {
Assertions.assertEquals(id, queryResults.get(0).getId());
}
+ @Test
+ @Transactional
+ void excludedSearchDropsRelPluginWhenAnySearchableFieldMatches() {
+
pluginMapper.insert(PluginDO.builder().id("excluded-rel-divide").name("mockRelExcluded").role("Proxy").sort(0).enabled(true)
+ .dateCreated(new Timestamp(0)).dateUpdated(new
Timestamp(0)).build());
+
pluginMapper.insert(PluginDO.builder().id("excluded-rel-other").name("mockRelRetained").role("HttpProcess").sort(1).enabled(true)
+ .dateCreated(new Timestamp(0)).dateUpdated(new
Timestamp(0)).build());
+
namespacePluginRelMapper.insertSelective(NamespacePluginRelDO.builder().id("rel-excluded-0").pluginId("excluded-rel-divide")
+ .namespaceId("excluded-search").enabled(true).sort(0).build());
+
namespacePluginRelMapper.insertSelective(NamespacePluginRelDO.builder().id("rel-excluded-1").pluginId("excluded-rel-other")
+ .namespaceId("excluded-search").enabled(true).sort(1).build());
+ NamespacePluginQueryCondition condition = new
NamespacePluginQueryCondition();
+ condition.setKeyword("!mockRelExcluded");
+ condition.init();
+ List<NamespacePluginVO> searched =
namespacePluginRelMapper.searchByCondition(condition);
+ Assertions.assertTrue(searched.stream().noneMatch(item ->
"mockRelExcluded".equals(item.getName())));
+ Assertions.assertTrue(searched.stream().anyMatch(item ->
"mockRelRetained".equals(item.getName())));
+ }
+
@Test
void testSelectByQueryWithStringNamespaceId() {
String namespaceId = "namespace-text";
diff --git
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/PluginMapperTest.java
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/PluginMapperTest.java
index b884dea5f4..6a53eded8f 100644
---
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/PluginMapperTest.java
+++
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/mapper/PluginMapperTest.java
@@ -40,6 +40,7 @@ import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test cases for PluginMapper.
@@ -245,6 +246,24 @@ public final class PluginMapperTest extends
AbstractSpringIntegrationTest {
assertThat(deleteResult, equalTo(1));
}
+ @Test
+ @org.springframework.transaction.annotation.Transactional
+ public void excludedSearchDropsPluginWhenAnySearchableFieldMatches() {
+ final PluginDO excluded =
PluginDO.builder().id("excluded-search-divide").name("mockExcludedPlugin").role("Proxy")
+ .sort(0).enabled(true).dateCreated(new
java.sql.Timestamp(0)).dateUpdated(new java.sql.Timestamp(0)).build();
+ final PluginDO retained =
PluginDO.builder().id("excluded-search-other").name("mockRetainedPlugin").role("HttpProcess")
+ .sort(1).enabled(true).dateCreated(new
java.sql.Timestamp(0)).dateUpdated(new java.sql.Timestamp(0)).build();
+ assertEquals(1, pluginMapper.insert(excluded));
+ assertEquals(1, pluginMapper.insert(retained));
+ final org.apache.shenyu.admin.model.query.PluginQueryCondition
condition =
+ new org.apache.shenyu.admin.model.query.PluginQueryCondition();
+ condition.setKeyword("!mockExcludedPlugin");
+ condition.init();
+ final List<PluginListVO> searched =
pluginService.searchByCondition(condition);
+ assertTrue(searched.stream().noneMatch(item ->
"mockExcludedPlugin".equals(item.getName())));
+ assertTrue(searched.stream().anyMatch(item ->
"mockRetainedPlugin".equals(item.getName())));
+ }
+
@Test
public void pagedListOmitsJarWhileDetailAndExportPreserveIt() {
final PluginDO plugin = PluginDO.buildPluginDO(buildPluginDTO());