refactor(接口测试): 分享报告的url加入白名单
This commit is contained in:
parent
5dbb2ed5fe
commit
fde19736dd
|
@ -79,6 +79,11 @@ public class FilterChainUtils {
|
||||||
filterChainDefinitionMap.put("/templates/user_import_en.xlsx", "anon");
|
filterChainDefinitionMap.put("/templates/user_import_en.xlsx", "anon");
|
||||||
filterChainDefinitionMap.put("/templates/user_import_cn.xlsx", "anon");
|
filterChainDefinitionMap.put("/templates/user_import_cn.xlsx", "anon");
|
||||||
|
|
||||||
|
//分享报告接口
|
||||||
|
filterChainDefinitionMap.put("/api/report/case/share/**", "anon");
|
||||||
|
filterChainDefinitionMap.put("/api/report/scenario/share/**", "anon");
|
||||||
|
filterChainDefinitionMap.put("/api/report/share/get/**", "anon");
|
||||||
|
|
||||||
return filterChainDefinitionMap;
|
return filterChainDefinitionMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class ApiReportController {
|
||||||
return apiReportService.get(id);
|
return apiReportService.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/get/{shareId}/{reportId}")
|
@GetMapping("/share/{shareId}/{reportId}")
|
||||||
@Operation(summary = "接口测试-接口报告-分享报告获取")
|
@Operation(summary = "接口测试-接口报告-分享报告获取")
|
||||||
public ApiReportDTO get(@PathVariable String shareId, @PathVariable String reportId) {
|
public ApiReportDTO get(@PathVariable String shareId, @PathVariable String reportId) {
|
||||||
ShareInfo shareInfo = apiReportShareService.checkResource(shareId);
|
ShareInfo shareInfo = apiReportShareService.checkResource(shareId);
|
||||||
|
@ -99,7 +99,7 @@ public class ApiReportController {
|
||||||
return apiReportService.getDetail(stepId, reportId);
|
return apiReportService.getDetail(stepId, reportId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/get/detail/{shareId}/{reportId}/{stepId}")
|
@GetMapping("/share/detail/{shareId}/{reportId}/{stepId}")
|
||||||
public List<ApiReportDetailDTO> selectReportContent(@PathVariable String shareId,
|
public List<ApiReportDetailDTO> selectReportContent(@PathVariable String shareId,
|
||||||
@PathVariable String reportId,
|
@PathVariable String reportId,
|
||||||
@PathVariable String stepId) {
|
@PathVariable String stepId) {
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class ApiScenarioReportController {
|
||||||
return apiScenarioReportService.get(id);
|
return apiScenarioReportService.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/get/{shareId}/{reportId}")
|
@GetMapping("/share/{shareId}/{reportId}")
|
||||||
@Operation(summary = "接口测试-接口报告-分享报告获取")
|
@Operation(summary = "接口测试-接口报告-分享报告获取")
|
||||||
public ApiScenarioReportDTO get(@PathVariable String shareId, @PathVariable String reportId) {
|
public ApiScenarioReportDTO get(@PathVariable String shareId, @PathVariable String reportId) {
|
||||||
ShareInfo shareInfo = apiReportShareService.checkResource(shareId);
|
ShareInfo shareInfo = apiReportShareService.checkResource(shareId);
|
||||||
|
@ -99,7 +99,7 @@ public class ApiScenarioReportController {
|
||||||
return apiScenarioReportService.getDetail(reportId, stepId);
|
return apiScenarioReportService.getDetail(reportId, stepId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/get/detail/{shareId}/{reportId}/{stepId}")
|
@GetMapping("/share/detail/{shareId}/{reportId}/{stepId}")
|
||||||
public List<ApiScenarioReportDetailDTO> selectReportContent(@PathVariable String shareId,
|
public List<ApiScenarioReportDetailDTO> selectReportContent(@PathVariable String shareId,
|
||||||
@PathVariable String reportId,
|
@PathVariable String reportId,
|
||||||
@PathVariable String stepId) {
|
@PathVariable String stepId) {
|
||||||
|
|
|
@ -427,7 +427,7 @@ public class ApiReportControllerTests extends BaseTest {
|
||||||
Assertions.assertNotNull(shareInfoDTO.getShareUrl());
|
Assertions.assertNotNull(shareInfoDTO.getShareUrl());
|
||||||
Assertions.assertNotNull(shareInfoDTO.getId());
|
Assertions.assertNotNull(shareInfoDTO.getId());
|
||||||
String shareId = shareInfoDTO.getId();
|
String shareId = shareInfoDTO.getId();
|
||||||
MvcResult mvcResult1 = this.requestGetWithOk(GET + shareId + "/" + "test-report-id")
|
MvcResult mvcResult1 = this.requestGetWithOk(BASIC+ "/share/" + shareId + "/" + "test-report-id")
|
||||||
.andReturn();
|
.andReturn();
|
||||||
ApiReportDTO apiReportDTO = ApiDataUtils.parseObject(JSON.toJSONString(parseResponse(mvcResult1).get("data")), ApiReportDTO.class);
|
ApiReportDTO apiReportDTO = ApiDataUtils.parseObject(JSON.toJSONString(parseResponse(mvcResult1).get("data")), ApiReportDTO.class);
|
||||||
Assertions.assertNotNull(apiReportDTO);
|
Assertions.assertNotNull(apiReportDTO);
|
||||||
|
@ -440,7 +440,7 @@ public class ApiReportControllerTests extends BaseTest {
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||||
.andExpect(status().is5xxServerError());
|
.andExpect(status().is5xxServerError());
|
||||||
|
|
||||||
mvcResult = this.requestGetWithOk(DETAIL + shareId + "/" + "test-report-id" + "/" + "test-report-step-id1")
|
mvcResult = this.requestGetWithOk(BASIC+ "/share/detail/" + shareId + "/" + "test-report-id" + "/" + "test-report-step-id1")
|
||||||
.andReturn();
|
.andReturn();
|
||||||
List<ApiReportDetailDTO> data = ApiDataUtils.parseArray(JSON.toJSONString(parseResponse(mvcResult).get("data")), ApiReportDetailDTO.class);
|
List<ApiReportDetailDTO> data = ApiDataUtils.parseArray(JSON.toJSONString(parseResponse(mvcResult).get("data")), ApiReportDetailDTO.class);
|
||||||
Assertions.assertNotNull(data);
|
Assertions.assertNotNull(data);
|
||||||
|
@ -449,7 +449,7 @@ public class ApiReportControllerTests extends BaseTest {
|
||||||
shareInfo1.setUpdateTime(1702950953000L);
|
shareInfo1.setUpdateTime(1702950953000L);
|
||||||
shareInfoMapper.updateByPrimaryKey(shareInfo1);
|
shareInfoMapper.updateByPrimaryKey(shareInfo1);
|
||||||
|
|
||||||
mockMvc.perform(getRequestBuilder(GET + shareId + "/" + "test-report-id"))
|
mockMvc.perform(getRequestBuilder(BASIC+ "/share/" + shareId + "/" + "test-report-id"))
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||||
.andExpect(status().is5xxServerError());
|
.andExpect(status().is5xxServerError());
|
||||||
|
|
||||||
|
@ -478,7 +478,7 @@ public class ApiReportControllerTests extends BaseTest {
|
||||||
projectApplicationMapper.insert(projectApplication);
|
projectApplicationMapper.insert(projectApplication);
|
||||||
}
|
}
|
||||||
|
|
||||||
mvcResult1 = this.requestGetWithOk(GET + shareId + "/" + "test-report-id")
|
mvcResult1 = this.requestGetWithOk(BASIC+ "/share/" + shareId + "/" + "test-report-id")
|
||||||
.andReturn();
|
.andReturn();
|
||||||
apiReportDTO = ApiDataUtils.parseObject(JSON.toJSONString(parseResponse(mvcResult1).get("data")), ApiReportDTO.class);
|
apiReportDTO = ApiDataUtils.parseObject(JSON.toJSONString(parseResponse(mvcResult1).get("data")), ApiReportDTO.class);
|
||||||
Assertions.assertNotNull(apiReportDTO);
|
Assertions.assertNotNull(apiReportDTO);
|
||||||
|
@ -489,7 +489,7 @@ public class ApiReportControllerTests extends BaseTest {
|
||||||
shareInfo1.setUpdateTime(1702950953000L);
|
shareInfo1.setUpdateTime(1702950953000L);
|
||||||
shareInfoMapper.updateByPrimaryKey(shareInfo1);
|
shareInfoMapper.updateByPrimaryKey(shareInfo1);
|
||||||
|
|
||||||
mockMvc.perform(getRequestBuilder(GET + shareId + "/" + "test-report-id"))
|
mockMvc.perform(getRequestBuilder(BASIC+ "/share/" + shareId + "/" + "test-report-id"))
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||||
.andExpect(status().is5xxServerError());
|
.andExpect(status().is5xxServerError());
|
||||||
}
|
}
|
||||||
|
|
|
@ -387,7 +387,7 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
||||||
Assertions.assertNotNull(shareInfoDTO.getShareUrl());
|
Assertions.assertNotNull(shareInfoDTO.getShareUrl());
|
||||||
Assertions.assertNotNull(shareInfoDTO.getId());
|
Assertions.assertNotNull(shareInfoDTO.getId());
|
||||||
String shareId = shareInfoDTO.getId();
|
String shareId = shareInfoDTO.getId();
|
||||||
MvcResult mvcResult1 = this.requestGetWithOk(GET + shareId + "/" + "test-scenario-report-id")
|
MvcResult mvcResult1 = this.requestGetWithOk(BASIC+ "/share/" + shareId + "/" + "test-scenario-report-id")
|
||||||
.andReturn();
|
.andReturn();
|
||||||
ApiScenarioReportDTO apiReportDTO = ApiDataUtils.parseObject(JSON.toJSONString(parseResponse(mvcResult1).get("data")), ApiScenarioReportDTO.class);
|
ApiScenarioReportDTO apiReportDTO = ApiDataUtils.parseObject(JSON.toJSONString(parseResponse(mvcResult1).get("data")), ApiScenarioReportDTO.class);
|
||||||
Assertions.assertNotNull(apiReportDTO);
|
Assertions.assertNotNull(apiReportDTO);
|
||||||
|
@ -400,7 +400,7 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||||
.andExpect(status().is5xxServerError());
|
.andExpect(status().is5xxServerError());
|
||||||
|
|
||||||
mvcResult = this.requestGetWithOk(DETAIL + shareId + "/" + "test-scenario-report-id" + "/" + "test-scenario-report-step-id1")
|
mvcResult = this.requestGetWithOk(BASIC+ "/share/detail/" + shareId + "/" + "test-scenario-report-id" + "/" + "test-scenario-report-step-id1")
|
||||||
.andReturn();
|
.andReturn();
|
||||||
List<ApiScenarioReportDetailDTO> data = ApiDataUtils.parseArray(JSON.toJSONString(parseResponse(mvcResult).get("data")), ApiScenarioReportDetailDTO.class);
|
List<ApiScenarioReportDetailDTO> data = ApiDataUtils.parseArray(JSON.toJSONString(parseResponse(mvcResult).get("data")), ApiScenarioReportDetailDTO.class);
|
||||||
Assertions.assertNotNull(data);
|
Assertions.assertNotNull(data);
|
||||||
|
@ -409,7 +409,7 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
||||||
shareInfo1.setUpdateTime(1702950953000L);
|
shareInfo1.setUpdateTime(1702950953000L);
|
||||||
shareInfoMapper.updateByPrimaryKey(shareInfo1);
|
shareInfoMapper.updateByPrimaryKey(shareInfo1);
|
||||||
|
|
||||||
mockMvc.perform(getRequestBuilder(GET + shareId + "/" + "test-scenario-report-id"))
|
mockMvc.perform(getRequestBuilder(BASIC+ "/share/" + shareId + "/" + "test-scenario-report-id"))
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||||
.andExpect(status().is5xxServerError());
|
.andExpect(status().is5xxServerError());
|
||||||
|
|
||||||
|
@ -436,7 +436,7 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
||||||
projectApplicationMapper.insert(projectApplication);
|
projectApplicationMapper.insert(projectApplication);
|
||||||
}
|
}
|
||||||
|
|
||||||
mvcResult1 = this.requestGetWithOk(GET + shareId + "/" + "test-scenario-report-id")
|
mvcResult1 = this.requestGetWithOk(BASIC+ "/share/" + shareId + "/" + "test-scenario-report-id")
|
||||||
.andReturn();
|
.andReturn();
|
||||||
apiReportDTO = ApiDataUtils.parseObject(JSON.toJSONString(parseResponse(mvcResult1).get("data")), ApiScenarioReportDTO.class);
|
apiReportDTO = ApiDataUtils.parseObject(JSON.toJSONString(parseResponse(mvcResult1).get("data")), ApiScenarioReportDTO.class);
|
||||||
Assertions.assertNotNull(apiReportDTO);
|
Assertions.assertNotNull(apiReportDTO);
|
||||||
|
@ -447,7 +447,7 @@ public class ApiScenarioReportControllerTests extends BaseTest {
|
||||||
shareInfo1.setUpdateTime(1702950953000L);
|
shareInfo1.setUpdateTime(1702950953000L);
|
||||||
shareInfoMapper.updateByPrimaryKey(shareInfo1);
|
shareInfoMapper.updateByPrimaryKey(shareInfo1);
|
||||||
|
|
||||||
mockMvc.perform(getRequestBuilder(GET + shareId + "/" + "test-scenario-report-id"))
|
mockMvc.perform(getRequestBuilder(BASIC+ "/share/" + shareId + "/" + "test-scenario-report-id"))
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
|
||||||
.andExpect(status().is5xxServerError());
|
.andExpect(status().is5xxServerError());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue