From 0c635ec003a6ca2c189850891893f8ec4e147512 Mon Sep 17 00:00:00 2001 From: zhouhao Date: Thu, 6 Aug 2026 18:21:20 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=8D=8F=E8=AE=AE=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E6=8F=90=E5=8D=87=E5=8D=8F=E8=AE=AE=E8=BD=AC=E6=8D=A2=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes: #769 --- .../device/web/ProtocolSupportController.java | 3 +- .../web/ProtocolSupportControllerTest.java | 38 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 jetlinks-manager/device-manager/src/test/java/org/jetlinks/community/device/web/ProtocolSupportControllerTest.java diff --git a/jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/web/ProtocolSupportController.java b/jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/web/ProtocolSupportController.java index 28fb8d2eb..52d7a6146 100644 --- a/jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/web/ProtocolSupportController.java +++ b/jetlinks-manager/device-manager/src/main/java/org/jetlinks/community/device/web/ProtocolSupportController.java @@ -202,7 +202,8 @@ public Mono protocolDetail(@PathVariable String id) { } @PostMapping("/convert") - @QueryAction + // 转换过程会下载并加载协议包,必须使用写权限而不是普通查询权限。 + @SaveAction @Hidden public Mono convertToDetail(@RequestParam(required = false) String transport, @RequestBody Mono entity) { return entity.map(ProtocolSupportEntity::toDeployDefinition) diff --git a/jetlinks-manager/device-manager/src/test/java/org/jetlinks/community/device/web/ProtocolSupportControllerTest.java b/jetlinks-manager/device-manager/src/test/java/org/jetlinks/community/device/web/ProtocolSupportControllerTest.java new file mode 100644 index 000000000..ad7789abf --- /dev/null +++ b/jetlinks-manager/device-manager/src/test/java/org/jetlinks/community/device/web/ProtocolSupportControllerTest.java @@ -0,0 +1,38 @@ +/* + * Copyright 2026 JetLinks https://www.jetlinks.cn + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetlinks.community.device.web; + +import org.hswebframework.web.authorization.annotation.QueryAction; +import org.hswebframework.web.authorization.annotation.SaveAction; +import org.junit.jupiter.api.Test; +import reactor.core.publisher.Mono; + +import java.lang.reflect.Method; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +class ProtocolSupportControllerTest { + + @Test + void convertShouldRequireSavePermission() throws NoSuchMethodException { + Method method = ProtocolSupportController.class + .getDeclaredMethod("convertToDetail", String.class, Mono.class); + + assertTrue(method.isAnnotationPresent(SaveAction.class)); + assertFalse(method.isAnnotationPresent(QueryAction.class)); + } +}