fix(接口测试): 分享部分接口移除登录拦截

--bug=1047735 --user=宋昌昌 【接口测试】定义-分享接口-复制链接-无痕浏览器打开-打开后未跳转到分享的接口 https://www.tapd.cn/55049933/s/1596321
This commit is contained in:
song-cc-rock 2024-10-23 14:30:32 +08:00 committed by Craftsman
parent 8e9d4d946b
commit 3ad0614441
4 changed files with 35 additions and 2 deletions

View File

@ -104,6 +104,14 @@ public class FilterChainUtils {
filterChainDefinitionMap.put("/test-plan/report/share/get-layout/**", "anon"); filterChainDefinitionMap.put("/test-plan/report/share/get-layout/**", "anon");
// 默认语言 // 默认语言
filterChainDefinitionMap.put("/user/local/config/default-locale", "anon"); filterChainDefinitionMap.put("/user/local/config/default-locale", "anon");
// 定义-分享
filterChainDefinitionMap.put("/api/doc/share/detail/**", "anon");
filterChainDefinitionMap.put("/api/doc/share/get-detail/**", "anon");
filterChainDefinitionMap.put("/api/doc/share/check/**", "anon");
filterChainDefinitionMap.put("/api/doc/share/module/**", "anon");
filterChainDefinitionMap.put("/api/doc/share/export/**", "anon");
filterChainDefinitionMap.put("/api/doc/share/stop/**", "anon");
filterChainDefinitionMap.put("/api/doc/share/download/file/**", "anon");
return filterChainDefinitionMap; return filterChainDefinitionMap;
} }

View File

@ -3,13 +3,17 @@ package io.metersphere.api.controller.definition;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import io.metersphere.api.domain.ApiDocShare; import io.metersphere.api.domain.ApiDocShare;
import io.metersphere.api.dto.definition.ApiDefinitionDTO;
import io.metersphere.api.dto.definition.ApiDocShareDTO; import io.metersphere.api.dto.definition.ApiDocShareDTO;
import io.metersphere.api.dto.definition.ApiDocShareDetail; import io.metersphere.api.dto.definition.ApiDocShareDetail;
import io.metersphere.api.dto.definition.request.*; import io.metersphere.api.dto.definition.request.*;
import io.metersphere.api.service.ApiTestService;
import io.metersphere.api.service.definition.ApiDefinitionExportService; import io.metersphere.api.service.definition.ApiDefinitionExportService;
import io.metersphere.api.service.definition.ApiDefinitionService;
import io.metersphere.api.service.definition.ApiDocShareLogService; import io.metersphere.api.service.definition.ApiDocShareLogService;
import io.metersphere.api.service.definition.ApiDocShareService; import io.metersphere.api.service.definition.ApiDocShareService;
import io.metersphere.sdk.constants.PermissionConstants; import io.metersphere.sdk.constants.PermissionConstants;
import io.metersphere.system.dto.ProtocolDTO;
import io.metersphere.system.dto.sdk.BaseTreeNode; import io.metersphere.system.dto.sdk.BaseTreeNode;
import io.metersphere.system.log.annotation.Log; import io.metersphere.system.log.annotation.Log;
import io.metersphere.system.log.constants.OperationLogType; import io.metersphere.system.log.constants.OperationLogType;
@ -45,6 +49,10 @@ public class ApiDocShareController {
private ApiDocShareService apiDocShareService; private ApiDocShareService apiDocShareService;
@Resource @Resource
private ApiDefinitionExportService apiDefinitionExportService; private ApiDefinitionExportService apiDefinitionExportService;
@Resource
private ApiTestService apiTestService;
@Resource
private ApiDefinitionService apiDefinitionService;
@PostMapping(value = "/page") @PostMapping(value = "/page")
@Operation(summary = "接口测试-定义-分页获取分享列表") @Operation(summary = "接口测试-定义-分页获取分享列表")
@ -100,12 +108,18 @@ public class ApiDocShareController {
@PostMapping("/module/tree") @PostMapping("/module/tree")
@Operation(summary = "接口测试-定义-分享-模块树") @Operation(summary = "接口测试-定义-分享-模块树")
public List<BaseTreeNode> getShareDocTree(@Validated @RequestBody ApiDocShareModuleRequest request) { public List<BaseTreeNode> getShareDocTree(@Validated @RequestBody ApiDocShareModuleRequest request) {
List<ProtocolDTO> protocols = apiTestService.getProtocols(request.getOrgId());
List<String> protocolList = protocols.stream().map(ProtocolDTO::getProtocol).toList();
request.setProtocols(protocolList);
return apiDocShareService.getShareTree(request); return apiDocShareService.getShareTree(request);
} }
@PostMapping("/module/count") @PostMapping("/module/count")
@Operation(summary = "接口测试-定义-分享-模块树数量") @Operation(summary = "接口测试-定义-分享-模块树数量")
public Map<String, Long> getShareDocTreeCount(@Validated @RequestBody ApiDocShareModuleRequest request) { public Map<String, Long> getShareDocTreeCount(@Validated @RequestBody ApiDocShareModuleRequest request) {
List<ProtocolDTO> protocols = apiTestService.getProtocols(request.getOrgId());
List<String> protocolList = protocols.stream().map(ProtocolDTO::getProtocol).toList();
request.setProtocols(protocolList);
return apiDocShareService.getShareTreeCount(request); return apiDocShareService.getShareTreeCount(request);
} }
@ -127,4 +141,10 @@ public class ApiDocShareController {
apiDefinitionExportService.downloadFile(projectId, fileId, SessionUtils.getUserId(), httpServletResponse); apiDefinitionExportService.downloadFile(projectId, fileId, SessionUtils.getUserId(), httpServletResponse);
} }
@GetMapping(value = "/get-detail/{id}")
@Operation(summary = "接口测试-接口管理-获取接口详情")
public ApiDefinitionDTO get(@PathVariable String id) {
return apiDefinitionService.get(id, SessionUtils.getUserId());
}
} }

View File

@ -16,4 +16,7 @@ public class ApiDocShareModuleRequest extends ApiModuleRequest {
@NotBlank(message = "{api_doc_share.id.not_blank}") @NotBlank(message = "{api_doc_share.id.not_blank}")
@Size(min = 1, max = 50, message = "{api_doc_share.id.length_range}") @Size(min = 1, max = 50, message = "{api_doc_share.id.length_range}")
private String shareId; private String shareId;
@Schema(description = "组织ID", requiredMode = Schema.RequiredMode.REQUIRED)
private String orgId;
} }

View File

@ -38,6 +38,7 @@ public class ApiDocShareControllerTests extends BaseTest {
private final static String MODULE_COUNT = BASE_PATH + "module/count"; private final static String MODULE_COUNT = BASE_PATH + "module/count";
private final static String EXPORT = BASE_PATH + "export/Swagger"; private final static String EXPORT = BASE_PATH + "export/Swagger";
private final static String DOWNLOAD = BASE_PATH + "download/file/"; private final static String DOWNLOAD = BASE_PATH + "download/file/";
private final static String GET_DETAIL = BASE_PATH + "/get-detail/";
@Order(1) @Order(1)
@Test @Test
@ -62,7 +63,7 @@ public class ApiDocShareControllerTests extends BaseTest {
ApiDocShareModuleRequest moduleRequest = new ApiDocShareModuleRequest(); ApiDocShareModuleRequest moduleRequest = new ApiDocShareModuleRequest();
moduleRequest.setShareId(docShare.getId()); moduleRequest.setShareId(docShare.getId());
moduleRequest.setProjectId(DEFAULT_PROJECT_ID); moduleRequest.setProjectId(DEFAULT_PROJECT_ID);
moduleRequest.setProtocols(List.of("HTTP", "SPX", "Redis", "MongoDB")); moduleRequest.setOrgId(DEFAULT_ORGANIZATION_ID);
this.requestPostWithOk(MODULE_TREE, moduleRequest); this.requestPostWithOk(MODULE_TREE, moduleRequest);
request.setId(docShare.getId()); request.setId(docShare.getId());
request.setName("share-2"); request.setName("share-2");
@ -86,6 +87,7 @@ public class ApiDocShareControllerTests extends BaseTest {
this.requestGetWithOk(DELETE + docShare.getId()); this.requestGetWithOk(DELETE + docShare.getId());
// 不存在的ID // 不存在的ID
this.requestGet(DELETE + "not-exist-id").andExpect(status().is5xxServerError()); this.requestGet(DELETE + "not-exist-id").andExpect(status().is5xxServerError());
this.requestGet(GET_DETAIL + "not-exist-id").andExpect(status().is5xxServerError());
} }
@Order(2) @Order(2)
@ -115,7 +117,7 @@ public class ApiDocShareControllerTests extends BaseTest {
ApiDocShareModuleRequest moduleRequest = new ApiDocShareModuleRequest(); ApiDocShareModuleRequest moduleRequest = new ApiDocShareModuleRequest();
moduleRequest.setShareId(docShare.getId()); moduleRequest.setShareId(docShare.getId());
moduleRequest.setProjectId(DEFAULT_PROJECT_ID); moduleRequest.setProjectId(DEFAULT_PROJECT_ID);
moduleRequest.setProtocols(List.of("HTTP", "SPX", "Redis", "MongoDB")); moduleRequest.setOrgId(DEFAULT_ORGANIZATION_ID);
this.requestPostWithOk(MODULE_COUNT, moduleRequest); this.requestPostWithOk(MODULE_COUNT, moduleRequest);
request.setName("share-5"); request.setName("share-5");
request.setRangeMatchSymbol("CONTAINS"); request.setRangeMatchSymbol("CONTAINS");