提交openapi单元测试代码

调整接口管理的字段位置
授权管理删掉无用配置
授权管理编辑改为重置生成ak sk功能
授权页面应该改成跟角色授权类型的效果
This commit is contained in:
xlh12306
2025-05-16 23:12:28 +08:00
parent 9aea5de668
commit fb188a83a1
14 changed files with 211 additions and 47 deletions

View File

@ -0,0 +1,35 @@
package org.jeecg.modules.openapi.test;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.jeecg.JeecgSystemApplication;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT,classes = JeecgSystemApplication.class)
@AutoConfigureMockMvc
public class SampleOpenApiTest {
@Autowired
private MockMvc mockMvc;
@Test
public void test() throws Exception {
String url = "/openapi/call/wYAu6xwg";
MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get(url)
.param("id","a7d7e77e06c84325a40932163adcdaa6")
.header("appkey","ak-8CVxh8aYRkzZ0Z2u")
.header("signature","3ec15caeaf9b6281d0ab825795f61e2d")
.header("timestamp","1747403650402");
String result = mockMvc.perform(requestBuilder).andReturn().getResponse().getContentAsString();
JSONObject jsonObject = JSON.parseObject(result);
Assertions.assertEquals(true, jsonObject.getBoolean("success"));
System.out.println(jsonObject);
}
}