fix(admin): scope namespace plugin enable to the request namespace #8029
LGTM. The enable path is now scoped to the request namespace, which matches the delete path already merged.
Checked:
BatchCommonDTO.namespaceId exists, so the controller signature change is safe.updateEnableByIdList now receives the filtered id list instead of the raw request ids, so foreign-namespace relations are never mutated.Objects and ListUtil are already imported in NamespacePluginServiceImpl.One non-blocking note: when the request mixes own and foreign ids the call silently applies to the owned subset. That is consistent with deleteNamespacePlugin, so fine as is.
Approved this earlier, but the checks are still red on a failure that is not yours.
build (shenyu-integrated-test-http) fails in CachePluginTest, and it is not caused by this PR:
[ERROR] CachePluginTest.testMemoryModle:54 expected: <true> but was: <false>
[ERROR] CachePluginTest.testRedisModle:73 expected: <true> but was: <false>
[ERROR] Tests run: 103, Failures: 2, Errors: 0, Skipped: 5
The same two cases are red on every other PR that touches this module right now, so this is the shared e2e case rather than your change. build is only an aggregate gate, so a single shared case turns the whole check red.
Could you keep this rebased and re-run once the http e2e case is fixed upstream? Nothing else blocks my approval.
@Duansg This PR is approved, but 11 checks are red: build (shenyu-integrated-test-websocket), build (shenyu-integrated-test-sdk-http), build (shenyu-integrated-test-combination), build (shenyu-integrated-test-tracing) (+7 more).
I inspected these lanes today and they fail for infrastructure reasons rather than on the diff — the integrated-test jobs die while starting their containers (Elasticsearch /_cat/health returning 000 until the job is cancelled), and the http lane also hits the known CachePluginTest.testMemoryModle / testRedisModle flake. The same jobs are red on master and on unrelated PRs right now.
Please rebase onto master and push (or ask for a re-run) so the checks execute again. If a case is still failing on a fresh run, paste the test name and I'll look properly.
Aias00
Duansg
Modifications
POST /namespacePlugin/enabledreceives aBatchCommonDTOthat carriesnamespaceId, but the controller forwarded only the ids:enabled(ids, enabled)loaded the relations with the unscopedselectByIdsand updated them withupdateEnableByIdList(WHERE id IN (...)), so a request for one namespace could enable or disable another namespace's plugin relations. TheonEnabledevent then synced the change to that namespace's gateways. #7571 fixed the same issue for batch delete.The
namespaceIdis now passed through the service signature, and the loaded relations are filtered to the request namespace before updating and publishing, mirroring #7571:If no relation remains after filtering, the method returns the existing
SYS_PLUGIN_ID_NOT_EXISTerror.Verifying this change
NamespacePluginServiceTest#testEnabledScopedToRequestNamespace: enables one own (namespace-a) and one foreign (namespace-b) relation fornamespace-a, and asserts only the own id reachesupdateEnableByIdListand only the own VO is published toonEnabled.NamespacePluginServiceTest#testEnabledRejectsForeignNamespaceOnly: a foreign-only request returnsSYS_PLUGIN_ID_NOT_EXISTwith no update and no event../mvnw -pl shenyu-admin test -Dtest='NamespacePluginServiceTest,NamespacePluginController*':NamespacePluginServiceTest13/13,NamespacePluginControllerTest1/1, related mapper/event/publisher tests green; checkstyle clean.Notes
selectByIds, oneupdateEnableByIdList). The only addition is an in-memory filter over the already-loaded list. No SQL or mapper changes.namespacePlugin/updateEn) already sendsnamespaceIdin the request body, so normal use is unchanged. A direct API call withoutnamespaceIdnow getsSYS_PLUGIN_ID_NOT_EXISTinstead of a global update, which is the unscoped path this PR closes./enabledByNamespacewas already scoped in SQL and is untouched.@NotEmptywas not added toBatchCommonDTO#namespaceId, becausePluginController,AppAuthControllerandSelectorControllershare that DTO./enabledas taking a "plainBatchCommonDTO, no namespace field"; the DTO does carrynamespaceId, and this PR applies the same scoping to it.Make sure that:
./mvnw clean install -Dmaven.javadoc.skip=true