build: add system test_resource_pool permission
This commit is contained in:
parent
90e0562c0a
commit
413fba51ba
|
@ -31,10 +31,10 @@ public class PermissionConstants {
|
||||||
public static final String SYSTEM_ORGANIZATION_READ_UPDATE = "SYSTEM_ORGANIZATION:READ+UPDATE";
|
public static final String SYSTEM_ORGANIZATION_READ_UPDATE = "SYSTEM_ORGANIZATION:READ+UPDATE";
|
||||||
public static final String SYSTEM_ORGANIZATION_READ_DELETE = "SYSTEM_ORGANIZATION:READ+DELETE";
|
public static final String SYSTEM_ORGANIZATION_READ_DELETE = "SYSTEM_ORGANIZATION:READ+DELETE";
|
||||||
|
|
||||||
public static final String SYSTEM_TEST_POOL_READ = "SYSTEM_TEST_POOL:READ";
|
public static final String SYSTEM_TEST_RESOURCE_POOL_READ = "SYSTEM_TEST_RESOURCE_POOL:READ";
|
||||||
public static final String SYSTEM_TEST_POOL_READ_ADD = "SYSTEM_TEST_POOL:READ+ADD";
|
public static final String SYSTEM_TEST_RESOURCE_POOL_READ_ADD = "SYSTEM_TEST_RESOURCE_POOL:READ+ADD";
|
||||||
public static final String SYSTEM_TEST_POOL_READ_UPDATE = "SYSTEM_TEST_POOL:READ+UPDATE";
|
public static final String SYSTEM_TEST_RESOURCE_POOL_READ_UPDATE = "SYSTEM_TEST_RESOURCE_POOL:READ+UPDATE";
|
||||||
public static final String SYSTEM_TEST_POOL_READ_DELETE = "SYSTEM_TEST_POOL:READ+DELETE";
|
public static final String SYSTEM_TEST_RESOURCE_POOL_READ_DELETE = "SYSTEM_TEST_RESOURCE_POOL:READ+DELETE";
|
||||||
|
|
||||||
public static final String SYSTEM_GROUP_READ = "SYSTEM_GROUP:READ";
|
public static final String SYSTEM_GROUP_READ = "SYSTEM_GROUP:READ";
|
||||||
public static final String SYSTEM_GROUP_READ_ADD = "SYSTEM_GROUP:READ+ADD";
|
public static final String SYSTEM_GROUP_READ_ADD = "SYSTEM_GROUP:READ+ADD";
|
||||||
|
|
|
@ -64,6 +64,7 @@ organization_not_exists=Organization is not exists
|
||||||
test_resource_pool_id_is_null=Test Resource Pool ID cannot be null
|
test_resource_pool_id_is_null=Test Resource Pool ID cannot be null
|
||||||
test_resource_pool_name_is_null=Test Resource Pool name cannot be null
|
test_resource_pool_name_is_null=Test Resource Pool name cannot be null
|
||||||
test_resource_pool_name_already_exists=The test resource pool name already exists
|
test_resource_pool_name_already_exists=The test resource pool name already exists
|
||||||
|
test_resource_pool_type_is_null=Test Resource Pool type cannot be null
|
||||||
load_test=Load Test
|
load_test=Load Test
|
||||||
test_resource_pool_is_use=This resource pool is in use and cannot be deleted
|
test_resource_pool_is_use=This resource pool is in use and cannot be deleted
|
||||||
only_one_k8s=Only one K8S can be added
|
only_one_k8s=Only one K8S can be added
|
||||||
|
|
|
@ -64,6 +64,8 @@ organization_not_exists=工作空间不存在
|
||||||
test_resource_pool_id_is_null=资源池ID不能为空
|
test_resource_pool_id_is_null=资源池ID不能为空
|
||||||
test_resource_pool_name_is_null=资源池名称不能为空
|
test_resource_pool_name_is_null=资源池名称不能为空
|
||||||
test_resource_pool_name_already_exists=资源池名称已存在
|
test_resource_pool_name_already_exists=资源池名称已存在
|
||||||
|
test_resource_pool_type_is_null=资源池类型不能为空
|
||||||
|
|
||||||
load_test=性能测试
|
load_test=性能测试
|
||||||
test_resource_pool_is_use=正在使用此资源池,无法删除
|
test_resource_pool_is_use=正在使用此资源池,无法删除
|
||||||
only_one_k8s=只能添加一个 K8S
|
only_one_k8s=只能添加一个 K8S
|
||||||
|
|
|
@ -64,6 +64,7 @@ organization_not_exists=工作空間不存在
|
||||||
test_resource_pool_id_is_null=資源池ID不能為空
|
test_resource_pool_id_is_null=資源池ID不能為空
|
||||||
test_resource_pool_name_is_null=資源池名稱不能為空
|
test_resource_pool_name_is_null=資源池名稱不能為空
|
||||||
test_resource_pool_name_already_exists=資源池名稱已存在
|
test_resource_pool_name_already_exists=資源池名稱已存在
|
||||||
|
test_resource_pool_type_is_null=資源池類型不能為空
|
||||||
load_test=性能測試
|
load_test=性能測試
|
||||||
test_resource_pool_is_use=正在使用此資源池,無法刪除
|
test_resource_pool_is_use=正在使用此資源池,無法刪除
|
||||||
only_one_k8s=只能添加一個 K8S
|
only_one_k8s=只能添加一個 K8S
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class TestResourcePoolController {
|
||||||
private TestResourcePoolService testResourcePoolService;
|
private TestResourcePoolService testResourcePoolService;
|
||||||
|
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@RequiresPermissions(PermissionConstants.SYSTEM_TEST_POOL_READ_ADD)
|
@RequiresPermissions(PermissionConstants.SYSTEM_TEST_RESOURCE_POOL_READ_ADD)
|
||||||
@RequestLog(type = OperationLogType.ADD, module = OperationLogModule.SYSTEM_TEST_RESOURCE_POOL, details = "#poolDTO.name")
|
@RequestLog(type = OperationLogType.ADD, module = OperationLogModule.SYSTEM_TEST_RESOURCE_POOL, details = "#poolDTO.name")
|
||||||
public TestResourcePoolDTO addTestResourcePool(@RequestBody TestResourcePoolDTO poolDTO) {
|
public TestResourcePoolDTO addTestResourcePool(@RequestBody TestResourcePoolDTO poolDTO) {
|
||||||
return testResourcePoolService.addTestResourcePool(poolDTO);
|
return testResourcePoolService.addTestResourcePool(poolDTO);
|
||||||
|
@ -35,7 +35,7 @@ public class TestResourcePoolController {
|
||||||
|
|
||||||
@GetMapping("/delete/{poolId}")
|
@GetMapping("/delete/{poolId}")
|
||||||
@CacheNode // 把监控节点缓存起来
|
@CacheNode // 把监控节点缓存起来
|
||||||
@RequiresPermissions(PermissionConstants.SYSTEM_TEST_POOL_READ_DELETE)
|
@RequiresPermissions(PermissionConstants.SYSTEM_TEST_RESOURCE_POOL_READ_DELETE)
|
||||||
@RequestLog(isBefore = true, type = OperationLogType.UPDATE, module = OperationLogModule.SYSTEM_TEST_RESOURCE_POOL,
|
@RequestLog(isBefore = true, type = OperationLogType.UPDATE, module = OperationLogModule.SYSTEM_TEST_RESOURCE_POOL,
|
||||||
details = "#msClass.getLogDetails(#testResourcePoolId)", msClass = TestResourcePoolService.class)
|
details = "#msClass.getLogDetails(#testResourcePoolId)", msClass = TestResourcePoolService.class)
|
||||||
public void deleteTestResourcePool(@PathVariable(value = "poolId") String testResourcePoolId) {
|
public void deleteTestResourcePool(@PathVariable(value = "poolId") String testResourcePoolId) {
|
||||||
|
@ -44,7 +44,7 @@ public class TestResourcePoolController {
|
||||||
|
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
@CacheNode // 把监控节点缓存起来
|
@CacheNode // 把监控节点缓存起来
|
||||||
@RequiresPermissions(PermissionConstants.SYSTEM_TEST_POOL_READ_UPDATE)
|
@RequiresPermissions(PermissionConstants.SYSTEM_TEST_RESOURCE_POOL_READ_UPDATE)
|
||||||
@RequestLog(type = OperationLogType.UPDATE, module = OperationLogModule.SYSTEM_TEST_RESOURCE_POOL,
|
@RequestLog(type = OperationLogType.UPDATE, module = OperationLogModule.SYSTEM_TEST_RESOURCE_POOL,
|
||||||
sourceId = "#testResourcePoolDTO.id", details = "#testResourcePoolDTO.name")
|
sourceId = "#testResourcePoolDTO.id", details = "#testResourcePoolDTO.name")
|
||||||
public void updateTestResourcePool(@RequestBody TestResourcePoolDTO testResourcePoolDTO) {
|
public void updateTestResourcePool(@RequestBody TestResourcePoolDTO testResourcePoolDTO) {
|
||||||
|
@ -52,7 +52,7 @@ public class TestResourcePoolController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/page")
|
@PostMapping("/page")
|
||||||
@RequiresPermissions(PermissionConstants.SYSTEM_TEST_POOL_READ)
|
@RequiresPermissions(PermissionConstants.SYSTEM_TEST_RESOURCE_POOL_READ)
|
||||||
public Pager<List<TestResourcePoolDTO>> listResourcePools(@RequestBody QueryResourcePoolRequest request) {
|
public Pager<List<TestResourcePoolDTO>> listResourcePools(@RequestBody QueryResourcePoolRequest request) {
|
||||||
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), true);
|
Page<Object> page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), true);
|
||||||
return PageUtils.setPageInfo(page, testResourcePoolService.listResourcePools(request));
|
return PageUtils.setPageInfo(page, testResourcePoolService.listResourcePools(request));
|
||||||
|
|
|
@ -104,6 +104,9 @@ public class TestResourcePoolService {
|
||||||
if (StringUtils.isBlank(resourcePoolName)) {
|
if (StringUtils.isBlank(resourcePoolName)) {
|
||||||
throw new MSException(Translator.get("test_resource_pool_name_is_null"));
|
throw new MSException(Translator.get("test_resource_pool_name_is_null"));
|
||||||
}
|
}
|
||||||
|
if (StringUtils.isBlank(testResourcePoolDTO.getType())) {
|
||||||
|
throw new MSException(Translator.get("test_resource_pool_type_is_null"));
|
||||||
|
}
|
||||||
TestResourcePoolExample example = new TestResourcePoolExample();
|
TestResourcePoolExample example = new TestResourcePoolExample();
|
||||||
TestResourcePoolExample.Criteria criteria = example.createCriteria();
|
TestResourcePoolExample.Criteria criteria = example.createCriteria();
|
||||||
criteria.andNameEqualTo(resourcePoolName);
|
criteria.andNameEqualTo(resourcePoolName);
|
||||||
|
|
|
@ -21,44 +21,24 @@
|
||||||
"resourceId": "SYSTEM_USER_ROLE"
|
"resourceId": "SYSTEM_USER_ROLE"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "SYSTEM_PROJECT:READ",
|
"id": "SYSTEM_TEST_RESOURCE_POOL:READ",
|
||||||
"name": "permission.SYSTEM_PROJECT.read",
|
"name": "permission.system_test_resource_pool.read",
|
||||||
"resourceId": "SYSTEM_PROJECT"
|
"resourceId": "SYSTEM_USER_ROLE"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "SYSTEM_PROJECT:READ+ADD",
|
"id": "SYSTEM_TEST_RESOURCE_POOL:READ+ADD",
|
||||||
"name": "permission.SYSTEM_PROJECT.add",
|
"name": "permission.system_test_resource_pool.add",
|
||||||
"resourceId": "SYSTEM_PROJECT"
|
"resourceId": "SYSTEM_USER_ROLE"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "SYSTEM_PROJECT:READ+EDIT",
|
"id": "SYSTEM_TEST_RESOURCE_POOL:READ+UPDATE",
|
||||||
"name": "permission.SYSTEM_PROJECT.edit",
|
"name": "permission.system_test_resource_pool.update",
|
||||||
"resourceId": "SYSTEM_PROJECT"
|
"resourceId": "SYSTEM_USER_ROLE"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "SYSTEM_PROJECT:READ+DELETE",
|
"id": "SYSTEM_TEST_RESOURCE_POOL:READ+DELETE",
|
||||||
"name": "permission.SYSTEM_PROJECT.delete",
|
"name": "permission.system_test_resource_pool.delete",
|
||||||
"resourceId": "SYSTEM_PROJECT"
|
"resourceId": "SYSTEM_USER_ROLE"
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "SYSTEM_PROJECT:READ+ENVIRONMENT_CONFIG",
|
|
||||||
"name": "permission.SYSTEM_PROJECT.environment_config",
|
|
||||||
"resourceId": "SYSTEM_PROJECT"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "SYSTEM_PROJECT:READ+ADD_USER",
|
|
||||||
"name": "permission.organization_user.add",
|
|
||||||
"resourceId": "SYSTEM_PROJECT"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "SYSTEM_PROJECT:READ+EDIT_USER",
|
|
||||||
"name": "permission.organization_user.edit",
|
|
||||||
"resourceId": "SYSTEM_PROJECT"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "SYSTEM_PROJECT:READ+DELETE_USER",
|
|
||||||
"name": "permission.organization_user.delete",
|
|
||||||
"resourceId": "SYSTEM_PROJECT"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"resource": [
|
"resource": [
|
||||||
|
@ -67,8 +47,8 @@
|
||||||
"name": "permission.system_role.name"
|
"name": "permission.system_role.name"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "SYSTEM_PROJECT",
|
"id": "SYSTEM_TEST_RESOURCE_POOL",
|
||||||
"name": "permission.system_organization.name"
|
"name": "permission.system_test_resource_pool.name"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package io.metersphere.system.controller;
|
package io.metersphere.system.controller;
|
||||||
|
|
||||||
import base.BaseTest;
|
import base.BaseTest;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import io.metersphere.sdk.constants.SessionConstants;
|
import io.metersphere.sdk.constants.SessionConstants;
|
||||||
import io.metersphere.sdk.util.JSON;
|
import io.metersphere.sdk.util.JSON;
|
||||||
import io.metersphere.system.domain.TestResource;
|
import io.metersphere.system.domain.TestResource;
|
||||||
|
@ -17,10 +15,8 @@ import org.springframework.http.MediaType;
|
||||||
import org.springframework.test.context.jdbc.Sql;
|
import org.springframework.test.context.jdbc.Sql;
|
||||||
import org.springframework.test.context.jdbc.SqlConfig;
|
import org.springframework.test.context.jdbc.SqlConfig;
|
||||||
import org.springframework.test.web.servlet.MockMvc;
|
import org.springframework.test.web.servlet.MockMvc;
|
||||||
import org.springframework.test.web.servlet.MvcResult;
|
import org.springframework.test.web.servlet.ResultMatcher;
|
||||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -37,6 +33,11 @@ class TestResourcePoolControllerTest extends BaseTest {
|
||||||
@Resource
|
@Resource
|
||||||
private MockMvc mockMvc;
|
private MockMvc mockMvc;
|
||||||
|
|
||||||
|
private static final String TEST_RESOURCE_POOL_ADD = "/test/resource/pool/add";
|
||||||
|
private static final String TEST_RESOURCE_POOL_UPDATE = "/test/resource/pool/update";
|
||||||
|
|
||||||
|
private static final ResultMatcher ERROR_REQUEST_MATCHER = status().is5xxServerError();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(1)
|
@Order(1)
|
||||||
void addTestResourcePool() throws Exception {
|
void addTestResourcePool() throws Exception {
|
||||||
|
@ -45,33 +46,30 @@ class TestResourcePoolControllerTest extends BaseTest {
|
||||||
testResourcePoolDTO.setType(ResourcePoolTypeEnum.NODE.name());
|
testResourcePoolDTO.setType(ResourcePoolTypeEnum.NODE.name());
|
||||||
setResources(testResourcePoolDTO);
|
setResources(testResourcePoolDTO);
|
||||||
|
|
||||||
MvcResult mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/test/resource/pool/add")
|
mockMvc.perform(MockMvcRequestBuilders.post(TEST_RESOURCE_POOL_ADD)
|
||||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||||
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
||||||
.content(JSON.toJSONString(testResourcePoolDTO))
|
.content(JSON.toJSONString(testResourcePoolDTO))
|
||||||
.contentType(MediaType.APPLICATION_JSON))
|
.contentType(MediaType.APPLICATION_JSON))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn();
|
||||||
//获取数据
|
|
||||||
JSONObject jsonObject = new JSONObject(Boolean.parseBoolean(mvcResult.getResponse().getContentAsString()));
|
|
||||||
JSONArray jsonArrayData = (JSONArray) jsonObject.get("data");
|
|
||||||
System.out.println(jsonArrayData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Order(2)
|
@Order(2)
|
||||||
void addUiTestResourcePoolFiled() throws Exception {
|
void addUiTestResourcePoolFiled() throws Exception {
|
||||||
TestResourcePoolDTO testResourcePoolDTO = new TestResourcePoolDTO();
|
//资源池名称为空
|
||||||
testResourcePoolDTO.setName("test_pool_filed");
|
TestResourcePoolDTO testResourcePoolDTO = generatorDto(true,false,false,false);
|
||||||
testResourcePoolDTO.setType(ResourcePoolTypeEnum.NODE.name());
|
this.requestPost(TEST_RESOURCE_POOL_ADD, testResourcePoolDTO, ERROR_REQUEST_MATCHER);
|
||||||
testResourcePoolDTO.setUiTest(true);
|
//资源池类型为空
|
||||||
mockMvc.perform(MockMvcRequestBuilders.post("/test/resource/pool/add")
|
testResourcePoolDTO = generatorDto(false,true,false,false);
|
||||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
this.requestPost(TEST_RESOURCE_POOL_ADD, testResourcePoolDTO, ERROR_REQUEST_MATCHER);
|
||||||
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
//资源池节点集合为空
|
||||||
.content(JSON.toJSONString(testResourcePoolDTO))
|
testResourcePoolDTO = generatorDto(false,false,true,false);
|
||||||
.contentType(MediaType.APPLICATION_JSON))
|
this.requestPost(TEST_RESOURCE_POOL_ADD, testResourcePoolDTO, ERROR_REQUEST_MATCHER);
|
||||||
.andExpect(status().is5xxServerError())
|
//UI的grid为空
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON));
|
testResourcePoolDTO = generatorDto(true,true,true,false);
|
||||||
|
this.requestPost(TEST_RESOURCE_POOL_ADD, testResourcePoolDTO, ERROR_REQUEST_MATCHER);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +96,7 @@ class TestResourcePoolControllerTest extends BaseTest {
|
||||||
testResourcePoolDTO.setName("test_pool");
|
testResourcePoolDTO.setName("test_pool");
|
||||||
testResourcePoolDTO.setType(ResourcePoolTypeEnum.NODE.name());
|
testResourcePoolDTO.setType(ResourcePoolTypeEnum.NODE.name());
|
||||||
setResources(testResourcePoolDTO);
|
setResources(testResourcePoolDTO);
|
||||||
mockMvc.perform(MockMvcRequestBuilders.post("/test/resource/pool/update")
|
mockMvc.perform(MockMvcRequestBuilders.post(TEST_RESOURCE_POOL_UPDATE)
|
||||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||||
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
||||||
.content(JSON.toJSONString(testResourcePoolDTO))
|
.content(JSON.toJSONString(testResourcePoolDTO))
|
||||||
|
@ -121,15 +119,17 @@ class TestResourcePoolControllerTest extends BaseTest {
|
||||||
@Test
|
@Test
|
||||||
@Order(5)
|
@Order(5)
|
||||||
void updateTestResourcePoolFiled() throws Exception {
|
void updateTestResourcePoolFiled() throws Exception {
|
||||||
TestResourcePoolDTO testResourcePoolDTO = new TestResourcePoolDTO();
|
TestResourcePoolDTO testResourcePoolDTO = generatorDto(true,false,false,false);
|
||||||
testResourcePoolDTO.setType(ResourcePoolTypeEnum.NODE.name());
|
this.requestPost(TEST_RESOURCE_POOL_UPDATE, testResourcePoolDTO, ERROR_REQUEST_MATCHER);
|
||||||
mockMvc.perform(MockMvcRequestBuilders.post("/test/resource/pool/update")
|
//资源池类型为空
|
||||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
testResourcePoolDTO = generatorDto(false,true,false,false);
|
||||||
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
this.requestPost(TEST_RESOURCE_POOL_UPDATE, testResourcePoolDTO, ERROR_REQUEST_MATCHER);
|
||||||
.content(JSON.toJSONString(testResourcePoolDTO))
|
//资源池节点集合为空
|
||||||
.contentType(MediaType.APPLICATION_JSON))
|
testResourcePoolDTO = generatorDto(false,false,true,false);
|
||||||
.andExpect(status().is5xxServerError())
|
this.requestPost(TEST_RESOURCE_POOL_UPDATE, testResourcePoolDTO, ERROR_REQUEST_MATCHER);
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON));
|
//UI的grid为空
|
||||||
|
testResourcePoolDTO = generatorDto(true,true,true,false);
|
||||||
|
this.requestPost(TEST_RESOURCE_POOL_UPDATE, testResourcePoolDTO, ERROR_REQUEST_MATCHER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -146,5 +146,38 @@ class TestResourcePoolControllerTest extends BaseTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void requestPost(String url, Object param, ResultMatcher resultMatcher) throws Exception {
|
||||||
|
mockMvc.perform(MockMvcRequestBuilders.post(url)
|
||||||
|
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||||
|
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
||||||
|
.content(JSON.toJSONString(param))
|
||||||
|
.contentType(MediaType.APPLICATION_JSON))
|
||||||
|
.andExpect(resultMatcher).andDo(print())
|
||||||
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON));
|
||||||
|
}
|
||||||
|
|
||||||
|
private TestResourcePoolDTO generatorDto(boolean noName, boolean noType, boolean noResources, boolean noUiGrid ){
|
||||||
|
TestResourcePoolDTO testResourcePoolDTO = new TestResourcePoolDTO();
|
||||||
|
//没名字
|
||||||
|
if (!noName) {
|
||||||
|
testResourcePoolDTO.setName("test_pool_test");
|
||||||
|
}
|
||||||
|
//没类型
|
||||||
|
if (!noType) {
|
||||||
|
testResourcePoolDTO.setType(ResourcePoolTypeEnum.NODE.name());
|
||||||
|
}
|
||||||
|
//没资源池
|
||||||
|
if (!noResources) {
|
||||||
|
setResources(testResourcePoolDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
testResourcePoolDTO.setUiTest(true);
|
||||||
|
//没UI的grid
|
||||||
|
if (!noUiGrid) {
|
||||||
|
testResourcePoolDTO.setGrid("localhost:4444");
|
||||||
|
}
|
||||||
|
return testResourcePoolDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue