Browse Source

[Fix] Privilege Reconstruction Data Query Fix & Resource Creation Post Oper… (#10313)

* Privilege Reconstruction Data Query Fix & Resource Creation Post Operations.

* Resource Retry

* e2e retry

* create project log add

* project list query log add

* clean project log

* delete delay

* delete delay

* remove post handle

* project e2e

* browser refresh

* browser refresh

* e2e fix

* e2e browser refresh

* rowk flow e2e fix

* mapper deduplication

* udf e2e

* e2e
3.1.0-release
WangJPLeo 3 years ago committed by GitHub
parent
commit
e3e39cbdea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/EnvironmentController.java
  2. 10
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/BaseService.java
  3. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/EnvironmentService.java
  4. 23
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertGroupServiceImpl.java
  5. 11
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/BaseServiceImpl.java
  6. 19
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
  7. 23
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/EnvironmentServiceImpl.java
  8. 26
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java
  9. 16
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
  10. 24
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java
  11. 1
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UdfFuncServiceImpl.java
  12. 16
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
  13. 13
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java
  14. 12
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java
  15. 10
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/EnvironmentServiceTest.java
  16. 3
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
  17. 10
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java
  18. 9
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapper.java
  19. 11
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/DataSourceMapper.java
  20. 11
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/EnvironmentMapper.java
  21. 11
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TenantMapper.java
  22. 17
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapper.xml
  23. 17
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/EnvironmentMapper.xml
  24. 2
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ResourceMapper.xml
  25. 21
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TenantMapper.xml
  26. 1
      dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/ProjectE2ETest.java
  27. 14
      dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/UdfManageE2ETest.java
  28. 17
      dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowE2ETest.java
  29. 8
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/permission/ResourcePermissionCheckService.java
  30. 5
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/permission/ResourcePermissionCheckServiceImpl.java

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/EnvironmentController.java

@ -173,7 +173,7 @@ public class EnvironmentController extends BaseController {
return result;
}
searchVal = ParameterUtils.handleEscapes(searchVal);
result = environmentService.queryEnvironmentListPaging(pageNo, pageSize, searchVal);
result = environmentService.queryEnvironmentListPaging(loginUser, pageNo, pageSize, searchVal);
return result;
}

10
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/BaseService.java

@ -21,7 +21,9 @@ import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.enums.AuthorizationType;
import org.apache.dolphinscheduler.dao.entity.User;
import org.slf4j.Logger;
import java.util.List;
import java.util.Map;
/**
@ -47,6 +49,14 @@ public interface BaseService {
*/
boolean isNotAdmin(User loginUser, Map<String, Object> result);
/**
* permissionPostHandle
* @param authorizationType
* @param userId
* @param ids
* @param logger
*/
void permissionPostHandle(AuthorizationType authorizationType, Integer userId, List<Integer> ids, Logger logger);
/**
* put message to map

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/EnvironmentService.java

@ -81,7 +81,7 @@ public interface EnvironmentService {
* @param pageSize page size
* @return environment list page
*/
Result queryEnvironmentListPaging(Integer pageNo, Integer pageSize, String searchVal);
Result queryEnvironmentListPaging(User loginUser, Integer pageNo, Integer pageSize, String searchVal);
/**
* query all environment

23
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertGroupServiceImpl.java

@ -23,16 +23,21 @@ import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.AuthorizationType;
import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.dao.entity.AlertGroup;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -118,11 +123,20 @@ public class AlertGroupServiceImpl extends BaseServiceImpl implements AlertGroup
putMsg(result,Status.USER_NO_OPERATION_PERM);
return result;
}
Page<AlertGroup> page = new Page<>(pageNo, pageSize);
IPage<AlertGroup> alertGroupIPage = alertGroupMapper.queryAlertGroupPage(
page, searchVal);
IPage<AlertGroup> alertGroupIPage;
PageInfo<AlertGroup> pageInfo = new PageInfo<>(pageNo, pageSize);
Page<AlertGroup> page = new Page<>(pageNo, pageSize);
if (loginUser.getUserType().equals(UserType.ADMIN_USER)) {
alertGroupIPage = alertGroupMapper.queryAlertGroupPage(page, searchVal);
} else {
Set<Integer> ids = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.ALERT_GROUP, loginUser.getId(), logger);
if (ids.isEmpty()) {
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
alertGroupIPage = alertGroupMapper.queryAlertGroupPageByIds(page, new ArrayList<>(ids), searchVal);
}
pageInfo.setTotal((int) alertGroupIPage.getTotal());
pageInfo.setTotalList(alertGroupIPage.getRecords());
result.setData(pageInfo);
@ -165,6 +179,7 @@ public class AlertGroupServiceImpl extends BaseServiceImpl implements AlertGroup
if (insert > 0) {
result.put(Constants.DATA_LIST, alertGroup);
putMsg(result, Status.SUCCESS);
permissionPostHandle(AuthorizationType.ALERT_GROUP, loginUser.getId(), Collections.singletonList(alertGroup.getId()), logger);
} else {
putMsg(result, Status.CREATE_ALERT_GROUP_ERROR);
}

11
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/BaseServiceImpl.java

@ -35,6 +35,7 @@ import java.io.IOException;
import java.text.MessageFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@ -47,6 +48,16 @@ public class BaseServiceImpl implements BaseService {
@Autowired
protected ResourcePermissionCheckService resourcePermissionCheckService;
@Override
public void permissionPostHandle(AuthorizationType authorizationType, Integer userId, List<Integer> ids, Logger logger) {
try{
resourcePermissionCheckService.postHandle(authorizationType, userId, ids, logger);
}catch (Exception e){
logger.error("post handle error", e);
throw new RuntimeException("resource association user error", e);
}
}
/**
* check admin
*

19
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java

@ -134,6 +134,7 @@ public class DataSourceServiceImpl extends BaseServiceImpl implements DataSource
try {
dataSourceMapper.insert(dataSource);
putMsg(result, Status.SUCCESS);
permissionPostHandle(AuthorizationType.DATASOURCE, loginUser.getId(), Collections.singletonList(dataSource.getId()), logger);
} catch (DuplicateKeyException ex) {
logger.error("Create datasource error.", ex);
putMsg(result, Status.DATASOURCE_EXIST);
@ -248,19 +249,31 @@ public class DataSourceServiceImpl extends BaseServiceImpl implements DataSource
Result result = new Result();
IPage<DataSource> dataSourceList = null;
Page<DataSource> dataSourcePage = new Page<>(pageNo, pageSize);
PageInfo<DataSource> pageInfo = new PageInfo<>(pageNo, pageSize);
if (canOperatorPermissions(loginUser,null,AuthorizationType.DATASOURCE,DATASOURCE_LIST)) {
if (!canOperatorPermissions(loginUser,null,AuthorizationType.DATASOURCE,DATASOURCE_LIST)) {
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
if (loginUser.getUserType().equals(UserType.ADMIN_USER)) {
dataSourceList = dataSourceMapper.selectPaging(dataSourcePage, UserType.ADMIN_USER.equals(loginUser.getUserType()) ? 0 : loginUser.getId(), searchVal);
} else {
Set<Integer> ids = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.DATASOURCE, loginUser.getId(), logger);
if (ids.isEmpty()) {
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
dataSourceList = dataSourceMapper.selectPagingByIds(dataSourcePage, new ArrayList<>(ids), searchVal);
}
List<DataSource> dataSources = dataSourceList != null ? dataSourceList.getRecords() : new ArrayList<>();
handlePasswd(dataSources);
PageInfo<DataSource> pageInfo = new PageInfo<>(pageNo, pageSize);
pageInfo.setTotal((int) (dataSourceList != null ? dataSourceList.getTotal() : 0L));
pageInfo.setTotalList(dataSources);
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}

23
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/EnvironmentServiceImpl.java

@ -24,6 +24,7 @@ import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.AuthorizationType;
import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils;
import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils.CodeGenerateException;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
@ -40,6 +41,7 @@ import org.apache.commons.collections4.SetUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@ -148,6 +150,7 @@ public class EnvironmentServiceImpl extends BaseServiceImpl implements Environme
}
result.put(Constants.DATA_LIST, env.getCode());
putMsg(result, Status.SUCCESS);
permissionPostHandle(AuthorizationType.ENVIRONMENT, loginUser.getId(), Collections.singletonList(env.getId()), logger);
} else {
putMsg(result, Status.CREATE_ENVIRONMENT_ERROR);
}
@ -163,14 +166,24 @@ public class EnvironmentServiceImpl extends BaseServiceImpl implements Environme
* @return environment list page
*/
@Override
public Result queryEnvironmentListPaging(Integer pageNo, Integer pageSize, String searchVal) {
Result result = new Result();
public Result queryEnvironmentListPaging(User loginUser, Integer pageNo, Integer pageSize, String searchVal) {
Result<Object> result = new Result();
Page<Environment> page = new Page<>(pageNo, pageSize);
IPage<Environment> environmentIPage = environmentMapper.queryEnvironmentListPaging(page, searchVal);
PageInfo<EnvironmentDto> pageInfo = new PageInfo<>(pageNo, pageSize);
IPage<Environment> environmentIPage;
if (loginUser.getUserType().equals(UserType.ADMIN_USER)) {
environmentIPage = environmentMapper.queryEnvironmentListPaging(page, searchVal);
} else {
Set<Integer> ids = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.ENVIRONMENT, loginUser.getId(), logger);
if (ids.isEmpty()) {
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
environmentIPage = environmentMapper.queryEnvironmentListPagingByIds(page, new ArrayList<>(ids), searchVal);
}
pageInfo.setTotal((int) environmentIPage.getTotal());
if (CollectionUtils.isNotEmpty(environmentIPage.getRecords())) {

26
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectServiceImpl.java

@ -43,6 +43,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@ -123,9 +124,11 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectServic
if (projectMapper.insert(project) > 0) {
result.put(Constants.DATA_LIST, project);
putMsg(result, Status.SUCCESS);
permissionPostHandle(AuthorizationType.PROJECTS, loginUser.getId(), Collections.singletonList(project.getId()), logger);
} else {
putMsg(result, Status.CREATE_PROJECT_ERROR);
}
logger.info("create project complete and id is :{}", project.getId());
return result;
}
@ -205,7 +208,7 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectServic
boolean checkResult = false;
if (project == null) {
putMsg(result, Status.PROJECT_NOT_FOUND, "");
} else if (!canOperatorPermissions(loginUser, new Object[]{project.getId()},AuthorizationType.PROJECTS,null)) {
} else if (!canOperatorPermissions(loginUser, new Object[]{project.getId()},AuthorizationType.PROJECTS,PROJECT)) {
putMsg(result, Status.USER_NO_OPERATION_PROJECT_PERM, loginUser.getUserName(), project.getName());
} else {
checkResult = true;
@ -226,10 +229,17 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectServic
public Result queryProjectListPaging(User loginUser, Integer pageSize, Integer pageNo, String searchVal) {
Result result = new Result();
PageInfo<Project> pageInfo = new PageInfo<>(pageNo, pageSize);
Page<Project> page = new Page<>(pageNo, pageSize);
if (!canOperatorPermissions(loginUser, null, AuthorizationType.PROJECTS, PROJECT)) {
putMsg(result, Status.NO_CURRENT_OPERATING_PERMISSION);
return result;
}
Set<Integer> projectIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.PROJECTS, loginUser.getId(), logger);
if (projectIds.isEmpty()) {
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
IPage<Project> projectIPage = projectMapper.queryProjectListPaging(page, new ArrayList<>(projectIds), searchVal);
List<Project> projectList = projectIPage.getRecords();
@ -353,6 +363,11 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectServic
Map<String, Object> result = new HashMap<>();
Set<Integer> projectIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.PROJECTS, loginUser.getId(), logger);
if (projectIds.isEmpty()) {
result.put(Constants.DATA_LIST, Collections.emptyList());
putMsg(result, Status.SUCCESS);
return result;
}
List<Project> projectList = projectMapper.listAuthorizedProjects(loginUser.getUserType().equals(UserType.ADMIN_USER) ? 0 : loginUser.getId(), new ArrayList<>(projectIds));
List<Project> resultList = new ArrayList<>();
@ -459,6 +474,11 @@ public class ProjectServiceImpl extends BaseServiceImpl implements ProjectServic
Map<String, Object> result = new HashMap<>();
Set<Integer> projectIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.PROJECTS, loginUser.getId(), logger);
if (projectIds.isEmpty()) {
result.put(Constants.DATA_LIST, Collections.emptyList());
putMsg(result, Status.SUCCESS);
return result;
}
List<Project> projects = projectMapper.listAuthorizedProjects(loginUser.getUserType().equals(UserType.ADMIN_USER) ? 0 : loginUser.getId(), new ArrayList<>(projectIds));
result.put(Constants.DATA_LIST, projects);

16
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java

@ -176,6 +176,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
try {
resourcesMapper.insert(resource);
putMsg(result, Status.SUCCESS);
permissionPostHandle(AuthorizationType.RESOURCE_FILE_ID, loginUser.getId(), Collections.singletonList(resource.getId()), logger);
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<Object, Object> entry : new BeanMap(resource).entrySet()) {
if (!"class".equalsIgnoreCase(entry.getKey().toString())) {
@ -269,6 +270,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
resourcesMapper.insert(resource);
updateParentResourceSize(resource, resource.getSize());
putMsg(result, Status.SUCCESS);
permissionPostHandle(AuthorizationType.RESOURCE_FILE_ID, loginUser.getId(), Collections.singletonList(resource.getId()), logger);
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<Object, Object> entry : new BeanMap(resource).entrySet()) {
if (!"class".equalsIgnoreCase(entry.getKey().toString())) {
@ -630,11 +632,6 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
}
Page<Resource> page = new Page<>(pageNo, pageSize);
int userId = loginUser.getId();
if (isAdmin(loginUser)) {
userId = 0;
}
if (directoryId != -1) {
Resource directory = resourcesMapper.selectById(directoryId);
if (directory == null) {
@ -642,11 +639,15 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
return result;
}
}
PageInfo<Resource> pageInfo = new PageInfo<>(pageNo, pageSize);
Set<Integer> resourcesIds = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.RESOURCE_FILE_ID, loginUser.getId(), logger);
if (resourcesIds.isEmpty()) {
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
IPage<Resource> resourceIPage = resourcesMapper.queryResourcePaging(page, directoryId, type.ordinal(), loginUser.getId(), searchVal, new ArrayList<>(resourcesIds));
PageInfo<Resource> pageInfo = new PageInfo<>(pageNo, pageSize);
pageInfo.setTotal((int) resourceIPage.getTotal());
pageInfo.setTotalList(resourceIPage.getRecords());
result.setData(pageInfo);
@ -1124,6 +1125,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
updateParentResourceSize(resource, resource.getSize());
putMsg(result, Status.SUCCESS);
permissionPostHandle(AuthorizationType.RESOURCE_FILE_ID, loginUser.getId(), Collections.singletonList(resource.getId()), logger);
Map<String, Object> resultMap = new HashMap<>();
for (Map.Entry<Object, Object> entry : new BeanMap(resource).entrySet()) {
if (!Constants.CLASS.equalsIgnoreCase(entry.getKey().toString())) {

24
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java

@ -28,6 +28,7 @@ import org.apache.dolphinscheduler.api.utils.RegexUtils;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.AuthorizationType;
import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.storage.StorageOperate;
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
@ -38,13 +39,19 @@ import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper;
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.*;
import static org.apache.dolphinscheduler.common.Constants.TENANT_FULL_NAME_MAX_LENGTH;
@ -55,6 +62,8 @@ import static org.apache.dolphinscheduler.common.Constants.TENANT_FULL_NAME_MAX_
@Service
public class TenantServiceImpl extends BaseServiceImpl implements TenantService {
private static final Logger logger = LoggerFactory.getLogger(TenantServiceImpl.class);
@Autowired
private TenantMapper tenantMapper;
@ -126,6 +135,7 @@ public class TenantServiceImpl extends BaseServiceImpl implements TenantService
result.put(Constants.DATA_LIST, tenant);
putMsg(result, Status.SUCCESS);
permissionPostHandle(AuthorizationType.TENANT, loginUser.getId(), Collections.singletonList(tenant.getId()),logger);
return result;
}
@ -147,10 +157,20 @@ public class TenantServiceImpl extends BaseServiceImpl implements TenantService
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
IPage<Tenant> tenantIPage;
Page<Tenant> page = new Page<>(pageNo, pageSize);
IPage<Tenant> tenantIPage = tenantMapper.queryTenantPaging(page, searchVal);
PageInfo<Tenant> pageInfo = new PageInfo<>(pageNo, pageSize);
if (loginUser.getUserType().equals(UserType.ADMIN_USER)) {
tenantIPage = tenantMapper.queryTenantPaging(page, searchVal);
} else {
Set<Integer> ids = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.TENANT, loginUser.getId(), logger);
if (ids.isEmpty()) {
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
tenantIPage = tenantMapper.queryTenantPagingByIds(page, new ArrayList<>(ids), searchVal);
}
pageInfo.setTotal((int) tenantIPage.getTotal());
pageInfo.setTotalList(tenantIPage.getRecords());
result.setData(pageInfo);

1
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UdfFuncServiceImpl.java

@ -137,6 +137,7 @@ public class UdfFuncServiceImpl extends BaseServiceImpl implements UdfFuncServic
udfFuncMapper.insert(udf);
putMsg(result, Status.SUCCESS);
permissionPostHandle(AuthorizationType.UDF, loginUser.getId(), Collections.singletonList(resource.getId()), logger);
return result;
}

16
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java

@ -17,6 +17,7 @@
package org.apache.dolphinscheduler.api.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.collections.CollectionUtils;
@ -29,6 +30,7 @@ import org.apache.dolphinscheduler.api.utils.CheckUtils;
import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.AuthorizationType;
import org.apache.dolphinscheduler.common.enums.Flag;
import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.storage.StorageOperate;
@ -77,6 +79,8 @@ import java.util.TimeZone;
import java.util.Arrays;
import java.util.stream.Collectors;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.USER_MANAGER;
/**
* users service impl
*/
@ -1023,15 +1027,17 @@ public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
@Override
public Map<String, Object> queryUserList(User loginUser) {
Map<String, Object> result = new HashMap<>();
if(resourcePermissionCheckService.functionDisabled()){
putMsg(result, Status.FUNCTION_DISABLED);
return result;
}
//only admin can operate
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
if (!canOperatorPermissions(loginUser,null, AuthorizationType.ACCESS_TOKEN, USER_MANAGER)) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
queryWrapper.ge("id", 0);
if (loginUser.getUserType().equals(UserType.GENERAL_USER)) {
queryWrapper.eq("id", loginUser.getId());
}
List<User> userList = userMapper.selectList(null);
result.put(Constants.DATA_LIST, userList);
putMsg(result, Status.SUCCESS);

13
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkerGroupServiceImpl.java

@ -24,6 +24,7 @@ import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.AuthorizationType;
import org.apache.dolphinscheduler.common.enums.NodeType;
import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.entity.WorkerGroup;
@ -36,6 +37,7 @@ import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@ -122,6 +124,7 @@ public class WorkerGroupServiceImpl extends BaseServiceImpl implements WorkerGro
workerGroupMapper.insert(workerGroup);
}
putMsg(result, Status.SUCCESS);
permissionPostHandle(AuthorizationType.WORKER_GROUP, loginUser.getId(), Collections.singletonList(workerGroup.getId()),logger);
return result;
}
@ -191,7 +194,15 @@ public class WorkerGroupServiceImpl extends BaseServiceImpl implements WorkerGro
return result;
}
List<WorkerGroup> workerGroups = getWorkerGroups(true);
List<WorkerGroup> workerGroups = new ArrayList<>();
if (loginUser.getUserType().equals(UserType.ADMIN_USER)) {
workerGroups = getWorkerGroups(true);
} else {
Set<Integer> ids = resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.WORKER_GROUP, loginUser.getId(), logger);
if (!ids.isEmpty()) {
workerGroups = workerGroupMapper.selectBatchIds(ids);
}
}
List<WorkerGroup> resultDataList = new ArrayList<>();
int total = 0;

12
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java

@ -49,8 +49,10 @@ import java.sql.Connection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.Assert;
import org.junit.Test;
@ -66,6 +68,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.DATASOURCE_DELETE;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.DATASOURCE_LIST;
/**
* data source service test
@ -194,12 +197,17 @@ public class DataSourceServiceTest {
@Test
public void queryDataSourceListPagingTest() {
Set<Integer> ids = new HashSet<>();
ids.add(1);
User loginUser = getAdminUser();
String searchVal = "";
int pageNo = 1;
int pageSize = 10;
Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.DATASOURCE, loginUser.getId(), null, baseServiceLogger)).thenReturn(true);
Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.DATASOURCE, null, 0, baseServiceLogger)).thenReturn(true);
Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.DATASOURCE, loginUser.getId(), DATASOURCE_LIST, baseServiceLogger)).thenReturn(true);
Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.DATASOURCE, null, loginUser.getId(), baseServiceLogger)).thenReturn(true);
Mockito.when(resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.DATASOURCE, loginUser.getId(), baseServiceLogger)).thenReturn(ids);
Result result = dataSourceService.queryDataSourceListPaging(loginUser, searchVal, pageNo, pageSize);
Assert.assertEquals(Status.SUCCESS.getCode(),(int)result.getCode());
}

10
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/EnvironmentServiceTest.java

@ -89,14 +89,6 @@ public class EnvironmentServiceTest {
public static final String workerGroups = "[\"default\"]";
@Before
public void setUp(){
}
@After
public void after(){
}
@Test
public void testCreateEnvironment() {
User loginUser = getGeneralUser();
@ -190,7 +182,7 @@ public class EnvironmentServiceTest {
page.setTotal(1L);
Mockito.when(environmentMapper.queryEnvironmentListPaging(Mockito.any(Page.class), Mockito.eq(environmentName))).thenReturn(page);
Result result = environmentService.queryEnvironmentListPaging(1, 10, environmentName);
Result result = environmentService.queryEnvironmentListPaging(getAdminUser(), 1, 10, environmentName);
logger.info(result.toString());
PageInfo<Environment> pageInfo = (PageInfo<Environment>) result.getData();
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getTotalList()));

3
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java

@ -117,6 +117,7 @@ public class ResourcesServiceTest {
private static final Logger serviceLogger = LoggerFactory.getLogger(BaseServiceImpl.class);
private static final Logger resourceLogger = LoggerFactory.getLogger(ResourcesServiceImpl.class);
@Before
public void setUp() {
@ -349,7 +350,7 @@ public class ResourcesServiceTest {
PowerMockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.RESOURCE_FILE_ID, 1, ApiFuncIdentificationConstant.FILE_VIEW, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.RESOURCE_FILE_ID, null, 0, serviceLogger)).thenReturn(true);
PowerMockito.when(resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.RESOURCE_FILE_ID, 1, serviceLogger)).thenReturn(getSetIds());
PowerMockito.when(resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.RESOURCE_FILE_ID, 1, resourceLogger)).thenReturn(getSetIds());
Mockito.when(resourcesMapper.queryResourcePaging(Mockito.any(Page.class), eq(-1), eq(0), eq(1), eq("test"), Mockito.any())).thenReturn(resourcePage);
Result result = resourcesService.queryResourceListPaging(loginUser, -1, ResourceType.FILE, "test", 1, 10);

10
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java

@ -27,6 +27,7 @@ import org.apache.dolphinscheduler.api.service.impl.UsersServiceImpl;
import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.AuthorizationType;
import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.storage.StorageOperate;
import org.apache.dolphinscheduler.common.utils.EncryptionUtils;
@ -50,6 +51,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static org.apache.dolphinscheduler.api.constants.ApiFuncIdentificationConstant.USER_MANAGER;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
@ -106,6 +108,8 @@ public class UsersServiceTest {
private String queueName = "UsersServiceTestQueue";
private static final Logger serviceLogger = LoggerFactory.getLogger(BaseServiceImpl.class);
@Before
public void before() {
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(false);
@ -226,13 +230,19 @@ public class UsersServiceTest {
@Test
public void testQueryUserList() {
User user = new User();
user.setUserType(UserType.ADMIN_USER);
user.setId(1);
//no operate
Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ACCESS_TOKEN,1, USER_MANAGER, serviceLogger)).thenReturn(true);
Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.ACCESS_TOKEN, null, 0, serviceLogger)).thenReturn(false);
Map<String, Object> result = usersService.queryUserList(user);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS));
//success
Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ACCESS_TOKEN,1, USER_MANAGER, serviceLogger)).thenReturn(true);
Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.ACCESS_TOKEN, null, 0, serviceLogger)).thenReturn(true);
user.setUserType(UserType.ADMIN_USER);
when(userMapper.selectList(null)).thenReturn(getUserList());
result = usersService.queryUserList(user);

9
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapper.java

@ -22,6 +22,7 @@ import org.apache.dolphinscheduler.dao.entity.AlertGroup;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.ibatis.annotations.Param;
import java.util.ArrayList;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@ -92,4 +93,12 @@ public interface AlertGroupMapper extends BaseMapper<AlertGroup> {
*/
<T> List<AlertGroup> listAuthorizedAlertGroupList (@Param("userId") int userId, @Param("alertGroupsIds")List<Integer> alertGroupsIds);
/**
* queryAlertGroupPageByIds
* @param page
* @param ids
* @param searchVal
* @return
*/
IPage<AlertGroup> queryAlertGroupPageByIds(Page<AlertGroup> page, @Param("ids") List<Integer> ids, @Param("searchVal") String searchVal);
}

11
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/DataSourceMapper.java

@ -17,10 +17,12 @@
package org.apache.dolphinscheduler.dao.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.dolphinscheduler.dao.entity.DataSource;
import org.apache.ibatis.annotations.Param;
import java.util.ArrayList;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@ -98,4 +100,13 @@ public interface DataSourceMapper extends BaseMapper<DataSource> {
* @return If the name does not exist or the user does not have permission, it will return null
*/
DataSource queryDataSourceByNameAndUserId(@Param("userId") int userId, @Param("name") String name);
/**
* selectPagingByIds
* @param dataSourcePage
* @param ids
* @param searchVal
* @return
*/
IPage<DataSource> selectPagingByIds(Page<DataSource> dataSourcePage, @Param("ids")List<Integer> ids, @Param("searchVal")String searchVal);
}

11
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/EnvironmentMapper.java

@ -17,11 +17,13 @@
package org.apache.dolphinscheduler.dao.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.dolphinscheduler.dao.entity.Environment;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -68,4 +70,13 @@ public interface EnvironmentMapper extends BaseMapper<Environment> {
* @return int
*/
int deleteByCode(@Param("code") Long code);
/**
* queryEnvironmentListPagingByIds
* @param page
* @param ids
* @param searchVal
* @return
*/
IPage<Environment> queryEnvironmentListPagingByIds(Page<Environment> page, @Param("ids")List<Integer> ids, @Param("searchName")String searchVal);
}

11
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TenantMapper.java

@ -17,6 +17,7 @@
package org.apache.dolphinscheduler.dao.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.dolphinscheduler.dao.entity.Tenant;
import org.apache.ibatis.annotations.Param;
@ -28,6 +29,7 @@ import org.springframework.cache.annotation.Cacheable;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.ArrayList;
import java.util.List;
/**
@ -82,4 +84,13 @@ public interface TenantMapper extends BaseMapper<Tenant> {
* @return true if exist else return null
*/
Boolean existTenant(@Param("tenantCode") String tenantCode);
/**
* queryTenantPagingByIds
* @param page
* @param ids
* @param searchVal
* @return
*/
IPage<Tenant> queryTenantPagingByIds(Page<Tenant> page, @Param("ids")List<Integer> ids, @Param("searchVal")String searchVal);
}

17
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapper.xml

@ -33,6 +33,23 @@
order by update_time desc
</select>
<select id="queryAlertGroupPageByIds" resultType="org.apache.dolphinscheduler.dao.entity.AlertGroup">
select
<include refid="baseSql"/>
from t_ds_alertgroup
where 1 = 1
<if test="searchVal != null and searchVal != ''">
and group_name like concat('%', #{searchVal}, '%')
</if>
<if test="ids != null and ids.size() > 0">
and id in
<foreach item="id" index="index" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
</if>
order by update_time desc
</select>
<select id="queryByGroupName" resultType="org.apache.dolphinscheduler.dao.entity.AlertGroup">
select
<include refid="baseSql"/>

17
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/EnvironmentMapper.xml

@ -43,6 +43,23 @@
</if>
order by create_time desc
</select>
<select id="queryEnvironmentListPagingByIds" resultType="org.apache.dolphinscheduler.dao.entity.Environment">
select
<include refid="baseSql"/>
from t_ds_environment
where 1=1
<if test="ids != null and ids.size() > 0">
and id in
<foreach item="id" index="index" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="searchName!=null and searchName != ''">
and name like concat('%', #{searchName}, '%')
</if>
order by create_time desc
</select>
<select id="queryByEnvironmentCode" resultType="org.apache.dolphinscheduler.dao.entity.Environment">
select
<include refid="baseSql"/>

2
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ResourceMapper.xml

@ -60,7 +60,7 @@
</include>
,u.user_name
from t_ds_resources d,t_ds_user u
where d.type=#{type} and d.pid=#{id} and u.id = #{userId}
where 1=1 and d.type=#{type} and d.pid=#{id} and u.id = #{userId}
<if test="resIds != null and resIds.size() > 0">
and d.id in
<foreach collection="resIds" item="i" open="(" close=")" separator=",">

21
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TenantMapper.xml

@ -54,6 +54,27 @@
</if>
order by t.update_time desc
</select>
<select id="queryTenantPagingByIds" resultType="org.apache.dolphinscheduler.dao.entity.Tenant">
SELECT
<include refid="baseSqlV2">
<property name="alias" value="t"/>
</include>
, q.queue_name
FROM t_ds_tenant t,t_ds_queue q
WHERE 1=1 and t.queue_id = q.id
<if test="ids != null and ids.size() > 0">
and t.id in
<foreach collection="ids" item="i" open="(" close=")" separator=",">
#{i}
</foreach>
</if>
<if test="searchVal != null and searchVal != ''">
and t.tenant_code like concat('%', #{searchVal}, '%')
</if>
order by t.update_time desc
</select>
<select id="existTenant" resultType="java.lang.Boolean">
select 1
from t_ds_tenant

1
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/ProjectE2ETest.java

@ -55,6 +55,7 @@ class ProjectE2ETest {
@Order(30)
void testDeleteProject() {
final ProjectPage page = new ProjectPage(browser);
browser.navigate().refresh();
page.delete(project);
await().untilAsserted(() -> {

14
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/UdfManageE2ETest.java

@ -120,9 +120,9 @@ public class UdfManageE2ETest {
new WebDriverWait(page.driver(), 10)
.until(ExpectedConditions.urlContains("/resource-manage"));
browser.navigate().refresh();
page.createDirectory(testDirectoryName, "test_desc");
browser.navigate().refresh();
await().untilAsserted(() -> assertThat(page.udfList())
.as("File list should contain newly-created file")
.extracting(WebElement::getText)
@ -151,7 +151,7 @@ public class UdfManageE2ETest {
@Order(30)
void testDeleteDirectory() {
final UdfManagePage page = new UdfManagePage(browser);
browser.navigate().refresh();
page.delete(testDirectoryName);
await().untilAsserted(() -> {
@ -172,9 +172,9 @@ public class UdfManageE2ETest {
final UdfManagePage page = new UdfManagePage(browser);
downloadFile("https://repo1.maven.org/maven2/org/apache/hive/hive-jdbc/3.1.2/hive-jdbc-3.1.2.jar", testUploadUdfFilePath.toFile().getAbsolutePath());
browser.navigate().refresh();
page.uploadFile(testUploadUdfFilePath.toFile().getAbsolutePath());
browser.navigate().refresh();
await().untilAsserted(() -> {
assertThat(page.udfList())
.as("File list should contain newly-created file")
@ -205,7 +205,7 @@ public class UdfManageE2ETest {
@Order(60)
void testRenameUdf() {
final UdfManagePage page = new UdfManagePage(browser);
browser.navigate().refresh();
page.rename(testUploadUdfFileName, testUploadUdfRenameFileName);
await().untilAsserted(() -> {
@ -220,7 +220,7 @@ public class UdfManageE2ETest {
@Order(70)
void testDeleteUdf() {
final UdfManagePage page = new UdfManagePage(browser);
browser.navigate().refresh();
page.delete(testUploadUdfRenameFileName);
await().untilAsserted(() -> {

17
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowE2ETest.java

@ -82,6 +82,7 @@ class WorkflowE2ETest {
@AfterAll
public static void cleanup() {
browser.navigate().refresh();
new NavBarPage(browser)
.goToNav(ProjectPage.class)
.goTo(project)
@ -89,7 +90,7 @@ class WorkflowE2ETest {
.cancelPublishAll()
.deleteAll()
;
browser.navigate().refresh();
new NavBarPage(browser)
.goToNav(ProjectPage.class)
.delete(project)
@ -103,7 +104,7 @@ class WorkflowE2ETest {
@Order(1)
void testCreateWorkflow() {
final String workflow = "test-workflow-1";
browser.navigate().refresh();
WorkflowDefinitionTab workflowDefinitionPage =
new ProjectPage(browser)
.goTo(project)
@ -130,7 +131,7 @@ class WorkflowE2ETest {
.anyMatch(
it -> it.getText().contains(workflow)
));
browser.navigate().refresh();
workflowDefinitionPage.publish(workflow);
}
@ -138,7 +139,7 @@ class WorkflowE2ETest {
@Order(10)
void testCreateSubWorkflow() {
final String workflow = "test-sub-workflow-1";
browser.navigate().refresh();
WorkflowDefinitionTab workflowDefinitionPage =
new ProjectPage(browser)
.goToNav(ProjectPage.class)
@ -163,7 +164,7 @@ class WorkflowE2ETest {
await().untilAsserted(() -> assertThat(
workflowDefinitionPage.workflowList()
).anyMatch(it -> it.getText().contains(workflow)));
browser.navigate().refresh();
workflowDefinitionPage.publish(workflow);
}
@ -171,7 +172,7 @@ class WorkflowE2ETest {
@Order(30)
void testRunWorkflow() {
final String workflow = "test-workflow-1";
browser.navigate().refresh();
final ProjectDetailPage projectPage =
new ProjectPage(browser)
.goToNav(ProjectPage.class)
@ -180,7 +181,7 @@ class WorkflowE2ETest {
projectPage
.goToTab(WorkflowInstanceTab.class)
.deleteAll();
browser.navigate().refresh();
projectPage
.goToTab(WorkflowDefinitionTab.class)
.run(workflow)
@ -198,7 +199,7 @@ class WorkflowE2ETest {
assertThat(row.isSuccess()).isTrue();
assertThat(row.executionTime()).isEqualTo(1);
});
browser.navigate().refresh();
// Test rerun
projectPage
.goToTab(WorkflowInstanceTab.class)

8
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/permission/ResourcePermissionCheckService.java

@ -58,4 +58,12 @@ public interface ResourcePermissionCheckService<T>{
* @return
*/
boolean functionDisabled();
/**
* associated with the current user after the resource is created
* @param authorizationType
* @param ids
* @param logger
*/
void postHandle(AuthorizationType authorizationType, Integer userId, List<Integer> ids, Logger logger);
}

5
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/permission/ResourcePermissionCheckServiceImpl.java

@ -88,6 +88,11 @@ public class ResourcePermissionCheckServiceImpl implements ResourcePermissionChe
return false;
}
@Override
public void postHandle(AuthorizationType authorizationType, Integer userId, List<Integer> ids, Logger logger) {
logger.debug("no post handle");
}
@Override
public <T> Set<T> userOwnedResourceIdsAcquisition(AuthorizationType authorizationType, Integer userId, Logger logger) {
User user = processService.getUserById(userId);

Loading…
Cancel
Save