mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-02 12:09:13 +08:00
refactor(项目管理): 增加权限设置
This commit is contained in:
parent
1cc839a087
commit
50fed7ada7
@ -13,6 +13,12 @@
|
||||
},
|
||||
{
|
||||
"id": "PROJECT:READ+UPDATE"
|
||||
},
|
||||
{
|
||||
"id": "PROJECT:READ+DELETE"
|
||||
},
|
||||
{
|
||||
"id": "PROJECT:READ+RECOVER"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -28,7 +28,6 @@ public class CleanupEnvironmentTests {
|
||||
@Order(1)
|
||||
public void testCleanupResource() throws Exception {
|
||||
serviceInvoker.invokeServices("test");
|
||||
cleanupEnvironmentResourceService.deleteResources("test");
|
||||
cleanupEnvironmentResourceService.cleanReportResources("test");
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.metersphere.project.controller;
|
||||
|
||||
|
||||
|
||||
import io.metersphere.project.dto.environment.EnvironmentConfig;
|
||||
import io.metersphere.project.dto.environment.EnvironmentRequest;
|
||||
import io.metersphere.project.dto.environment.KeyValue;
|
||||
@ -38,11 +37,10 @@ import io.metersphere.sdk.util.JSON;
|
||||
import io.metersphere.system.base.BaseTest;
|
||||
import io.metersphere.system.controller.handler.ResultHolder;
|
||||
import io.metersphere.system.log.constants.OperationLogType;
|
||||
import io.metersphere.system.request.PluginUpdateRequest;
|
||||
import io.metersphere.system.service.JdbcDriverPluginService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@ -97,8 +95,12 @@ public class EnvironmentControllerTests extends BaseTest {
|
||||
private EnvironmentMapper environmentMapper;
|
||||
@Resource
|
||||
private EnvironmentBlobMapper environmentBlobMapper;
|
||||
@Resource
|
||||
private JdbcDriverPluginService jdbcDriverPluginService;
|
||||
@Value("${spring.datasource.url}")
|
||||
private String dburl;
|
||||
@Value("${spring.datasource.username}")
|
||||
private String username;
|
||||
@Value("${spring.datasource.password}")
|
||||
private String password;
|
||||
|
||||
public static <T> T parseObjectFromMvcResult(MvcResult mvcResult, Class<T> parseClass) {
|
||||
try {
|
||||
@ -795,37 +797,15 @@ public class EnvironmentControllerTests extends BaseTest {
|
||||
public void testDataValidate() throws Exception {
|
||||
//测试mysql
|
||||
DataSource dataSource = new DataSource();
|
||||
dataSource.setDbUrl("jdbc:mysql://101.43.186.75:3307/metersphere?autoReconnect=false&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false");
|
||||
dataSource.setPassword("Password123@mysql");
|
||||
dataSource.setUsername("root");
|
||||
dataSource.setDbUrl(dburl);
|
||||
dataSource.setPassword(password);
|
||||
dataSource.setUsername(username);
|
||||
dataSource.setDriverId(StringUtils.join("system", "&", "com.mysql.cj.jdbc.Driver"));
|
||||
dataSource.setDriver("com.mysql.cj.jdbc.Driver");
|
||||
this.requestPost(validate, dataSource, status().isOk());
|
||||
//校验权限
|
||||
requestPostPermissionsTest(Arrays.asList(PermissionConstants.PROJECT_ENVIRONMENT_READ, PermissionConstants.PROJECT_ENVIRONMENT_READ_ADD, PermissionConstants.PROJECT_ENVIRONMENT_READ_UPDATE),
|
||||
validate, dataSource);
|
||||
|
||||
//测试oracle 需要上传驱动jar包
|
||||
// 校验数据库驱动上传成功
|
||||
PluginUpdateRequest request = new PluginUpdateRequest();
|
||||
request.setName("my-driver");
|
||||
request.setOrganizationIds(Arrays.asList(DEFAULT_ORGANIZATION_ID));
|
||||
File myDriver = new File(
|
||||
this.getClass().getClassLoader().getResource("file/ojdbc11.jar")
|
||||
.getPath()
|
||||
);
|
||||
request.setGlobal(true);
|
||||
request.setEnable(true);
|
||||
this.requestMultipartWithOkAndReturn("/plugin/add",
|
||||
getDefaultMultiPartParam(request, myDriver));
|
||||
Assertions.assertEquals(jdbcDriverPluginService.getJdbcDriverClass(DEFAULT_ORGANIZATION_ID), Arrays.asList("oracle.jdbc.OracleDriver", "com.mysql.cj.jdbc.Driver"));
|
||||
dataSource = new DataSource();
|
||||
dataSource.setDbUrl("jdbc:oracle:thin:@123.56.8.132:1521/orclpdb1.localdomain");
|
||||
dataSource.setPassword("dataease");
|
||||
dataSource.setUsername("dataease");
|
||||
dataSource.setDriverId("oracle.jdbc.OracleDriver&oracle.jdbc.OracleDriver");
|
||||
dataSource.setDriver("oracle.jdbc.OracleDriver");
|
||||
this.requestPost(validate, dataSource, status().isOk());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -13,7 +13,7 @@ VALUES ('delete', 'test2', 'deleted@metersphere.io', MD5('deleted@metersphere.io
|
||||
UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin',1);
|
||||
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time, enable,module_setting) VALUES ('projectId', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1, '["apiTest","uiTest"]');
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time,enable) VALUES ('projectId1', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目1', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1);
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time,enable) VALUES ('projectId1', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目1', '系统默认创建的项目', 'test', 'test', unix_timestamp() * 1000, unix_timestamp() * 1000,1);
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time,update_time,enable ) VALUES ('projectId2', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目2', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1);
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time,update_time,enable, module_setting) VALUES ('projectId3', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目3', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1,'["apiTest","uiTest"]');
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time,update_time,enable, module_setting) VALUES ('projectId4', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目4', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1,'["apiTest","uiTest","loadTest"]');
|
||||
|
@ -118,6 +118,7 @@ public class CommonProjectService {
|
||||
memberRequest.setUserIds(addProjectDTO.getUserIds());
|
||||
}
|
||||
projectMapper.insertSelective(project);
|
||||
serviceInvoker.invokeCreateServices(project.getId());
|
||||
//添加项目管理员 创建的时候如果没有传管理员id 则默认创建者为管理员
|
||||
this.addProjectAdmin(memberRequest, createUser, path,
|
||||
OperationLogType.ADD.name(), Translator.get("add"), module);
|
||||
|
@ -99,7 +99,7 @@ public class UserInviteService {
|
||||
" <tr>\n" +
|
||||
" <td style=\"padding: 14px 24px 7px; color: #8492a6;\">\n" +
|
||||
" <span style=\"color:#7952B3\">" + inviteUser + "</span>\n" +
|
||||
" " + Translator.get("user.email.invite_ms") + "MeterSphere\n" +
|
||||
" " + Translator.get("user.email.invite_ms") + "\n" +
|
||||
" </td>\n" +
|
||||
" </tr>\n" +
|
||||
" <tr>\n" +
|
||||
|
@ -17,7 +17,7 @@ VALUES ('test', 'test', 'admin3@metersphere.io', MD5('admin2@metersphere.io'),
|
||||
UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, NULL, NUll, '', 'LOCAL', NULL, 'admin', 'admin');
|
||||
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time, enable,module_setting) VALUES ('projectId', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1, '["apiTest","uiTest"]');
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time,enable) VALUES ('projectId1', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目1', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1);
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time,enable) VALUES ('projectId1', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目1', '系统默认创建的项目', 'test', 'test', unix_timestamp() * 1000, unix_timestamp() * 1000,1);
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time,update_time,enable ) VALUES ('projectId2', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目2', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1);
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time,update_time,enable, module_setting) VALUES ('projectId3', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目3', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1,'["apiTest","uiTest"]');
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time,update_time,enable, module_setting) VALUES ('projectId4', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目4', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1,'["apiTest","uiTest","loadTest"]');
|
||||
|
@ -1,7 +1,7 @@
|
||||
# 插入测试数据
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time,module_setting) VALUES ('projectId', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000, '["apiTest","uiTest"]');
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time, enable,module_setting) VALUES ('projectId', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1, '["apiTest","uiTest"]');
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time,enable) VALUES ('projectId1', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目1', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1);
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time,enable) VALUES ('projectId1', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目1', '系统默认创建的项目', 'test', 'test', unix_timestamp() * 1000, unix_timestamp() * 1000,1);
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time,update_time,enable ) VALUES ('projectId2', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目2', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1);
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time,update_time,enable, module_setting) VALUES ('projectId3', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目3', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1,'["apiTest","uiTest"]');
|
||||
replace INTO project (id, num, organization_id, name, description, create_user, update_user, create_time,update_time,enable, module_setting) VALUES ('projectId4', null, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目4', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000,1,'["apiTest","uiTest","loadTest"]');
|
||||
|
Loading…
Reference in New Issue
Block a user