Browse Source

[Bug] Resource default auth function disabled false. (#12467)

* resource function disable check fix

Co-authored-by: Kerwin <37063904+zhuangchong@users.noreply.github.com>
3.2.0-release
JiPeng Wang 2 years ago committed by GitHub
parent
commit
606a5aeee5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
  2. 8
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java

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

@ -1831,7 +1831,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
@Override
public Map<String, Object> authorizeResourceTree(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>();
if (!resourcePermissionCheckService.functionDisabled()) {
if (resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED);
return result;
}
@ -1981,7 +1981,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
@Override
public Map<String, Object> unauthorizedUDFFunction(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>();
if (!resourcePermissionCheckService.functionDisabled()) {
if (resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED);
return result;
}
@ -2019,7 +2019,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
@Override
public Map<String, Object> authorizedUDFFunction(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>();
if (!resourcePermissionCheckService.functionDisabled()) {
if (resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED);
return result;
}
@ -2039,7 +2039,7 @@ public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesSe
@Override
public Map<String, Object> authorizedFile(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>();
if (!resourcePermissionCheckService.functionDisabled()) {
if (resourcePermissionCheckService.functionDisabled()) {
putMsg(result, Status.FUNCTION_DISABLED);
return result;
}

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

@ -740,7 +740,7 @@ public class ResourcesServiceTest {
// test admin user
List<Integer> resIds = new ArrayList<>();
resIds.add(1);
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true);
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(false);
Mockito.when(resourcesMapper.queryResourceExceptUserId(userId)).thenReturn(getResourceList());
Map<String, Object> result = resourcesService.authorizeResourceTree(user, userId);
logger.info(result.toString());
@ -798,7 +798,7 @@ public class ResourcesServiceTest {
int userId = 3;
// test admin user
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true);
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(false);
Mockito.when(udfFunctionMapper.queryUdfFuncExceptUserId(userId)).thenReturn(getUdfFuncList());
Mockito.when(udfFunctionMapper.queryAuthedUdfFunc(userId)).thenReturn(getSingleUdfFuncList());
Map<String, Object> result = resourcesService.unauthorizedUDFFunction(user, userId);
@ -826,7 +826,7 @@ public class ResourcesServiceTest {
int userId = 3;
// test admin user
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true);
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(false);
Mockito.when(udfFunctionMapper.queryAuthedUdfFunc(userId)).thenReturn(getUdfFuncList());
Map<String, Object> result = resourcesService.authorizedUDFFunction(user, userId);
logger.info(result.toString());
@ -855,7 +855,7 @@ public class ResourcesServiceTest {
// test admin user
List<Integer> resIds = new ArrayList<>();
resIds.add(1);
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(true);
Mockito.when(resourcePermissionCheckService.functionDisabled()).thenReturn(false);
Mockito.when(resourceUserMapper.queryResourcesIdListByUserIdAndPerm(Mockito.anyInt(), Mockito.anyInt()))
.thenReturn(resIds);
Mockito.when(resourcesMapper.queryResourceListById(Mockito.any())).thenReturn(getResourceList());

Loading…
Cancel
Save