diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/UserLocalConfigController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/UserLocalConfigController.java index 84ce7bf1a3..78874444ec 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/UserLocalConfigController.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/UserLocalConfigController.java @@ -31,12 +31,6 @@ public class UserLocalConfigController { return userLocalConfigService.add(request, SessionUtils.getUserId()); } - @GetMapping("/validate/{id}") - @Operation(summary = "系统设置-个人中心-我的设置-本地执行-验证是否通过") - public boolean validate(@PathVariable String id) { - return userLocalConfigService.validate(id); - } - @GetMapping("/get") @Operation(summary = "系统设置-个人中心-我的设置-本地执行-获取本地执行") public List get() { diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserLocalConfigService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserLocalConfigService.java index f83dd7c375..89f679a5a7 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserLocalConfigService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/UserLocalConfigService.java @@ -21,8 +21,6 @@ import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.net.HttpURLConnection; -import java.net.URI; import java.util.List; @Service @@ -73,24 +71,6 @@ public class UserLocalConfigService { } - public boolean validate(String id) { - UserLocalConfig userLocalConfig = checkResourceById(id); - HttpURLConnection connection = null; - try { - URI url = new URI(userLocalConfig.getUserUrl()); - connection = (HttpURLConnection) url.toURL().openConnection(); - connection.setConnectTimeout(3000); - return connection.getResponseCode() == HttpURLConnection.HTTP_OK; - } catch (Exception e) { - return false; - } finally { - if (connection != null) { - connection.disconnect(); - } - } - - } - public List get(String userId) { UserLocalConfigExample userLocalConfigExample = new UserLocalConfigExample(); userLocalConfigExample.createCriteria().andCreateUserEqualTo(userId); @@ -99,12 +79,8 @@ public class UserLocalConfigService { public void enable(String id) { UserLocalConfig userLocalConfig = checkResourceById(id); - if (validate(id)) { - userLocalConfig.setEnable(true); - userLocalConfigMapper.updateByPrimaryKeySelective(userLocalConfig); - } else { - throw new MSException(Translator.get("current_user_local_config_not_validate")); - } + userLocalConfig.setEnable(true); + userLocalConfigMapper.updateByPrimaryKeySelective(userLocalConfig); } public void disable(String id) { diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserLocalConfigControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserLocalConfigControllerTests.java index 9999202bc9..14677d6692 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserLocalConfigControllerTests.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/UserLocalConfigControllerTests.java @@ -79,21 +79,6 @@ public class UserLocalConfigControllerTests extends BaseTest { } - @Test - @Order(2) - public void testValidate() throws Exception { - UserLocalConfigExample userLocalConfigExample = new UserLocalConfigExample(); - userLocalConfigExample.createCriteria().andCreateUserEqualTo("admin").andTypeEqualTo("API"); - UserLocalConfig userLocalConfig = userLocalConfigMapper.selectByExample(userLocalConfigExample).get(0); - requestGet(String.format(VALIDATE, userLocalConfig.getId())); - userLocalConfigExample.clear(); - userLocalConfigExample.createCriteria().andCreateUserEqualTo("admin").andTypeEqualTo("UI"); - userLocalConfig = userLocalConfigMapper.selectByExample(userLocalConfigExample).get(0); - requestGet(String.format(VALIDATE, userLocalConfig.getId())); - //不存在的 - requestGet(String.format(VALIDATE, UUID.randomUUID().toString()), status().is5xxServerError()); - } - @Test @Order(3) public void testUpdate() throws Exception { @@ -134,10 +119,6 @@ public class UserLocalConfigControllerTests extends BaseTest { checkLog(userLocalConfig.getId(), OperationLogType.UPDATE); //不存在的 requestGet(String.format(ENABLE, UUID.randomUUID().toString()), status().is5xxServerError()); - userLocalConfigExample.clear(); - userLocalConfigExample.createCriteria().andCreateUserEqualTo("admin").andTypeEqualTo("UI"); - userLocalConfig = userLocalConfigMapper.selectByExample(userLocalConfigExample).get(0); - requestGet(String.format(ENABLE, userLocalConfig.getId())).andExpect(status().is5xxServerError()); } @Test