build: 初始化的组织项目使用固定的数字ID
This commit is contained in:
parent
133900359b
commit
594fabe413
|
@ -2,9 +2,9 @@
|
|||
SET SESSION innodb_lock_wait_timeout = 7200;
|
||||
|
||||
-- 初始化组织
|
||||
INSERT INTO organization (id, num, name, description, create_user, update_user, create_time, update_time) VALUES ('default_organization', 100001, '默认组织', '系统默认创建的组织', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||
INSERT INTO organization (id, num, name, description, create_user, update_user, create_time, update_time) VALUES ('100001', 100001, '默认组织', '系统默认创建的组织', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||
-- 初始化项目
|
||||
INSERT INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time) VALUES ('default_project', 100001, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||
INSERT INTO project (id, num, organization_id, name, description, create_user, update_user, create_time, update_time) VALUES ('100001100001', 100001, (SELECT id FROM organization WHERE name LIKE '默认组织'), '默认项目', '系统默认创建的项目', 'admin', 'admin', unix_timestamp() * 1000, unix_timestamp() * 1000);
|
||||
|
||||
-- 初始化用户
|
||||
insert into user(id, name, email, password, create_time, update_time, language, last_organization_id, phone, source, last_project_id, create_user, update_user,deleted)
|
||||
|
@ -107,7 +107,7 @@ INSERT INTO test_resource_pool_blob (id, configuration) VALUES ('a6374438-80fc-4
|
|||
|
||||
-- 初始化内置自定义字段和模板
|
||||
INSERT INTO custom_field(id, name, scene, `type`, remark, internal, scope_type, create_time, update_time, create_user, scope_id)
|
||||
VALUES(uuid(), 'functional_priority', 'FUNCTIONAL', 'SELECT', '', 1, 'ORGANIZATION', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', 'default_organization');
|
||||
VALUES(uuid(), 'functional_priority', 'FUNCTIONAL', 'SELECT', '', 1, 'ORGANIZATION', UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', '100001');
|
||||
INSERT INTO custom_field_option (field_id,value,`text`,internal)
|
||||
VALUES ((select id from custom_field where name = 'functional_priority'), 'P0', 'P0', 1);
|
||||
INSERT INTO custom_field_option (field_id,value,`text`,internal)
|
||||
|
@ -118,14 +118,14 @@ INSERT INTO custom_field_option (field_id,value,`text`,internal)
|
|||
VALUES ((select id from custom_field where name = 'functional_priority'), 'P3', 'P3', 1);
|
||||
|
||||
INSERT INTO template (id,name,remark,internal,update_time,create_time,create_user,scope_type,scope_id,enable_third_part,scene)
|
||||
VALUES (uuid(), 'functional_default', '', 1, UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', 'ORGANIZATION', 'default_organization', 0, 'FUNCTIONAL');
|
||||
VALUES (uuid(), 'functional_default', '', 1, UNIX_TIMESTAMP() * 1000, UNIX_TIMESTAMP() * 1000, 'admin', 'ORGANIZATION', '100001', 0, 'FUNCTIONAL');
|
||||
INSERT INTO template_custom_field(id, field_id, template_id, required, pos, api_field_id, default_value)
|
||||
VALUES(uuid(), (select id from custom_field where name = 'functional_priority'), (select id from template where name = 'functional_default'), 1, 0, NULL, NULL);
|
||||
|
||||
|
||||
-- 初始化内置消息机器人
|
||||
Insert into project_robot(id, project_id, name, platform, webhook, type, app_key, app_secret, enable, create_user, create_time, update_user, update_time, description) VALUES (UUID_SHORT(), 'default_project', '站内信', 'IN_SITE', 'NONE', null, null, null, true, 'admin', unix_timestamp() * 1000,'admin', unix_timestamp() * 1000, null);
|
||||
Insert into project_robot(id, project_id, name, platform, webhook, type, app_key, app_secret, enable, create_user, create_time, update_user, update_time, description) VALUES (UUID_SHORT(), 'default_project', '邮件', 'MAIL', 'NONE', null, null, null, true, 'admin', unix_timestamp() * 1000,'admin', unix_timestamp() * 1000, null);
|
||||
Insert into project_robot(id, project_id, name, platform, webhook, type, app_key, app_secret, enable, create_user, create_time, update_user, update_time, description) VALUES (UUID_SHORT(), '100001100001', '站内信', 'IN_SITE', 'NONE', null, null, null, true, 'admin', unix_timestamp() * 1000,'admin', unix_timestamp() * 1000, null);
|
||||
Insert into project_robot(id, project_id, name, platform, webhook, type, app_key, app_secret, enable, create_user, create_time, update_user, update_time, description) VALUES (UUID_SHORT(), '100001100001', '邮件', 'MAIL', 'NONE', null, null, null, true, 'admin', unix_timestamp() * 1000,'admin', unix_timestamp() * 1000, null);
|
||||
|
||||
-- set innodb lock wait timeout to default
|
||||
SET SESSION innodb_lock_wait_timeout = DEFAULT;
|
||||
|
|
|
@ -79,8 +79,8 @@ public abstract class BaseTest {
|
|||
protected static final String DEFAULT_UPDATE = "update";
|
||||
protected static final String DEFAULT_DELETE = "delete/{0}";
|
||||
protected static final String DEFAULT_USER_PASSWORD = "metersphere";
|
||||
protected static final String DEFAULT_PROJECT_ID = "default_project";
|
||||
protected static final String DEFAULT_ORGANIZATION_ID = "default_organization";
|
||||
protected static final String DEFAULT_PROJECT_ID = "100001100001";
|
||||
protected static final String DEFAULT_ORGANIZATION_ID = "100001";
|
||||
|
||||
/**
|
||||
* 可以重写该方法定义 BASE_PATH
|
||||
|
|
|
@ -289,7 +289,7 @@ public class ProjectApplicationControllerTests extends BaseTest {
|
|||
@Test
|
||||
@Order(21)
|
||||
public void testGetApiResourcePool() throws Exception {
|
||||
this.requestGetWithOkAndReturn(GET_API_RESOURCE_POOL_URL + "/default_organization");
|
||||
this.requestGetWithOkAndReturn(GET_API_RESOURCE_POOL_URL + "/100001");
|
||||
}
|
||||
/**
|
||||
* ==========接口测试 end==========
|
||||
|
|
|
@ -90,11 +90,11 @@ public class ProjectControllerTests extends BaseTest {
|
|||
@Order(3)
|
||||
public void testGetOptionsSuccess() throws Exception {
|
||||
|
||||
MvcResult mvcResult = this.responseGet(getOptions + "default_organization");
|
||||
MvcResult mvcResult = this.responseGet(getOptions + "100001");
|
||||
List<Project> list = parseObjectFromMvcResult(mvcResult, List.class);
|
||||
Assertions.assertNotNull(list);
|
||||
ProjectExample example = new ProjectExample();
|
||||
example.createCriteria().andOrganizationIdEqualTo("default_organization").andEnableEqualTo(true);
|
||||
example.createCriteria().andOrganizationIdEqualTo("100001").andEnableEqualTo(true);
|
||||
Assertions.assertEquals(projectMapper.countByExample(example), list.size());
|
||||
|
||||
mvcResult = mockMvc.perform(MockMvcRequestBuilders.post("/login")
|
||||
|
@ -105,7 +105,7 @@ public class ProjectControllerTests extends BaseTest {
|
|||
.andReturn();
|
||||
String sessionId = JsonPath.read(mvcResult.getResponse().getContentAsString(), "$.data.sessionId");
|
||||
String csrfToken = JsonPath.read(mvcResult.getResponse().getContentAsString(), "$.data.csrfToken");
|
||||
mvcResult = mockMvc.perform(MockMvcRequestBuilders.get(getOptions + "default_organization")
|
||||
mvcResult = mockMvc.perform(MockMvcRequestBuilders.get(getOptions + "100001")
|
||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
|
@ -123,7 +123,7 @@ public class ProjectControllerTests extends BaseTest {
|
|||
.andReturn();
|
||||
sessionId = JsonPath.read(mvcResult.getResponse().getContentAsString(), "$.data.sessionId");
|
||||
csrfToken = JsonPath.read(mvcResult.getResponse().getContentAsString(), "$.data.csrfToken");
|
||||
mvcResult = mockMvc.perform(MockMvcRequestBuilders.get(getOptions + "default_organization")
|
||||
mvcResult = mockMvc.perform(MockMvcRequestBuilders.get(getOptions + "100001")
|
||||
.header(SessionConstants.HEADER_TOKEN, sessionId)
|
||||
.header(SessionConstants.CSRF_TOKEN, csrfToken)
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
|
@ -134,7 +134,7 @@ public class ProjectControllerTests extends BaseTest {
|
|||
Assertions.assertEquals(0, list.size());
|
||||
|
||||
//权限校验
|
||||
requestGetPermissionTest(PermissionConstants.PROJECT_BASE_INFO_READ, getOptions + "default_organization");
|
||||
requestGetPermissionTest(PermissionConstants.PROJECT_BASE_INFO_READ, getOptions + "100001");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -155,7 +155,7 @@ public class ProjectControllerTests extends BaseTest {
|
|||
UserDTO userDTO = parseObjectFromMvcResult(mvcResult, UserDTO.class);
|
||||
Assertions.assertNotNull(userDTO);
|
||||
Assertions.assertEquals("projectId", userDTO.getLastProjectId());
|
||||
request.setProjectId("default_project");
|
||||
request.setProjectId("100001100001");
|
||||
//权限校验
|
||||
requestPostPermissionTest(PermissionConstants.PROJECT_BASE_INFO_READ, prefix + "/switch", request);
|
||||
}
|
||||
|
|
|
@ -21,10 +21,10 @@ replace INTO project (id, num, organization_id, name, description, create_user,
|
|||
|
||||
|
||||
# 插入测试数据 给组织增加成员
|
||||
replace INTO user_role_relation (id, user_id, role_id, source_id, organization_id, create_time, create_user )VALUES ('user_role_relation1','admin1','org_admin','default_organization','default_organization','1684747668321','admin');
|
||||
replace INTO user_role_relation (id, user_id, role_id, source_id, organization_id, create_time, create_user )VALUES ('user_role_relation2','delete','org_admin','default_organization','default_organization','1684747668321','admin');
|
||||
replace INTO user_role_relation (id, user_id, role_id, source_id, organization_id, create_time, create_user )VALUES ('user_role_relation6','delete','project_member','projectId1','default_organization','1684747668321','admin');
|
||||
replace INTO user_role_relation (id, user_id, role_id, source_id, organization_id, create_time, create_user )VALUES ('user_role_relation3','admin1','project_member','projectId1','default_organization','1684747668321','admin');
|
||||
replace INTO user_role_relation (id, user_id, role_id, source_id, organization_id, create_time, create_user )VALUES ('user_role_relation4','admin1','project_member','projectId2','default_organization','1684747668321','admin');
|
||||
replace INTO user_role_relation (id, user_id, role_id, source_id, organization_id, create_time, create_user )VALUES ('user_role_relation5','admin1','project_member','projectId3','default_organization','1684747668321','admin');
|
||||
replace INTO user_role_relation (id, user_id, role_id, source_id, organization_id, create_time, create_user )VALUES ('user_role_relation1','admin1','org_admin','100001','100001','1684747668321','admin');
|
||||
replace INTO user_role_relation (id, user_id, role_id, source_id, organization_id, create_time, create_user )VALUES ('user_role_relation2','delete','org_admin','100001','100001','1684747668321','admin');
|
||||
replace INTO user_role_relation (id, user_id, role_id, source_id, organization_id, create_time, create_user )VALUES ('user_role_relation6','delete','project_member','projectId1','100001','1684747668321','admin');
|
||||
replace INTO user_role_relation (id, user_id, role_id, source_id, organization_id, create_time, create_user )VALUES ('user_role_relation3','admin1','project_member','projectId1','100001','1684747668321','admin');
|
||||
replace INTO user_role_relation (id, user_id, role_id, source_id, organization_id, create_time, create_user )VALUES ('user_role_relation4','admin1','project_member','projectId2','100001','1684747668321','admin');
|
||||
replace INTO user_role_relation (id, user_id, role_id, source_id, organization_id, create_time, create_user )VALUES ('user_role_relation5','admin1','project_member','projectId3','100001','1684747668321','admin');
|
||||
replace INTO user_role_permission(id, role_id, permission_id) VALUES ('user_role_permission1','project_member','PROJECT_BASE_INFO:READ');
|
||||
|
|
Loading…
Reference in New Issue