mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-11-30 02:58:31 +08:00
feat: add system version check
This commit is contained in:
parent
3d45c1d03d
commit
7de1e43681
@ -0,0 +1,20 @@
|
||||
package io.metersphere.system.controller;
|
||||
|
||||
import io.metersphere.system.service.SystemVersionService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RequestMapping("/system/version")
|
||||
@RestController
|
||||
public class SystemVersionController {
|
||||
|
||||
@Resource
|
||||
private SystemVersionService systemVersionService;
|
||||
|
||||
@GetMapping("/current")
|
||||
public String getVersion() {
|
||||
return systemVersionService.getVersion();
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package io.metersphere.system.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class SystemVersionService {
|
||||
|
||||
public String getVersion() {
|
||||
return System.getenv("MS_VERSION");
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package io.metersphere.system.controller;
|
||||
|
||||
import base.BaseTest;
|
||||
import io.metersphere.sdk.constants.SessionConstants;
|
||||
import io.metersphere.sdk.dto.QueryResourcePoolRequest;
|
||||
import io.metersphere.sdk.util.JSON;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
public class SystemVersionControllerTest extends BaseTest {
|
||||
|
||||
@Resource
|
||||
private MockMvc mockMvc;
|
||||
@Test
|
||||
@Order(10)
|
||||
void getVersion() throws Exception {
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/system/version/current")
|
||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk()).andDo(print());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user