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)); + } +}